Raised This Month: $ Target: $400
 0% 

Setting player name


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
steel_1988
Junior Member
Join Date: Apr 2009
Old 04-02-2009 , 07:04   Setting player name
Reply With Quote #1

Im not sure if this is an AMX bug or something? But with the following code, when you connect the first time it forces your name.. But if you retry it ignores it and does not force your name, it keeps it as whatever your counter-strike config was set to.

Any ideas? I need to force the name each time they connect.

public client_connect(id)
{
new newName[33]
get_user_info(id,"name",newName,32)

if(containi(newName,"[NEW NAME]") == -1)
{
format(newName,32,"[NEW NAME] %s",newName)
set_user_info(id,"name",newName)
}
}
steel_1988 is offline
Dores
Veteran Member
Join Date: Jun 2008
Location: You really don't wanna k
Old 04-02-2009 , 07:16   Re: Setting player name
Reply With Quote #2

Try checking his name at client_infochanged(id). It is called whenever his name is set/he changes his name(it is called in other events too, but the name is the important thing here).

PHP Code:
#include <amxmodx>

#define NAME_TAG    "[NEW_NAME]"

public client_infochanged(id)
{
    static 
name[32];
    
get_user_info(id"name"name31);
    
    if(
containi(nameNAME_TAG) == -1)
    {
        
format(name31"%s %s"NAME_TAGname);
        
        
set_user_info(id"name"name);
    }

__________________
O o
/Ż________________________
| IMMA FIRIN' MAH LAZOR!!!
\_ŻŻŻ
Dores is offline
Dores
Veteran Member
Join Date: Jun 2008
Location: You really don't wanna k
Old 04-02-2009 , 10:58   Re: Setting player name
Reply With Quote #3

Quote:
Originally Posted by Dores View Post
Try checking his name at client_infochanged(id). It is called whenever his name is set...
What I meant by this is when he connects into the game, when the game sets his name so everyone could see it in the scoreboard, client_infochanged() is called.
__________________
O o
/Ż________________________
| IMMA FIRIN' MAH LAZOR!!!
\_ŻŻŻ
Dores is offline
steel_1988
Junior Member
Join Date: Apr 2009
Old 04-02-2009 , 07:29   Re: Setting player name
Reply With Quote #4

Yeah but then it is only going to set their name if they change it.

If you use my code it sets their name when they join but if they retry it doesn't set it again for some reason..

With your way it is only going to set if when info is changed. I need it when they join the server (set it always.. not just the first time)
steel_1988 is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 04-02-2009 , 09:27   Re: Setting player name
Reply With Quote #5

In my tests, client_infochanged() is called several times when a client is connecting to the server. (3 or 4 if I remember correctly)
__________________
fysiks is offline
YamiKaitou
Has a lovely bunch of coconuts
Join Date: Apr 2006
Location: Texas
Old 04-02-2009 , 11:06   Re: Setting player name
Reply With Quote #6

Quote:
Originally Posted by fysiks View Post
In my tests, client_infochanged() is called several times when a client is connecting to the server. (3 or 4 if I remember correctly)
Correct, 1 for putinserver, 1 for team change, 1 for class change. There may be another, but those are the 3 that I remember. This is why you need to filter the calls by checking if the old name equals the new name.
__________________
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
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 04-02-2009 , 19:41   Re: Setting player name
Reply With Quote #7

Quote:
Originally Posted by YamiKaitou View Post
Correct, 1 for putinserver, 1 for team change, 1 for class change. There may be another, but those are the 3 that I remember. This is why you need to filter the calls by checking if the old name equals the new name.
client_connect() (it showed up before connect but after putinserver)
__________________
fysiks is offline
steel_1988
Junior Member
Join Date: Apr 2009
Old 04-02-2009 , 20:44   Re: Setting player name
Reply With Quote #8

The code should be working tho.. I did a server_print("code executed"); under where it sets the name..

It shows each time, however the persons name is not being set.. It only sets it the first time they connect...

If they then retry, their name stays as whatever their name is set to in their settings.. but i still see the message in the server console.
steel_1988 is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 04-02-2009 , 21:31   Re: Setting player name
Reply With Quote #9

Do some more troubleshooting. Server print name, tag, newname, or whatever to see if the name is correct or the if statement is being executed or etc. That's what I would do.
__________________
fysiks is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 04-03-2009 , 00:00   Re: Setting player name
Reply With Quote #10

Try adding quotes around the name since it does contain space(s).

format(name, 31, "^"%s %s^"", NAME_TAG, name);
__________________
Bugsy 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 02:17.


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