SA-MP Forums Archive
ekstra money when killing a wanted people does not work - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: ekstra money when killing a wanted people does not work (/showthread.php?tid=249620)



ekstra money when killing a wanted people does not work - Madsen - 19.04.2011

when killing a wanted people i do not get the ekstra money i am suppose to get. there is no errors or warnings in my script here is the code:
pawn Код:
wantedlevel = GetPlayerWantedLevel(killerid);
    SetPlayerWantedLevel(killerid, wantedlevel+1);
    Kills[playerid] = 0;
    Kills[killerid]++;
    SetPlayerWantedLevel(playerid, 0);
   
    if(Kills[playerid] == 1)
    {
        GivePlayerMoney(killerid, 5);
        SendClientMessage(killerid, COLOR_GREEN, "( $ ) you got 5 for killing a player 1 with star");
    }
    else
    if(Kills[playerid] == 2)
    {
        GivePlayerMoney(killerid, 15);
        SendClientMessage(killerid, COLOR_GREEN, "( $ ) you got 15 for killing a player with 2 stars");
    }
    else
    if(Kills[playerid] == 3)
    {
        GivePlayerMoney(killerid, 30);
        SendClientMessage(killerid, COLOR_GREEN, "( $ ) you got 30 for killing a player with 3 stars");
    }
    else
    if(Kills[playerid] == 4)
    {
        GivePlayerMoney(killerid, 60);
        SendClientMessage(killerid, COLOR_GREEN, "( $ ) you got 60 for killing a player with 4 stars");
    }
    else
    if(Kills[playerid] == 5)
    {
        GivePlayerMoney(killerid, 100);
        SendClientMessage(killerid, COLOR_GREEN, "( $ ) you got 100 for killing a player with 5 stars");
    }
    else
    if(Kills[playerid] > 5)
    {
        SendClientMessage(killerid, COLOR_GREEN, "( $ ) you got 150 for killing a most wanted player");
        GivePlayerMoney(killerid, 150);
    }



Re: ekstra money when killing a wanted people does not work - Stigg - 19.04.2011

Use the killerid.

pawn Код:
if(Kills[killerid] == 1)



Re: ekstra money when killing a wanted people does not work - Madsen - 19.04.2011

Quote:
Originally Posted by Stigg
Посмотреть сообщение
Use the killerid.

pawn Код:
if(Kills[killerid] == 1)
are you sure because its the player that died if his wanted level is 1 then the player killing him will get 5 dollars.


Re: ekstra money when killing a wanted people does not work - Stigg - 19.04.2011

Quote:
Originally Posted by Madsen
Посмотреть сообщение
are you sure because its the player that died if his wanted level is 1 then the player killing him will get 5 dollars.
It's what i use and it works like a charm. So i'm sure yes.
Just look here:

http://forum.sa-mp.com/showthread.ph...t=killingspree


Re: ekstra money when killing a wanted people does not work - admantis - 19.04.2011

Why are you using Kills[playerid] ? You are not getting his Kills, but his wanted level. Plus, Kills are set to 0 when he dies THEN the check, it will be always 0 and the other conditions will never get called.
Stop reseting the player data THEN checking it, it will be always 0!
Wanted level should NOT be reset and then checking it! Remove it!

pawn Код:
new WantedLevel = GetPlayerWantedLevel(playerid);
if(WantedLevel == 1)
    {
        GivePlayerMoney(killerid, 5);
        SendClientMessage(killerid, COLOR_GREEN, "( $ ) you got 5 for killing a player 1 with star");
    }
    else
    if(WantedLevel == 2)
    {
        GivePlayerMoney(killerid, 15);
        SendClientMessage(killerid, COLOR_GREEN, "( $ ) you got 15 for killing a player with 2 stars");
    }
    else
    if(WantedLevel == 3)
    {
        GivePlayerMoney(killerid, 30);
        SendClientMessage(killerid, COLOR_GREEN, "( $ ) you got 30 for killing a player with 3 stars");
    }
    else
    if(WantedLevel == 4)
    {
        GivePlayerMoney(killerid, 60);
        SendClientMessage(killerid, COLOR_GREEN, "( $ ) you got 60 for killing a player with 4 stars");
    }
    else
    if(WantedLevel == 5)
    {
        GivePlayerMoney(killerid, 100);
        SendClientMessage(killerid, COLOR_GREEN, "( $ ) you got 100 for killing a player with 5 stars");
    }
    else
    if(WantedLevel > 5)
    {
        SendClientMessage(killerid, COLOR_GREEN, "( $ ) you got 150 for killing a most wanted player");
        GivePlayerMoney(killerid, 150);
    }
I'd suggest a 'switch .. case' structure anyways.


Re: ekstra money when killing a wanted people does not work - Madsen - 19.04.2011

Quote:
Originally Posted by admantis
Посмотреть сообщение
Why are you using Kills[playerid] ? You are not getting his Kills, but his wanted level. Plus, Kills are set to 0 when he dies THEN the check, it will be always 0 and the other conditions will never get called.
Stop reseting the player data THEN checking it, it will be always 0!
Wanted level should NOT be reset and then checking it! Remove it!

pawn Код:
new WantedLevel = GetPlayerWantedLevel(playerid);
if(WantedLevel == 1)
    {
        GivePlayerMoney(killerid, 5);
        SendClientMessage(killerid, COLOR_GREEN, "( $ ) you got 5 for killing a player 1 with star");
    }
    else
    if(WantedLevel == 2)
    {
        GivePlayerMoney(killerid, 15);
        SendClientMessage(killerid, COLOR_GREEN, "( $ ) you got 15 for killing a player with 2 stars");
    }
    else
    if(WantedLevel == 3)
    {
        GivePlayerMoney(killerid, 30);
        SendClientMessage(killerid, COLOR_GREEN, "( $ ) you got 30 for killing a player with 3 stars");
    }
    else
    if(WantedLevel == 4)
    {
        GivePlayerMoney(killerid, 60);
        SendClientMessage(killerid, COLOR_GREEN, "( $ ) you got 60 for killing a player with 4 stars");
    }
    else
    if(WantedLevel == 5)
    {
        GivePlayerMoney(killerid, 100);
        SendClientMessage(killerid, COLOR_GREEN, "( $ ) you got 100 for killing a player with 5 stars");
    }
    else
    if(WantedLevel > 5)
    {
        SendClientMessage(killerid, COLOR_GREEN, "( $ ) you got 150 for killing a most wanted player");
        GivePlayerMoney(killerid, 150);
    }
I'd suggest a 'switch .. case' structure anyways.
thanks i think this will help. reason why i did it the way i did is because i can not remove the errors but you helped me alot here so thanks


Re: ekstra money when killing a wanted people does not work - Madsen - 19.04.2011

Quote:
Originally Posted by Madsen
Посмотреть сообщение
thanks i think this will help. reason why i did it the way i did is because i can not remove the errors but you helped me alot here so thanks
it did not work :S


Re: ekstra money when killing a wanted people does not work - admantis - 19.04.2011

Share code :P


Re: ekstra money when killing a wanted people does not work - Madsen - 19.04.2011

Quote:
Originally Posted by Stigg
Посмотреть сообщение
It's what i use and it works like a charm. So i'm sure yes.
Just look here:

http://forum.sa-mp.com/showthread.ph...t=killingspree
the thing he does is giving a player who is on killing spree a bonus not the player killing a guy thats on a spree


Re: ekstra money when killing a wanted people does not work - Madsen - 19.04.2011

Quote:
Originally Posted by admantis
Посмотреть сообщение
Share code :P
pawn Код:
public OnPlayerDeath(playerid, killerid, reason)
{
    if(sw[playerid] == 1)
    {
        SendClientMessage(killerid, COLOR_GREEN, "( ! ) You got a bonus for killing a player in ShotgunWar");
        SendClientMessage(killerid, COLOR_GREEN, "( $ ) +150");
        GivePlayerMoney(killerid, 150);
        SendClientMessage(playerid, COLOR_NORMALRED, "( $ ) -10");
        GivePlayerMoney(playerid, -10);
    }
    else
    if(cw[playerid] == 1)
    {
        SendClientMessage(killerid, COLOR_GREEN, "( ! ) You got 175 for killing a player in ChainsawWar");
        SendClientMessage(killerid, COLOR_GREEN, "( $ ) +175");
        GivePlayerMoney(killerid, 175);
        SendClientMessage(playerid, COLOR_NORMALRED, "( $ ) -10");
        GivePlayerMoney(playerid, -10);
    }
    else
    if(m4w[playerid] == 1)
    {
        SendClientMessage(killerid, COLOR_GREEN, "( ! ) You got a bonus for killing a player in M4WAR");
        SendClientMessage(killerid, COLOR_GREEN, "( $ ) +150");
        GivePlayerMoney(killerid, 150);
        SendClientMessage(playerid, COLOR_NORMALRED, "( $ ) -10");
        GivePlayerMoney(playerid, -10);
    }
    else
    if(mgw[playerid] == 1)
    {
        SendClientMessage(killerid, COLOR_GREEN, "( ! ) You got a bonus for killing a player in MinigunWar");
        SendClientMessage(killerid, COLOR_GREEN, "( $ ) +200");
        GivePlayerMoney(killerid, 200);
        SendClientMessage(playerid, COLOR_NORMALRED, "( $ ) -10");
        GivePlayerMoney(playerid, -10);
    }
    else
    if(fistfight[playerid] == 1)
    {
        SendClientMessage(killerid, COLOR_GREEN, "( ! ) You got less for killing a player in Fist fight");
        SendClientMessage(killerid, COLOR_GREEN, "( $ ) +50");
        GivePlayerMoney(killerid, 50);
        SendClientMessage(playerid, COLOR_NORMALRED, "( $ ) -10");
        GivePlayerMoney(playerid, -10);
    }
    else
    if(dew[playerid] == 1)
    {
        SendClientMessage(killerid, COLOR_GREEN, "( ! ) You got a bonus for killing a player in Desert Eagle War");
        SendClientMessage(killerid, COLOR_GREEN, "( $ ) +250");
        GivePlayerMoney(killerid, 50);
        SendClientMessage(playerid, COLOR_NORMALRED, "( $ ) -10");
        GivePlayerMoney(playerid, -10);
    }
    else
    if(m4w[playerid] == 0 || sw[playerid] == 0 || mgw[playerid] == 0 || fistfight[playerid] == 0 || dew[playerid] == 0)
    {
        SendClientMessage(killerid, COLOR_GREEN, "You just killed a player");
        SendClientMessage(killerid, COLOR_GREEN, "( $ ) +100");
        GivePlayerMoney(killerid, 100);
        SendClientMessage(playerid, COLOR_NORMALRED, "( $ ) -10");
        GivePlayerMoney(playerid, -10);
        SetPlayerVirtualWorld(playerid, 0);
        SetPlayerInterior(playerid, 0);
    }
   
    wantedlevel = GetPlayerWantedLevel(killerid);
    SetPlayerWantedLevel(killerid, wantedlevel+1);
    SetPlayerWantedLevel(playerid, 0);
    WantedLevel = GetPlayerWantedLevel(playerid);
   
    if(WantedLevel == 1)
    {
        GivePlayerMoney(killerid, 5);
        SendClientMessage(killerid, COLOR_GREEN, "( $ ) you got 5 for killing a player 1 with star");
    }
    else
    if(WantedLevel == 2)
    {
        GivePlayerMoney(killerid, 15);
        SendClientMessage(killerid, COLOR_GREEN, "( $ ) you got 15 for killing a player with 2 stars");
    }
    else
    if(WantedLevel == 3)
    {
        GivePlayerMoney(killerid, 30);
        SendClientMessage(killerid, COLOR_GREEN, "( $ ) you got 30 for killing a player with 3 stars");
    }
    else
    if(WantedLevel == 4)
    {
        GivePlayerMoney(killerid, 60);
        SendClientMessage(killerid, COLOR_GREEN, "( $ ) you got 60 for killing a player with 4 stars");
    }
    else
    if(WantedLevel == 5)
    {
        GivePlayerMoney(killerid, 100);
        SendClientMessage(killerid, COLOR_GREEN, "( $ ) you got 100 for killing a player with 5 stars");
    }
    else
    if(WantedLevel > 5)
    {
        SendClientMessage(killerid, COLOR_GREEN, "( $ ) you got 150 for killing a most wanted player");
        GivePlayerMoney(killerid, 150);
    }
   
    SendDeathMessage(killerid, playerid, reason);
    GivePlayerMoney(playerid, 100);

    // Cityhall
    if IsPlayerInRangeOfPoint(playerid, 200, 368.2953,173.8816,1008.3828)
    *then SendClientMessage(killerid, 0xFF0000FF, "( ! ) You are kicked by the server for: Kill in a Forbidden Place")
    && Kick(killerid);
    else
    // Bank
    if IsPlayerInRangeOfPoint(playerid, 200, 347.2672,173.7295,1014.1875)
    *then SendClientMessage(killerid, 0xFF0000FF, "( ! ) You are kicked by the server for: Kill in a Forbidden Place")
    && Kick(killerid);
    return 1;
}