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-13-2007 , 15:49   question with get_user_weapons
Reply With Quote #1

how can i look at what weapons a user has ?

will this work ??

Code:
new weapons[32] 
new num
get_user_weapons(id, weapons, num) 
 

if (containi(Weapons,"CSW_M4A1") ) { ACTIONS
mexykanu is offline
teame06
i have a hat
Join Date: Feb 2005
Location: Hat City
Old 02-13-2007 , 16:05   Re: question with get_user_weapons
Reply With Quote #2

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         }       }
__________________
No private support via Instant Message
GunGame:SM Released
teame06 is offline
Send a message via AIM to teame06
mexykanu
Member
Join Date: Oct 2006
Old 02-14-2007 , 05:49   Re: question with get_user_weapons
Reply With Quote #3

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 #4

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 #5

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 #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
Alka
AMX Mod X Plugin Approver
Join Date: Dec 2006
Location: malloc(null)
Old 02-14-2007 , 10:22   Re: question with get_user_weapons
Reply With Quote #7

hi. black rose how can i make a HUD msg to show the "curent weapon" in hand? Thanks ;)

Ex: Weapon: Ak47
Weapon: AWP
Weapon glock18

Ps: I try with this above functions!but give me an error!
__________________
Still...lovin' . Connor noob! Hello
Alka is offline
mexykanu
Member
Join Date: Oct 2006
Old 02-14-2007 , 12:06   Re: question with get_user_weapons
Reply With Quote #8

black rose, i don't know if it matters for you, but you'll always recieve +karma from me. thanks, i understand now
mexykanu is offline
[ --<-@ ] Black Rose
ANNIHILATED
Join Date: Sep 2005
Location: Stockholm, Sweden.
Old 02-14-2007 , 17:33   Re: question with get_user_weapons
Reply With Quote #9

Quote:
Originally Posted by Alka View Post
hi. black rose how can i make a HUD msg to show the "curent weapon" in hand? Thanks ;)

Ex: Weapon: Ak47
Weapon: AWP
Weapon glock18

Ps: I try with this above functions!but give me an error!
Code:
#include <amxmodx> new const g_Weapons[][] = {     "", "p228", "", "scout", "hegrenade",     "xm1014", "c4", "mac10", "aug", "smokegrenade",     "elite", "fiveseven", "ump45", "sg550", "galil",     "famas", "usp", "glock18", "awp", "mp5",     "m249", "m3", "m4a1", "tmp", "g3sg1",     "flashbang", "deagle", "sg552", "ak47", "knife",     "p90" }; new g_HUD[64] = "Weapon: %s"; public plugin_init() {     register_event("CurWeapon", "event_CurWeapon", "b") } public event_CurWeapon(id) {     new temp = get_user_weapon(id, temp, temp)     set_hudmessage(255, 0, 255, -1.0, 0.35, 0, 6.0, 12.0, 0.1, 0.1, 3)     show_hudmessage(id, g_HUD, g_Weapons[temp])     // g_Weapons[read_data(2)], Not a good way. Switch from knife to another weapons still returns knife. }
[ --<-@ ] Black Rose is offline
Alka
AMX Mod X Plugin Approver
Join Date: Dec 2006
Location: malloc(null)
Old 02-14-2007 , 18:28   Re: question with get_user_weapons
Reply With Quote #10

Oouuu thanks again man...It's worknig Perfect!
__________________
Still...lovin' . Connor noob! Hello
Alka is offline
Reply


Thread Tools
Display Modes

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