ID:178334
 
I'd like to know if it's possible to limit the amount of characters that a player can input. For example, limit a player to 24 characters for their name, 128 characters when chatting, etc. Probably is, I just haven't seen a thread explaining how to, and never found it in DM's help index.
Yes it is. All you have to do is download Deadrons Character handling library and read ovver it and the demo and you will learn.
Matic293 wrote:
I'd like to know if it's possible to limit the amount of characters that a player can input. For example, limit a player to 24 characters for their name, 128 characters when chatting, etc.

You bet there is! There's two methods of doing this:

1) You can make them choose another name if their name is over 24 characters. (using length())
mob/Login()
while(!name) //until they have a name...
var/tempname = input("What's your name?") //ask them their name
if(length(tempname) > 24) return //if it's too long, ask them again (accomplished with the while() statement)
else //if it's of acceptable length
name = tempname //set the name to what they chose
..()

2) You can take the first 24 characters of the name, and risk their name being cut off. (using copytext())
mob/Login()
var/tempname = input("What's your name?") //ask them their name
name = copytext(tempname,1,25) //make their name the first 25 characters of what they typed in

Personally, I prefer #1, but you can use #2 if you want :)

Your question about limitting chat messages to 128 characters is accomplished with copytext(). All you'd do is make <font face=system>msg = copytext(msg,1,129)</font> to make the message only include the first 128 characters :)

=V
In response to Vortezz
Thanks for your help! So it sounds like DM skipped the abililty to stop the input cursor after a certain amount of characters? That is more to what I was hoping for, but as long as there isn't another player named "Antidisestablishmentarianist", I'll be a happy camper. =,