AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   name function with double name arg (https://forums.alliedmods.net/showthread.php?t=134293)

sparkey 08-03-2010 02:17

name function with double name arg
 
PHP Code:

    if ((!equal(nick"0")) && (!equal(nick"")))
    {
        
set_user_info(id"name", ("%s %s",get_stat(sid),nick));
    }
    else
    {
        
set_user_info(id"name", ("%s %s",get_stat(sid),glob));
    } 

is this completely wrong? In my head i think it should work but maybe not ;p

It seems that it only uses the second argument and not the first.

nikodz 08-03-2010 02:49

Re: name function with double name arg
 
If you want to change player name user client_cmd instead set_user_info.
If client ID=sid in your script...
PHP Code:

client_cmd(sid"name "%%s"" get_stat(sid), glob); 


Spunky 08-03-2010 02:56

Re: name function with double name arg
 
PHP Code:

client_cmd(id"name ^"%%s^"" get_stat(sid), glob); 

You have to use escape sequences when using quotes within quotes.

sparkey 08-03-2010 13:26

Re: name function with double name arg
 
Thx for your answers.

The thing is that the set_user_info can execute proper earlier then the client_cmd and that is why i am using it. Dont know why really but it seems that the client_cmd wont execute when a player is not in a team. I am also using an update function which runs every 10 minutes but i want the name to be changed on connect and not 10 seconds later if you know what i mean :)

Thanks guys

hleV 08-03-2010 15:17

Re: name function with double name arg
 
PHP Code:

    if (nick[0] && !equal(nick"0"))
        
client_cmd(id"name ^"%%s^""get_stat(sid), nick);
    else
        
client_cmd(id"name ^"%%s^""get_stat(sid), glob); 


sparkey 08-03-2010 17:57

Re: name function with double name arg
 
Yes that was exactly what the guy above wrote and it did not work but thanks for your answer anyway.

Seta00 08-03-2010 18:38

Re: name function with double name arg
 
Use setinfo:
Code:
    if (nick[0] && !equal(nick, "0"))         set_user_info(id, "name",  "%s %s", get_stat(sid), nick);     else         set_user_info(id, "name", "%s %s", get_stat(sid), glob);

fysiks 08-03-2010 18:48

Re: name function with double name arg
 
@Seta, you can't format in set_user_info().

PHP Code:

    new szString[32]
    if (
nick[0] && !equal(nick"0"))
        
formatex(szStringcharsmax(szString), "%s %s"get_stat(sid), nick)
    else
        
formatex(szStringcharsmax(szString), "%s %s"get_stat(sid), glob)
    
set_user_info(id"name"szString


sparkey 08-03-2010 18:49

Re: name function with double name arg
 
Thx for your answer.

That was the function i started with first and tried it just as you wrote but it seems that the function cant handle all that parameters.

gsop.cpp(460) : error 088: number of arguments does not match definition

fysiks 08-03-2010 18:54

Re: name function with double name arg
 
Quote:

Originally Posted by sparkey (Post 1260863)
Thx for your answer.

That was the function i started with first and tried it just as you wrote but it seems that the function cant handle all that parameters.

gsop.cpp(460) : error 088: number of arguments does not match definition

See my post above.


All times are GMT -4. The time now is 00:14.

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