AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   get_weaponname help (https://forums.alliedmods.net/showthread.php?t=76676)

[X]-RayCat 08-28-2008 13:23

get_weaponname help
 
Im using get_weaponname, but its returing weapon_* names and i want my own names:
  • p228
  • scout
  • hegrenade
  • xm1014
  • mac10
  • aug
  • smokegrenade
  • elite
  • fiveseven
  • ump45
  • sg550
  • galil
  • famas
  • usp
  • glock18
  • awp
  • mp5navy
  • m249
  • m3
  • m4a1
  • tmp
  • shield
  • g3sg1
  • flashbang
  • deagle
  • sg552
  • ak47
  • p90
Code:
static wname[32] get_weaponname(Killer, wname, sizeof wname - 1)

fxfighter 08-28-2008 13:25

Re: get_weaponname help
 
why not get the weapon id and use it in a array whit your names?

[X]-RayCat 08-28-2008 13:30

Re: get_weaponname help
 
Quote:

Originally Posted by fxfighter (Post 677363)
why not get the weapon id and use it in a array whit your names?

Demonstrate?

Arkshine 08-28-2008 13:42

Re: get_weaponname help
 
Quote:

static wname[32]
get_weaponname(Killer, wname, sizeof wname - 1)
After retrieving the name, just use 'wname[6]' in your next code to ignore 'weapon_' .

[X]-RayCat 08-28-2008 14:06

Re: get_weaponname help
 
Quote:

Originally Posted by arkshine (Post 677374)
After retrieving the name, just use 'wname[6]' in your next code to ignore 'weapon_' .

You meant wname[7]? And by the way its returning false names. o_O

Alka 08-28-2008 14:09

Re: get_weaponname help
 
You can use replace()... "weapon_" with "".

Arkshine 08-28-2008 14:12

Re: get_weaponname help
 
Depending its code, it's useless to use a native when you can do what i've said.

w e a p o n _
0 1 2 3 4 5 6 so, wname[6] will show your weapon name without "weapon_"

[X]-RayCat 08-28-2008 14:18

Re: get_weaponname help
 
Quote:

Originally Posted by arkshine (Post 677391)
Depending its code, it's useless to use a native when you can do what i've said.

w e a p o n _
0 1 2 3 4 5 6 so, wname[6] will show your weapon name without "weapon_"

w e a p o n _
0 1 2 3 4 5 6 7 = wname[7] right?

Arkshine 08-28-2008 14:25

Re: get_weaponname help
 
You're right. Forget to count the character after _. :mrgreen:

[X]-RayCat 08-28-2008 14:32

Re: get_weaponname help
 
Quote:

Originally Posted by fxfighter (Post 677402)
dont know what your conclusion is of what i wrote.
but will just say what i ment so enyone can understand it.

weaponid wpname
PHP Code:

 1   weapon_p228
 0    weapon_shield         
 3   weapon_scout                         
 4   weapon_hegrenade              
 5   weapon_xm1014
 6   weapon_c4     
 7   weapon_mac10 
 8   weapon_aug 
 9   weapon_smokegrenade      
10   weapon_elite                   
11   weapon_fiveseven   
12   weapon_ump45                      
13   weapon_sg550             
14   weapon_galil           
15   weapon_famas              
16   weapon_usp       
17   weapon_glock18        
18   weapon_awp          
19   weapon_mp5navy      
20   weapon_m249                        
21   weapon_m3
22   weapon_m4a1
23   weapon_tmp
24   weapon_g3sg1
25   weapon_flashbang
26   weapon_deagle
27   weapon_sg552
28   weapon_ak47
29   weapon_knife
30   weapon_p90 

so just get the wpid of the gun instead of name.
make an array
PHP Code:

new array[][]={
"nothing and shield name",
"p228",
"scout",
"he",
...


use the wpid to acces the new name like
array[weaponid]
This is usefull if you wanna use other names if you just wanna remove weapon or add it do as arkshine said

Yeah i thought of that in the first place. :)

@Arkshine i dont know why, but it returns wrong names.. :O


All times are GMT -4. The time now is 03:12.

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