SA-MP Forums Archive
player with best online killings - 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: player with best online killings (/showthread.php?tid=642830)



player with best online killings - Sarti - 07.10.2017

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!


Re: player with best online killings - Sew_Sumi - 07.10.2017

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.


Re: player with best online killings - Sarti - 08.10.2017

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


Re: player with best online killings - SyS - 08.10.2017

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.


Re: player with best online killings - Sarti - 08.10.2017

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


Re: player with best online killings - RIDE2DAY - 09.10.2017

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.


Re: player with best online killings - Sarti - 13.10.2017

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


Re: player with best online killings - Sew_Sumi - 13.10.2017

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...


Re: player with best online killings - raydx - 13.10.2017

Add break; to the end of your loop.


Re: player with best online killings - Sew_Sumi - 13.10.2017

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.