AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Weapon name (https://forums.alliedmods.net/showthread.php?t=222503)

Sutar 08-03-2013 13:35

Weapon name
 
Hi, I get a code of arms, and how do I translate it in the name?
I tried through get_weaponname
but that is not

for example
if index weapon 29 but function gives "weapon_knife" but need to "knife"
delete the line weapon_ impossible, because some of the names do not match weapons

Black Rose 08-03-2013 14:29

Re: Weapon name
 
Code:
new wpnIndex = 29, wpnName[32]; get_weaponname(wpnIndex, wpnName, 31); copy(wpnName, 31, wpnName[7]); server_print(wpnName);
Code:

knife

or

Code:
new wpnIndex = 29, wpnName[32]; get_weaponname(wpnIndex, wpnName, 31); if ( equal(wpnName[7], "knife") )     server_print("true");

Code:

true

akcaliberg 08-03-2013 14:30

Re: Weapon name
 
You can remove specific strings from a source string . If that is what you are asking about ?

Code:
new szWeaponName[] = "weapon_knife"; format(szWeaponName, charsmax(szWeaponName), szWeaponName[7]) // szWeaponName will be "knife"

DWIGHTpN 08-03-2013 14:40

Re: Weapon name
 
Example:
PHP Code:

public client_PreThink(id) {
           new 
weaponID,ammo,clip;
           
weaponID get_user_weapon(idclip,ammo);
           
// get_user_weapon return CSW_ + weapon ID.

          // Now get weapon name from id.
          
new szWeapon[50];
          
get_weaponname(weaponIDszWeaponcharsmax(szWeapon));
          
// Now we have weapon name (weapon_knife for ex).

          
replace(szWeaponcharsmax(szWeapon), "weapon_""");
          
// Now we have weapon name without "weapon_".



Sutar 08-03-2013 16:42

Re: Weapon name
 
I said that if you remove the prefix "weapon_" can not get
for example, the weapon can not match the name of the desired

Black Rose 08-03-2013 18:11

Re: Weapon name
 
Quote:

Originally Posted by Sutar (Post 2005004)
I said that if you remove the prefix "weapon_" can not get
for example, the weapon can not match the name of the desired

If you're not matching the weapons you obviously need to edit your input to match it.
Here's a list of weapon names in the game. The mp5 differs from mp5 and mp5navy depending on what function is used.

Code:
new const g_Weapons[33][] = {     "", "p228", "shield", "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", "kevlar", "assault" };

Sutar 08-04-2013 06:46

Re: Weapon name
 
You can link to where there is a list of weapons and their names?

DWIGHTpN 08-04-2013 08:02

Re: Weapon name
 
http://wiki.amxmodx.org/CS_Weapons_Information

Sutar 08-04-2013 08:05

Re: Weapon name
 
Quote:

Originally Posted by DWIGHTpN (Post 2005368)

thank you


All times are GMT -4. The time now is 15:46.

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