OnPlayerDeath problem
#1

Server Logs
Код:
[17:58:22] [debug] Run time error 4: "Array index out of bounds"
[17:58:22] [debug]  Accessing element at index 65535 past array upper bound 499
[17:58:22] [debug] AMX backtrace:
[17:58:22] [debug] #0 0004b0a8 in ?? (0x00000000, 0x0000ffff, 0x000000ff) from Dom.amx
[17:58:22] [debug] #1 0000560c in public OnPlayerDeath (0x00000000, 0x0000ffff, 0x000000ff) from Dom.amx
[17:58:22] [death] Domy died 255
OnPlayerDeath
Код:
public OnPlayerDeath(playerid, killerid, reason)
{
	SendDeathMessage(killerid, playerid, reason);
 	SetPlayerScore (killerid, GetPlayerScore (killerid) + 1);
	SendClientMessage(killerid,COLOR_LIGHTGREEN,"You Have Get 2$ For and 1 Score ");
	SetPlayerHealth(playerid, 0.00);
	Player[killerid][pKills]++;
   	Player[playerid][pDeaths]++;
   	FogEnabled[playerid] = false;
 	GameTextForPlayer(playerid, "~r~Wasted", 5000, 3);
	GivePlayerMoney(killerid,2);
return 1;
}
Reply
#2

You didn't check if the killerid was a valid player deaths were there is no killer will show up as INVALID_PLAYER_ID
Reply
#3

Likw this?>
Код:
public OnPlayerDeath(playerid, killerid, reason)
{
  if(killerid != INVALID_PLAYER_ID)
    {
	SendDeathMessage(killerid, playerid, reason);
 	SetPlayerScore (killerid, GetPlayerScore (killerid) + 1);
	SendClientMessage(killerid,COLOR_LIGHTGREEN,"You Have Get 2$ For and 1 Score ");
	SetPlayerHealth(playerid, 0.00);
	Player[killerid][pKills]++;
   	Player[playerid][pDeaths]++;
   	FogEnabled[playerid] = false;
 	GameTextForPlayer(playerid, "~r~Wasted", 5000, 3);
	GivePlayerMoney(killerid,2);
}
return 1;
}
Reply
#4

No, add only the part that use killerid inside brackets []. If the player dies by himself/herself, it won't add +1 deaths like that.

pawn Код:
public OnPlayerDeath(playerid, killerid, reason)
{
    SendDeathMessage(killerid, playerid, reason);
    if(killerid != INVALID_PLAYER_ID)
    {
        SetPlayerScore (killerid, GetPlayerScore (killerid) + 1);
        SendClientMessage(killerid,COLOR_LIGHTGREEN,"You Have Get 2$ For and 1 Score ");
        Player[killerid][pKills]++;
        GivePlayerMoney(killerid,2);
    }
    SetPlayerHealth(playerid, 0.00);
    Player[playerid][pDeaths]++;
    FogEnabled[playerid] = false;
    GameTextForPlayer(playerid, "~r~Wasted", 5000, 3);
    return 1;
}
Reply
#5

Thanks FixEd
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)