Advertisement
Guest User

Untitled

a guest
Nov 16th, 2017
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 3.19 KB | None | 0 0
  1. /**
  2. *** Plugin that "fixes" the bug on es_ maps.
  3. *** Players that have escaped will get the following:
  4. ***     - Noclip
  5. ***     - Invisibility
  6. ***     - Inability to receive damage
  7. ***     - Inability to cause damage
  8. ***     - All weapons removed.
  9. ***     - Inability to use buttons.
  10. ***     - Pass through other players
  11. ***
  12. **/
  13.  
  14.  
  15. #include <amxmodx>
  16. #include <amxmisc>
  17. #include <hamsandwich>
  18. #include <cstrike>
  19. #include <fun>
  20. #include <engine>
  21.  
  22.  
  23. #define PLUGIN "Escape Bug Fix"
  24. #define VERSION "1.0"
  25. #define AUTHOR "ClaviFicial"
  26.  
  27. //Keeps track of escaping players.
  28. new g_esc[32]
  29.  
  30. //Keeps track of player positions. Used when checking for nearby players (semiclip)
  31. new Float:g_sc_origin[32][3]
  32.  
  33. public plugin_init() {
  34.     register_plugin(PLUGIN, VERSION, AUTHOR)
  35.     RegisterHam(Ham_Use, "func_button", "block_use", 0)
  36.     RegisterHam(Ham_TakeDamage, "player", "block_damage", 0)
  37.     register_touch("func_escapezone", "player", "onEscape")
  38.     RegisterHam(Ham_Spawn, "player", "resetEsc", 1)
  39. }
  40.  
  41. //Executed when a player reaches the escape zone (Terrorists only)
  42. public onEscape(ent, id) {
  43.     client_print(id, print_chat, "[ESCAPE] You escaped. You're now unable to affect the remainder of the round.")
  44.     strip_user_weapons(id)
  45.     new team = get_user_team(id)
  46.     if (team == 1) {
  47.         g_esc[id] = 1
  48.         set_user_godmode(id, 1)
  49.         set_user_noclip(id, 1)
  50.         set_user_rendering(id, kRenderFxNone, 0, 0, 0, kRenderTransAlpha, 0)
  51.     }
  52. }
  53.  
  54.  
  55. //Distance between two players.
  56. public Float:dist(p1, p2) {
  57.     if(p1 == p2) {
  58.         return 1000.0
  59.     }
  60.    
  61.     new Float:o1[3], Float:o2[3]
  62.     o1 = g_sc_origin[p1]
  63.     o2 = g_sc_origin[p2]
  64.    
  65.     new Float:d = distance(o1, o2)
  66.     if(g_esc[p1] != 1 && g_esc[p2] != 1) {
  67.         d = d * 1000
  68.     }
  69.     return d
  70. }
  71.  
  72. //Distance between two vectors.
  73. public Float:distance(Float:origin1[3], Float:origin2[3]) {
  74.     new Float:d = float(sqroot(power(floatround(origin2[0] - origin1[0]), 2) + power(floatround(origin2[1] - origin1[1]), 2) + power(floatround(origin2[2] - origin1[2]), 2)))
  75.     return d
  76. }
  77.  
  78. //Executed each frame. Checks for nearby players in order to activate semiclip (only if player has escaped)
  79. public client_PreThink(id)
  80. {  
  81.     new On = SOLID_BBOX
  82.     entity_get_vector(id, EV_VEC_origin, g_sc_origin[id])
  83.    
  84.     new plrs[32], plrnum
  85.     get_players(plrs, plrnum)
  86.     for (new i = 0; i < plrnum; i++) {
  87.     if (dist(id, plrs[i]) < 100.0) {
  88.         On = SOLID_NOT
  89.     }
  90.     }
  91.    
  92.     entity_set_int(id,EV_INT_solid,On)
  93. }
  94.  
  95.  
  96. //Blocks use on buttons if player has escaped.
  97. public block_use(btn, id) {
  98.     if (g_esc[id] == 1) {
  99.         return HAM_SUPERCEDE
  100.     }
  101.     return PLUGIN_CONTINUE
  102. }
  103.  
  104. //Blocks damage if either attacker or victim has escaped.
  105. public block_damage(victim, inflictor, attacker, Float:damage, damagebits) {
  106.     if (g_esc[victim] == 1 || g_esc[attacker] == 1) {
  107.         return HAM_SUPERCEDE
  108.     }
  109.     return HAM_IGNORED
  110. }
  111.  
  112. public roundStart(id) {
  113.     new plrs[32], plrnum
  114.     get_players(plrs, plrnum)
  115.     for (new i = 0; i < plrnum; i++) {
  116.         resetEsc(plrs[i])
  117.     }
  118. }
  119.  
  120. //Resets all Escape variables on respawn.
  121. public resetEsc(id) {
  122.     if(!is_user_alive(id)) {
  123.         return
  124.     }
  125.     g_esc[id] = 0
  126.     set_user_godmode(id, 0)
  127.     set_user_noclip(id, 0)
  128.     set_user_rendering(id, kRenderFxNone, 0, 0, 0, kRenderTransAlpha, 255)
  129.     return
  130. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement