Raised This Month: $ Target: $400
 0% 

Find lowest number..


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
XunTric
BANNED
Join Date: Jan 2005
Location: Norway/Norge
Old 04-20-2005 , 11:54   Find lowest number..
Reply With Quote #1

I need to know how to find the lowest number...

Lets say I have 1,2,3,4 and 5.
How do I let the plugin find that 1 is the lowest number there?

In my case, I got a variable that holds your points.
How do I let the plugin find who gots the lowest number on that variable?

Like if I have:
Points = 10
And somebody else have:
Points = 20

How do I let the plugin find out who that got the lowest number on the Points variable?

Thanks...
XunTric is offline
Twilight Suzuka
bad
Join Date: Jul 2004
Location: CS lab
Old 04-20-2005 , 13:08  
Reply With Quote #2

Code:
 main ( val1, val2 )
__________________
Twilight Suzuka is offline
Send a message via AIM to Twilight Suzuka Send a message via MSN to Twilight Suzuka
slurpycof
Senior Member
Join Date: Nov 2004
Old 04-20-2005 , 13:10  
Reply With Quote #3

If you want to check everyone, you can modify this code that I use in my frequent fragger program

Code:
 adm_check_slots(){     new maxslots = get_maxplayers()     new kickme = 0, playtime, unlimited = 0x7fffffff, adm_check_time     for(new i = 1; i <= maxslots; ++i){         if (!is_user_connected(i) && !is_user_connecting(i)) continue         if (get_user_flags(i) & ADMIN_RESERVATION) continue         playtime = get_user_time(i)         adm_check_time = (playtime + connecttime[i])         if(unlimited > adm_check_time){             unlimited = adm_check_time             kickme = i         }     }     return kickme }
slurpycof is offline
XunTric
BANNED
Join Date: Jan 2005
Location: Norway/Norge
Old 04-20-2005 , 14:35  
Reply With Quote #4

Quote:
Originally Posted by Twilight Suzuka
Code:
 main ( val1, val2 )
I didnt get that...

Is val1 and val2 just examples or...?

so can i have like:
main(20,50,60)

So will it return 20, since its the lowest number?

But I want to check a variable that holds a number, and I want to check all players in the server.

In my plugin, all people got a variable called PlayerPoints, that holds a number.
How do I make it check all players, and return who that got lowest number on my PlayerPoints variable?

Will it be like this?

(I want to kick the guy with lowest playerpoints..)

Code:
new LowestPoints[33] = main(PlayerPoints[id]) server_cmd("kick %s", LowestPoints[id])
XunTric is offline
PM
hello, i am pm
Join Date: Jan 2004
Location: Canalization
Old 04-20-2005 , 14:44  
Reply With Quote #5

You could try something like:

Code:
GetLowestValID(begin, end, arr[]) {    new ilow = begin;    new vlow = arr[begin];    for (new i = begin; i <= end; ++i)    {       if (arr[i] < vlow)       {          vlow = arr[i];          ilow = i;       }    }    return ilow; }

Then, you could use:
Code:
new i = GetLowestValID(1 /* 1 is the first index to test */, 32 /* 32 will be the last index that is checked */, array);

(untested)
__________________
hello, i am pm
PM is offline
XunTric
BANNED
Join Date: Jan 2005
Location: Norway/Norge
Old 04-20-2005 , 14:50  
Reply With Quote #6

Umm...
That kind of code is the stuff I dont know much of yet.
(Looping, array and all that stuff...)

Could you write me an example that will check who got the lowest number on my "PlayerPoints[id]" variable?
So I dont have edit it

From
Copy and paste - fan
XunTric is offline
PM
hello, i am pm
Join Date: Jan 2004
Location: Canalization
Old 04-20-2005 , 15:26  
Reply With Quote #7

Copy & paste the function
Code:
GetLowestValID(begin, end, arr[]) {    new ilow = begin;    new vlow = arr[begin];    for (new i = begin; i <= end; ++i)    {       if (arr[i] < vlow)       {          vlow = arr[i];          ilow = i;       }    }    return ilow; }

In your code, use:
Code:
new no_idea_what_your_variable_name_should_be_but_this_long_name_might_crash_the_compiler_mwahahahah = GetLowestValID(1, 32, PlayerPoints);
And hope that it'll work.
__________________
hello, i am pm
PM is offline
XunTric
BANNED
Join Date: Jan 2005
Location: Norway/Norge
Old 04-20-2005 , 15:50  
Reply With Quote #8

PM: Check your PM
XunTric is offline
v3x
Veteran Member
Join Date: Oct 2004
Location: US
Old 04-20-2005 , 16:33  
Reply With Quote #9

It's not hard to understand at all..
__________________
What am I doing these days? Well, I run my own Rust server. It's heavily modded. If you'd like to join, the ip is 167.114.101.67:28116

I also created a website called Rust Tools. It will calculate and tell you the raw amounts of resources needed to craft items.
v3x is offline
Reply



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

Forum Jump


All times are GMT -4. The time now is 09:51.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode