Getting the top killer - 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)
+--- Thread: Getting the top killer (
/showthread.php?tid=514345)
Getting the top killer -
HitterHitman - 21.05.2014
Hello friends I want to know how can i detect the player with highest kills I use the variable
to store the kills also i just want the top killer from online players. Anyhelp? Thanks.
Re: Getting the top killer -
JFF - 21.05.2014
pawn Код:
new topkills = 0;
new topid = -1;
for(new i=0; i < MAX_PLAYERS; i++)
{
if(topkills < PlayerKills[i])
{
topkills = PlayerKills[i];
topid = i;
}
}
Topid = the playerid who got the highest kills
u can use it like this
pawn Код:
GivePlayerMoney(topid, amount);
topkills = the kills that the top killers has
P.S Didnt test it because i am on phone if theres any error tell me
Re: Getting the top killer -
HitterHitman - 21.05.2014
You mean
pawn Код:
GivePlayerMoney(topid,amount);
right?
Re: Getting the top killer -
JFF - 21.05.2014
Quote:
Originally Posted by HitterHitman
You mean
pawn Код:
GivePlayerMoney(topid,amount);
right?
|
Ops yeah sorry
Re: Getting the top killer - Guest4390857394857 - 21.05.2014
use isplayerconnected function & loop through all users, using your kills variable,, then get the result listed in dialog.
Re: Getting the top killer -
HitterHitman - 21.05.2014
Quote:
Originally Posted by JFF
Ops yeah sorry
|
Works great but i am using the topid's name in a string for eg. TextDrawSetString(topper, TopidName);
The problem is that it sets the string to " " but how can i make it like when there is no topid it sets the string to "None"?
Re: Getting the top killer -
JFF - 21.05.2014
Quote:
Originally Posted by HitterHitman
Works great but i am using the topid's name in a string for eg. TextDrawSetString(topper, TopidName);
The problem is that it sets the string to " " but how can i make it like when there is no topid it sets the string to "None"?
|
pawn Код:
if(topid == -1)
{
TextDrawSetString(topper, "None");
}
This should work
Re: Getting the top killer -
HitterHitman - 21.05.2014
Thanks works perfectly.