Problem with freezing REP++
#9

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(playeridkilleridreason)
{
    
SendDeathMessage(killeridplayeridreason);
    
    if(
Captured[playerid][CAPZONE] == && 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(GREENgString);
                
SetPlayerScore(killerid,GetPlayerScore(killerid)+);
                
GivePlayerMoney(killerid300);
                
SendClientMessage(killeridGREEN,"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(GREENgString);
                
GivePlayerMoney(killerid600);
                
SetPlayerScore(killerid,GetPlayerScore(killerid)+);
                
SendClientMessage(killeridGREEN,"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(GREENgString);
                
GivePlayerMoney(killerid900);
                
SetPlayerScore(killerid,GetPlayerScore(killerid)+);
                
SendClientMessage(killeridGREEN,"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(GREENgString);
                
SetPlayerScore(killerid,GetPlayerScore(killerid)+);
                
GivePlayerMoney(killerid1000);
                
SendClientMessage(killeridGREEN,"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(GREENgString);
                
SetPlayerScore(killerid,GetPlayerScore(killerid)+);
                
GivePlayerMoney(killerid2500);
                
SendClientMessage(killeridGREEN,"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(GREENgString);
                
SetPlayerScore(killerid,GetPlayerScore(killerid)+);
                
GivePlayerMoney(killerid3500);
                
SendClientMessage(killeridGREEN,"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(GREENgString);
                
SetPlayerScore(killerid,GetPlayerScore(killerid)+);
                
GivePlayerMoney(killerid4000);
                
SendClientMessage(killeridGREEN,"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(GREENgString);
                
SetPlayerScore(killerid,GetPlayerScore(killerid)+);
                
GivePlayerMoney(killerid4500);
                
SendClientMessage(killeridGREEN,"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(GREENgString);
                
SetPlayerScore(killerid,GetPlayerScore(killerid)+);
                
GivePlayerMoney(killerid5000);
                
SendClientMessage(killeridGREEN,"You recieved 5000$ and +5 scores for your 35 spree!");
            }
        }
        new 
cash random(100);
        
format(gString100"You have killed %s and got 100$ and + 1 score!"PlayerName(playerid), cash);
        
SendClientMessage(killeridGREENgString);
        
format(gString100"You have been killed by %s!"PlayerName(killerid));
        
SendClientMessage(playeridREDgString);
        
SetPlayerScore(killerid,GetPlayerScore(killerid)+);
        
GivePlayerMoney(killerid,100);
    }
    return 
1;

Reply


Messages In This Thread
Problem with freezing REP++ - by Mijata - 17.05.2015, 19:21
Re: Problem with freezing REP++ - by Bingo - 17.05.2015, 19:30
Re: Problem with freezing REP++ - by Mijata - 17.05.2015, 19:36
Re: Problem with freezing REP++ - by Vitos - 17.05.2015, 20:30
Re: Problem with freezing REP++ - by icra - 18.05.2015, 03:56
Re: Problem with freezing REP++ - by EBook - 18.05.2015, 05:29
Re: Problem with freezing REP++ - by Bingo - 18.05.2015, 07:16
Re: Problem with freezing REP++ - by Mijata - 18.05.2015, 11:11
Re: Problem with freezing REP++ - by Konstantinos - 18.05.2015, 11:17
Re: Problem with freezing REP++ - by Mijata - 18.05.2015, 11:26

Forum Jump:


Users browsing this thread: 1 Guest(s)