Raised This Month: $ Target: $400
 0% 

[REQ]new get_user_name format


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
LagParty
Junior Member
Join Date: Jul 2008
Old 12-18-2008 , 14:59   [REQ]new get_user_name format
Reply With Quote #1

i've searched but didn't get any results close to this.

it's quite simple, instead of:
PHP Code:
new name[32]
get_user_name(id,name,31
use:

PHP Code:
new name[32] = get_user_name(id
that would be better for making simple messages like:

PHP Code:
client_print(0,print_chat,"%s has connected to the server.",get_user_name(id)) 
is it possible? thanks.
LagParty is offline
xPaw
Retired AMX Mod X Moderator
Join Date: Jul 2008
Old 12-18-2008 , 15:03   Re: [REQ]new get_user_name format
Reply With Quote #2

mm try this
PHP Code:
stock get_user_name2id ) {
    if( !
is_user_connectedid ) )
        return 
0;
    
    new 
name[32];
    
get_user_nameidname31 );
    
    return 
name;

__________________
xPaw is offline
YamiKaitou
Has a lovely bunch of coconuts
Join Date: Apr 2006
Location: Texas
Old 12-18-2008 , 15:04   Re: [REQ]new get_user_name format
Reply With Quote #3

No, it is not possible due to the way strings are handled I believe. Also, this is a scripting question, so moved to Scripting Help

EDIT:
Maybe it is possible, didn't think Pawn let you return strings
__________________
ProjectYami Laboratories

I do not browse the forums regularly anymore. If you need me for anything (asking questions or anything else), then PM me (be descriptive in your PM, message containing only a link to a thread will be ignored).
YamiKaitou is offline
Dores
Veteran Member
Join Date: Jun 2008
Location: You really don't wanna k
Old 12-18-2008 , 15:07   Re: [REQ]new get_user_name format
Reply With Quote #4

Test it, though it probably won't work.
Code:
                    /*    TEST                        version 1.0                         by Dores */ #include <amxmodx> get_user_name2( index ) {     new name[ 32 ];     get_user_name( index, name, 31 );         return name; } public plugin_init() {     register_plugin( "Constant Name Return Test", "1.0", "Dores" );     register_clcmd( "say name", "Cmd_ShowName" ); } public Cmd_ShowName( id ) {     client_print( id, print_chat, "My name is %s", get_user_name2( id ) ); }
EDIT: Damn, looks like xPaw already helped you exactly like me. Well, at least my version has a test command. ;-)
__________________
O o
/Ż________________________
| IMMA FIRIN' MAH LAZOR!!!
\_ŻŻŻ
Dores is offline
LagParty
Junior Member
Join Date: Jul 2008
Old 12-18-2008 , 15:10   Re: [REQ]new get_user_name format
Reply With Quote #5

thanks for the answers. I made some scripts for sa-mp a few years ago and i remember that many strings were handled that way.
LagParty is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 12-18-2008 , 15:20   Re: [REQ]new get_user_name format
Reply With Quote #6

IMPORTANT NOTE!!
If you are returning strings, the receiving string MUST be the SAME SIZE as the string being returned:
Code:
stock get_user_name2(client) {     static name[32];     get_user_name(client, name, sizeof(name) - 1);     return name; } function(client) {     // valid     new name[32] = get_user_name2(client);         // invalid     new name[64] = get_user_name2(client); }
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
LagParty
Junior Member
Join Date: Jul 2008
Old 12-19-2008 , 03:36   Re: [REQ]new get_user_name format
Reply With Quote #7

but i guess it's no problem to use format(etc,24,"%s",get_user_name2(id)) or is it? (because format will only take the first 24 characters of the string)
LagParty is offline
FreeLayer
Member
Join Date: Mar 2011
Old 06-05-2011 , 23:22   Re: [REQ]new get_user_name format
Reply With Quote #8

man me puedes pasar el amx lulo plz
FreeLayer is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 06-06-2011 , 00:18   Re: [REQ]new get_user_name format
Reply With Quote #9

Quote:
Originally Posted by FreeLayer View Post
man me puedes pasar el amx lulo plz
English only.
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
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 09:17.


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