18.05.2015, 11:17
Actually OnPlayerDeath stops working due to run time error 4. You never check if killerid is valid player before using it in arrays except the last part.
PHP код:
public OnPlayerDeath(playerid, killerid, reason)
{
SendDeathMessage(killerid, playerid, reason);
if(Captured[playerid][CAPZONE] == 0 && IsPlayerCapturing[playerid][CAPZONE] == 1)
{
LeavingCAPZONE(playerid);
}
Streaks[playerid] = 0;
pInfo[playerid][Spawned] = 0;
pInfo[playerid][Deaths]++;
if (killerid != INVALID_PLAYER_ID)
{
pInfo[killerid][Kills]++;
Streaks[killerid] += 1;
switch(Streaks[killerid]) //IMPORTANT: with the function "switch", you're switching / toggling through the killstreaks of a player (Streals). you need the killerid here, because the playerid is the one which is GETTING killed
{
case 3:
{
format(gString,SOS," %s Has a killing spree (3 kills) (Reward:300$ + 2 score)",GetName(killerid));
SendClientMessageToAll(GREEN, gString);
SetPlayerScore(killerid,GetPlayerScore(killerid)+2 );
GivePlayerMoney(killerid, 300);
SendClientMessage(killerid, GREEN,"You recieved 300$ and +2 scores for your 3 spree!");
}
case 6:
{
format(gString,SOS," %s Has a killing spree (6 kills) (Reward:600$ + 2 score)",GetName(killerid));
SendClientMessageToAll(GREEN, gString);
GivePlayerMoney(killerid, 600);
SetPlayerScore(killerid,GetPlayerScore(killerid)+2 );
SendClientMessage(killerid, GREEN,"You recieved 600$ and +2 scores for your 6 spree!");
}
case 9:
{
format(gString,SOS," %s Has a killing spree (9 kills) (Reward:900$ + 2 score)",GetName(killerid));
SendClientMessageToAll(GREEN, gString);
GivePlayerMoney(killerid, 900);
SetPlayerScore(killerid,GetPlayerScore(killerid)+2 );
SendClientMessage(killerid, GREEN,"You recieved 900$ and +2 scores for your 9 spree!");
}
case 12:
{
format(gString,SOS," %s Has a killing spree (12 kills) (Reward:1000$ + 4 score)",GetName(killerid));
SendClientMessageToAll(GREEN, gString);
SetPlayerScore(killerid,GetPlayerScore(killerid)+4 );
GivePlayerMoney(killerid, 1000);
SendClientMessage(killerid, GREEN,"You recieved 1000$ and +4 scores for your 12 spree!");
}
case 15:
{
format(gString,SOS," %s Has a killing spree (15 kills) (Reward:2500$ + 4 score)",GetName(killerid));
SendClientMessageToAll(GREEN, gString);
SetPlayerScore(killerid,GetPlayerScore(killerid)+4 );
GivePlayerMoney(killerid, 2500);
SendClientMessage(killerid, GREEN,"You recieved 2500$ and +4 scores for your 15 spree!");
}
case 20:
{
format(gString,SOS," %s Has a killing spree (20 kills) (Reward:3500$ + 4 score)",GetName(killerid));
SendClientMessageToAll(GREEN, gString);
SetPlayerScore(killerid,GetPlayerScore(killerid)+4 );
GivePlayerMoney(killerid, 3500);
SendClientMessage(killerid, GREEN,"You recieved 3500$ and +4 scores for your 20 spree!");
}
case 25:
{
format(gString,SOS," %s Has a killing spree (25 kills) (Reward:4000$ + 4 score)",GetName(killerid));
SendClientMessageToAll(GREEN, gString);
SetPlayerScore(killerid,GetPlayerScore(killerid)+4 );
GivePlayerMoney(killerid, 4000);
SendClientMessage(killerid, GREEN,"You recieved 4000$ and +4 scores for your 25 spree!");
}
case 30:
{
format(gString,SOS," %s Has a killing spree (30 kills) (Reward:4500$ + 4 score)",GetName(killerid));
SendClientMessageToAll(GREEN, gString);
SetPlayerScore(killerid,GetPlayerScore(killerid)+4 );
GivePlayerMoney(killerid, 4500);
SendClientMessage(killerid, GREEN,"You recieved 4500$ and +4 scores for your 30 spree!");
}
case 35:
{
format(gString,SOS," %s Has a killing spree (35 kills) (Reward:5000$ + 5 score)",GetName(killerid));
SendClientMessageToAll(GREEN, gString);
SetPlayerScore(killerid,GetPlayerScore(killerid)+5 );
GivePlayerMoney(killerid, 5000);
SendClientMessage(killerid, GREEN,"You recieved 5000$ and +5 scores for your 35 spree!");
}
}
new cash = random(100);
format(gString, 100, "You have killed %s and got 100$ and + 1 score!", PlayerName(playerid), cash);
SendClientMessage(killerid, GREEN, gString);
format(gString, 100, "You have been killed by %s!", PlayerName(killerid));
SendClientMessage(playerid, RED, gString);
SetPlayerScore(killerid,GetPlayerScore(killerid)+1 );
GivePlayerMoney(killerid,100);
}
return 1;
}