Problem saving Deaths
#1

Hello there.
I have encountered a new problem today, i found out that deaths dont count.
Notice that server is'nt hosted.



Notice aswell these codes.

OnPlayerConnect
PHP код:
if(fexist(UserPath(playerid)))
    {
        
INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra true, .extra playerid);
        
ShowPlayerDialog(playeridDIALOG_LOGINDIALOG_STYLE_INPUT,""COL_WHITE"Login",""COL_WHITE"Type your password below to login.","Login","Quit");
    } 
OnPlayerDeath
PHP код:
PlayerInfo[killerid][pKills]++;
PlayerInfo[playerid][pDeaths]++; 
OnPlayerDisconnect
PHP код:
INI_WriteInt(File,"Deaths",PlayerInfo[playerid][pDeaths]); 
However Admin level saves with the same way, i have no problem with it.
Reply
#2

If that's all the code you have in OnPlayerDeath it will generate an out of bounds runtime error when killerid is invalid (i.e. when the players kills himself) and in such cases unexpected things happen. Show the entire OnPlayerDeath callback (or at least the entire control flow).
Reply
#3

PHP код:
public OnPlayerDeath(playeridkilleridreason)
{
    
PlayerInfo[killerid][pKills]++;
    
PlayerInfo[playerid][pDeaths]++;
    return 
1;

That's all, sir.
EDIT:
PHP код:
public OnPlayerDeath(playeridkilleridreason)
{
    if(
killerid==INVALID_PLAYER_ID)
    
PlayerInfo[playerid][pDeaths]++;
    else
    {
    
PlayerInfo[killerid][pKills]++;
    
PlayerInfo[playerid][pDeaths]++;
    }
    return 
1;

Works fine now, thanks alot.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)