Advertisement
ColdWar-Pawn

_MagicStyle_ Admins connected

May 1st, 2013
395
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 3.29 KB | None | 0 0
  1. /* Plugin generated by AMXX-Studio */
  2.  
  3.  
  4.  
  5.  
  6. #include <amxmodx>
  7. #include <engine>
  8.  
  9.  
  10.  
  11.  
  12. #define PLUGIN "Show Admins Online"
  13. #define VERSION "1.1"
  14. #define AUTHOR "vato loco [GE-S] & Alka"
  15.  
  16.  
  17.  
  18.  
  19. new bool:g_bAdminNick
  20. new bool:is_admin_connected[33]
  21. new g_msg[512]
  22.  
  23.  
  24.  
  25.  
  26. new g_admin_enable
  27. new g_online_color
  28. new g_offline_color
  29. new g_msg_xypos
  30.  
  31.  
  32.  
  33.  
  34. new g_SyncAdmin
  35. new g_iAdminCount
  36. new g_iMaxPlayers
  37.  
  38.  
  39.  
  40.  
  41. new g_ClassName[] = "admin_msg"
  42.  
  43.  
  44.  
  45.  
  46. public plugin_init()
  47. {
  48.     register_plugin( PLUGIN, VERSION, AUTHOR )
  49.    
  50.     register_think(g_ClassName,"ForwardThink")
  51.    
  52.     g_admin_enable = register_cvar("sa_plugin_on","1")
  53.     g_online_color = register_cvar("sa_online_color","0 130 0")
  54.     g_offline_color = register_cvar("sa_offline_color","255 0 0")
  55.     g_msg_xypos = register_cvar("sa_msg_xypos","0.02 0.2")
  56.    
  57.     g_SyncAdmin = CreateHudSyncObj()
  58.     g_iMaxPlayers = get_maxplayers()
  59.    
  60.     new iEnt = create_entity("info_target")
  61.     entity_set_string(iEnt, EV_SZ_classname, g_ClassName)
  62.     entity_set_float(iEnt, EV_FL_nextthink, get_gametime() + 2.0)
  63. }
  64.  
  65.  
  66.  
  67.  
  68. public client_putinserver(id)
  69. {
  70.     new flags = get_user_flags(id);
  71.     if(flags  & ADMIN_KICK && !(flags & ADMIN_BAN))
  72.     {
  73.         is_admin_connected[id] = true
  74.         g_iAdminCount++
  75.         set_admin_msg()
  76.     }
  77.     if(g_iAdminCount == 0)
  78.         set_admin_msg()
  79. }
  80.  
  81.  
  82.  
  83.  
  84. public client_disconnect(id)
  85. {
  86.     if(is_admin_connected[id])
  87.     {
  88.         is_admin_connected[id] = false
  89.         g_iAdminCount--
  90.         set_admin_msg()
  91.     }
  92. }
  93.  
  94.  
  95.  
  96.  
  97. public client_infochanged(id)
  98. {
  99.     if(is_admin_connected[id])
  100.     {
  101.         static NewName[32], OldName[32]
  102.         get_user_info(id, "name", NewName, 31)
  103.         get_user_name(id, OldName, 31)
  104.        
  105.         if(!equal(OldName, NewName))
  106.         {
  107.             g_bAdminNick = true
  108.         }
  109.     }
  110. }
  111.  
  112.  
  113.  
  114.  
  115. public set_admin_msg()
  116. {
  117.     static g_iAdminName[32], pos, i
  118.     pos = 0
  119.     pos += formatex(g_msg[pos], 511-pos, "Admins Online: %d^n", g_iAdminCount)
  120.     pos += formatex(g_msg[pos], 511-pos, "To see all clubs say /server")
  121.     for(i = 1 ; i <= g_iMaxPlayers ; i++)
  122.     {    
  123.         if(is_admin_connected[i])
  124.         {
  125.             get_user_name(i, g_iAdminName, 31)
  126.             pos += formatex(g_msg[pos], 511-pos, "^n%s", g_iAdminName)
  127.         }
  128.     }
  129. }
  130.  
  131.  
  132.  
  133.  
  134. public admins_online()
  135. {
  136.     if(get_pcvar_num(g_admin_enable))
  137.     {
  138.         static r, g, b, Float:x,Float:y
  139.         HudMsgPos(x,y)
  140.        
  141.         if (g_iAdminCount > 0)
  142.         {
  143.             HudMsgColor(g_online_color, r, g, b)
  144.             set_hudmessage(r, g, b, x, y, _, _, 4.0, _, _, 4)
  145.             ShowSyncHudMsg(0, g_SyncAdmin, "%s", g_msg)
  146.         }
  147.         else
  148.         {
  149.             HudMsgColor(g_offline_color, r, g, b)
  150.             set_hudmessage(r, g, b, x, y, _, _, 4.0, _, _, 4)
  151.             ShowSyncHudMsg(0, g_SyncAdmin, "%s", g_msg)
  152.         }
  153.     }
  154.     return PLUGIN_HANDLED
  155. }
  156.  
  157.  
  158.  
  159.  
  160. public ForwardThink(iEnt)
  161. {
  162.     admins_online()
  163.    
  164.     if(g_bAdminNick)
  165.     {
  166.         set_admin_msg()
  167.         g_bAdminNick = false
  168.     }
  169.     entity_set_float(iEnt, EV_FL_nextthink, get_gametime() + 2.0)
  170. }
  171.  
  172.  
  173.  
  174.  
  175. public HudMsgColor(cvar, &r, &g, &b)
  176. {
  177.     static color[16], piece[5]
  178.     get_pcvar_string(cvar, color, 15)
  179.    
  180.     strbreak( color, piece, 4, color, 15)
  181.     r = str_to_num(piece)
  182.    
  183.     strbreak( color, piece, 4, color, 15)
  184.     g = str_to_num(piece)
  185.     b = str_to_num(color)
  186. }
  187.  
  188.  
  189.  
  190.  
  191. public HudMsgPos(&Float:x, &Float:y)
  192. {
  193.     static coords[16], piece[10]
  194.     get_pcvar_string(g_msg_xypos, coords, 15)
  195.    
  196.     strbreak(coords, piece, 9, coords, 15)
  197.     x = str_to_float(piece)
  198.     y = str_to_float(coords)
  199. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement