0.3x bug or dafuq?
#1

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

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

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

Vukilore: No it's about playerid when /kill

Here you can see what I was doin':



and

Reply
#5

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

Never saw that i put that out. I'm sorry
Reply
#7

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


Forum Jump:


Users browsing this thread: 1 Guest(s)