[ASK] Query under OnPlayerDeath ?
#1

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
Reply
#2

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....
Reply
#3

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, "", "");
Reply
#4

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?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)