AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Easy question (https://forums.alliedmods.net/showthread.php?t=317558)

PawNod 07-19-2019 10:41

Easy question
 
how can ı give weapon if wood[33] is the highest from all player

thEsp 07-19-2019 11:02

Re: Easy question
 
Where do you think you are, a mind readers forum?

PawNod 07-19-2019 12:42

Re: Easy question
 
I want to find the player with the highest wood [33] variable from all players

Relaxing 07-19-2019 13:43

Re: Easy question
 
Quote:

Originally Posted by thEsp (Post 2659775)
Code:
new Highest = wood[ 0 ] new id; for( new i = 1; i < sizeof wood; i++ ) {       if( wood[ i ] > Highest){            Highest = wood[ i ]            id = i;       } } wood[id] // array index with highest value

Also, rename thread title to something like: Find the highest number in array.

PawNod 07-19-2019 16:56

Re: Easy question
 
@Relaxing thanks for support i will try it

HamletEagle 07-20-2019 02:25

Re: Easy question
 
I smell infinite loop here. The condition should be <

Bugsy 07-20-2019 12:28

Re: Easy question
 
Also, the scope of the id variable is limited to the for-loop, it should be defined outside if it is needed outside of the loop.


All times are GMT -4. The time now is 17:23.

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