Raised This Month: $ Target: $400
 0% 

command not working right


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
YamiKaitou
Has a lovely bunch of coconuts
Join Date: Apr 2006
Location: Texas
Old 04-19-2007 , 20:11   command not working right
Reply With Quote #1

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;

__________________
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
pRED*
Join Date: Dec 2006
Old 04-20-2007 , 03:46   Re: command not working right
Reply With Quote #2

Try setting a task in client_putinserver to wait a second (maybe less.. play around with it) which then calls the set name function
pRED* is offline
YamiKaitou
Has a lovely bunch of coconuts
Join Date: Apr 2006
Location: Texas
Old 04-20-2007 , 11:16   Re: command not working right
Reply With Quote #3

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.
__________________
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
teame06
i have a hat
Join Date: Feb 2005
Location: Hat City
Old 04-20-2007 , 13:39   Re: command not working right
Reply With Quote #4

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.
__________________
No private support via Instant Message
GunGame:SM Released
teame06 is offline
Send a message via AIM to teame06
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 06:42.


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