Advertisement
Guest User

Untitled

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