AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   get_user_weapon2() give me only one letter (https://forums.alliedmods.net/showthread.php?t=105100)

Alucard^ 10-01-2009 06:33

get_user_weapon2() give me only one letter
 
Well the problem is with the stock by xPaw:

http://forums.alliedmods.net/showthread.php?t=88242

PHP Code:

#include <amxmodx>
#include <amxmisc>

#define PLUGIN    "New Plugin"
#define AUTHOR    "Alucard"
#define VERSION    "1.0"

public plugin_init()
{
    
register_plugin(PLUGINVERSIONAUTHOR)
    
register_clcmd("say /test""Test")
}

public 
Test(id)
{
    
client_print(idprint_chat"Your weapon is: %s"get_user_weapon2(id) )
}

public 
get_user_weapon2(id)
{
    new 
szWeapon[20]
    
get_weaponname(get_user_weapon(id), szWeaponcharsmax(szWeapon) )
    
    return 
szWeapon[7]


For example with USP, i get this message:

Quote:

Your weapon is: uVfnz
And with knife i get:

Quote:

Your weapon is: k
o.O

Alka 10-01-2009 07:21

Re: get_user_weapon2() give me only one letter
 
Why don't you pass it byref?

Sylwester 10-01-2009 08:10

Re: get_user_weapon2() give me only one letter
 
PHP Code:

#include <amxmodx>
#include <amxmisc>

#define PLUGIN    "New Plugin"
#define AUTHOR    "Alucard"
#define VERSION    "1.0"

public plugin_init()
{
    
register_plugin(PLUGINVERSIONAUTHOR)
    
register_clcmd("say /test""Test")
}

public 
Test(id)
{
    
client_print(idprint_chat"Your weapon is: %s"get_user_weapon2(id) )
}

public 
get_user_weapon2(id)
{
    new 
szWeapon[20]
    
get_weaponname(get_user_weapon(id), szWeaponcharsmax(szWeapon) )
    
copy(szWeapon19szWeapon[7])
    return 
szWeapon



SnoW 10-01-2009 08:58

Re: get_user_weapon2() give me only one letter
 
PHP Code:

public get_user_weapon2id )
{
    new 
szWeapon20 ]
    
get_weaponnameget_user_weaponid ), szWeaponcharsmaxszWeapon ) )
    return 
stringszWeapon] )
}  
stringoper[ ] )
    return 
oper


Bugsy 10-01-2009 19:42

Re: get_user_weapon2() give me only one letter
 
IMO, easier to just do

PHP Code:

new szWeapon20 ]
get_weaponnameget_user_weaponid ), szWeapon19 

Then use szWeapon[ 7 ] to retrieve weapon name without the "weapon_"

PHP Code:

new szWeapon20 ]
get_weaponnameget_user_weaponid ), szWeapon19 )

client_printid print_chat "I am using %s" szWeapon] ); 


Alucard^ 10-01-2009 22:29

Re: get_user_weapon2() give me only one letter
 
Thx all, i tested bugsy code and work perfect.


All times are GMT -4. The time now is 22:35.

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