Raised This Month: $ Target: $400
 0% 

Comparing values of variable


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
[ --<-@ ] Black Rose
ANNIHILATED
Join Date: Sep 2005
Location: Stockholm, Sweden.
Old 02-03-2007 , 18:10   Re: Comparing values of variable
Reply With Quote #2

Code:
new a, b, tempid, pId[32], pNum; get_players(pId, pNum) for ( new c ; c < pNum ; c++ ) {     tempid = pId[c]     if ( Player_totalkills[tempid] > b ) {         a = tempid         b = Player_totalkills[tempid]     } }
most kills: Player_totalkills[a]

Notice this only works if there are one with the highest kills. If two players has the same and highest score, the second one would be ignored.

EDIT: Another, better way.
Code:
new a, tempid, pId[32], pNum; get_players(pId, pNum) for ( new b ; b < pNum ; b++ ) {     tempid = pId[b]     if ( Player_totalkills[tempid] > Player_totalkills[a] )         a = tempid }

Last edited by [ --<-@ ] Black Rose; 02-06-2007 at 07:10.
[ --<-@ ] Black Rose is offline
 



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 00:41.


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