Finding The Greatest Variable Value In The Server
#1

Hey guyz. I need help making a code to find the person that has the greatest variable of TotalKills[MAX_PLAYERS].

Example:

If billy is TotalKills = 10;
and If john is TotalKills = 59;

John would be the person with the greatest.

Thanks for your help!
Reply
#2

wrong topic - delete please
Reply
#3

Wrong topic? How is this wrong topic. Im asking for help.
Reply
#4

Dresden you feel dumb right?


Can you be more specific, lolumadd?
Reply
#5

Quote:
Originally Posted by Compton's Eazy E
Dresden you feel dumb right?


Can you be more specific, lolumadd?
On a timer for my gamemode I want it to check which player has the highest value in that one variable. I dont know how I can explain it better. ^^
Reply
#6

ud need to loop every play through every player with 2 for loops and do in it

if(TotalKills[firstplayerid] > TotalKills[secondplayerid])
{
Whatever you want when it got checked that first player got higher score
}
Reply
#7

Quote:
Originally Posted by Compton's Eazy E
Dresden you feel dumb right?


Can you be more specific, lolumadd?
He means when a certain amount of time has gone by, have a message appear saying "% has the most kills!".But he doesn't know how to make this, well i think
Reply
#8

Quote:
Originally Posted by ┤ŞąiBЄЯҒПŋ├
ud need to loop every play through every player with 2 for loops and do in it

if(TotalKills[firstplayerid] > TotalKills[secondplayerid])
{
Whatever you want when it got checked that first player got higher score
}
Can you make that fully. I dont know how I would do that.
This is what im thinking

pawn Код:
for(new i = 0; i < GetMaxPlayers(); i++)
    {
        if(IsPlayerConnected(i))
        {
            for(new player = 0; player < GetMaxPlayers(); player++)
            {
                if(IsPlayerConnected(player))
                {
new bestsofar;
if(TotalKills[i] > TotalKills[player]) { bestsofar = i;
else if(TotalKills[player] > TotalKills[i]) { bestsofar = player;

tryagain:
if( i == GetMaxPlayers() && player == GetMaxPlayers()) {
GetPlayerName(bestsofar, nameoftheguy
%s has the most kills!, nameoftheguy
}
else
{
goto tryagain;
}
Reply
#9

Quote:
Originally Posted by lolumadd [cod5server.tk
]
Quote:
Originally Posted by ┤ŞąiBЄЯҒПŋ├
ud need to loop every play through every player with 2 for loops and do in it

if(TotalKills[firstplayerid] > TotalKills[secondplayerid])
{
Whatever you want when it got checked that first player got higher score
}
Can you make that fully. I dont know how I would do that.
This is what im thinking

pawn Код:
for(new i = 0; i < GetMaxPlayers(); i++)
    {
        if(IsPlayerConnected(i))
        {
            for(new player = 0; player < GetMaxPlayers(); player++)
            {
                if(IsPlayerConnected(player))
                {
new bestsofar;
if(TotalKills[i] > TotalKills[player]) { bestsofar = i;
else if(TotalKills[player] > TotalKills[i]) { bestsofar = player;

if( i == GetMaxPlayers() && player == GetMaxPlayers()) {
GetPlayerName(bestsofar, nameoftheguy
%s has the most kills!, nameoftheguy
sry I can'T i have to go to bed i scripted all night my eyes hurt X_X
when there were nobody who helped u until tomorro evening ill help u..
baibai
Reply
#10

Lul, I don't even know why I'm still messing with Pawn, but here:
Код:
new HighestScore;
new TotalKills[MAX_PLAYERS];
new KillUpdate[MAX_PLAYER_NAME];

forward MyTimer();
public MyTimer()
{
	new killstr[128];
	new kill=0;
	do
	{
	  if(TotalKills[kill] > HighestScore)
	  {
	    GetPlayerName(kill, KillUpdate, sizeof(KillUpdate));
	    format(killstr, 128, "%s has set the new kill spree record at %i kills!", KillUpdate, TotalKills[kill]);
	    SendClientMessageToAll(color, killstr);
	    HighestScore = TotalKills[kill];
	  }
	  kill++;
	}
	while(kill<MAX_PLAYERS);
	return 0;
}
Use something similar to that.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)