Command help
#1

Guys, i wish to create a command on a gamemode for an specific job that allows anyone with that job to change change his name, since a player with that name has not yet registered, or, if someone has already got that name, that person is offline. I could write that code myself if the gamemode i have my hands on was written by me, but it wasnt. So it would be a lot complicated for me to write that since i am not so much experienced with coding. If someone could write that code, doesnt matter if incomplete, but just to give me an idead of how to write that code, i would be very thankful.

Thanks in advance.
Reply
#2

It's pretty easy if you have an INI system, you can generate the INI filename check if it exists, mysql or sqlite you can make a query.
Reply
#3

Hello.
Correct me if I'm wrong, but you want a system where players can register accounts for their user names.
Then, when someone connects and their user name has already been registered by someone else, they can change their name.
Reply
#4

No. I am helping script a server where Hitman is one of the professions. I would like a code where a Hitman member could change his in game name to disguise himself. But the restrictions to that name would be if there is someone with that name online or not. If it has someone online with that name the Hitman cant change to that name. If there isnt anyone with that name online, the hitman can use that name, even though there is already someone with an account registered with that name, but not online. And then, in order not to save the login information wrong due to the name changing, the server would change automatically to the original name on the disconnect.
Reply
#5

Ok. Quite a request there =p.

Regarding the command itself, there should be a limit as to how often the player can use this. You could use PVars to record the last time the player used the command, the name they changed to and their original name (if this is needed).
To make it only available for hitmen, you would need to get the player's job, using whatever job system you have, and make sure they're a hitman.

Name Changing
So. The first way you could do this is by hiding the player's real name, then attaching a 3D label above their head to display a fake name.
ShowPlayerNameTagForPlayer- Hide a player's name for a specific player (use in a for loop to hide for all players).
CreatePlayer3DTextLabel- Create the 3D label
This would save you a lot of effort working out whether the name they have chosen is available and making sure that the player's account is still saved correctly.
The 3D label may look a little fake, but that could be a way for perceptive players to work out if someone is a hitman.


The second way, the way you originally intended to use, would first need to make sure the name is valid:
  1. The player's name is not currently set to it: SetPlayerName returns 0 if that isn't true
  2. It's not currently in use by someone else, it's the correct length and doesn't contain invalid characters: SetPlayerName returns -1 if any of that isn't true
  3. It's not a registered name; Although you said you wanted this allowed, if the player who registered that name tried to connect, they wouldn't be able to because someone in-game already has their name.
It would then need to store the player's original name in a PVar, so that the player's account can still be correctly saved (whenever the server tries to save the player's account, it would check if this Pvar contains any value, and if it does, save to that account instead).
Creating a log entry would be helpful for tracking the player (e.g. "PLAYER disguised themself as PLAYER1"). So that if the player breaks any rules after changing their name, you know their true identity.
There would still be a problem with new players trying to connect with the name the player has disguised themself as, since the name is available for registering, but people can't connect with it until the disguised player has changed their name.
But anyway, the player's name would now be set to the new name. Any future name changes would not update the PVar containing their original name.
Reply
#6

Thanks for the reply! Ill test it out soon.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)