Raised This Month: $ Target: $400
 0% 

Check gun names is array table


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
scrtxxcaz
Senior Member
Join Date: Feb 2007
Location: a place u cant find
Old 06-28-2008 , 04:15   Check gun names is array table
Reply With Quote #1

would this work?? im not to familiar with using tables like the one i made named GUNNAMES or if its even called a table.

PHP Code:
#define MAX_GUNS 8
// gun table
new const GUNNAMES[MAX_GUNS][] = {
      
"CSW_M4A1",  // 0
      
"CSW_AK47",  // 1
      
"CSW_AWP",  // 2
      
"CSW_DEAGLE",  // 3
      
"CSW_USP",  // 4
      
"CSW_GLOCK",  // 5
      
"CSW_MP5NAVY",  // 6
      
"CSW_SCOUT"  // 7
}
public 
plugin_init() {
      
register_plugin(PLUGINVERSIONAUTHOR)
      
register_event("CurWeapon""Event_CurWeapon""be""1=1""3>0""2!4""2!6""2!9""2!25""2!29")
}
public 
Event_CurWeapon(id,GUNNAMES)
{
      new 
wclip,wammo,WeaponID
      
//get gun weaponID
      
WeaponID get_user_weapon(id,wclip,wammo)
      
//use switch to see what number the weapon is in the table
      
switch(WeaponID)
      {
                  case 
0: {
                       
client_print(id,print_chat,"You are using the M4A1,")
                  }
      }

__________________
Please leave your name when giving me any karma

Counter Strike Freeze Tag
Status: Testing.... (bugs)

Revised Registration
Status: In Progress
scrtxxcaz is offline
Send a message via AIM to scrtxxcaz
DA
Veteran Member
Join Date: Nov 2005
Location: Germany/Münster
Old 06-28-2008 , 04:46   Re: Check gun names is array table
Reply With Quote #2

What you want with this table? Currently their are Strings in it.
__________________
DA is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 06-28-2008 , 05:47   Re: Check gun names is array table
Reply With Quote #3

Code:
public plugin_init() {       register_plugin(PLUGIN, VERSION, AUTHOR)       register_event("CurWeapon", "Event_CurWeapon", "be", "1=1", "3>0", "2!4", "2!6", "2!9", "2!25", "2!29") } public Event_CurWeapon(id) {     new szWeaponName[32]     get_weaponname( read_data(2), szWeaponName, 31 )     client_print(id,print_chat,"You are using the %s", szWeaponName[7] ) }
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
scrtxxcaz
Senior Member
Join Date: Feb 2007
Location: a place u cant find
Old 06-28-2008 , 06:12   Re: Check gun names is array table
Reply With Quote #4

sorry for the confusion...basically what i want to use this table for is to save the gun names in strings and then call on them in events like death, damage and current weapon. It checks what weapon they have or killed some one with and it compares it to the strings in table of gun names(rather then using tons of if statments to check for each gun). Once the gun name is found the person gets .. lets say a kill for that certain gun.

not sure if that makes sense... kind of hard to explain.

EDIT:
PHP Code:
#define MAX_GUNS 8
// gun table
new kill[32][8]
new const 
GUNNAMES[MAX_GUNS][] = {
      
"CSW_M4A1",  // 0
      
"CSW_AK47",  // 1
      
"CSW_AWP",  // 2
      
"CSW_DEAGLE",  // 3
      
"CSW_USP",  // 4
      
"CSW_GLOCK",  // 5
      
"CSW_MP5NAVY",  // 6
      
"CSW_SCOUT"  // 7
}
public 
plugin_init() {
      
register_plugin(PLUGINVERSIONAUTHOR)
      
register_event("CurWeapon""Event_CurWeapon""be""1=1""3>0""2!4""2!6""2!9""2!25""2!29")
}
public 
Event_CurWeapon(id,GUNNAMES)
{
      new 
wclip,wammo,WeaponID
      
//get gun weaponID
      
WeaponID get_user_weapon(id,wclip,wammo)
      
//use switch to see what number the weapon is in the table
      
switch(WeaponID)
      {
                  case 
0: {
                       
kill[id][GUNNAME]++                       
                  }
      }

__________________
Please leave your name when giving me any karma

Counter Strike Freeze Tag
Status: Testing.... (bugs)

Revised Registration
Status: In Progress
scrtxxcaz is offline
Send a message via AIM to scrtxxcaz
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 06-28-2008 , 06:41   Re: Check gun names is array table
Reply With Quote #5

The point is you can't compare an integer ( when CurWeapon is fired with a m4a1, read_data(2) is equal to get_user_weapon(id) and is equal to CSW_M4A1 that is equal to 22) with a string.
Open amxconst.inc :

#define CSW_M4A1 22

So, you can't compare CSW_M4A1 with "CSW_M4A1" that is completely a different thing.

If you us get_weaponname native with value 22 or CSW_M4A1, it with give you weapon_m4a1 :

Code:
new szWeaponName[16] get_weaponname(22, szWeaponName, 15)

Then szWeaponName is "weapon_m4a1"


I hope you understand better now.


get_weaponname calls a table that you don't need to create again ;)
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
scrtxxcaz
Senior Member
Join Date: Feb 2007
Location: a place u cant find
Old 06-28-2008 , 06:45   Re: Check gun names is array table
Reply With Quote #6

ahhh... i see now thanx.
__________________
Please leave your name when giving me any karma

Counter Strike Freeze Tag
Status: Testing.... (bugs)

Revised Registration
Status: In Progress
scrtxxcaz is offline
Send a message via AIM to scrtxxcaz
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:02.


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