SA-MP Forums Archive
0.3x bug or dafuq? - 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: 0.3x bug or dafuq? (/showthread.php?tid=414863)



0.3x bug or dafuq? - aco_SRBIJA - 10.02.2013

Well, I was making a register&login system with cini system (cessil's one) and I was seeing it is having some problems. I thought it was problem in cini but no. It simple made everytime deaths=0 what was false, because I used /kill few times. I was putting random numbers to save, and not my deads and it was working good. Password thing is geart working. I thought my vars are probs, so I did made new deads; puted under OnPlayerDeath deads++ and on register to add it to file and on disconnect to update it to file, with printing a number of deaths. Output was 0, I was wondering why, felt free to post here.


Code that I used to /kill:

Код:
CMD:kill(playerid)
{
    SetPlayerHealth(playerid,0.00);
    SendClientMessage(playerid,-1,#COL_RED"You have commited suicide!");
    return 1;
}
tests after some time:

Код:
CMD:kill(playerid)
{
    SetPlayerHealth(playerid,0.00);
    SendClientMessage(playerid,-1,#COL_RED"You have commited suicide!");
    PlayerInfo[playerid][pDeaths]=PlayerInfo[playerid][pDeaths]+1;
    return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
    printf("========Deaths: %d=========",PlayerInfo[playerid][pDeaths]);
    cini_Update(playerid,"ddd","Admin",PlayerInfo[playerid][pAdmin],"Kills",PlayerInfo[playerid][pKills],"Deaths",PlayerInfo[playerid][pDeaths]);
    return 1;
}
Used /kill 2 times, get output 2 times, all cool. Modify a bit and....

Код:
public OnPlayerDeath(playerid, killerid, reason)
{
    PlayerInfo[playerid][pDeaths]=PlayerInfo[playerid][pDeaths]+1; // tried  PlayerInfo[playerid][pDeaths]++;
    return 1;
}

CMD:kill(playerid)
{
    SetPlayerHealth(playerid,0.00);
    SendClientMessage(playerid,-1,#COL_RED"You have commited suicide!");
    return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
    printf("========Deaths: %d=========",PlayerInfo[playerid][pDeaths]);
    cini_Update(playerid,"ddd","Admin",PlayerInfo[playerid][pAdmin],"Kills",PlayerInfo[playerid][pKills],"Deaths",PlayerInfo[playerid][pDeaths]);
    return 1;
}
Output was 0.

What the hell is going on


Re: 0.3x bug or dafuq? - Meta - 11.02.2013

Place a print line in OnPlayerDeath to see if it is called at all.


Re : 0.3x bug or dafuq? - Vukilore - 11.02.2013

Maybe because of killerid in an array ? (if you don't show us your OnPDeath)


Re: 0.3x bug or dafuq? - aco_SRBIJA - 11.02.2013

Vukilore: No it's about playerid when /kill

Here you can see what I was doin':



and




Re: 0.3x bug or dafuq? - Whitetiger - 11.02.2013

if you're committing suicide, then killerid will be 65535. check if killerid is connected before setting an array with killerid. you're setting a killerid array outside of the killerid != INVALID_PLAYER_ID.

also, you should use crash detect because it will show you all index out of bounds errors on arrays.


Re: 0.3x bug or dafuq? - aco_SRBIJA - 12.02.2013

Never saw that i put that out. I'm sorry


Re: 0.3x bug or dafuq? - Kontrol - 15.02.2013

Why not simply PlayerInfo[playerid][pDeaths] ++; ?