how to allow only character and number in string
#1

hi i want to let player type a hex color.
just like FF0000 (yellow).but if player type "F$0000", ":" will make colors bug
how to limit only 26 english characters and number in string?limit player type special character
Reply
#2

Regular Expressions maybe?
Reply
#3

Quote:
Originally Posted by Logic_
Посмотреть сообщение
Regular Expressions maybe?
good idea.but i don't want to install plugin.have others way?some simple pawn code to do it...
Reply
#4

Limit text to 6 characters long (RRGGBB) and check if it is a hex number:
pawn Код:
// example:
new colour;
if (strlen(inputtext) == 6 && !sscanf(inputtext, "x", colour))
{
    // your code
}
Reply
#5

Quote:
Originally Posted by ******
Посмотреть сообщение
sscanf "x"
Quote:
Originally Posted by Calisthenics
Посмотреть сообщение
Limit text to 6 characters long (RRGGBB) and check if it is a hex number
NICE!!!I DONE!!!THANK A LOT!!!
Код:
if(sscanf(playercolor, "{x}")) return Warning(playerid,"please type a color code");
Reply
#6

Quote:
Originally Posted by ******
Посмотреть сообщение
So you didn't notice all the responses after you saying you didn't want to use a plugin were to use a plugin?
hmm...nobody will install a complexity plugin for a simple function and use ram of idle(just talk from my script).but sscanf service too many functions.sscanf no only solve this problem
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)