Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- *** Plugin that "fixes" the bug on es_ maps.
- *** Players that have escaped will get the following:
- *** - Noclip
- *** - Invisibility
- *** - Inability to receive damage
- *** - Inability to cause damage
- *** - All weapons removed.
- *** - Inability to use buttons.
- *** - Pass through other players
- ***
- **/
- #include <amxmodx>
- #include <amxmisc>
- #include <hamsandwich>
- #include <cstrike>
- #include <fun>
- #include <engine>
- #define PLUGIN "Escape Bug Fix"
- #define VERSION "1.0"
- #define AUTHOR "ClaviFicial"
- //Keeps track of escaping players.
- new g_esc[32]
- //Keeps track of player positions. Used when checking for nearby players (semiclip)
- new Float:g_sc_origin[32][3]
- public plugin_init() {
- register_plugin(PLUGIN, VERSION, AUTHOR)
- RegisterHam(Ham_Use, "func_button", "block_use", 0)
- RegisterHam(Ham_TakeDamage, "player", "block_damage", 0)
- register_touch("func_escapezone", "player", "onEscape")
- RegisterHam(Ham_Spawn, "player", "resetEsc", 1)
- }
- //Executed when a player reaches the escape zone (Terrorists only)
- public onEscape(ent, id) {
- client_print(id, print_chat, "[ESCAPE] You escaped. You're now unable to affect the remainder of the round.")
- strip_user_weapons(id)
- new team = get_user_team(id)
- if (team == 1) {
- g_esc[id] = 1
- set_user_godmode(id, 1)
- set_user_noclip(id, 1)
- set_user_rendering(id, kRenderFxNone, 0, 0, 0, kRenderTransAlpha, 0)
- }
- }
- //Distance between two players.
- public Float:dist(p1, p2) {
- if(p1 == p2) {
- return 1000.0
- }
- new Float:o1[3], Float:o2[3]
- o1 = g_sc_origin[p1]
- o2 = g_sc_origin[p2]
- new Float:d = distance(o1, o2)
- if(g_esc[p1] != 1 && g_esc[p2] != 1) {
- d = d * 1000
- }
- return d
- }
- //Distance between two vectors.
- public Float:distance(Float:origin1[3], Float:origin2[3]) {
- 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)))
- return d
- }
- //Executed each frame. Checks for nearby players in order to activate semiclip (only if player has escaped)
- public client_PreThink(id)
- {
- new On = SOLID_BBOX
- entity_get_vector(id, EV_VEC_origin, g_sc_origin[id])
- new plrs[32], plrnum
- get_players(plrs, plrnum)
- for (new i = 0; i < plrnum; i++) {
- if (dist(id, plrs[i]) < 100.0) {
- On = SOLID_NOT
- }
- }
- entity_set_int(id,EV_INT_solid,On)
- }
- //Blocks use on buttons if player has escaped.
- public block_use(btn, id) {
- if (g_esc[id] == 1) {
- return HAM_SUPERCEDE
- }
- return PLUGIN_CONTINUE
- }
- //Blocks damage if either attacker or victim has escaped.
- public block_damage(victim, inflictor, attacker, Float:damage, damagebits) {
- if (g_esc[victim] == 1 || g_esc[attacker] == 1) {
- return HAM_SUPERCEDE
- }
- return HAM_IGNORED
- }
- public roundStart(id) {
- new plrs[32], plrnum
- get_players(plrs, plrnum)
- for (new i = 0; i < plrnum; i++) {
- resetEsc(plrs[i])
- }
- }
- //Resets all Escape variables on respawn.
- public resetEsc(id) {
- if(!is_user_alive(id)) {
- return
- }
- g_esc[id] = 0
- set_user_godmode(id, 0)
- set_user_noclip(id, 0)
- set_user_rendering(id, kRenderFxNone, 0, 0, 0, kRenderTransAlpha, 255)
- return
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement