AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   [REQ]new get_user_name format (https://forums.alliedmods.net/showthread.php?t=82183)

LagParty 12-18-2008 14:59

[REQ]new get_user_name format
 
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.

xPaw 12-18-2008 15:03

Re: [REQ]new get_user_name format
 
mm try this
PHP Code:

stock get_user_name2id ) {
    if( !
is_user_connectedid ) )
        return 
0;
    
    new 
name[32];
    
get_user_nameidname31 );
    
    return 
name;



YamiKaitou 12-18-2008 15:04

Re: [REQ]new get_user_name format
 
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

Dores 12-18-2008 15:07

Re: [REQ]new get_user_name format
 
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. ;-)

LagParty 12-18-2008 15:10

Re: [REQ]new get_user_name format
 
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.

Exolent[jNr] 12-18-2008 15:20

Re: [REQ]new get_user_name format
 
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); }

LagParty 12-19-2008 03:36

Re: [REQ]new get_user_name format
 
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)

FreeLayer 06-05-2011 23:22

Re: [REQ]new get_user_name format
 
man me puedes pasar el amx lulo plz

Exolent[jNr] 06-06-2011 00:18

Re: [REQ]new get_user_name format
 
Quote:

Originally Posted by FreeLayer (Post 1482209)
man me puedes pasar el amx lulo plz

English only.


All times are GMT -4. The time now is 09:17.

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