Advertisement
Guest User

Untitled

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