Raised This Month: $ Target: $400
 0% 

question with get_user_weapons


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
[ --<-@ ] Black Rose
ANNIHILATED
Join Date: Sep 2005
Location: Stockholm, Sweden.
Old 02-14-2007 , 09:56   Re: question with get_user_weapons
Reply With Quote #6

weapid is different in every loop.
Code:
new weapons[32], num get_user_weapons(id, weapons, num)
now the user had 3 weapons; knife, usp and m4a1.
you check the loop if user has m4a1.
Code:
for(new i = 0; i < num; i++) {     if ( weapons[i] == CSW_M4A1 ) {         // This is called when user has m4a1        }    }
That will check first weapons[0] then weapons[1] then weapons[2]. If any of the wepons[x] is CSW_M4A1 the code will be called.

lets say array would be
Code:
weapons[0] = CSW_KNIFE weapons[1] = CSW_USP weapons[2] = CSW_M4A1
Then the loop would first check weapons[0] if that is CSW_M4A1. But that if statement would return false so the code will continue, when it finds CSW_M4A1 the if statement will return true and code would be called.
Then it would still continue untill the end if you don't stop it urself.

Code:
new weapons[32], num get_user_weapons(id, weapons, num) for(new i = 0; i < num; i++) {     weapid = weapons[i]; // This is only necessary if you use this value more than once.     if ( weapid == CSW_M4A1 ) {         // This is called when user has a m4a1     }     else if ( weapid == CSW_AK47 ) {         // This is called when user has an ak47     } }

Last edited by [ --<-@ ] Black Rose; 02-14-2007 at 09:59.
[ --<-@ ] 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