Wanted level +1 on player kill?? (bugged)
#1

Hi People,

I have added a simple bit of script, When an innocent player gets killed, the killer gets a +1 wanted star.

The trouble is.. when I kill someone the first time I dont get the reward money or a wanted star.

In order to get a wanted star or reward, I have to kill the person twice.


Is the code right? or could there be another script messing around with it?



Код:
public OnPlayerSpawn(playerid)
{
    SetPlayerWantedLevel(playerid, 0); //reset wanted level
}

Код:
public OnPlayerDeath(playerid, killerid, reason)
{

if (GetPlayerWantedLevel(playerid) == 0)
{

SendClientMessage(killerid,COLOR_RED, "You killed an innocent person!, wanted level has been increased.");
SetPlayerWantedLevel(killerid, GetPlayerWantedLevel(killerid) + 1); 

}



else if (GetPlayerWantedLevel(playerid) => 1) 

{ 

GivePlayerMoney(killerid,10000); 
SendClientMessage(killerid,COLOR_GREEN, "You killed a player with a level 1 wanted level"); 
SendClientMessage(killerid,COLOR_WHITE, "You get $10,000 reward");

}

}
thanks in advance!
Reply
#2

if (GetPlayerWantedLevel(playerid) == 0)
{
GivePlayerMoney(killerid,10000);
SendClientMessage(killerid,COLOR_RED, "You killed an innocent person!, wanted level has been increased.");
SetPlayerWantedLevel(killerid, GetPlayerWantedLevel(killerid) + 1);

}
Reply
#3

The only problem I saw was that you wrote "=>" instead of ">="


Here again the same code just everything in OnPlayerDeath
pawn Код:
public OnPlayerDeath(playerid, killerid, reason)
{
    if(killerid != INVALID_PLAYER_ID)
    { //jumping from cliff and so on
        if (GetPlayerWantedLevel(playerid) == 0)
        {
            SendClientMessage(killerid, COLOR_RED, "You killed an innocent person!, wanted level has been increased.");
            SetPlayerWantedLevel(killerid, GetPlayerWantedLevel(killerid) + 1);
        } else {
            SendClientMessage(killerid, COLOR_GREEN, "You killed a wanted player!, you get $10,000 reward.");
            GivePlayerMoney(killerid, 10_000);
        }
    }
    SetPlayerWantedLevel(playerid, 0);
}
And try to check for the messages, if none appeared try to debug the problem out
Reply
#4

Quote:
Originally Posted by Nero_3D
Посмотреть сообщение
The only problem I saw was that you wrote "=>" instead of ">="


Here again the same code just everything in OnPlayerDeath
pawn Код:
public OnPlayerDeath(playerid, killerid, reason)
{
    if(killerid != INVALID_PLAYER_ID)
    { //jumping from cliff and so on
        if (GetPlayerWantedLevel(playerid) == 0)
        {
            SendClientMessage(killerid, COLOR_RED, "You killed an innocent person!, wanted level has been increased.");
            SetPlayerWantedLevel(killerid, GetPlayerWantedLevel(killerid) + 1);
        } else {
            SendClientMessage(killerid, COLOR_GREEN, "You killed a wanted player!, you get $10,000 reward.");
            GivePlayerMoney(killerid, 10_000);
        }
    }
    SetPlayerWantedLevel(playerid, 0);
}
And try to check for the messages, if none appeared try to debug the problem out
Yeah Nothing shows at all the first time, but the second kill registers. I will defo try debug mode soon.


thanks for the advice!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)