HLMOD.HU Forrás Megtekintés - www.hlmod.hu
  1. /* Fordította SmaCk
  2. Copyright 2011 m0skVi4a ;]
  3.  
  4. Plugin created in Bulgaria
  5.  
  6.  
  7. Plugin thread 1
  8. http://www.amxmodxbg.org/forum/viewtopic.php?t=35879
  9.  
  10. Plugin thread 2
  11. http://forums.alliedmods.net/showthread.php?t=168274
  12.  
  13. Original posted by m0skVi4a ;]
  14.  
  15.  
  16.  
  17. Description:
  18.  
  19. This plugin change the Counter - Strike 1.6 classic style to Surf. The plugin have help, respawn, spawn protection, semiclip system and timer.
  20.  
  21.  
  22. Commands:
  23.  
  24. say /surfhelp
  25. say_team /surfhelp
  26. to show the Surf Mod help MOTD
  27.  
  28. say /respawn
  29. say_team /respawn
  30. to respawn you
  31.  
  32. say /surftimer
  33. say_team /surftimer
  34. to open surf timer menu
  35.  
  36.  
  37. CVARS:
  38.  
  39. "surf_on" - Is the plugin on(1) or off(0). Default: 1
  40. "surf_help" - Is the surf help on(1) or off(0). Default: 1
  41. "surf_help_mes" - In how many seconds to display the surf help message. Default: 120.0
  42. "surf_respawn" - Is the respawning on(1) or off(0). Default: 1
  43. "surf_respawn_command" - Is the say /respawn command on(1) or off(0). Default: 1
  44. "surf_respawn_time" - Time in seconds after dead to respawn. Default: 1.0
  45. "surf_sp" - Is the spawn protection on(1) or off(0) Default: 1
  46. "surf_sp_time" - How many seconds is the protection. Default: 5.0
  47. "surf_semi" - Is the semiclip on(1) or off(0). Default: 1
  48. "surf_timer" - Is the surf timer on(1) or off(0). Default: 1
  49. "surf_timer_hud" - Time in seconds after Stop timer to stop timers hud. Default: 10.0
  50.  
  51. All CVARS are without quotes
  52.  
  53.  
  54. Credits:
  55.  
  56. m0skVi4a ;] - for the idea and making the plugin
  57. ConnorMcLeod - for his Semiclip plugin
  58. SpeeD - for his Spawn Protection plugin and testing the plugin
  59. L@m3r40 =] - for ideas and testing the plugin
  60. SGT - for ideas for the plugin
  61. SmaCk - Magyarra forditas
  62.  
  63.  
  64. Changelog:
  65.  
  66. August 11, 2011 - v1.0 - First Release
  67. August 21, 2011 - v1.1 - Changed semiclip method, added Universal Timer, added code styling, small optimization.
  68. September 26, 2011 - v1.2 - Fixed some bugs
  69. October 1, 2011 - v1.3 - Litle optimization, added multilingual file, SurfMod Help MOTD is in CSTRIKE dir, Fixed bug that don't spawns you when connect, added "surf_respawn_command" cvar.
  70. October 2, 2011 - v1.3 FIX 1 - Fixed bug respawn on connect when plugin is off, there are merge some features in the semiclip
  71. October 2, 2011 - v1.3 FIX 2 - Fixed bug that don't spawns you when connect
  72. November 8, 2011 - v1.3 FIX 3 - Fixed bug that don't spawns you when connect
  73. November 27, 2011 - v1.4 - Changed somethings in the plugin for more functional work, Surf Timer is mainly changed, Changed respawn on connect method
  74. Junius 20, 2015 - v1.4 - Magyarra forditas
  75.  
  76.  
  77. Visit www.amxmodxbg.org
  78. Visit www.forums.alliedmods.net
  79. */
  80.  
  81.  
  82. #include <amxmodx>
  83. #include <amxmisc>
  84. #include <cstrike>
  85. #include <engine>
  86. #include <fakemeta>
  87. #include <fun>
  88. #include <hamsandwich>
  89.  
  90. #define MarkUserAlive(%1) g_bAlive |= 1<<(%1 & 31)
  91. #define ClearUserAlive(%1) g_bAlive &= ~(1<<(%1 & 31))
  92. #define IsAlive(%1) g_bAlive & 1<<(%1 & 31)
  93.  
  94. #define TASK_RES 2213
  95. #define TASK_PROT 1123
  96. #define TASK_TIMER 2133
  97. #define TASK_HUD 3312
  98. #define TASK_STOP 1132
  99.  
  100. new g_on, g_help, g_helpint, g_res, g_res_com, g_restime, g_spenabled, g_sptime, g_semi, g_timer, g_hud;
  101. new bool:is_started[33], bool:is_pauseed[33];
  102.  
  103. new g_hour[33], g_min[33], g_sec[33];
  104.  
  105. new SPTimer[33];
  106. new g_sync_hud1, g_sync_hud2, SayTxT;
  107. new const prefix[]="[SURF MOD]";
  108. new g_bAlive;
  109. const MAX_PLAYERS = 32;
  110. new g_iTeam[MAX_PLAYERS+1];
  111.  
  112. new const g_szTeams[][] =
  113. {
  114. "",
  115. "TERRORIST",
  116. "CT"
  117. }
  118.  
  119. enum {
  120. _T = 1,
  121. _CT
  122. }
  123. new g_iTeamSemiclip = _T | _CT
  124.  
  125. public plugin_init()
  126. {
  127. register_plugin("Surf Mod", "1.4", "m0skVi4a ;]")
  128.  
  129. g_on = register_cvar("surf_on", "1")
  130. g_help = register_cvar("surf_help", "1")
  131. g_helpint = register_cvar("surf_help_mes", "120.0")
  132. g_res = register_cvar("surf_respawn", "1")
  133. g_res_com = register_cvar("surf_respawn_command", "1")
  134. g_restime = register_cvar("surf_respawn_time", "1.0")
  135. g_spenabled = register_cvar("surf_sp","1")
  136. g_sptime = register_cvar("surf_sp_time", "5")
  137. g_semi = register_cvar("surf_semi", "1")
  138. g_timer = register_cvar("surf_timer", "1")
  139. g_hud = register_cvar("Surf_timer_hud", "10.0")
  140.  
  141. register_dictionary("surfmod.txt");
  142.  
  143. register_menucmd(register_menuid("Timer Menu"), 1023, "TimerMenuHandler")
  144. register_clcmd("say /surfhelp","SurfHelpMOTD")
  145. register_clcmd("say_team /surfhelp","SurfHelpMOTD")
  146. register_clcmd("say /respawn", "RespawnComand")
  147. register_clcmd("say_team /respawn", "RespawnComand")
  148. register_clcmd("say /surftimer", "TimerMenu")
  149. register_clcmd("say_team /surftimer", "TimerMenu")
  150.  
  151. register_event("DeathMsg", "DeathMsg","a")
  152. register_forward(FM_AddToFullPack, "AddToFullPack", 1)
  153. RegisterHam(Ham_Spawn, "player", "PlayerSpawn", 1)
  154. RegisterHam(Ham_Player_PreThink, "player", "PreThink", 1)
  155.  
  156. g_sync_hud1 = CreateHudSyncObj()
  157. g_sync_hud2 = CreateHudSyncObj()
  158. SayTxT = get_user_msgid("SayText")
  159.  
  160. new MapName[64]
  161. get_mapname(MapName, charsmax(MapName))
  162.  
  163. if(contain(MapName, "surf_") != -1)
  164. {
  165. set_pcvar_num(g_on, 1)
  166. }
  167. else
  168. {
  169. set_pcvar_num(g_on, 0)
  170. }
  171. }
  172.  
  173. public plugin_cfg()
  174. {
  175. if(get_pcvar_num(g_on))
  176. {
  177. set_cvar_num("sv_airaccelerate", 100)
  178.  
  179. new ConfDir[32], File[192];
  180.  
  181. get_configsdir(ConfDir, charsmax(ConfDir));
  182. formatex(File, charsmax( File ), "%s/surfmod.cfg", ConfDir);
  183.  
  184. if(!file_exists(File))
  185. {
  186. server_print("%L", LANG_SERVER, "CSF_ERROR", File);
  187. }
  188. else
  189. {
  190. server_cmd("exec %s", File);
  191. server_print("%L", LANG_SERVER, "CFG_EXEC", File);
  192. }
  193. }
  194. }
  195.  
  196. public client_connect(id)
  197. {
  198. is_started[id] = false
  199. is_pauseed[id] = false
  200. remove_task(id+TASK_RES)
  201. remove_task(id+TASK_PROT)
  202. remove_task(id+TASK_TIMER)
  203. remove_task(id+TASK_HUD)
  204. remove_task(id+TASK_STOP)
  205. }
  206.  
  207. public client_disconnect(id)
  208. {
  209. is_started[id] = false
  210. is_pauseed[id] = false
  211. remove_task(id+TASK_RES)
  212. remove_task(id+TASK_PROT)
  213. remove_task(id+TASK_TIMER)
  214. remove_task(id+TASK_HUD)
  215. remove_task(id+TASK_STOP)
  216. ClearUserAlive(id)
  217. }
  218.  
  219. public client_putinserver(id)
  220. {
  221. if(!get_pcvar_num(g_on))
  222. return
  223.  
  224. set_task(5.0, "CheckUser", id)
  225. set_task(get_pcvar_float(g_helpint), "SurfCommands", id)
  226. }
  227.  
  228. public CheckUser(id)
  229. {
  230. if(is_user_connected(id))
  231. {
  232. if(!is_user_alive(id) && cs_get_user_team(id) == CS_TEAM_T || cs_get_user_team(id) == CS_TEAM_CT)
  233. {
  234. Respawning(id+TASK_RES)
  235. }
  236. else
  237. {
  238. set_task(5.0, "CheckUser", id)
  239. }
  240. }
  241. }
  242.  
  243. public DeathMsg(id)
  244. {
  245. if(!get_pcvar_num(g_on))
  246. return
  247.  
  248. id = read_data(2)
  249.  
  250. if(get_pcvar_num(g_res))
  251. {
  252. set_task(get_pcvar_float(g_restime), "Respawning", id+TASK_RES)
  253. }
  254.  
  255. if(get_pcvar_num(g_semi))
  256. {
  257. if(is_user_alive(id))
  258. {
  259. MarkUserAlive(id)
  260. }
  261. else
  262. {
  263. ClearUserAlive(id)
  264. }
  265. }
  266.  
  267. if(get_pcvar_num(g_timer))
  268. {
  269. remove_task(id+TASK_TIMER)
  270. set_task(get_pcvar_float(g_hud), "StopHud", id)
  271. }
  272. }
  273.  
  274. public PlayerSpawn(id)
  275. {
  276. if(!get_pcvar_num(g_on))
  277. return
  278.  
  279. if(get_pcvar_num(g_spenabled) && is_user_alive(id))
  280. {
  281. remove_task(id+TASK_PROT)
  282. set_user_godmode(id)
  283. set_user_rendering(id)
  284. Glowing(id)
  285. Protection(id+TASK_PROT)
  286. }
  287.  
  288. if(get_pcvar_num(g_semi))
  289. {
  290. if(is_user_alive(id))
  291. {
  292. MarkUserAlive(id)
  293. const XTRA_OFS_PLAYER = 5
  294. const m_iTeam = 114
  295. g_iTeam[id] = get_pdata_int(id, m_iTeam, XTRA_OFS_PLAYER)
  296. }
  297. else
  298. {
  299. ClearUserAlive(id)
  300. }
  301. }
  302. }
  303.  
  304. public SurfHelpMOTD(id)
  305. {
  306. if(get_pcvar_num(g_on) && get_pcvar_num(g_help) && is_user_connected(id))
  307. {
  308. show_motd(id, "surfmodhelp.txt", "Surf Mod Magyar Segitseg");
  309. }
  310. }
  311.  
  312. public SurfCommands(id)
  313. {
  314. if(get_pcvar_num(g_on) && get_pcvar_num(g_help) && is_user_connected(id))
  315. {
  316. client_printcolor(id, "%L", LANG_SERVER, "HELP_MESS", prefix)
  317. set_task(get_pcvar_float(g_helpint),"SurfCommands")
  318. }
  319. }
  320.  
  321. public RespawnComand(id)
  322. {
  323. if(!get_pcvar_num(g_on) || !is_user_connected(id))
  324. return
  325.  
  326. if(!get_pcvar_num(g_res))
  327. {
  328. client_printcolor(id, "%L", LANG_SERVER, "RES_DIS", prefix)
  329. return
  330. }
  331.  
  332. if(!get_pcvar_num(g_res_com))
  333. {
  334. client_printcolor(id, "%L", LANG_SERVER, "RES_COM", prefix)
  335. return
  336. }
  337.  
  338. new CsTeams:team = cs_get_user_team(id)
  339.  
  340. if(team == CS_TEAM_T || team == CS_TEAM_CT)
  341. {
  342. if(!task_exists(id+TASK_RES))
  343. {
  344. set_task(get_pcvar_float(g_restime),"Respawning",id+TASK_RES)
  345. }
  346. }
  347. else
  348. {
  349. client_printcolor(id, "%L", LANG_SERVER, "RES_TEAM", prefix)
  350. return
  351. }
  352. }
  353.  
  354. public Respawning(id)
  355. {
  356. id -= TASK_RES
  357.  
  358. if(cs_get_user_team(id) == CS_TEAM_SPECTATOR || cs_get_user_team(id) == CS_TEAM_UNASSIGNED)
  359. return
  360.  
  361. ExecuteHamB(Ham_CS_RoundRespawn,id)
  362. remove_task(id+TASK_TIMER)
  363. remove_task(id+TASK_HUD)
  364. client_printcolor(id, "%L", LANG_SERVER, "RESPAWN", prefix)
  365. give_item(id, "weapon_knife")
  366. }
  367.  
  368. public Glowing(id)
  369. {
  370. new CsTeams:team = cs_get_user_team(id)
  371.  
  372. if(team == CS_TEAM_T)
  373. {
  374. set_user_rendering(id, kRenderFxGlowShell, 255, 0, 0, kRenderNormal, 10)
  375. }
  376. else if(team == CS_TEAM_CT)
  377. {
  378. set_user_rendering(id, kRenderFxGlowShell, 0, 0, 255, kRenderNormal, 10)
  379. }
  380. SPTimer[id] = get_pcvar_num(g_sptime)
  381. }
  382.  
  383. public Protection(id)
  384. {
  385. id -= TASK_PROT
  386. set_user_godmode(id, 1)
  387.  
  388. if(SPTimer[id] == 0)
  389. {
  390. set_hudmessage(255, 0, 0, -1.0, 0.65, 1, 0.02, 3.0,_,_,-1)
  391. ShowSyncHudMsg(id, g_sync_hud1, "%L", LANG_SERVER, "PROT_OFF")
  392. }
  393. else
  394. {
  395. set_hudmessage(0, 255, 0, -1.0, 0.65, 0, 0.02, 1.0,_,_,-1)
  396. ShowSyncHudMsg(id, g_sync_hud1, "%L", LANG_SERVER, "PROT_ON", SPTimer[id], SPTimer[id] > 1 ? "s" : "")
  397. }
  398.  
  399. --SPTimer[id]
  400.  
  401. if(SPTimer[id] >= 0)
  402. {
  403. set_task(1.0, "Protection", id+TASK_PROT)
  404. }
  405. else
  406. {
  407. set_user_godmode(id)
  408. set_user_rendering(id)
  409. }
  410. }
  411.  
  412. public AddToFullPack(es, e, iEnt, id, hostflags, player, pSet)
  413. {
  414. if(get_pcvar_num(g_on) && get_pcvar_num(g_semi) && player && id != iEnt && IsAlive(id) && g_iTeamSemiclip & g_iTeam[id] && IsAlive(iEnt) && g_iTeam[id] == g_iTeam[iEnt] && get_orig_retval())
  415. {
  416. set_es(es, ES_Solid, SOLID_NOT)
  417. }
  418. }
  419.  
  420. public PreThink(id)
  421. {
  422. if(!get_pcvar_num(g_on) || !get_pcvar_num(g_semi) || IsAlive(id) == 0 || !(g_iTeamSemiclip & g_iTeam[id]))
  423. {
  424. return
  425. }
  426.  
  427. new iPlayers[MAX_PLAYERS], iNum, iPlayer;
  428. get_players(iPlayers, iNum, "ae", g_szTeams[g_iTeam[id]])
  429.  
  430. for(new i; i<iNum; i++)
  431. {
  432. iPlayer = iPlayers[i]
  433. if(id != iPlayer)
  434. {
  435. entity_set_int(iPlayer, EV_INT_solid, SOLID_NOT)
  436. }
  437. }
  438. }
  439.  
  440. public client_PostThink(id)
  441. {
  442. if(!get_pcvar_num(g_on) || !get_pcvar_num(g_semi) || IsAlive(id) == 0 || !(g_iTeamSemiclip & g_iTeam[id]))
  443. {
  444. return
  445. }
  446.  
  447. new iPlayers[MAX_PLAYERS], iNum, iPlayer;
  448. get_players(iPlayers, iNum, "ae", g_szTeams[g_iTeam[id]])
  449.  
  450. for(new i; i<iNum; i++)
  451. {
  452. iPlayer = iPlayers[i]
  453. if(id != iPlayer)
  454. {
  455. entity_set_int(iPlayer, EV_INT_solid, SOLID_SLIDEBOX)
  456. }
  457. }
  458. }
  459.  
  460. public TimerMenu(id)
  461. {
  462. if(!get_pcvar_num(g_on) || !get_pcvar_num(g_timer))
  463. return
  464.  
  465. static menu[512];
  466. new lenght, keys;
  467. lenght = 0
  468.  
  469. lenght += formatex(menu[lenght], charsmax(menu), "%L", LANG_SERVER, "TIMER_MENU_TITLE")
  470.  
  471. if(!is_started[id])
  472. {
  473. lenght += formatex(menu[lenght], charsmax(menu), "%L", LANG_SERVER, "TIMER_MENU_START")
  474. keys = MENU_KEY_1|MENU_KEY_0;
  475. }
  476. else
  477. {
  478. lenght += formatex(menu[lenght], charsmax(menu), "%L", LANG_SERVER, "TIMER_MENU_RESTART")
  479.  
  480. if(!is_pauseed[id])
  481. {
  482. lenght += formatex(menu[lenght], charsmax(menu), "%L", LANG_SERVER, "TIMER_MENU_PAUSE")
  483. }
  484. else
  485. {
  486. lenght += formatex(menu[lenght], charsmax(menu), "%L", LANG_SERVER, "TIMER_MENU_UNPAUSE")
  487. }
  488. lenght += formatex(menu[lenght], charsmax(menu), "%L", LANG_SERVER, "TIMER_MENU_STOP")
  489. keys = MENU_KEY_1|MENU_KEY_2|MENU_KEY_3|MENU_KEY_0;
  490. }
  491.  
  492. lenght += formatex(menu[lenght], charsmax(menu), "%L", LANG_SERVER, "TIMER_MENU_EXIT")
  493.  
  494. show_menu(id, keys, menu, -1, "Timer Menu")
  495. }
  496.  
  497. public TimerMenuHandler(id, key)
  498. {
  499. switch(key)
  500. {
  501. case 0:
  502. {
  503. is_started[id] = true
  504. reStartTimer(id)
  505. }
  506. case 1:
  507. {
  508. if(!is_pauseed[id])
  509. {
  510. is_pauseed[id] = true
  511. }
  512. else
  513. {
  514. is_pauseed[id] = false
  515. }
  516. unPauseTimer(id)
  517. }
  518. case 2:
  519. {
  520. StopTimer(id)
  521. }
  522. case 9:
  523. {
  524. return PLUGIN_HANDLED
  525. }
  526. }
  527. TimerMenu(id)
  528. return PLUGIN_HANDLED
  529. }
  530.  
  531. public reStartTimer(id)
  532. {
  533. if(is_user_alive(id))
  534. {
  535. remove_task(id+TASK_TIMER)
  536. g_hour[id] = 0
  537. g_min[id] = 0
  538. g_sec[id] = 0
  539. set_task(1.0,"TimerMain",id+TASK_TIMER)
  540. if(task_exists(id+TASK_STOP))
  541. {
  542. remove_task(id+TASK_STOP)
  543. }
  544. if(!task_exists(id+TASK_HUD))
  545. {
  546. TimerHud(id+TASK_HUD)
  547. }
  548. }
  549. }
  550.  
  551. public TimerMain(id)
  552. {
  553. id -= TASK_TIMER
  554.  
  555. if(is_user_connected(id))
  556. {
  557. g_sec[id]++
  558.  
  559. if(g_sec[id] >= 60)
  560. {
  561. g_min[id]++
  562. g_sec[id] = 0
  563. }
  564.  
  565. if(g_min[id] >= 60)
  566. {
  567. g_hour[id]++
  568. if(g_hour[id] >= 24)
  569. {
  570. g_hour[id] = 0
  571. }
  572. g_min[id] = 0
  573. }
  574.  
  575. set_task(1.0, "TimerMain", id+TASK_TIMER)
  576. }
  577. else
  578. {
  579. remove_task(id+TASK_TIMER)
  580. }
  581. }
  582.  
  583. public TimerHud(id)
  584. {
  585. id -= TASK_HUD
  586.  
  587. if(is_user_connected(id))
  588. {
  589. set_hudmessage(0, 255, 0, -1.0, 0.90, 0, 0.0, 0.3, 0.0, 0.0, -1)
  590. ShowSyncHudMsg(id, g_sync_hud2, "%L", LANG_SERVER, "TIMER_HUD", g_hour[id] < 10 ? "0" : "", g_hour[id], g_min[id] < 10 ? "0" : "", g_min[id], g_sec[id] < 10 ? "0" : "", g_sec[id])
  591.  
  592. set_task(0.1,"TimerHud",id+TASK_HUD)
  593. }
  594. }
  595.  
  596. public unPauseTimer(id)
  597. {
  598. if(is_user_alive(id))
  599. {
  600. if(!is_pauseed[id])
  601. {
  602. TimerMain(id+TASK_TIMER)
  603. }
  604. else
  605. {
  606. remove_task(id+TASK_TIMER)
  607. }
  608. }
  609. }
  610.  
  611. public StopTimer(id)
  612. {
  613. if(is_user_alive(id) && is_started[id])
  614. {
  615. remove_task(id+TASK_TIMER)
  616. set_task(get_pcvar_float(g_hud), "StopHud", id+TASK_STOP)
  617. is_started[id] = false
  618. }
  619. }
  620.  
  621. public StopHud(id)
  622. {
  623. id -= TASK_STOP
  624.  
  625. if(is_user_alive(id))
  626. {
  627. remove_task(id+TASK_HUD)
  628. }
  629. }
  630.  
  631. stock client_printcolor(const id, const input[], any:...)
  632. {
  633. new count = 1, players[32];
  634. static msg[191];
  635. vformat(msg,190,input,3);
  636. replace_all(msg,190,"!g","^4");
  637. replace_all(msg,190,"!n","^1");
  638. replace_all(msg,190,"!t","^3");
  639. replace_all(msg,190,"!w","^0");
  640. if(id) players[0] = id; else get_players(players,count,"ch");
  641. for (new i = 0; i < count; i++)
  642. if(is_user_connected(players[i]))
  643. {
  644. message_begin(MSG_ONE_UNRELIABLE, SayTxT,_, players[i]);
  645. write_byte(players[i]);
  646. write_string(msg);
  647. message_end();
  648. }
  649. }
  650.