Skip to content

SetPlayerName return problem #28

@IstuntmanI

Description

@IstuntmanI

SetPlayerName return values:

1 The name was changed successfully
0 The player already has that name
-1 The name can not be changed (it's already in use, too long or has invalid characters)


It returns the good values without this plugin, but with it I get only the 0 and 1 returns:

For '[SG]stuntman' SetPlayerName returned '1' .
For 'test' SetPlayerName returned '1' .
For '[test]' SetPlayerName returned '1' .
For '@$' SetPlayerName returned '1' .
For '@
$%' SetPlayerName returned '1' . <- Should return -1 (invalid) as it does without YSF. Doesn't actually change the name anyway.
For 'helloworld' SetPlayerName returned '1' .
For '>test' SetPlayerName returned '1' . <- Should return -1 (invalid) as it does without YSF. Doesn't actually change the name anyway.
For 'test' SetPlayerName returned '1' .
For 'test' SetPlayerName returned '0' .
For 'testdsasadkdsakjdsajjkasaddsds' SetPlayerName returned '1' . <- Should return -1 (too long) as it does without YSF. Doesn't actually change the name anyway.

As I can see in the Scripting.cpp code, you ALWAYS return 1 if SetPlayerName returns NON-ZERO. You should return SetPlayerName's return value (with plugin's name validity check). Also, you should reset player's name for other players only if SetPlayerName returned 1.

Maybe you should also make SetPlayerNameForPlayer support those return values ? (I don't actually use this function)


How I discovered this (creative players discovering things again): I have a name changing system based on those returns and it messed up some players accounts (who changed to invalid names). They complained that they were able to change names to things like "#invisible ||" and "J O H N C E N A" as SetPlayerName returns 1 and the script updates the player's database row's name because of it. When he connects with that new name (which wasn't set in-game the last time but got updated in database because of return 1) SA:MP tells him that his name is invalid, as it should. Result: the player lost his account and I have to manually change his account's name to a valid one directly from the database.


TL;DR: Bug: SetPlayerName never returns -1.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions