Advertisement
Guest User

pinfo

a guest
Oct 15th, 2019
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.99 KB | None | 0 0
  1. /*
  2. * Comments:
  3. * Displays player information. For Example...
  4. * First Nick is the very first nick they had when their profile was created.
  5. * Time Played is total time person has played on your server. Not just their current session.
  6. * [ FIRST NICK: OneEyed ][ CONNECTS: 152 ][ ROUNDS: 25 ][ TIME PLAYED: 2 Days 3 Hrs 52 Mins ]
  7. *
  8. * Note:
  9. * Plugin is self-sufficient, just compile and add to plugins.ini / plugin folder and your set.
  10. * All player data will be saved into pinfo.vault @ amxmodx/data/vault folder.
  11. *
  12. * Chat Command:
  13. * /name name - Typed in chat. If no name specified, returns your own info.
  14. *
  15. * Version : 2.0
  16. * Requires: AMXX 1.70+ and NVAULT module
  17. * Gametype: CS/NS/DOD
  18. *
  19. * Author: OneEyed
  20. * Date: 01-23-2006
  21. * Email: joelruiz2@gmail.com
  22. * IRC: #modns (gamesurge.net)
  23. *
  24. * Tested :
  25. * WIN32 Tested and Approved! LINUX untested.
  26. *
  27. * Credits:
  28. * voogru - He used it on his server (I sorta replicated it)
  29. *
  30. * Change Log:
  31. * v2.0 - Updated plugin to use nVault instead of *.ini file.
  32. * v1.1 - Fixed to update played time at round end/map change, no more looped task.
  33. *
  34. */
  35.  
  36. //---------------------------------------------------------------------------------------------
  37. //-------------------DO NOT EDIT BELOW---------------------------------------------------------
  38. #include <amxmodx>
  39. #include <amxmisc>
  40. #include <nvault>
  41. #include <colorchat>
  42.  
  43. new Float:g_onlinetime[33]
  44. new maxplayers
  45.  
  46. new Vault
  47. static const VAULTNAME[] = "pinfo"
  48.  
  49. static const TITLE[] = "PInfo"
  50. static const VERSION[] = "2.0"
  51. static const AUTHOR[] = "OneEyed"
  52. //---------------------------------------------------------------------------------------------------
  53. public plugin_init()
  54. {
  55. register_plugin(TITLE, VERSION, AUTHOR)
  56. register_cvar(TITLE,VERSION,FCVAR_SERVER) //plugin displays as cvar for HLSW or whatever
  57.  
  58. maxplayers = get_maxplayers()
  59. register_clcmd("say","handle_say")
  60.  
  61. new modname[32]
  62. get_modname(modname,31)
  63.  
  64. if(equali("cstrike",modname))
  65. register_event("SendAudio","EndofRound","a","2=%!MRAD_terwin","2=%!MRAD_ctwin","2=%!MRAD_rounddraw")
  66. else if(equali("ns",modname))
  67. register_event("GameStatus", "EndofRound", "ab", "1=2")
  68. else if(equali("dod",modname))
  69. register_event("RoundState","EndofRound","a","1=3","1=4")
  70. }
  71. //---------------------------------------------------------------------------------------------------
  72. public plugin_end() { //update user on map change but not 2 times
  73. new Float:gametime = get_gametime()
  74. for(new id=1;id<=maxplayers;id++)
  75. if( is_user_connected(id) )
  76. updateUser(id, 0, 0, floatround(gametime - g_onlinetime[id]))
  77. }
  78. //---------------------------------------------------------------------------------------------------
  79. public EndofRound() {
  80. new Float:gametime = get_gametime()
  81. for(new id=1;id<=maxplayers;id++)
  82. if( is_user_connected(id) && !is_user_bot(id)) {
  83. updateUser(id, 1, 0, floatround(gametime - g_onlinetime[id]))
  84. g_onlinetime[id] = gametime
  85. }
  86. }
  87. //---------------------------------------------------------------------------------------------------
  88. public client_putinserver(id) {
  89. if(is_user_connected(id) && !is_user_bot(id)) {
  90. updateUser(id, 0, 1, 0)
  91. g_onlinetime[id] = get_gametime() - 3.0
  92. }
  93. }
  94. //---------------------------------------------------------------------------------------------------
  95. public client_disconnect(id) {
  96. if(!is_user_bot(id))
  97. updateUser(id, 0, 0, floatround(get_gametime()-g_onlinetime[id]))
  98. g_onlinetime[id] = 0.0
  99. }
  100. //---------------------------------------------------------------------------------------------------
  101. public handle_say(id) {
  102. new said[192]
  103. read_args(said,191)
  104. remove_quotes(said)
  105. if( (containi(said, "/name") != -1) ) {
  106. new info[7]
  107. new name[34]
  108. new data[2]
  109. data[0] = id
  110.  
  111. parse(said, info, 6, name, 33)
  112. if(equali(info, "/name"))
  113. if(equal(name[0],"")) {
  114. data[1] = id
  115. set_task(0.1, "printUserInfo", id, data, 2)
  116. }
  117. else
  118. {
  119. data[1] = cmd_target(id,name,2) // Don't block access...
  120. if(data[1])
  121. set_task(0.1, "printUserInfo", id, data, 2)
  122. else
  123. client_print(id,print_chat,"There is no player with that name.")
  124. }
  125. }
  126. return PLUGIN_CONTINUE
  127. }
  128. //---------------------------------------------------------------------------------------------------
  129. updateUser(id, rounds, connects, time) {
  130.  
  131. Vault = nvault_open( VAULTNAME )
  132. if(Vault == INVALID_HANDLE)
  133. server_print("Error opening nVault file: %s",VAULTNAME)
  134. else
  135. {
  136. new steamid[32], playerinfo[4][32] // "FIRSTNICK" "ROUNDS" "CONNECTIONS" "TOTALTIME"
  137. new key[32], val[511], TimeStamp
  138.  
  139. get_user_authid(id,steamid,31)
  140. format(key,32,"%s",steamid)
  141.  
  142. if( nvault_lookup(Vault, key, val, 510, TimeStamp) )
  143. {
  144. parse(val, playerinfo[0], 31, playerinfo[1], 31, playerinfo[2], 31, playerinfo[3], 31)
  145. new update[511]
  146. rounds += str_to_num( playerinfo[1] )
  147. connects += str_to_num( playerinfo[2] )
  148. time += str_to_num( playerinfo[3] )
  149. format(update,510,"^"%s^" %i %i %i",playerinfo[0], rounds, connects, time)
  150. nvault_set(Vault, key, update)
  151. }
  152. else
  153. {
  154. new update[511], name[32]
  155. get_user_name(id, name, 31)
  156. format(update,510,"^"%s^" %i %i %i",name,0,1,0)
  157. nvault_set(Vault, key, update)
  158. }
  159. nvault_close(Vault)
  160. }
  161. }
  162. //---------------------------------------------------------------------------------------------------
  163. public printUserInfo(userids[])
  164. {
  165. new id = userids[0]
  166. new playerid = userids[1]
  167.  
  168. Vault = nvault_open( VAULTNAME )
  169. if(Vault == INVALID_HANDLE)
  170. server_print("Error opening nVault file: %s",VAULTNAME)
  171. else
  172. {
  173. new steamid[32], playerinfo[4][64] // "FIRSTNICK" "ROUNDS" "CONNECTIONS" "TOTALTIME"
  174. new key[32], val[511], TimeStamp, text[512]
  175.  
  176. get_user_authid(playerid,steamid,31)
  177. format(key,32,"%s",steamid)
  178.  
  179. if( nvault_lookup(Vault, key, val, 510, TimeStamp) )
  180. {
  181. parse(val, playerinfo[0], 63, playerinfo[1], 63, playerinfo[2], 63, playerinfo[3], 63)
  182.  
  183. new Float:gametime = get_gametime()
  184. new onlinetime = floatround( gametime - g_onlinetime[playerid] )
  185. new ptime = str_to_num(playerinfo[3]) + onlinetime
  186. new days = ptime / 86400
  187. new hours = (ptime / 3600) % 24
  188. new minutes = (ptime / 60) % 60
  189. new seconds = ptime % 60
  190. new totaltime[64]
  191. new sday[16], shr[16], smin[16], ssec[16]
  192.  
  193. format(sday,15,"%i Day%s ",days, (days==1?"s":""))
  194. format(shr,15,"%i Hr%s ",hours, (hours==1?"s":""))
  195. format(smin,15,"%i Min%s ",minutes, (minutes==1?"s":""))
  196. format(ssec,15,"%i Sec%s ",seconds, (seconds==1?"s":""))
  197. format(totaltime, 63, "%s%s%s%s", (days >= 1 ? sday:""), (hours >= 1 ? shr:""), smin, (hours==0 ? ssec:""))
  198. format(text,511,"")
  199. ColorChat(0, TEAM_COLOR,"^1[FIRST NICK: ^4%s^1] [CONNECTS: ^3%s^1] [ROUNDS: ^4%s^1] [TIME PLAYED: ^3%s^1]",playerinfo[0],playerinfo[2],playerinfo[1],totaltime)
  200.  
  201. nvault_close(Vault)
  202.  
  203. updateUser(playerid, 0, 0, onlinetime)
  204. g_onlinetime[playerid] = gametime
  205. }
  206. }
  207. return PLUGIN_HANDLED
  208. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement