Raised This Month: $ Target: $400
 0% 

question with get_user_weapons


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
mexykanu
Member
Join Date: Oct 2006
Old 02-14-2007 , 05:49   Re: question with get_user_weapons
Reply With Quote #1

oh so that's what i was doing wrong:

Code:
   new weapons[32] 
   new num, weapid
   get_user_weapons(id, weapons, num)
 
   for(new i = 0; i < num; i++)
   {
       weapid = weapons[i];
   }
 
if(weapid == CSW_M4A1)
       {
           // Do stuff
       }
thanks

another question:
Code:
if(weapid == CSW_M4A1)
are you sure this will look and see if in the weapons there is a m4a1 ? because it looks like it will work only if weapid has ONLY "CSW_M4A1"

Last edited by mexykanu; 02-14-2007 at 05:51.
mexykanu is offline
[ --<-@ ] Black Rose
ANNIHILATED
Join Date: Sep 2005
Location: Stockholm, Sweden.
Old 02-14-2007 , 07:10   Re: question with get_user_weapons
Reply With Quote #2

the 'if' part is suppose to be inside the loop as teame06 posted.
[ --<-@ ] Black Rose is offline
mexykanu
Member
Join Date: Oct 2006
Old 02-14-2007 , 07:36   Re: question with get_user_weapons
Reply With Quote #3

ok i got that, but if i use only if , will it look in weapid only for CSW_M4A1 ? i mean.. it will not work if i have 100 weapons, it only looks for that field.
mexykanu is offline
[ --<-@ ] 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 #4

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


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