SA-MP Forums Archive
OnPlayerDeath problem - 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: OnPlayerDeath problem (/showthread.php?tid=484574)



OnPlayerDeath problem - MBilal - 31.12.2013

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;
}



Re: OnPlayerDeath problem - Pottus - 31.12.2013

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


Re: OnPlayerDeath problem - MBilal - 31.12.2013

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;
}



Re: OnPlayerDeath problem - Konstantinos - 31.12.2013

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;
}



Re: OnPlayerDeath problem - MBilal - 31.12.2013

Thanks FixEd