AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   command not working right (https://forums.alliedmods.net/showthread.php?t=54207)

YamiKaitou 04-19-2007 20:11

command not working right
 
I am creating a plugin that sets select client's names during client_authorized or client_putinserver. But, it will not exec the command. I have tried doing it through another function, identical code, and it works. Am I not allowed to change the client's name that early?


Here is my code if it helps any
PHP Code:

#include <amxmodx>
#include <amxmisc>

#define PLUGIN "Name Randomizer"
#define VERSION "1.0"
#define AUTHOR "Yami Kaitou"
#define YAMIDEFAULT "Yami"

new configdir[128];

public 
plugin_init()
{
    
register_plugin(PLUGINVERSIONAUTHOR);
    
register_concmd("newname","newname",ADMIN_ALL," - If you have random names, generates you a new name");
    
get_configsdir(configdir,127);
}

public 
client_putinserver(id)
{
    new 
authid[34];
    
get_user_authid(id,authid,33);
    if (
equal(authid,"STEAM_0:0:9176827")) //Yami
    
{
        new 
name[32],file[128];
        
format(file,127,"%s/names/yami.txt",configdir);
        if (!
file_exists(file))
        {
            
format(name,31,"]LA[ %s v2",YAMIDEFAULT);
        }
        else
        {
            new 
num[5],junklen,number;
            
read_file(file,0,num,4,junklen);
            
number str_to_num(num);
            new 
line[512],len;
            new 
rand random_num(1,number);
            
read_file(file,rand,line,511,len);
            
format(name,31,"]LA[ %s v2",line);
        }
        
client_cmd(id,"name ^"%s^"",name);
    }
}

public 
newname(id)
{
    new 
authid[34];
    
get_user_authid(id,authid,33);
    if (
equal(authid,"STEAM_0:0:9176827")) //Yami
    
{
        new 
name[32],file[128];
        
format(file,127,"%s/names/yami.txt",configdir);
        if (!
file_exists(file))
        {
            
format(name,31,"]LA[ %s v2",YAMIDEFAULT);
        }
        else
        {
            new 
num[5],junklen,number;
            
read_file(file,0,num,4,junklen);
            
number str_to_num(num);
            new 
line[512],len;
            new 
rand random_num(1,number);
            
read_file(file,rand,line,511,len);
            
format(name,31,"]LA[ %s v2",line);
        }
        
client_cmd(id,"name ^"%s^"",name);
    }
    return 
PLUGIN_HANDLED;



pRED* 04-20-2007 03:46

Re: command not working right
 
Try setting a task in client_putinserver to wait a second (maybe less.. play around with it) which then calls the set name function

YamiKaitou 04-20-2007 11:16

Re: command not working right
 
Okay, but know I have another question still related to this. Does client_infochanged get called when a client connects to the server? I had a plugin that was able to change their name successfully when they connected, but I can't seem to find it again to see how it works.

teame06 04-20-2007 13:39

Re: command not working right
 
Yes, it does get called somewhere inbetween putinserver and when they are shown the motd. I havn't logged if it on putinserver or if it inbetween putinserver or when they are shown the motd.


All times are GMT -4. The time now is 06:42.

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