[ASK] Query under OnPlayerDeath ? - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: [ASK] Query under OnPlayerDeath ? (
/showthread.php?tid=578664)
[ASK] Query under OnPlayerDeath ? -
VenomMancer - 21.06.2015
Look :
pawn Код:
public OnPlayerDeath(playerid, killerid, reason)
{
new query[128];
pInfo[killerid][Kills]++;
pInfo[playerid][Deaths]++;
mysql_format(mysql, query, sizeof(query), "UPDATE `players` SET `Kills`='%d' WHERE `ID`='%d'",pInfo[killerid][Kills],pInfo[killerid][ID]);
mysql_pquery(mysql, query, "", "");
mysql_format(mysql, query, sizeof(query), "UPDATE `players` SET `Deaths`='%d' WHERE `ID`='%d'",pInfo[playerid][Deaths],pInfo[playerid][ID]);
mysql_pquery(mysql, query, "", "");
return 1;
}
This safety?
Or will make server lag/crash?
#Sorryformybadenglish
Re: [ASK] Query under OnPlayerDeath ? -
Dusan01 - 21.06.2015
Nope, it should not make server laggy or crash, u dont have 100 death every second...
BUt i suggest u if u are using DM script u shuld make to save player stats afther he disconnect (OnPlayerDisconect)...
and maybe every 30min or 15min....
Re: [ASK] Query under OnPlayerDeath ? -
Konstantinos - 21.06.2015
If you are about to update kills/deaths in OnPlayerDeath, then don't use variables just for getting the increased value. And why would you execute a query if the killer is not valid?
pawn Код:
new query[52];
if (killerid != INVALID_PLAYER_ID)
{
mysql_format(mysql, query, sizeof(query), "UPDATE players SET Kills=Kills+1 WHERE ID=%d", pInfo[killerid][ID]);
mysql_pquery(mysql, query, "", "");
}
mysql_format(mysql, query, sizeof(query), "UPDATE players SET Deaths=Deaths+1 WHERE ID=%d", pInfo[playerid][ID]);
mysql_pquery(mysql, query, "", "");
Re: [ASK] Query under OnPlayerDeath ? -
VenomMancer - 21.06.2015
Quote:
Originally Posted by Konstantinos
If you are about to update kills/deaths in OnPlayerDeath, then don't use variables just for getting the increased value. And why would you execute a query if the killer is not valid?
pawn Код:
new query[52];
if (killerid != INVALID_PLAYER_ID) { mysql_format(mysql, query, sizeof(query), "UPDATE players SET Kills=Kills+1 WHERE ID=%d", pInfo[killerid][ID]); mysql_pquery(mysql, query, "", ""); }
mysql_format(mysql, query, sizeof(query), "UPDATE players SET Deaths=Deaths+1 WHERE ID=%d", pInfo[playerid][ID]); mysql_pquery(mysql, query, "", "");
|
'And why would you execute a query if the killer is not valid?' I am not. Already used in my GM!
So this will not make server crash?