Kills/Deaths Problem
#1

pawn Код:
public OnPlayerDeath(playerid, killerid, reason)
{
    pInfo[killerid][Kills]++;
    pInfo[playerid][Deaths]++;
    if(pInfo[killerid][VIP] > 0)
    {
    SetPlayerScore(killerid, GetPlayerScore(killerid) + 1);
    }
    return 1;
}
But the Killerid his Kills don't go 1+
And the playerid his Deaths dont go +1
Reply
#2

can you show your pInfo?
Reply
#3

nvm...show us your enum
Reply
#4

try:
pawn Код:
pInfo[killerid][Kills] +=1;
pInfo[playerid][Deaths] +=1;
Reply
#5

pawn Код:
enum iDetails {
    Pass,
    Cash,
    Score,
    Admin,
    Kills,
    Deaths,
    VIP,
    Muted
};
@Patomaxx, not working
Reply
#6

Quote:
Originally Posted by geerdinho8
Посмотреть сообщение
But the Killerid his Kills don't go 1+
And the playerid his Deaths dont go +1
How you testing it ? Saving in file or using /stats to see ?

Problem is not here. If you got /stats cmd, paste it here.
Reply
#7

You must add
if(0 <= killerid <= MAX_PLAYERS-1)
or
if(killerid != INVALID_PLAYER_ID)
then stats killerid ++ because if player dies /kill or explode killerid == 65565 so Your pInfo[65565 max is MAX_PLAYERS][Kills] will crash
Reply
#8

What Jefff tried to say was:

You need to check whether killerid is valid before you set an array using it, otherwise it will crash/stop.

pawn Код:
public OnPlayerDeath(playerid, killerid, reason)
{
    if(killerid != INVALID_PLAYER_ID) // Valid killer
    {
        pInfo[killerid][Kills]++;
        if(pInfo[killerid][VIP] > 0) SetPlayerScore(killerid, GetPlayerScore(killerid) + 1);
    }
    pInfo[playerid][Deaths]++;
    return 1;
}
Reply
#9

Quote:
Originally Posted by Amel_PAtomAXx
Посмотреть сообщение
try:
pawn Код:
pInfo[killerid][Kills] +=1;
pInfo[playerid][Deaths] +=1;
pawn Код:
main()
{
    new a, b;
    a++;
    b+=1;
    printf("%d",a);
    printf("%d",b);
}
Reply
#10

pawn Код:
public OnPlayerDeath(playerid, killerid, reason)
{
    if(IsPlayerConnected(playerid) || IsPlayerConnected(killerid))
    {
        pInfo[killerid][Kills]++;
        pInfo[playerid][Deaths]++;
        if(pInfo[killerid][VIP] > 0)
        {
           SetPlayerScore(killerid, GetPlayerScore(killerid) + 1);
        }
    }
    return 1;
}

and check's others filterscripts.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)