strfind numbers
#1

I would like to do to detect if player name has numbers in their names, its for RP names so:

Player name for example:
Dimitri_Vegas - Good
Dimitri_Vegas1 - bad

How to detect it with strfind? but all the numbers, i mean if the player has number/numbers in his name.
Reply
#2

https://sampwiki.blast.hk/wiki/Strfind
Just check from 1 to 9 actually, and if he has like 19 he will still get kicked.

You can add a stock and it would be like
pawn Код:
if(strfind(name, "1", true) == 0) return Kick(playerid);
All over till you get to 9.

Hope that helped.

(PS:Not really sure about "== 0" part as I never dealt with strfind)
Reply
#3

A string is nothing more than an array filled with ASCII-character codes for each letter. Instead of using strfind for every number, you can do something like this:
Код:
for (new c; c < sizeof(name); c++)
{
    if ('0' <= name[c] <= '9') return Kick(playerid);
}
Note that '0' and '9' are NOT numbers, but ASCII characters. What happens here is that the script checks if the ASCII code of name[c] (a character in your name) is between the ASCII number of '0' (which is 48 ) and the ASCII number of '9' (which is 57). So if any of the name's characters is between those ASCII characters in the list, it will kick the player. The full ASCII list can be found here.
Reply
#4

Quote:
Originally Posted by Basssiiie
Посмотреть сообщение
A string is nothing more than an array filled with ASCII-character codes for each letter. Instead of using strfind for every number, you can do something like this:
Код:
for (new c; c < sizeof(name); c++)
{
    if ('0' <= name[c] <= '9') return Kick(playerid);
}
Note that '0' and '9' are NOT numbers, but ASCII characters. What happens here is that the script checks if the ASCII code of name[c] (a character in your name) is between the ASCII number of '0' (which is 48 ) and the ASCII number of '9' (which is 57). So if any of the name's characters is between those ASCII characters in the list, it will kick the player. The full ASCII list can be found here.
Thanks it works! +REP
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)