Getting the top killer
#1

Hello friends I want to know how can i detect the player with highest kills I use the variable
pawn Код:
PlayerKills[playerid]
to store the kills also i just want the top killer from online players. Anyhelp? Thanks.
Reply
#2

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
Reply
#3

You mean
pawn Код:
GivePlayerMoney(topid,amount);
right?
Reply
#4

Quote:
Originally Posted by HitterHitman
Посмотреть сообщение
You mean
pawn Код:
GivePlayerMoney(topid,amount);
right?
Ops yeah sorry
Reply
#5

use isplayerconnected function & loop through all users, using your kills variable,, then get the result listed in dialog.
Reply
#6

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"?
Reply
#7

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
Reply
#8

Thanks works perfectly.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)