Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SetPlayerName return problem #28

Closed
IstuntmanI opened this issue Mar 10, 2016 · 5 comments
Closed

SetPlayerName return problem #28

IstuntmanI opened this issue Mar 10, 2016 · 5 comments

Comments

@IstuntmanI
Copy link

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.

@oscar-broman
Copy link
Contributor

J O H N C E N A

That's not a bug, it's a feature.

@Crayder
Copy link

Crayder commented Mar 11, 2016

Well, it would still be nice to know if the function failed instead.

An alternative until this is fixed (if, it is) would be to just hook the function and test the name yourself.

@IstuntmanI
Copy link
Author

What do you mean by failing ? The -1 and 0 returns are exactly for that.

At this moment I just unloaded the plugin, because I'm not using anything from it. I started using YSF again a few weeks ago just by loading the plugin, I wanted to see if there are no bugs and it seems like it was a good decision.

@Crayder
Copy link

Crayder commented Mar 11, 2016

No, I mean we should have the -1 so we know more of why it failed.

@ghost
Copy link

ghost commented Mar 11, 2016

Will be fixed later today when I arrive from fucking school :D

Thanks.

E: Fixed.

@ghost ghost closed this as completed Mar 11, 2016
@djacicd djacicd mentioned this issue Nov 21, 2017
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants