Advertisement
ejdrienxd

Untitled

Dec 6th, 2019
156
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.53 KB | None | 0 0
  1. #include <amxmodx>
  2. #include <fakemeta>
  3.  
  4. /****** Customization Area ******/
  5. // Flag to allow admin to reconnect without hudmessage
  6. // This is usefull when you reconnect with another nick to watch a suspected cheater
  7. // This will still set back your score/money/...
  8. #define ADMIN_SILENT ADMIN_KICK
  9.  
  10. // Color for hud message
  11. #define RED 0
  12. #define GREEN 100
  13. #define BLUE 200
  14. /********************************/
  15.  
  16. #define PLUGIN "Reconnect Features"
  17. #define AUTHOR "ConnorMcLeod"
  18. #define VERSION "0.2.4 BETA"
  19.  
  20. #define MAX_PLAYERS 32
  21. #define MAX_STORED 64
  22.  
  23. #define OFFSET_CSMONEY 115
  24. #define OFFSET_CSDEATHS 444
  25.  
  26. #define TASK_KILL 1946573517
  27. #define TASK_CLEAR 2946573517
  28. #define TASK_PLAYER 3946573517
  29.  
  30.  
  31. enum Storage {
  32. StoreSteamId[20],
  33. StoreFrags,
  34. StoreDeaths,
  35. StoreMoney,
  36. StoreRound
  37. }
  38.  
  39. new g_CurInfos[MAX_PLAYERS+1][Storage]
  40. new g_StoredInfos[MAX_STORED][Storage]
  41.  
  42. new bool:g_bPlayerNonSpawnEvent[MAX_PLAYERS + 1]
  43. new g_iFwFmClientCommandPost
  44.  
  45. new g_iRoundNum
  46.  
  47. new g_pcvarTime, g_pcvarScore, g_pcvarMoney, g_pcvarSpawn, g_pcvarStartMoney, g_pcvarNotify
  48. new mp_startmoney
  49. new g_msgidDeathMsg
  50. new g_iMaxPlayers
  51.  
  52. public plugin_init()
  53. {
  54. register_plugin(PLUGIN, VERSION, AUTHOR)
  55. register_dictionary("reconnect.txt")
  56.  
  57. register_cvar("reconnect_features", VERSION, FCVAR_SERVER|FCVAR_EXTDLL|FCVAR_SPONLY)
  58. g_pcvarTime = register_cvar("amx_noreconnect_time", "45")
  59. g_pcvarScore = register_cvar("amx_noreconnect_score", "1")
  60. g_pcvarMoney = register_cvar("amx_noreconnect_money", "1")
  61. g_pcvarSpawn = register_cvar("amx_noreconnect_spawn", "1")
  62. g_pcvarStartMoney = register_cvar("amx_noreconnect_startmoney", "0")
  63. g_pcvarNotify = register_cvar("amx_noreconnect_notify", "1")
  64.  
  65. register_event("HLTV", "eNewRound", "a", "1=0", "2=0")
  66.  
  67. register_event("TextMsg", "eRestart", "a", "2&#Game_C", "2&#Game_w")
  68.  
  69. register_event("ResetHUD", "Event_ResetHUD", "b")
  70. register_event("TextMsg", "Event_TextMsg_GameWillRestartIn", "a", "2=#Game_will_restart_in")
  71. register_clcmd("fullupdate", "ClientCommand_fullupdate")
  72.  
  73. register_event("Money", "eMoney", "be")
  74. register_event("ScoreInfo", "eScoreInfo", "a")
  75. }
  76.  
  77. public plugin_cfg()
  78. {
  79. mp_startmoney = get_cvar_pointer("mp_startmoney")
  80. g_msgidDeathMsg = get_user_msgid("DeathMsg")
  81. g_iMaxPlayers = global_get(glb_maxClients)
  82. }
  83.  
  84. public Event_TextMsg_GameWillRestartIn()
  85. {
  86. static id
  87. for(id = 1; id <= g_iMaxPlayers; ++id)
  88. if( is_user_alive(id) )
  89. g_bPlayerNonSpawnEvent[id] = true
  90. }
  91.  
  92. public ClientCommand_fullupdate(id)
  93. {
  94. g_bPlayerNonSpawnEvent[id] = true
  95. static const szClientCommandPost[] = "Forward_ClientCommand_Post"
  96. g_iFwFmClientCommandPost = register_forward(FM_ClientCommand, szClientCommandPost, 1)
  97. return PLUGIN_CONTINUE
  98. }
  99.  
  100. public Forward_ClientCommand_Post(id)
  101. {
  102. unregister_forward(FM_ClientCommand, g_iFwFmClientCommandPost, 1)
  103. g_bPlayerNonSpawnEvent[id] = false
  104. return FMRES_HANDLED
  105. }
  106.  
  107. public Event_ResetHUD(id)
  108. {
  109. if (!is_user_alive(id))
  110. return
  111.  
  112. if (g_bPlayerNonSpawnEvent[id])
  113. {
  114. g_bPlayerNonSpawnEvent[id] = false
  115. return
  116. }
  117.  
  118. Forward_PlayerSpawn(id)
  119. }
  120.  
  121. Forward_PlayerSpawn(id)
  122. {
  123. if(g_CurInfos[id][StoreRound] == g_iRoundNum)
  124. {
  125. g_CurInfos[id][StoreRound] = 0
  126. set_task(0.1, "task_delay_kill", id+TASK_KILL)
  127. }
  128. }
  129.  
  130. public task_delay_kill(id)
  131. {
  132. id -= TASK_KILL
  133.  
  134. new Float:fFrags
  135. pev(id, pev_frags, fFrags)
  136. set_pev(id, pev_frags, ++fFrags)
  137.  
  138. set_pdata_int(id, OFFSET_CSDEATHS, get_pdata_int(id, OFFSET_CSDEATHS) - 1)
  139.  
  140. new msgblock = get_msg_block(g_msgidDeathMsg)
  141. set_msg_block(g_msgidDeathMsg, BLOCK_ONCE)
  142. dllfunc(DLLFunc_ClientKill, id)
  143. set_msg_block(g_msgidDeathMsg, msgblock)
  144.  
  145. client_print(id, print_chat, "[Info] %L", id, "RF_SPAWN")
  146. }
  147.  
  148. public eMoney(id)
  149. {
  150. g_CurInfos[id][StoreMoney] = read_data(1)
  151. }
  152.  
  153. public eScoreInfo()
  154. {
  155. new id = read_data(1)
  156. if(!(1<= id <= g_iMaxPlayers))
  157. return
  158.  
  159. g_CurInfos[id][StoreFrags] = read_data(2)
  160. g_CurInfos[id][StoreDeaths] = read_data(3)
  161. }
  162.  
  163. public eRestart()
  164. {
  165. for(new i; i < MAX_STORED; i++)
  166. {
  167. remove_task(i+TASK_CLEAR)
  168. remove_task(i+TASK_PLAYER)
  169. g_StoredInfos[i][StoreSteamId][0] = 0
  170. }
  171. }
  172.  
  173. public eNewRound()
  174. {
  175. g_iRoundNum++
  176. }
  177.  
  178. public client_disconnect(id)
  179. {
  180. if(is_user_bot(id) || is_user_hltv(id))
  181. {
  182. return
  183. }
  184.  
  185. new Float:fTaskTime = get_pcvar_float(g_pcvarTime)
  186. if(!fTaskTime)
  187. return
  188.  
  189. static iFree
  190. for(iFree = 0; iFree <= MAX_STORED; iFree++)
  191. {
  192. if(iFree == MAX_STORED)
  193. {
  194. return
  195. }
  196. if(!g_StoredInfos[iFree][StoreSteamId][0])
  197. break
  198. }
  199.  
  200. copy(g_StoredInfos[iFree][StoreSteamId], 19, g_CurInfos[id][StoreSteamId])
  201. g_StoredInfos[iFree][StoreFrags] = g_CurInfos[id][StoreFrags]
  202. g_StoredInfos[iFree][StoreDeaths] = g_CurInfos[id][StoreDeaths]
  203. g_StoredInfos[iFree][StoreMoney] = g_CurInfos[id][StoreMoney]
  204. g_StoredInfos[iFree][StoreRound] = g_iRoundNum
  205.  
  206. g_CurInfos[id][StoreSteamId][0] = 0
  207. g_CurInfos[id][StoreFrags] = 0
  208. g_CurInfos[id][StoreDeaths] = 0
  209. g_CurInfos[id][StoreMoney] = 0
  210. g_CurInfos[id][StoreRound] = 0
  211.  
  212. set_task(fTaskTime, "task_clear", iFree+TASK_CLEAR)
  213. }
  214.  
  215. public task_clear(iTaskId)
  216. {
  217. iTaskId -= TASK_CLEAR
  218. g_StoredInfos[iTaskId][StoreSteamId][0] = 0
  219. }
  220.  
  221. public client_putinserver(id)
  222. {
  223. if(is_user_bot(id) || is_user_hltv(id))
  224. return
  225.  
  226. g_bPlayerNonSpawnEvent[id] = false
  227.  
  228. static szSteamId[20]
  229. get_user_authid(id, szSteamId, 19)
  230. copy(g_CurInfos[id][StoreSteamId], 19, szSteamId)
  231.  
  232. for(new i; i < MAX_STORED; i++)
  233. {
  234. if(!g_StoredInfos[i][StoreSteamId][0])
  235. continue
  236.  
  237. if( equal(g_StoredInfos[i][StoreSteamId], szSteamId, strlen(szSteamId)) )
  238. {
  239. if(get_pcvar_num(g_pcvarScore))
  240. {
  241. set_pev(id, pev_frags, float(g_StoredInfos[i][StoreFrags]))
  242. set_pdata_int(id, OFFSET_CSDEATHS, g_StoredInfos[i][StoreDeaths])
  243. g_CurInfos[id][StoreFrags] = g_StoredInfos[i][StoreFrags]
  244. g_CurInfos[id][StoreDeaths] = g_StoredInfos[i][StoreDeaths]
  245. }
  246. if(get_pcvar_num(g_pcvarMoney))
  247. {
  248. new iMoney = g_StoredInfos[i][StoreMoney]
  249. new iStartMoney = get_pcvar_num(mp_startmoney)
  250. if(get_pcvar_num(g_pcvarStartMoney) && iMoney > iStartMoney)
  251. {
  252. set_pdata_int(id, OFFSET_CSMONEY, iStartMoney)
  253. g_CurInfos[id][StoreMoney] = iStartMoney
  254. }
  255. else
  256. {
  257. set_pdata_int(id, OFFSET_CSMONEY, iMoney)
  258. g_CurInfos[id][StoreMoney] = iMoney
  259. }
  260. }
  261. if(get_pcvar_num(g_pcvarSpawn))
  262. {
  263. g_CurInfos[id][StoreRound] = g_StoredInfos[i][StoreRound]
  264. }
  265.  
  266. g_StoredInfos[i][StoreSteamId][0] = 0
  267.  
  268. new iNotifyType = get_pcvar_num(g_pcvarNotify)
  269. if(iNotifyType && !(get_user_flags(id)&ADMIN_SILENT) )
  270. {
  271. static szName[32]
  272. get_user_name(id, szName, 31)
  273. if( iNotifyType == 1 )
  274. {
  275. set_hudmessage(RED, GREEN, BLUE, -1.0, 0.35, 2, 3.0, 10.0, 0.1, 0.2, -1)
  276. show_hudmessage(0, "%L", LANG_PLAYER, "RF_ALL", szName)
  277. }
  278. else
  279. {
  280. client_print(0, print_chat, "** [Info] %L", LANG_PLAYER, "RF_ALL", szName)
  281. }
  282. }
  283. return
  284. }
  285. }
  286. g_CurInfos[id][StoreRound] = -1
  287. }
  288. /*
  289. public task_print_player(id)
  290. {
  291. if(is_user_connected(id -= TASK_PLAYER))
  292. {
  293. static szText[128]
  294. new n = formatex(szText, 127, "** [Reconnect Features] %L", id, "RF_PLAYER_PRINT")
  295. if(get_pcvar_num(g_pcvarScore))
  296. n += formatex(szText[n], 127 - n, " %L", id, "RF_SCORE")
  297. if(get_pcvar_num(g_pcvarMoney))
  298. n += formatex(szText[n], 127 - n, " %L", id, "RF_MONEY")
  299. client_print(id, print_chat, szText)
  300. }
  301. }
  302. */
  303. /* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
  304. *{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang1045\\ f0\\ fs16 \n\\ par }
  305. */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement