Raised This Month: $51 Target: $400
 12% 

[Help] get_user_name questions


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
ghost95v
Senior Member
Join Date: Apr 2014
Location: somewhere in universe
Old 01-20-2015 , 12:03   [Help] get_user_name questions
Reply With Quote #1

Hello, i tested a simple plugin on my server, but im in doubt if this part of code (below) its wrong for "get_user_name" for sender, and target of Cmd...

also i got a Crash, when i runned this plugin.


PHP Code:
new TargetName[32], szName[32]
    
get_user_name(idszName31)  // im in doubt if i can user twice "get_user_name" like this case?
    
get_user_name(TargetPlayerTargetNamecharsmax(TargetName))
    
// the function to give health here...
    
    
DoSayTextMessage(0"^x04[CS]^x01 [ADMIN]^x04 %s^x01 gaved Health Pack to^x03 %s"szNameTargetName
__________________
ghost95v is offline
Send a message via Skype™ to ghost95v
Natsheh
Veteran Member
Join Date: Sep 2012
Old 01-20-2015 , 12:07   Re: [Help] get_user_name questions
Reply With Quote #2

Post the full code?

No need to be shy we all men here?
Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 01-20-2015 , 12:09   Re: [Help] get_user_name questions
Reply With Quote #3

You can use as many get_user_name as you want, the crash is not from that. You should use charsmax for szName string-array size as you do for TargetName, apart of that everything is fine.
The crash is not from getting the name, you should post your full code or start debugging in order to find what's wrong. We don't know how your DoSayTextMessage works so it may cause a crash aswell.

So, post more code if you want help.
__________________
HamletEagle is offline
ghost95v
Senior Member
Join Date: Apr 2014
Location: somewhere in universe
Old 01-20-2015 , 12:27   Re: [Help] get_user_name questions
Reply With Quote #4

Quote:
Originally Posted by Natsheh View Post

No need to be shy we all men here?
Ive liked girls to be here...

Ok, well...

here its the part of registered concmd

PHP Code:
public plugin_init() {
        
register_concmd("amx_example""cmdDo_it"ADMIN_CFG"<target>");

here its the part of the cmdDo_it

PHP Code:
public cmdDo_it(idlevelcid)
{
    if(!
cmd_access(idlevelcid2))
    {
        
console_print(id"CS] Access is denied!")
        return 
PLUGIN_HANDLED
    
}
        
    new 
iTarget[32]
    
read_argv(1iTargetcharsmax(iTarget))
    
    new 
TargetPlayer cmd_target(idiTarget2)
    
    if(!
TargetPlayer)
    {
        
console_print(id"[CS] Cannot find that name, be more specific!")
        return 
PLUGIN_HANDLED
    
}
    
    if(!
is_user_alive(TargetPlayer))
    {
        
console_print(id"[CS] Cannot give to dead player!")
        return 
PLUGIN_HANDLED
    
}
    
    if(
read_argc() != 2)
    return 
PLUGIN_HANDLED
        
new TargetName[32], szName[32
        
get_user_name(idszName31)  // im in doubt if i can user twice "get_user_name" like thiscase? 
        
get_user_name(TargetPlayerTargetNamecharsmax(TargetName)) 
        
// the function to give health here... 
     
         
DoSayTextMessage(0"^x04[CS]^x01 [ADMIN]^x04 %s^x01 gaved Health Pack to^x03 %s"szNameTargetName)  

here its the part of "DoSayTextMessage", other parts are Alright, ive runned always fine.

PHP Code:
DoSayTextMessageiTargetcMessage[ ], any: ... )
{
    static 
cBuffer192 ];
    
vformatcBuffer191cMessage);

    
message_beginMSG_ONE_UNRELIABLEgmsgSayText_iTarget );
    
write_byteiTarget );
    
write_stringcBuffer );
    
message_end( );

__________________

Last edited by ghost95v; 01-20-2015 at 14:56.
ghost95v is offline
Send a message via Skype™ to ghost95v
Natsheh
Veteran Member
Join Date: Sep 2012
Old 01-20-2015 , 16:09   Re: [Help] get_user_name questions
Reply With Quote #5

The parameters of say text msg ( iTarget, const cMessage[], ...)

y forget to add const to the sec parameter!
Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
ghost95v
Senior Member
Join Date: Apr 2014
Location: somewhere in universe
Old 01-20-2015 , 17:10   Re: [Help] get_user_name questions
Reply With Quote #6

Quote:
Originally Posted by Natsheh View Post
The parameters of say text msg ( iTarget, const cMessage[], ...)

y forget to add const to the sec parameter!
the both variables "iTarget" and "cMessage" are const's... not needed to add const
its same shit, like you do "new const" when you can do just const
__________________

Last edited by ghost95v; 01-20-2015 at 17:14.
ghost95v is offline
Send a message via Skype™ to ghost95v
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 18:52.


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