07.05.2012, 16:23
(
Последний раз редактировалось C0dy09; 07.05.2012 в 16:32.
Причина: corriger code
)
Hello all,
i know about threaded queries, but i have some questions:
-for example a login process:
How I have to write the Script and OnQueryFinish that it prevent from server lagging?
this way:
or maybe this way:
i hope you can help me understand this better/corriger my code
MfG. Cody09
//Iґm going to learn english
^^
i know about threaded queries, but i have some questions:
-for example a login process:
How I have to write the Script and OnQueryFinish that it prevent from server lagging?
this way:
Код:
#define MYSQL_CHECK_PLAYER (1)
stock mysql_CheckAccount(playerid)
{
new Name[MAX_PLAYER_NAME];
GetPlayerName(playerid, Name, MAX_PLAYER_NAME);
mysql_real_escape_string(Name, Name);
format(query, sizeof(query), "SELECT * FROM "MYSQL_ACC_TBL" WHERE Name = '%s' ORDER BY `id` DESC LIMIT 1", Name);
mysql_query(query,MYSQL_CHECK_PLAYER,playerid);
mysql_store_result();
return mysql_num_rows();
}
public OnPlayerConnect(playerid)
{
if(mysql_CheckAccount(playerid) == 1)
{
gPlayerAccount[playerid] = 1;
return 1;
}
else
{
gPlayerAccount[playerid] = 0;
return 1;
}
return 1;
}
public OnQueryFinish(query[], resultid, extraid, connectionHandle)
{
switch(resultid)
{
case MYSQL_CHECK_PLAYER:
{
return 1;
}
}
return 1;
}
Код:
#define MYSQL_CHECK_PLAYER (1)
stock mysql_CheckAccount(playerid)
{
new Name[MAX_PLAYER_NAME];
GetPlayerName(playerid, Name, MAX_PLAYER_NAME);
mysql_real_escape_string(Name, Name);
format(query, sizeof(query), "SELECT * FROM "MYSQL_ACC_TBL" WHERE Name = '%s' ORDER BY `id` DESC LIMIT 1", Name);
mysql_query(query,MYSQL_CHECK_PLAYER,playerid);
}
public OnPlayerConnect(playerid)
{
mysql_CheckAccount(playerid);
return 1;
}
public OnQueryFinish(query[], resultid, extraid, connectionHandle)
{
switch(resultid)
{
case MYSQL_CHECK_PLAYER:
{
mysql_store_result();
if(mysql_num_rows() ==1) gPlayerAccount[extraid] = 1;
else gPlayerAccount[extraid] = 0;
}
}
return 1;
}
MfG. Cody09
//Iґm going to learn english
^^

