05.05.2013, 18:05
(
Последний раз редактировалось BossZk; 05.05.2013 в 22:14.
)
Quote:
You're not even checking if killerid is valid. If it's INVALID_PLAYER_ID (playerid killed themselves) your arrays will try to access invalid index which is out of bounds and the rest of the callback won't be executed.
|
Still not working for me
edit:
PHP код:
public OnPlayerDeath(playerid, killerid, reason)
{
if(killerid == INVALID_PLAYER_ID)
{
SendDeathMessage(INVALID_PLAYER_ID, playerid, reason);
return 1;
}
if(killerid != INVALID_PLAYER_ID)
{
if(gTeam{killerid} == CIVILIAN)
{
SetPlayerWantedLevel(killerid,GetPlayerWantedLevel(killerid) + 10);
SendClientMessage(killerid, COLOR_RED, "[Murder Committed] Your wanted level has increased by 10!");
SetPlayerWantedLevel(playerid, 0);
SendDeathMessage(killerid,playerid,reason);
return 1;
}
if(gTeam{playerid} == CIVILIAN && gTeam{killerid} == POLICE || gTeam{killerid} == SWAT || gTeam{killerid} == ARMY)
{
if(GetPlayerWantedLevel(playerid) == 0)
{
SetPlayerScore(killerid, GetPlayerScore(killerid)-1);
SendClientMessage(killerid, COLOR_WHITE, "DONT KILL innocent players! /pc! /rules!");
//GivePlayerCash(killerid, -10000);
//SetPlayerHealth(killerid, 0.0);
SendDeathMessage(killerid,playerid,reason);
return 1;
}
else if(GetPlayerWantedLevel(playerid) <= 3 && GetPlayerWantedLevel(playerid) >= 1)
{
SendClientMessage(killerid, COLOR_WHITE, "DONT KILL innocent suspects! /pc! Ticket them! /tk!");
SetPlayerScore(killerid, GetPlayerScore(killerid)-1);
//SetPlayerHealth(killerid, 0.0);
SendDeathMessage(killerid,playerid,reason);
return 1;
}
else if(GetPlayerWantedLevel(playerid) >= 4)
{
if(gTeam{killerid} == POLICE)
{
new str2[200];
SetPlayerScore(killerid, GetPlayerScore(killerid)+1);
format(str2, sizeof(str2), "Suspect %s [%d] has been taken down by Officer %s [%d]",GetName(playerid),playerid,GetName(killerid),killerid);
SendClientMessageToAll(COLOR_RED,str2);
SendClientMessage(killerid, COLOR_BLUE, "You have received $2000 for taking down a Medium Wanted Level criminal!");
GivePlayerMoney(killerid, 2000);
SetPlayerWantedLevel(playerid, 0);
SendDeathMessage(killerid,playerid,reason);
return 1;
}
}
else if(gTeam{killerid} == ARMY)
{
new str2[200];
SetPlayerScore(killerid, GetPlayerScore(killerid)+1);
format(str2, sizeof(str2), "S.A Army Member %s [%d] has been taken down %s (%d) by deadly force!",GetName(killerid),killerid,GetName(playerid),playerid);
SendClientMessageToAll(ARMY_COLOUR,str2);
SendClientMessage(killerid, ARMY_COLOUR," Good Job! You have received $5000 for taking down a Medium Wanted Level criminal.");
GivePlayerMoney(killerid, 5000);
SetPlayerWantedLevel(playerid, 0);
SendDeathMessage(killerid,playerid,reason);
return 1;
}
else if(gTeam{killerid} == SWAT)
{
new str2[200];
SetPlayerScore(killerid, GetPlayerScore(killerid)+1);
format(str2, sizeof(str2), "SWAT Member %s [%d] has been taken down suspect %s (%d)!",GetName(killerid),killerid,GetName(playerid),playerid);
SendClientMessageToAll(SWAT_COLOUR,str2);
SendClientMessage(killerid, SWAT_COLOUR," Good Job! You have received $2500 for taking down a Medium Wanted Level criminal.");
GivePlayerMoney(killerid, 2500);
SetPlayerWantedLevel(playerid, 0);
SendDeathMessage(killerid,playerid,reason);
return 1;
}
}
else if(GetPlayerWantedLevel(playerid) >= 9)
{
if(gTeam{killerid} == POLICE)
{
new str2[200];
SetPlayerScore(killerid, GetPlayerScore(killerid)+1);
format(str2, sizeof(str2), "Suspect %s [%d] has been taken down by Officer %s [%d]",GetName(playerid),playerid,GetName(killerid),killerid);
SendClientMessageToAll(COLOR_RED,str2);
SendClientMessage(killerid, COLOR_BLUE, "You have received $5000 for taking down a High Wanted Level criminal!");
GivePlayerMoney(killerid, 5000);
SetPlayerWantedLevel(playerid, 0);
SendDeathMessage(killerid,playerid,reason);
return 1;
}
else if(gTeam{killerid} == ARMY)
{
new str2[200];
SetPlayerScore(killerid, GetPlayerScore(killerid)+3);
format(str2, sizeof(str2), "S.A Army Member %s [%d] has been taken down %s (%d) by deadly force!",GetName(killerid),killerid,GetName(playerid),playerid);
SendClientMessageToAll(SWAT_COLOUR,str2);
SendClientMessage(killerid, SWAT_COLOUR," Good Job! You have received $10000 for taking down a High Wanted Level criminal.");
GivePlayerMoney(killerid, 10000);
SetPlayerWantedLevel(playerid, 0);
SendDeathMessage(killerid,playerid,reason);
return 1;
}
else if(gTeam{killerid} == SWAT)
{
new str2[200];
SetPlayerScore(killerid, GetPlayerScore(killerid)+1);
format(str2, sizeof(str2), "SWAT Member %s [%d] has been taken down suspect %s (%d)!",GetName(killerid),killerid,GetName(playerid),playerid);
SendClientMessageToAll(SWAT_COLOUR,str2);
SendClientMessage(killerid, SWAT_COLOUR," Good Job! You have received $7500 for taking down a High Wanted Level criminal.");
GivePlayerMoney(killerid, 7500);
SetPlayerWantedLevel(playerid, 0);
SendDeathMessage(killerid,playerid,reason);
return 1;
}
}
if(!IsPlayerConnected(killerid))
{
new string[200];
format(string,sizeof(string),"[DEATH] %s(%d) Has killed themselves .. ",GetName(playerid),playerid);
SendClientMessageToAll(COLOR_PINK,string);
SendDeathMessage(INVALID_PLAYER_ID,playerid,reason);
SetPlayerWantedLevel(playerid,0);
}
SetPlayerWantedLevel(playerid, 0); //reset wanted level
}
return 1;
}
EDIT: Fixed it myself, thanks anyways