SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help > Help Archive

 
 
Thread Tools Display Modes
Old 19/10/2009, 02:08 AM   #1
lolumadd
Huge Clucker
 
Join Date: Sep 2009
Posts: 369
Reputation: 8
Default Finding The Greatest Variable Value In The Server

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!
__________________
lolumadd is offline  
Old 19/10/2009, 02:16 AM   #2
Dresden
Little Clucker
 
Join Date: Sep 2009
Posts: 15
Reputation: 0
Default Re: Finding The Greatest Variable Value In The Server

wrong topic - delete please
Dresden is offline  
Old 19/10/2009, 02:19 AM   #3
lolumadd
Huge Clucker
 
Join Date: Sep 2009
Posts: 369
Reputation: 8
Default Re: Finding The Greatest Variable Value In The Server

Wrong topic? How is this wrong topic. Im asking for help.
__________________
lolumadd is offline  
Old 19/10/2009, 02:35 AM   #4
Eazy_Efolife
High-roller
 
Join Date: Aug 2009
Posts: 1,203
Reputation: 15
Default Re: Finding The Greatest Variable Value In The Server

Dresden you feel dumb right?


Can you be more specific, lolumadd?
Eazy_Efolife is offline  
Old 19/10/2009, 02:36 AM   #5
lolumadd
Huge Clucker
 
Join Date: Sep 2009
Posts: 369
Reputation: 8
Default Re: Finding The Greatest Variable Value In The Server

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. ^^
__________________
lolumadd is offline  
Old 19/10/2009, 02:39 AM   #6
saiberfun
High-roller
 
saiberfun's Avatar
 
Join Date: Nov 2008
Location: Germany
Posts: 3,590
Reputation: 383
Default Re: Finding The Greatest Variable Value In The Server

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
}
__________________
This could be your space to advertise. :3
saiberfun is offline  
Old 19/10/2009, 02:39 AM   #7
craponnaruto
Big Clucker
 
Join Date: Jul 2009
Posts: 143
Reputation: 0
Default Re: Finding The Greatest Variable Value In The Server

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
craponnaruto is offline  
Old 19/10/2009, 02:46 AM   #8
lolumadd
Huge Clucker
 
Join Date: Sep 2009
Posts: 369
Reputation: 8
Default Re: Finding The Greatest Variable Value In The Server

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

Code:
	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;
}
__________________
lolumadd is offline  
Old 19/10/2009, 02:52 AM   #9
saiberfun
High-roller
 
saiberfun's Avatar
 
Join Date: Nov 2008
Location: Germany
Posts: 3,590
Reputation: 383
Default Re: Finding The Greatest Variable Value In The Server

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

Code:
	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
__________________
This could be your space to advertise. :3
saiberfun is offline  
Old 19/10/2009, 02:52 AM   #10
Tannz0rz
Huge Clucker
 
Tannz0rz's Avatar
 
Join Date: Dec 2007
Posts: 434
Reputation: 35
Default Re: Finding The Greatest Variable Value In The Server

Lul, I don't even know why I'm still messing with Pawn, but here:
Code:
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.
__________________
Tannz0rz is offline  
 

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
TextDraws as server variable?? How to i change to Player Variable? DarrenReeder Help Archive 2 06/04/2010 08:02 AM
Who do you think is the greatest sportsperson of all time / of their sport hazdog Everything and Nothing 11 12/10/2009 01:34 AM
I really need help on making Counter Strike server [My Problem: VARIABLE] virspector Help Archive 4 28/08/2009 10:34 AM
warning 219: local variable "timecounter" shadows a variable at a preceding leve PKRanger Help Archive 3 08/08/2009 05:04 PM
about finding server in browser Sfinx_17 Help Archive 7 14/06/2009 09:17 PM


All times are GMT. The time now is 08:15 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.