|
Veteran Member
Join Date: Aug 2014
Location: Your mom house -Portugal
|

04-13-2016
, 14:32
Check character then replace
|
#1
|
I want to only allow A-Z, 0-9, and a few special characters like [](),.-~#=+-, on nicknames.
PHP Code:
new const g_AllowNickCharacter [][] = { "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "x", "z", "<", ">", ",", "+", "*", "'", "?", "=", ")", "(", "/", "#", ".", "-", ";", ":", "_", "ç", "~", "", "!", "|", "\", "[", "]", "1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "@" }
If the player uses a character that is not one of those mentioned above, it will get removed.
This is a test i did, its only for the first character:
PHP Code:
public client_infochanged(id) { if(!is_user_bot(id) && !is_user_hltv(id)) { new const name[] = "name" new szNewName[33] get_user_info(id, name, szNewName, charsmax(szNewName))
for(new i = 0; i < sizeof(g_AllowNickCharacter); i++) if(!(equal(szNewName[0], g_AllowNickCharacter[i]) != -1)) replace(szNewName, charsmax(szNewName), szNewName[0], "")
set_user_info(id, name, szNewName) } }
Whats wrong?
Last edited by Syturi0; 04-13-2016 at 14:35.
|
|