Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <amxmodx>
- #include <fakemeta>
- #include <regex>
- new g_szPattern[] = "[^\x20-\x7E]+"
- new Regex:g_RegexPattern, g_ReturnValue
- new g_szName[33][32]
- public plugin_init()
- {
- register_plugin("Nick validator", "1.0", "WaLkZ")
- register_forward(FM_ClientUserInfoChanged, "fwd_ClientUserInfoChanged")
- g_RegexPattern = regex_compile_ex(g_szPattern, g_ReturnValue)
- }
- public client_putinserver(id)
- {
- get_user_name(id, g_szName[id], charsmax(g_szName[]))
- if (regex_match_c(g_szName[id], g_RegexPattern, g_ReturnValue ) > 0)
- {
- server_cmd("kick #%d ^"Special symbols detected in name^"", get_user_userid(id))
- }
- }
- public fwd_ClientUserInfoChanged(id, buffer)
- {
- static szNewName[32]
- get_user_info(id, "name", szNewName, charsmax(szNewName))
- if (equal(szNewName, g_szName[id]))
- {
- return FMRES_IGNORED
- }
- if (regex_match_c(szNewName, g_RegexPattern, g_ReturnValue ) > 0)
- {
- client_print(id, print_console, "Special symbols in the nick are not allowed here :)")
- engfunc(EngFunc_SetClientKeyValue, id, buffer, "name", g_szName[id])
- return FMRES_SUPERCEDE
- }
- return FMRES_IGNORED
- }
Advertisement
Add Comment
Please, Sign In to add comment