Finding The Greatest Variable Value In The Server -
lolumadd - 19.10.2009
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!
Re: Finding The Greatest Variable Value In The Server -
Dresden - 19.10.2009
wrong topic - delete please
Re: Finding The Greatest Variable Value In The Server -
lolumadd - 19.10.2009
Wrong topic? How is this wrong topic. Im asking for help.
Re: Finding The Greatest Variable Value In The Server -
Eazy_Efolife - 19.10.2009
Dresden you feel dumb right?
Can you be more specific, lolumadd?
Re: Finding The Greatest Variable Value In The Server -
lolumadd - 19.10.2009
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. ^^
Re: Finding The Greatest Variable Value In The Server -
saiberfun - 19.10.2009
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
}
Re: Finding The Greatest Variable Value In The Server -
craponnaruto - 19.10.2009
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
Re: Finding The Greatest Variable Value In The Server -
lolumadd - 19.10.2009
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;
}
Re: Finding The Greatest Variable Value In The Server -
saiberfun - 19.10.2009
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
Re: Finding The Greatest Variable Value In The Server -
Tannz0rz - 19.10.2009
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.