[Tutorial] Getting a bonus for filling the kills table
#1


-Kills Table Bonus-

*This is my first ever tutorial,and also my first tutorial after a 6 months brake off scripting,so I still might have a few mistakes,just correct me if you spot them*


Well anyhow,I will teach you in here how give a play a bonus,if he has filled the kills table with his name
If you didn't understand,then you will see later what I mean,I don't have a picture right now since my SA:MP does not work,sorry for that.
Here we go:

Start by putting those variables on the top of your gamemode/filterscript;
pawn Code:
new TopKiller;
new TopKills = 0;
What do they mean?
TopKiller - the person who is the top killer(..)
TopKills - everytime the player kills someone,the TopKills will be increased by 1.Once the player has 5 TopKills ,he will fill the kills table and will get a bonus.

Now,put this code in the OnPlayerDeath public.
I will divide this code to 3 parts,and will explain to you about each and every part:
pawn Code:
if(killerid != TopKiller)
    {
        TopKiller = killerid;
        TopKills = 0;
    }
    TopKills++;
    if(TopKills == 5)
    {
        format(String,sizeof(String),"You have filled the kills board with your name and recived a 25000$ bonus!");
        SendClientMessage(playerid,0xFF0000DD,String);
        GivePlayerMoney(killerid,25000);
        TopKills = 0;
    }
Now to the explanation:

Part I
pawn Code:
if(killerid != TopKiller)
    {
        TopKiller = killerid;
        TopKills = 0;
    }
What does it do?
It checks if the last killer is another player,and if it is,it resets the previous top killer's kills to 0 and starts counting the new top killer kills.

Part II
pawn Code:
TopKills++;
Nothing much to explain,if the 'if' condition on the above does not exist (or whatever the right word is),then it adds +1 kill to the top killer kills count.

Part III
pawn Code:
if(TopKills == 5)
    {
        format(String,sizeof(String),"You have filled the kills board with your name and recived a 25000$ bonus!");
        SendClientMessage(playerid,0xFF0000DD,String);
        GivePlayerMoney(killerid,25000);
        TopKills = 0;
    }
This part is the most important part.
It checks if the Top Killer has reached a total kills of 5,.If he had,then it gives him the bonus + sends him a message about his achievement (of course that you can change the amount of money he gets,that's off-topic so I will not explain about that)

And that's pretty much it,I hope you like this tutorial
And again,if you spot any mistake or have any question,don't hesitate to ask
Greetings,Nuriel
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 5 Guest(s)