simeonniko

Untitled

Oct 9th, 2017
172
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 1.13 KB | None | 0 0
  1. #include <amxmodx>
  2. #include <fakemeta>
  3. #include <regex>
  4.  
  5. new g_szPattern[] = "[^\x20-\x7E]+"
  6. new Regex:g_RegexPattern, g_ReturnValue
  7. new g_szName[33][32]
  8.  
  9. public plugin_init()
  10. {
  11.     register_plugin("Nick validator", "1.0", "WaLkZ")
  12.    
  13.     register_forward(FM_ClientUserInfoChanged, "fwd_ClientUserInfoChanged")
  14.  
  15.     g_RegexPattern = regex_compile_ex(g_szPattern, g_ReturnValue)
  16. }
  17.  
  18. public client_putinserver(id)
  19. {
  20.     get_user_name(id, g_szName[id], charsmax(g_szName[]))
  21.    
  22.     if (regex_match_c(g_szName[id], g_RegexPattern, g_ReturnValue ) > 0)
  23.     {
  24.         server_cmd("kick #%d ^"Special symbols detected in name^"", get_user_userid(id))
  25.     }
  26. }
  27.  
  28. public fwd_ClientUserInfoChanged(id, buffer)
  29. {
  30.     static szNewName[32]
  31.     get_user_info(id, "name", szNewName, charsmax(szNewName))
  32.    
  33.     if (equal(szNewName, g_szName[id]))
  34.     {
  35.         return FMRES_IGNORED
  36.     }
  37.  
  38.     if (regex_match_c(szNewName, g_RegexPattern, g_ReturnValue ) > 0)
  39.     {
  40.         client_print(id, print_console, "Special symbols in the nick are not allowed here :)")
  41.        
  42.         engfunc(EngFunc_SetClientKeyValue, id, buffer, "name", g_szName[id])
  43.        
  44.         return FMRES_SUPERCEDE
  45.     }
  46.  
  47.     return FMRES_IGNORED
  48. }
Advertisement
Add Comment
Please, Sign In to add comment