kills not doing anything!
#1

It compiled, gave me no errors at all, but it does nothing aswell. If i kill a civilian with 4+ wanted level, it does none of what i have wrote

PHP код:
public OnPlayerDeath(playeridkilleridreason)
{
    if(
gTeam{killerid} == CIVILIAN)
    {
        
SetPlayerWantedLevel(killerid,GetPlayerWantedLevel(killerid) + 10);
        
SendClientMessage(killeridCOLOR_RED"[Murder Committed] Your wanted level has increased by 10!");
        
SetPlayerWantedLevel(playerid0);
        return 
1;
    }
        if(
gTeam{playerid} == CIVILIAN && gTeam{killerid} == POLICE || gTeam{killerid} == SWAT || gTeam{killerid} == ARMY)
    {
        if(
GetPlayerWantedLevel(playerid) == 0)
        {
            
SetPlayerScore(killeridGetPlayerScore(killerid)-1);
            
SendClientMessage(killeridCOLOR_WHITE"DONT KILL innocent players! /pc! /rules!");
            
//GivePlayerCash(killerid, -10000);
            //SetPlayerHealth(killerid, 0.0);
            
return 1;
        }
        else if(
GetPlayerWantedLevel(playerid) <= && GetPlayerWantedLevel(playerid) >= 1)
        {
            
SendClientMessage(killeridCOLOR_WHITE"DONT KILL innocent suspects! /pc! Ticket them! /tk!");
            
SetPlayerScore(killeridGetPlayerScore(killerid)-1);
            
//SetPlayerHealth(killerid, 0.0);
            
return 1;
        }
        else if(
GetPlayerWantedLevel(playerid) >= 4)
        {
            if(
gTeam{killerid} == POLICE)
            {
                new 
str2[200];
                
SetPlayerScore(killeridGetPlayerScore(killerid)+1);
                
format(str2sizeof(str2), "Suspect %s [%d] has been taken down by Officer %s [%d]",GetName(playerid),playerid,GetName(killerid),killerid);
                
SendClientMessageToAll(COLOR_RED,str2);
                
SendClientMessage(killeridCOLOR_BLUE"You have received $2000 for taking down a Medium Wanted Level criminal!");
                
GivePlayerMoney(killerid2000);
                
SetPlayerWantedLevel(playerid0);
                return 
1;
            }
        }
        else if(
gTeam{killerid} == ARMY)
            {
                new 
str2[200];
                
SetPlayerScore(killeridGetPlayerScore(killerid)+1);
                
format(str2sizeof(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(killeridARMY_COLOUR," Good Job! You have received $5000 for taking down a Medium Wanted Level criminal.");
                
GivePlayerMoney(killerid5000);
                
SetPlayerWantedLevel(playerid0);
                return 
1;
            }
            else if(
gTeam{killerid} == SWAT)
            {
                new 
str2[200];
                
SetPlayerScore(killeridGetPlayerScore(killerid)+1);
                
format(str2sizeof(str2), "SWAT Member %s [%d] has been taken down suspect %s (%d)!",GetName(killerid),killerid,GetName(playerid),playerid);
                
SendClientMessageToAll(SWAT_COLOUR,str2);
                
SendClientMessage(killeridSWAT_COLOUR," Good Job! You have received $2500 for taking down a Medium Wanted Level criminal.");
                
GivePlayerMoney(killerid2500);
                
SetPlayerWantedLevel(playerid0);
                return 
1;
            }
    }
    else if(
GetPlayerWantedLevel(playerid) >= 9)
    {
        if(
gTeam{killerid} == POLICE)
        {
                 new 
str2[200];
                
SetPlayerScore(killeridGetPlayerScore(killerid)+1);
                
format(str2sizeof(str2), "Suspect %s [%d] has been taken down by Officer %s [%d]",GetName(playerid),playerid,GetName(killerid),killerid);
                
SendClientMessageToAll(COLOR_RED,str2);
                
SendClientMessage(killeridCOLOR_BLUE"You have received $5000 for taking down a High Wanted Level criminal!");
                
GivePlayerMoney(killerid5000);
                
SetPlayerWantedLevel(playerid0);
                return 
1;
        }
        else if(
gTeam{killerid} == ARMY)
        {
                new 
str2[200];
                
SetPlayerScore(killeridGetPlayerScore(killerid)+3);
                
format(str2sizeof(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(killeridSWAT_COLOUR," Good Job! You have received $10000 for taking down a High Wanted Level criminal.");
                
GivePlayerMoney(killerid10000);
                
SetPlayerWantedLevel(playerid0);
                return 
1;
        }
        else if(
gTeam{killerid} == SWAT)
            {
                new 
str2[200];
                
SetPlayerScore(killeridGetPlayerScore(killerid)+1);
                
format(str2sizeof(str2), "SWAT Member %s [%d] has been taken down suspect %s (%d)!",GetName(killerid),killerid,GetName(playerid),playerid);
                
SendClientMessageToAll(SWAT_COLOUR,str2);
                
SendClientMessage(killeridSWAT_COLOUR," Good Job! You have received $7500 for taking down a High Wanted Level criminal.");
                
GivePlayerMoney(killerid7500);
                
SetPlayerWantedLevel(playerid0);
                return 
1;
            }
    }
    
SendDeathMessage(killeridplayeridreason);
    
SetPlayerWantedLevel(playerid0); //reset wanted level
    
return 1;

Reply
#2

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.
Reply
#3

Quote:
Originally Posted by MP2
Посмотреть сообщение
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.
Could you please help, im new to scripting, and im running on two hours of sleep, my heads not kind of working atm aswell.. thanks

Still not working for me

edit:
PHP код:
public OnPlayerDeath(playeridkilleridreason)
{
        if(
killerid == INVALID_PLAYER_ID)
        {
            
SendDeathMessage(INVALID_PLAYER_IDplayeridreason);
            return 
1;
        }
    if(
killerid != INVALID_PLAYER_ID)
    {
        if(
gTeam{killerid} == CIVILIAN)
        {
            
SetPlayerWantedLevel(killerid,GetPlayerWantedLevel(killerid) + 10);
            
SendClientMessage(killeridCOLOR_RED"[Murder Committed] Your wanted level has increased by 10!");
            
SetPlayerWantedLevel(playerid0);
            
SendDeathMessage(killerid,playerid,reason);
            return 
1;
        }
        if(
gTeam{playerid} == CIVILIAN && gTeam{killerid} == POLICE || gTeam{killerid} == SWAT || gTeam{killerid} == ARMY)
        {
            if(
GetPlayerWantedLevel(playerid) == 0)
            {
                
SetPlayerScore(killeridGetPlayerScore(killerid)-1);
                
SendClientMessage(killeridCOLOR_WHITE"DONT KILL innocent players! /pc! /rules!");
                
//GivePlayerCash(killerid, -10000);
                //SetPlayerHealth(killerid, 0.0);
                
SendDeathMessage(killerid,playerid,reason);
                return 
1;
            }
            else if(
GetPlayerWantedLevel(playerid) <= && GetPlayerWantedLevel(playerid) >= 1)
            {
                
SendClientMessage(killeridCOLOR_WHITE"DONT KILL innocent suspects! /pc! Ticket them! /tk!");
                
SetPlayerScore(killeridGetPlayerScore(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(killeridGetPlayerScore(killerid)+1);
                    
format(str2sizeof(str2), "Suspect %s [%d] has been taken down by Officer %s [%d]",GetName(playerid),playerid,GetName(killerid),killerid);
                    
SendClientMessageToAll(COLOR_RED,str2);
                    
SendClientMessage(killeridCOLOR_BLUE"You have received $2000 for taking down a Medium Wanted Level criminal!");
                    
GivePlayerMoney(killerid2000);
                    
SetPlayerWantedLevel(playerid0);
                    
SendDeathMessage(killerid,playerid,reason);
                    return 
1;
                }
            }
            else if(
gTeam{killerid} == ARMY)
            {
                new 
str2[200];
                
SetPlayerScore(killeridGetPlayerScore(killerid)+1);
                
format(str2sizeof(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(killeridARMY_COLOUR," Good Job! You have received $5000 for taking down a Medium Wanted Level criminal.");
                
GivePlayerMoney(killerid5000);
                
SetPlayerWantedLevel(playerid0);
                
SendDeathMessage(killerid,playerid,reason);
                return 
1;
            }
            else if(
gTeam{killerid} == SWAT)
            {
                new 
str2[200];
                
SetPlayerScore(killeridGetPlayerScore(killerid)+1);
                
format(str2sizeof(str2), "SWAT Member %s [%d] has been taken down suspect %s (%d)!",GetName(killerid),killerid,GetName(playerid),playerid);
                
SendClientMessageToAll(SWAT_COLOUR,str2);
                
SendClientMessage(killeridSWAT_COLOUR," Good Job! You have received $2500 for taking down a Medium Wanted Level criminal.");
                
GivePlayerMoney(killerid2500);
                
SetPlayerWantedLevel(playerid0);
                
SendDeathMessage(killerid,playerid,reason);
                return 
1;
            }
    }
    else if(
GetPlayerWantedLevel(playerid) >= 9)
    {
        if(
gTeam{killerid} == POLICE)
        {
                 new 
str2[200];
                
SetPlayerScore(killeridGetPlayerScore(killerid)+1);
                
format(str2sizeof(str2), "Suspect %s [%d] has been taken down by Officer %s [%d]",GetName(playerid),playerid,GetName(killerid),killerid);
                
SendClientMessageToAll(COLOR_RED,str2);
                
SendClientMessage(killeridCOLOR_BLUE"You have received $5000 for taking down a High Wanted Level criminal!");
                
GivePlayerMoney(killerid5000);
                
SetPlayerWantedLevel(playerid0);
                
SendDeathMessage(killerid,playerid,reason);
                return 
1;
        }
        else if(
gTeam{killerid} == ARMY)
        {
                new 
str2[200];
                
SetPlayerScore(killeridGetPlayerScore(killerid)+3);
                
format(str2sizeof(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(killeridSWAT_COLOUR," Good Job! You have received $10000 for taking down a High Wanted Level criminal.");
                
GivePlayerMoney(killerid10000);
                
SetPlayerWantedLevel(playerid0);
                
SendDeathMessage(killerid,playerid,reason);
                return 
1;
        }
        else if(
gTeam{killerid} == SWAT)
            {
                new 
str2[200];
                
SetPlayerScore(killeridGetPlayerScore(killerid)+1);
                
format(str2sizeof(str2), "SWAT Member %s [%d] has been taken down suspect %s (%d)!",GetName(killerid),killerid,GetName(playerid),playerid);
                
SendClientMessageToAll(SWAT_COLOUR,str2);
                
SendClientMessage(killeridSWAT_COLOUR," Good Job! You have received $7500 for taking down a High Wanted Level criminal.");
                
GivePlayerMoney(killerid7500);
                
SetPlayerWantedLevel(playerid0);
                
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(playerid0); //reset wanted level
    
}
    return 
1;

---------------------------------------------------------------------------------------------------------------
EDIT: Fixed it myself, thanks anyways
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)