player with best online killings
#1

Code:
stock bestkill()
{

new string[120];

new Player;


for(new i=0; i<MAX_PLAYERS; i++)
{
    if(IsPlayerConnected(i))
    {

         if(BKills[i] < 1)
	{
         format(string, sizeof(string), "Best Player Killer Of Day None , Kills: 
         (0)",PlayerInfo[PlayerЗ[pName],Player,BKills[Player]);
	 SendClientMessageToAll(COLOR_BEST, string);
         }
         else
         {
         if(BKills[i] > BKills[Player]) Player = i;
        format(string, sizeof(string), "Best Player Killer Of Day %s(%d), Kills: (%d)",PlayerInfo[Player]
        [pName],Player,BKills[Player]);
	SendClientMessageToAll(COLOR_BEST, string);

         }
}
}
when 2 players have the same kills when running stock does not detect anyone as best killer
HELP!
Reply
#2

When this does work, it will spam the shit out of you every time it picks up a player higher than the 'best', it will show another line.

The format line, and the SendClientMessageToAll should be OUTSIDE the loop.
Reply
#3

I understand but if there are 2 players with the same kills does not come out any better, I would like one at least
Reply
#4

find the largest kills amount by looping and then loop again to concat the details of player having same amount of largest kills to a string and show that string as a message.
Reply
#5

Quote:
Originally Posted by SyS
View Post
find the largest kills amount by looping and then loop again to concat the details of player having same amount of largest kills to a string and show that string as a message.
could you give me an example please
Reply
#6

PHP Code:
GetBestKillerID()
{
    new 
kills 0;
    new 
killerid INVALID_PLAYER_ID;
    for(new 
0GetPlayerPoolSize(); <= tx++)
    {
        if(!
IsPlayerConnected(x)) continue;
        if(
p_Kills[x] > kills)
        {
            
kills p_Kills[x];
            
killerid x;
        }
    }
    return 
killerid;
}
// - Somewhere - //
new name[24];
new 
message[144];
new 
best_killer_id GetBestKillerID();
GetPlayerName(best_killer_idnamesizeof(name));
format(messagesizeof(message), "Player [%d]%s is the best killer ever, with an amount of %d kills."best_killer_idnamep_Kills[best_killer_id]);
SendClientMessageToAll(-1message); 
Dude, this isn't tested but I think it should work.
Reply
#7

Quote:
Originally Posted by RIDE2DAY
View Post
PHP Code:
GetBestKillerID()
{
    new 
kills 0;
    new 
killerid INVALID_PLAYER_ID;
    for(new 
0GetPlayerPoolSize(); <= tx++)
    {
        if(!
IsPlayerConnected(x)) continue;
        if(
p_Kills[x] > kills)
        {
            
kills p_Kills[x];
            
killerid x;
        }
    }
    return 
killerid;
}
// - Somewhere - //
new name[24];
new 
message[144];
new 
premio 50000
new best_killer_id GetBestKillerID();
GetPlayerName(best_killer_idnamesizeof(name));
format(messagesizeof(message), "Player [%d]%s is the best killer ever, with an amount of %d kills."best_killer_idnamep_Kills[best_killer_id]);
SendClientMessageToAll(-1message);
format(stringsizeof(string), "[SERVER]:
Congratulations, You've Been The Highest Killer Player Of The Day, bonus: {00C017}$%d. +3 Score"
,Premio);
SendClientMessage(best_killer_id0x00CA97FFstring);
GivePlayerCash(best_killer_id,Premio); 
Dude, this isn't tested but I think it should work.
It worked for me but now when I receive the prize the prize is repeated for players connected
example:
if there are 20 players, the prize for the best killer is repeated 20 times
Reply
#8

Quote:
Originally Posted by Sarti
View Post
if there are 20 players, the prize for the best killer is repeated 20 times
That's what I said about before... Obviously you've got this inside a loop by simply copy-pasting it in the wrong place...
Reply
#9

Add break; to the end of your loop.
Reply
#10

Quote:
Originally Posted by raydx
View Post
Add break; to the end of your loop.
Can you not guess... It's pretty clear what the issue is if you know what is going on.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)