SetPlayerName Bug?
#1

I have a script that changes your playername when you connect to the server which only seems to work (For me as the host anyways) if nobody else is on the server. When I connect with anyone else on the server though, it won't work correctly, everyone on the server will see my old name after it has been changed to something else. However, when I check who's on the server through the server list, it'll display me as my new changed name...

I've done quite a bit of testing, the script verifies that my name was actually changed although everyone including myself still sees my old name instead of the changed name. I was thinking maybe it might have been because of me having ID 0? Well anyways, I've done alot of searching, even tried putting that SetPlayerName to a timer, but no solution could be found. So has anyone ever had a similar problem with this sort of thing?

Update: Sorry, other players do see the changed name, only myself see my old name still on chat & in the TAB list
Reply
#2

What are you changing it to?
Reply
#3

( Thank you for responding Lenny )
I don't think it really matters what I'm changing the playername to because it works just fine when nobody else is on the server, but if you connect while others are on the server, the name doesn't update for THAT player, but everyone else on the server does see the change... Example:
( I connect using the playername 'Test' and the script will change my name to 'Change' )

This is what you see if you're the player whose name is being changed when you chat & say Hello
Test: Hello

This is what everyone else on the server sees though:
Change: Hello

I can work around the chat though to display the name correctly, but un-able to update the new player's name in the TAB list for THAT player, everyone else sees them as the new changed name... So this isn't really too serious of an issue to me anymore

But if anyone knows something about this, would be nice to know the cause & what can be done about it
Reply
#4

Very difficult to help you without any code posted.
Reply
#5

Are you sure you're not changing the name of the player to something similar or the same as what someone else is already named on the server?

You can't have two "Carl", for example, and you can't have one "Carl" and one "cArl"
Reply
#6

As the function is used, I have it message the player whether the name change was successful, is not a valid name or that name is already used with a switch/case. It always returns that the name change was successful, it's a valid name & nobody else on the server is using it. There are NO changes at all when I log on the server alone which then it works & when I log on the server with other players which is does not work (Only the player cant see the changes, everyone else can)... So there's no reason to display any code because there's nothing wrong with the way it's scripted else it wouldnt work at all etc.

I also tried putting it in a timer to constantly change your name which didn't work. You know that console message you get when you do sucessfully change your name, I also get that everytime. It's NOT a script error, just a bug of some sort.

Just like the SetPlayerTeam doesn't always work as it should, people suggest you throw it in a timer to make it work
Reply
#7

ok well without the code, it is STILL difficult to help, because I (or we) have nothing to base our assumprions / ideas on.

When you use SetPlayerName(), I believe there should be an echo in the logs '[nick] player changed to other'
( or something like that ) Are you getting this message?


You mentioned that you see the new name in the tab list, but the old name when you talk?. Is that Global chat? what function are you referring to? SendClientMessageToall? SendPlayerMessageToall? or a custom function. Perhaps the problem is there.

This sounds like a problem which nearly drove me mad a while ago, a tiny error was hanging my script and not crashing it, in the end I found it by inserting about 50 sequential printf commands.

If you can't find the problem in the SetPlayerName() part of the script, check the other areas I guess.
Reply
#8

I do get the server's echo log messages about the player's name being changed, but the player whose name was changed is the only one who does not see the changes... The name in chat and in the TAB list are always the same, I just said I could code a work around so the updated name displays in chat correctly for the player. There is no special/custom chat code, just uses the default chat style.

I'll try a few more tests, some methods I didnt try yet, create a very simple name change for example just in case, then when complete, I'll edit this post with the results...
Reply
#9

I've found that OnPlayerConnect can be dodgy to do client code in sometimes. One thing I'd suggest to try is move your code to the first OnPlayerRequestClass call.

I personally do not do code in OnPlayerConnect until the player has seen the class selection, as I've had 'not fully connected' problems before. You could try something like this to 'resolve' the issue:

pawn Код:
new
    bool:g_abPlayerFullyConnected[MAX_PLAYERS],
    bool:g_abPlayerSeenClassSelect[MAX_PLAYERS];

public OnPlayerConnect(playerid)
{
    // Maybe put your variable resetting here, it depends on your
    // script.

    // Halt the code, the player is not fully connected.
    if (!g_abPlayerFullyConnected[playerid])
        return 1;

    // The rest of your code here, most definately try putting SetPlayerName
    // here.
}

public OnPlayerRequestClass(playerid, classid)
{
    g_abPlayerFullyConnected[playerid] = true;

    if (!g_abPlayerSeenClassSelect[playerid])
    {
        g_abPlayerSeenClassSelect[playerid] = true;

        // This will now call the OnPlayerConnect function and it will not 'halt'
        OnPlayerConnect(playerid);
    }

    // The rest of your code here.
}

public OnPlayerDisconnect(playerid, reason)
{
    g_abPlayerFullyConnected[playerid] = false;
    g_abPlayerSeenClassSelect[playerid] = false;

    // Your code here.
}
Reply
#10

This is stupid, if you don't post code you are just wasting our time, and should just fix the problem yourself.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)