Skocz do zawarto艣ci

Witamy w Nieoficjalnym polskim support'cie AMX Mod X

Witamy w Nieoficjalnym polskim support'cie AMX Mod X, jak w wi臋kszo艣ci spo艂eczno艣ci internetowych musisz si臋 zarejestrowa膰 aby m贸c odpowiada膰 lub zak艂ada膰 nowe tematy, ale nie b贸j si臋 to jest prosty proces w kt贸rym wymagamy minimalnych informacji.
  • Rozpoczynaj nowe tematy i odpowiedaj na inne
  • Zapisz si臋 do temat贸w i for, aby otrzymywa膰 automatyczne uaktualnienia
  • Dodawaj wydarzenia do kalendarza spo艂eczno艣ciowego
  • Stw贸rz sw贸j w艂asny profil i zdobywaj nowych znajomych
  • Zdobywaj nowe do艣wiadczenia

Do艂膮czona grafika Do艂膮czona grafika

Guest Message by DevFuse
 

Zdj臋cie

Pro艣ba o poprawienie Czas na serwerze


  • Zamkni臋ty Temat jest zamkni臋ty
Brak odpowiedzi do tego tematu

#1 Truposz WWL

    Profesjonalista

  • U偶ytkownik

Reputacja: 41
Pomocny

  • Post贸w:159
  • Lokalizacja:Duczki
Offline

Napisano 20.03.2011 18:03

Witam,
pr贸bowa艂em sklei膰 sobie jeden plugin i wysz艂o na to 偶e tworzy tabele ale nie dodaje 偶adnego rekordu. Prosi艂bym o poprawienie sma poni偶ej
/* Plugin generated by AMXX-Studio */

#include <amxmodx>
#include <amxmisc>
#include <sqlx>


#define PLUGIN "Timer"
#define VERSION "1.0"
#define AUTHOR "Truposz[WWL]"

new SqlConnected, Handle:SQL_TUPLE, iCzas[33], iPlayerid[33];

public plugin_init() {
register_plugin(PLUGIN, VERSION, AUTHOR)

register_cvar("amx_sql_host","127.0.0.1",FCVAR_PROTECTED)
register_cvar("amx_sql_user","root",FCVAR_PROTECTED)
register_cvar("amx_sql_pass","",FCVAR_PROTECTED)
register_cvar("amx_sql_database","bf2",FCVAR_PROTECTED)
ConnectSql();
}
public plugin_end()
{
SQL_FreeHandle(SQL_TUPLE);
}
public ConnectSql()
{
if(SqlConnected) return PLUGIN_CONTINUE;
new Host[65], User[65], Haslo[65], Baza[65];
get_cvar_string("amx_sql_host", Host, 64);
get_cvar_string("amx_sql_user", User, 64);
get_cvar_string("amx_sql_pass", Haslo, 64);
get_cvar_string("amx_sql_database", Baza, 64);

SQL_TUPLE = SQL_MakeDbTuple(Host, User, Haslo, Baza);

new sZapytanie[512];
format(sZapytanie, 511, "CREATE TABLE IF NOT EXISTS `bf2ranks3` (`playerid` varchar(35) , `Czas` int(11), `Data` int(11))");
SQL_ThreadQuery(SQL_TUPLE, "ConnectSqlHandle", sZapytanie);
return PLUGIN_CONTINUE;
}
public ConnectSqlHandle(FailState, Handle:Query, Error[], Errcode, Data[], DataSize)
{
if(Errcode)
{
server_print("Error on Table query: %s",Error);
}
if(FailState == TQUERY_CONNECT_FAILED)
{
server_print("Could not connect to SQL database.");
}
else if(FailState == TQUERY_QUERY_FAILED)
{
server_print("Table Query failed.");
}
return PLUGIN_CONTINUE;
}
public client_connect(id){
if(SqlConnected)
{
//server_print("Loading Record ... [Step 2/4]"); //ForDebug
new sZapytanie[512], playerid[32];
get_user_name(id, playerid, 31)
format(sZapytanie, 511, "SELECT * FROM `bf2ranks3` WHERE `playerid` = '%s'", playerid);
SQL_ThreadQuery(SQL_TUPLE, "CheckRecordHandle", sZapytanie);
//server_print("Loading Record ... [Step 3/4]"); //ForDebug
}
else ConnectSql();
}
public CheckRecordHandle(id, FailState, Handle:Query, Error[], Errcode, Data[], DataSize)
{
if(Errcode)
{
server_print("Error on CheckRecords query: %s",Error);
return PLUGIN_CONTINUE;
}
if(FailState == TQUERY_CONNECT_FAILED)
{
server_print("Could not connect to SQL database.");
return PLUGIN_CONTINUE;
}
else if(FailState == TQUERY_QUERY_FAILED)
{
server_print("ChaeckRecords Query failed.");
return PLUGIN_CONTINUE;
}
if(SQL_NumResults(Query) > 0)
{
//server_print("Loading Record ... [Step 4/4]"); //ForDebug
iPlayerid[id] = SQL_ReadResult(Query,SQL_FieldNameToNum(Query,"playerid"));
iCzas[id] = SQL_ReadResult(Query,SQL_FieldNameToNum(Query,"playerid"));
//server_print("Loading Record Complete!"); //ForDebug
}
else
{
//server_print("Loading Record ... [Step 4/4] (Create 1/2)"); //ForDebug
new sZapytanie[512], playerid[32];
get_user_name(id, playerid, 31)
format(sZapytanie, 511, "INSERT INTO `bf2ranks3` (`playerid`, `Czas`, `Data`) VALUES ('%s', '0', '0')", playerid);
SQL_ThreadQuery(SQL_TUPLE, "CreateMapRecordHandle", sZapytanie);
//server_print("Loading Record ... [Step 4/4] (Create 2/2)"); //ForDebug
}
return PLUGIN_CONTINUE;
}
public CreateMapRecordHandle (FailState, Handle:Query, Error[], Errcode, Data[], DataSize)
{
if(Errcode)
server_print("Error on CreateMapRecord query: %s",Error);
if(FailState == TQUERY_CONNECT_FAILED)
server_print("Could not connect to SQL database.");
else if(FailState == TQUERY_QUERY_FAILED)
server_print("CreateMapRecord Query failed.");
//server_print("Loading Record Complete! (Create Complete!)"); //ForDebug
return PLUGIN_CONTINUE;
}
public client_putinserver(id){
set_task(10.0, "licz", id, _, _, "b")
}
public licz(id){
iCzas[id] += 10
}
public client_disconnect(id)
{
remove_task(id)
new idata;
idata = get_systime();
if(SqlConnected)
{
//ColorChat(0, "^x04 Please Wait ... Saving record ... [Step 3/4]"); //ForDebug
new sZapytanie[512];
format(sZapytanie, 511, "UPDATE `bf2ranks3` SET `Czas` = '%s', `Data` = '%d' WHERE `playerid` = '%s'", iCzas[id], idata, iPlayerid[id]);
SQL_ThreadQuery(SQL_TUPLE, "Save2SQLHandle", sZapytanie);
//ColorChat(0, "^x04 Please Wait ... Saving record ... [Step 4/4]"); //ForDebug
}
else ConnectSql();
}
public Save2SQLHandle(FailState, Handle:Query, Error[], Errcode, Data[], DataSize)
{
if(Errcode)
server_print("Error on Save2SQL query: %s",Error);
if(FailState == TQUERY_CONNECT_FAILED)
server_print("Could not connect to SQL database.");
else if(FailState == TQUERY_QUERY_FAILED)
server_print("Save2SQL Query failed.");
//ColorChat(0, "^x04 Saving Complete !"); //ForDebug
return PLUGIN_CONTINUE;
}

  • +
  • -
  • 0




U偶ytkownicy przegl膮daj膮cy ten temat: 0

0 u偶ytkownik贸w, 0 go艣ci, 0 anonimowych