PDA

View Full Version : Getting the top killer


HitterHitman
21/05/2014, 03:26 AM
Hello friends I want to know how can i detect the player with highest kills I use the variable PlayerKills[playerid] to store the kills also i just want the top killer from online players. Anyhelp? Thanks.

JFF
21/05/2014, 03:47 AM
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

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

HitterHitman
21/05/2014, 03:55 AM
You mean

GivePlayerMoney(topid,amount);


right?

JFF
21/05/2014, 04:02 AM
You mean

GivePlayerMoney(topid,amount);


right?
Ops yeah sorry

Guest4390857394857
21/05/2014, 05:27 AM
use isplayerconnected function & loop through all users, using your kills variable,, then get the result listed in dialog. :D

HitterHitman
21/05/2014, 01:17 PM
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"?

JFF
21/05/2014, 01:22 PM
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"?

if(topid == -1)
{
TextDrawSetString(topper, "None");
}


This should work

HitterHitman
21/05/2014, 01:38 PM
Thanks works perfectly.