SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help > Tutorials

Reply
 
Thread Tools Display Modes
Old 24/11/2011, 06:26 PM   #1
nuriel8833
High-roller
 
nuriel8833's Avatar
 
Join Date: Jun 2009
Location: Israel
Posts: 1,187
Reputation: 16
Default Getting a bonus for filling the kills table


-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
__________________
Back to forums
Although I am not scripting much,only my gamemode on my free time

My works:
80.179.219.89:7778
[Tutorial] Kills Table BonusLast.fm
nuriel8833 is offline   Reply With Quote
Old 25/11/2011, 09:34 AM   #2
Mr_Scripter
Huge Clucker
 
Mr_Scripter's Avatar
 
Join Date: Mar 2011
Posts: 390
Reputation: 33
Default Re: Getting a bonus for filling the kills table

Nice tut
__________________

Current Project: Stunt-DM-Drift-Race.
Done: 0%
Looking for 2Mappers... Pm Me

Gamemodes
SanAndreas Team DeathMatch Gamemode-4 hours work
Mr_Scripter is offline   Reply With Quote
Old 26/11/2011, 05:51 PM   #3
nuriel8833
High-roller
 
nuriel8833's Avatar
 
Join Date: Jun 2009
Location: Israel
Posts: 1,187
Reputation: 16
Default Re: Getting a bonus for filling the kills table

Quote:
Originally Posted by Mr_Scripter View Post
Nice tut
Thanks
__________________
Back to forums
Although I am not scripting much,only my gamemode on my free time

My works:
80.179.219.89:7778
[Tutorial] Kills Table BonusLast.fm
nuriel8833 is offline   Reply With Quote
Old 26/11/2011, 05:53 PM   #4
Mr_Scripter
Huge Clucker
 
Mr_Scripter's Avatar
 
Join Date: Mar 2011
Posts: 390
Reputation: 33
Default Re: Getting a bonus for filling the kills table

118 Views and No comments ... lol
__________________

Current Project: Stunt-DM-Drift-Race.
Done: 0%
Looking for 2Mappers... Pm Me

Gamemodes
SanAndreas Team DeathMatch Gamemode-4 hours work
Mr_Scripter is offline   Reply With Quote
Old 27/11/2011, 03:54 PM   #5
nuriel8833
High-roller
 
nuriel8833's Avatar
 
Join Date: Jun 2009
Location: Israel
Posts: 1,187
Reputation: 16
Default Re: Getting a bonus for filling the kills table

Quote:
Originally Posted by Mr_Scripter View Post
118 Views and No comments ... lol
Yea that sucks >.>
I really hope I will get more comments soon cause I didnt make this tutorial for nothing..
__________________
Back to forums
Although I am not scripting much,only my gamemode on my free time

My works:
80.179.219.89:7778
[Tutorial] Kills Table BonusLast.fm
nuriel8833 is offline   Reply With Quote
Old 27/11/2011, 03:57 PM   #6
Kostas'
High-roller
 
Kostas''s Avatar
 
Join Date: Sep 2011
Location: Athens, Greece
Posts: 1,103
Reputation: 100
Default Re: Getting a bonus for filling the kills table

Very nice tutorial man.
__________________
Knowledge:
  • HTML
  • Pascal
  • Visual Basic
  • Algorithm
    • Pseudocode
Kostas' is offline   Reply With Quote
Old 27/11/2011, 05:16 PM   #7
Mr_Scripter
Huge Clucker
 
Mr_Scripter's Avatar
 
Join Date: Mar 2011
Posts: 390
Reputation: 33
Default Re: Getting a bonus for filling the kills table

Quote:
Originally Posted by nuriel8833 View Post
Yea that sucks >.>
I really hope I will get more comments soon cause I didnt make this tutorial for nothing..
i hope you get more comments/reps then you will probally make more tutorials and i can learn more ...
__________________

Current Project: Stunt-DM-Drift-Race.
Done: 0%
Looking for 2Mappers... Pm Me

Gamemodes
SanAndreas Team DeathMatch Gamemode-4 hours work
Mr_Scripter is offline   Reply With Quote
Old 30/11/2011, 06:05 PM   #8
nuriel8833
High-roller
 
nuriel8833's Avatar
 
Join Date: Jun 2009
Location: Israel
Posts: 1,187
Reputation: 16
Default Re: Getting a bonus for filling the kills table

Quote:
Originally Posted by Kostas' View Post
Very nice tutorial man.
Thanks
__________________
Back to forums
Although I am not scripting much,only my gamemode on my free time

My works:
80.179.219.89:7778
[Tutorial] Kills Table BonusLast.fm
nuriel8833 is offline   Reply With Quote
Old 01/12/2011, 12:21 PM   #9
Rudy_
Gangsta
 
Rudy_'s Avatar
 
Join Date: Nov 2011
Location: -Sweet Home- Reputation:9999
Posts: 865
Reputation: 137
Default Re: Getting a bonus for filling the kills table

Nice tutorial
__________________

Quote:
Originally Posted by StevoSamp View Post
Example please ? You get rap from me
Rudy_ is offline   Reply With Quote
Old 01/12/2011, 03:25 PM   #10
NessaHD
Huge Clucker
 
NessaHD's Avatar
 
Join Date: Sep 2011
Location: Bosnia & Herzegovina
Posts: 328
Reputation: 25
Default Re: Getting a bonus for filling the kills table

Nice tutorial.
__________________
=============

Im back! Forgot how to script, so im on my way to learn it again.

Im a xbox user. My gamertag is Chaos Nessa. Add me

Preparing to fail, is failing to prepare.


=============
NessaHD is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Filling a String Nonameman Help Archive 6 22/08/2010 09:07 PM
Error the needs filling thekingman100 Help Archive 5 09/08/2010 09:17 AM
Health filling bug XtremeChio Help Archive 1 05/08/2009 02:07 PM


All times are GMT. The time now is 06:49 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.