AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Suggestions / Requests (https://forums.alliedmods.net/forumdisplay.php?f=12)
-   -   zombie mod ? (https://forums.alliedmods.net/showthread.php?t=53697)

neogeo 04-09-2007 10:41

zombie mod ?
 
hi
if someone can add an option that humans can buy nigthvision and that humans cannot hurt humans and zombies cannot hurt zombies.
also if we can remove the dark.

thanks

ps : sry for my bad english

plugins :
Code:

/*
zombie mod 2.0.1
 by apophis ([email protected])

commands:
        amx_zombies - toggles zombie mod. optional 1 or 0 to enable/disable.
        say /flashlight - serverside flashlight that others can see and is somewhat brighter
        say /zombies - tells how many zombies there are
        say /fixcontrols - fixes broken controls for zombies
cvars:
        amx_zombie_health - health of zombies. first zombie gets 2x health (default: 640)
        amx_zombie_speed - maxspeed of zombies. normal human maxspeed is 320.0 (default: 140.0)
        amx_zombie_mode - Status of zombie mod
        amx_zombie_hitzones - hitzones for zombies. (default: 7)
        amx_zombie_model - whether or not to change player to a zombie model when they turn undead. hitboxes can't be changed in cs so they aren't in the right places on the zombie model. (default: 1)
        amx_zombie_defaultnvg - sets whether to use green nvg for zombies or not and instead serverside nightvision that can flicker during lag (default: 1)
        amx_zombie_nvcolor - color of serverside nightvision for zombies in r g b format. only has effect when defaultnvg is 0 (default: 255 0 0)
        amx_zombie_specnvcolor - nightvision color for spectators. only has effect when specnv is 1 (default: 10 100 0)
        amx_zombie_randomspawn - random spawn locations (random locations are gathered in the first few rounds) (default: 1)
        amx_zombie_specnv - nightvision for spectators (default: 1)
        amx_zombie_custspecnv - custom colored server side spectator nightvision (default: 0)
        amx_zombie_lightning - sets lights to kind of be like lightning (default: 1)
        amx_zombie_brainvision - human players give off this ring thing to zombies (default: 0)
        amx_zombie_infecttime - time it takes for a person that's infected to turn into a zombie (default 0.1)
        amx_zombie_flashlight - toggles serverside flashlight (default: 1)
        amx_zombie_flashlightcolor - color of serverside flashlight in r g b format. only has effect when zombie_flashlight is 1 (default: 200 1 0)
        amx_zombie_vote - enables or disables vote_zombie say command (default: 1)
motd-type stuff:
        One person aandomly turns into a zombie near the start of the round
        Zombies get nightvision and humans don't
        The game is HUMANS vs ZOMBIES.
        The round ends when all the zombies are dead or everyone is a zombie
        Zombies cannot use weapons and humans can only use pistols/shotguns/SMGs

*** THE RESTMENU PLUGIN MUST BE ENABLED TO RESTRICT NVGS FOR HUMANS ***
You should probably put this plugin before most other plugins
changes:
        2.0.1
        - remove fakemeta requirement (from some test stuff)
        2.0
        - make zombies show up as terrorists by request
        - added more messages by request
        - added amx_zombie_customspecnv to use custom server sided nightvision instead of regular nightvision for spectators
        - removed flashlights for zombies again
        - removes c4 when dropped
        - removes bomb site
        - added vote_zombie say command to start a vote, cvar amx_zombie_vote enables/disables vote
        1.6.11
        - increased buyzone
        - zombies have no knockback
        - changed flashlights
        1.6.10
        - fix for files in restriction menu
        - changed flashlight to PAS message
        - changed score stuff to broadcast message
        - added another check to see if zombies are living
        - fixed first zombie killing self
        - added message on team select
        - went back to old way of ending round
        1.6.9
        - changed some hitzone stuff
        - amx_zombie_flashlight cvar
        - changed some other round ending stuff and random zombie at start stuff
        - fixed blank say_team
        - changed ZombieMod cvar to show status of mod
        1.6.8
        - zombie brain vision (amx_zombie_brainvision) (kinda lame)
        - amx_zombie_infecttime cvar
        - fixed flashlight turning off
        - fixed c4 dropping
        1.6.7
        - fixed random zombie not being picked after no players on server
        - made people not turn into zombie after round over
        - fixed client command exploit
        - changed weapon handling
        - changed radar blocking
        1.6.6
        - made changing amx_zombie_mode cvar not break things
        - made it so zombie mod can still be on with less than 2 players
        1.6.5
        - only kills one person instead of an entire team
        1.6.4
        - made flashlight stay on after new round after turning into a zombie
        - sets zombies maxspeed more often
        - fixed some invalid entity stuff
        - defaulted amx_zombie_lightning to 1
        - made sure random spawns are on ground and not in sky/water
        - decreased zombie nv range
        - fixed deathmessages
        - added team damage again
        1.6.3
        - added amx_zombie_nvcolor and amx_zombie_specnvcolor cvars
        - renamed amx_zombie_nvg to amx_zombie_defaultnvg
        - increased random spawn distance
        - set decay on flashlight
        - added /fixcontrols
        - random spawn better detects crouching and swimming
        1.6.2
        - amx_zombie_lightning cvar
        - fixed nightvision
        1.6.1
        - amx_zombie_specnv cvar
        - only knives turn people into zombies
        1.6
        - random spawns
        1.5
        - amx_zombie_nvg cvar
        1.4
        - serverside red nightvision
        - message for disabling zombies when too few players
        - might have fixed health going to 0
        - spectators have yellow nightvision
        - amx_zombie_lights cvar
        1.3
        - amx_zombie_model cvar
        1.1
        - kills hostages on start
        - resets cvars to old values
        - amx_zombie_hitzones cvar
        1.0
        - first release
*/
#include <amxmodx>
#include <cstrike>
#include <amxmisc>
#include <engine>
#include <fun>
#define MAX_SPAWNS 32
#define MAX_BUYZONES 10
#define MAX_BOMBSITES 10
new spriteBrainVision, gmsgTeamInfo, gmsgNVGToggle, gmsgRadar, zombie_enabled, lastlights, Float:old_buyzones[MAX_BUYZONES][3], old_buyzone_ent[MAX_BUYZONES]
new round_over,buy_zones[MAX_SPAWNS + MAX_SPAWNS], old_player_deathmatch_ent[MAX_SPAWNS], old_player_start_ent[MAX_SPAWNS], rand_set, randpos_max,Float:old_player_start[MAX_SPAWNS][3], Float:old_player_deathmatch[MAX_SPAWNS][3], Float:rand_pos[MAX_SPAWNS + MAX_SPAWNS][3], maxplayers, old_ff, old_roundtime, randzombie, gmsgSayText, gmsgDeathMsg, zombies[33], gmsgScoreInfo, flashlight[33]
new bombsites, Float:bsite_min[MAX_BOMBSITES][3], Float:bsite_max[MAX_BOMBSITES][3], Float:bsite_origin[MAX_BOMBSITES][3], vote_count[2]
#define sound_count 3
new zombie_sounds[sound_count][] = {"nihilanth/nil_alone.wav", "nihilanth/nil_comes.wav", "nihilanth/nil_slaves.wav"}
#define TE_DLIGHT 27
new CsTeams:old_team[33]
public plugin_init() {
        register_plugin("Zombie Mod", "2.0.1", "apophis")
        register_cvar("ZombieMod", "2.0", FCVAR_SERVER)
        set_cvar_string("ZombieMod", "2.0.1 (off)")
        register_concmd("amx_zombies", "toggle_zombies", ADMIN_LEVEL_B, "- toggles zombie mode")
        register_event("DeathMsg", "player_death", "a")
        register_event("Damage","event_damage","b","2!0","3=0","4!0")
        register_event("CurWeapon", "switch_weapon", "be", "1=1")
        register_event("Health", "do_health", "b")
        register_event("SendAudio", "end_round", "a", "2&%!MRAD_terwin", "2&%!MRAD_ctwin", "2&%!MRAD_rounddraw")
        register_event("ResetHUD","spawn_event","be","1=1")
        register_event("HideWeapon","shield_check","b")
        register_event("ShowMenu","team_select","b","4&Team_Select")
        register_event("StatusIcon", "c4_dropped", "be", "1=1", "1=2", "2=c4")
        register_clcmd("say_team", "do_teamsay", 0)
        register_clcmd("say", "do_say", 0)
        register_clcmd("say vote_zombie", "zombie_vote", 0, "- starts a zombie vote")
        register_menucmd(register_menuid("Zombie Mode"),MENU_KEY_1|MENU_KEY_2,"voteCount")
        /*register_clcmd("cl_setautobuy","block")
        register_clcmd("cl_autobuy","block")
        register_clcmd("cl_setrebuy","block")
        register_clcmd("cl_rebuy","block")*/
        register_menucmd(register_menuid("#Buy", 1 ),511,"block_zombie")
        register_menucmd(register_menuid("BuyPistol", 1 ),511,"block_zombie")
        register_menucmd(register_menuid("BuyShotgun", 1 ),511,"block_zombie")
        register_menucmd(register_menuid("BuySub", 1 ),511,"block_zombie")
          register_menucmd(register_menuid("BuyRifle", 1),511,"block")
          register_menucmd(register_menuid("BuyMachine", 1),511,"block")
          register_menucmd(register_menuid("BuyItem", 1),511,"block_zombie")
        register_menucmd(-28,511,"block_zombie")
        register_menucmd(-29,511,"block_zombie")
          register_menucmd(-30,511,"block_zombie")
          register_menucmd(-32,511,"block_zombie")
          register_menucmd(-31,511,"block")
          register_menucmd(-33,511,"block")
          register_menucmd(-34,511,"block_zombie")
        gmsgSayText = get_user_msgid("SayText")
        gmsgScoreInfo = get_user_msgid("ScoreInfo")
        gmsgDeathMsg = get_user_msgid("DeathMsg")
        gmsgRadar = get_user_msgid("Radar")
        gmsgTeamInfo = get_user_msgid("TeamInfo")
        gmsgNVGToggle = get_user_msgid("NVGToggle")
        register_cvar("amx_zombie_mode","0")
        register_cvar("amx_zombie_health","640")
        register_cvar("amx_zombie_speed","140.0")
        register_cvar("amx_zombie_hitzones","7")
        register_cvar("amx_zombie_model","1")
        register_cvar("amx_zombie_defaultnvg","1")
        register_cvar("amx_zombie_randomspawn","1")
        register_cvar("amx_zombie_specnv","1")
        register_cvar("amx_zombie_customspecnv","0")
        register_cvar("amx_zombie_lightning","1")
        register_cvar("amx_zombie_nvcolor", "255 0 0")
        register_cvar("amx_zombie_flashlightcolor", "200 1 0")
        register_cvar("amx_zombie_specnvcolor", "10 100 0")
        register_cvar("amx_zombie_brainvision","0")
        register_cvar("amx_zombie_infecttime","0.1")
        register_cvar("amx_zombie_flashlight","1")
        register_cvar("amx_zombie_vote", "1")
        set_cvar_num("amx_zombie_mode",0)
        set_msg_block(gmsgRadar,BLOCK_NOT)
        //set_user_hitzones(0, 0, 255)
        randpos_max = 0
        rand_set = 0
        randzombie = 0
        round_over = 0
        zombie_enabled = 0
        maxplayers = get_maxplayers()
        new i
        for (i = 0; i < 33; i++) {
                flashlight[i] = 0
                old_team[i] = CsTeams:0
        }
        for (i = 0; i < MAX_SPAWNS; i++) {
                old_player_deathmatch_ent[i] = 0
                old_player_deathmatch[i] = Float:{0.0,0.0,0.0}
                old_player_start_ent[i] = 0
                old_player_start[i] = Float:{0.0,0.0,0.0}
        }
        for (i = 0; i < (MAX_SPAWNS + MAX_SPAWNS); i++) {
                buy_zones[i] = 0
        }
        for (i = 0; i < MAX_BUYZONES; i++) {
                old_buyzone_ent[i] = 0
                old_buyzones[i] = Float:{0.0,0.0,0.0}
        }
        set_task(2.0, "check_zombies", 4578294)
        return PLUGIN_CONTINUE
}

public voteCount(id, key) {
        if (get_cvar_num("amx_vote_answers")) {
                new name[32]
                get_user_name(id,name,31)
                client_print(0,print_chat,"%s voted %s", name, key ? "against" : "for")
        }
        ++vote_count[key]
        return PLUGIN_HANDLED
}
public vote_check() {
        new votes_num = vote_count[0] + vote_count[1]
        new ratio = votes_num ? floatround(get_cvar_float("amx_vote_ratio") * float(votes_num), floatround_ceil) : 1
        if (vote_count[0] > ratio) {
                client_print(0, print_chat, "* Voting successful (got ^"%d^") (needed ^"%d^")", vote_count[0], ratio)
                if (zombie_enabled == 1)
                        zombie_off()
                else
                        zombie_on()
        } else {
                client_print(0, print_chat, "* Voting failed (got ^"%d^") (needed ^"%d^")", vote_count[0], ratio)
        }
}

public fake_nightvision(id, on)  {
        message_begin(MSG_ONE, gmsgNVGToggle, {0,0,0}, id)
        write_byte(on)
        message_end()
}

public zombie_vote(id) {
        if (get_cvar_num("amx_zombie_vote") != 1) {
                client_print(id, print_chat,"* Zombie voting is disabled")
                return PLUGIN_HANDLED
        }
        new Float:voting = get_cvar_float("amx_last_voting")
        if (voting > get_gametime()) {
                client_print(id, print_chat,"* There is already a vote in progress")
                return PLUGIN_HANDLED
        }
        if (voting && (voting + get_cvar_float("amx_vote_delay") > get_gametime()))  {
                client_print(id,print_chat,"* Voting not allowed at this time")
                return PLUGIN_HANDLED
        }
          new authid[32],name[32]
          get_user_authid(id,authid,31)
          get_user_name(id,name,31)

        log_amx("Vote: ^"%s<%d><%s><>^" vote zombie",
                    name,get_user_userid(id),authid)
        new activity = get_cvar_num("amx_show_activity")
        if (activity > 0) {
                switch (activity) {
                        case 2: client_print(0,print_chat, "%s %s: vote zombies", (is_user_admin(id)?"ADMIN":"USER"), name)
                        case 1: client_print(0,print_chat, "%s: vote zombies", (is_user_admin(id)?"ADMIN":"USER"), name)
                }
        }

        new Float:vote_time = get_cvar_float("amx_vote_time") + 2.0
        vote_count = {0, 0}
        new menu_msg[256]
        format(menu_msg, 255, "\y%s zombie mode ?\w^n^n1. Yes^n2. No", ((zombie_enabled == 1) ? "Disable" : "Enable"))
        show_menu(0, MENU_KEY_1|MENU_KEY_2, menu_msg, floatround(vote_time),"Zombie Mode")
       
        set_task(vote_time, "vote_check", 58924)
        set_cvar_float("amx_last_voting",  get_gametime() + vote_time )
        return PLUGIN_HANDLED
}

public plugin_log(){
    new args = read_logargc()
    if (args == 2){
        new msg[32]
        read_logargv(1, msg, 31)
        if(msg[6] == 'S')
            new_round()
    }
}
public plugin_precache() {
        precache_model("models/player/zombie/zombie.mdl")
        precache_sound("scientist/c1a0_sci_catscream.wav")
        spriteBrainVision = precache_model("sprites/white.spr")
        for (new i = 0; i < sound_count; i++)
                precache_sound(zombie_sounds[i])
}
public team_select(id) {
        if (zombie_enabled != 1)
                return PLUGIN_CONTINUE
        client_print(id, print_chat, "Zombie Mod is currently active. ONLY KILL ZOMBIES. DO NOT ATTACK HUMAN PLAYERS.")
        return PLUGIN_CONTINUE
}
public flashlight_on(id) {
        if ((zombie_enabled != 1) || !is_user_connected(id))
                return -1
        if ((flashlight[id] > 0) && is_valid_ent(flashlight[id]))
                return flashlight[id]

        new ent = create_entity("light_spot")
        if (ent) {
                new Float:origin[3], Float:angles[3]
                entity_get_vector(id, EV_VEC_origin, origin)
                entity_get_vector(id, EV_VEC_angles, angles)
                DispatchKeyValue(ent, "classname", "light_spot")
                DispatchKeyValue(ent, "_cone2", "45")
                DispatchKeyValue(ent, "_cone", "30")
                DispatchKeyValue(ent, "pitch", "0")
                DispatchKeyValue(ent, "_fade", "1.4")
                DispatchKeyValue(ent, "angles", "0 0 0")
                DispatchKeyValue(ent, "origin", "0 0 0")
                new _light[16]
                get_cvar_string("amx_zombie_flashlightcolor", _light, 15)
                add(_light, 15, " 250")
                DispatchKeyValue(ent, "_light", "255 0 0 250")
                DispatchSpawn(ent)
                entity_set_vector(ent, EV_VEC_origin, origin)
                entity_set_vector(ent, EV_VEC_angles, angles)       
                flashlight[id] = ent
                return ent
        }
        return -1
}

public flashlight_off(id) {
        if ((flashlight[id] > 0) && is_valid_ent(flashlight[id]))
                remove_entity(flashlight[id])

        flashlight[id] = 0
        return 0
}

public new_round() {
        if (zombie_enabled != 1)
                return PLUGIN_CONTINUE
        set_task(random_float(2.0, 15.0), "random_zombie")
        round_over = 0
        new ent, n_ent
        ent = find_ent_by_class(-1, "hostage_entity")
        while (ent > 0) {
                n_ent = find_ent_by_class(ent, "hostage_entity")
                entity_set_float(ent, EV_FL_health, -1.0)
                fakedamage(ent, "worldspawn", 10.0, 1)
                ent = n_ent
        }
        //set_user_hitzones(0, 0, 0)
        client_print(0, print_chat, "ZOMBIE MODE IS ENABLED. DO NOT ATTACK HUMANS. ONLY ATTACK ZOMBIES")
        return PLUGIN_CONTINUE
}
public c4_dropped(id) {
        if (zombie_enabled != 1)
                return PLUGIN_CONTINUE
        engclient_cmd(id, "drop", "weapon_c4")
        set_task(0.1, "delete_c4")
        return PLUGIN_CONTINUE
}
public delete_c4() {
        new ent = find_ent_by_class(-1, "weaponbox")
        while (ent > 0) {
                new model[33]
                entity_get_string(ent, EV_SZ_model, model, 32)
                if (equali(model, "models/w_backpack.mdl")) {
                        remove_entity(ent)
                        return PLUGIN_CONTINUE
                }
                ent = find_ent_by_class(ent, "weaponbox")
        }
        return PLUGIN_CONTINUE
}
public make_buyzone(Float:coords[3], pos) {
        new ent = create_entity("func_buyzone")
        if (ent) {
                buy_zones[pos] = ent
                DispatchKeyValue(ent, "classname", "func_buyzone")
                DispatchSpawn(ent)
                entity_set_size(ent, Float:{-30.0, -30.0, -30.0}, Float:{30.0, 30.0, 30.0})
                entity_set_string(ent, EV_SZ_classname, "func_buyzone")
                entity_set_origin(ent, coords)
        }
        return PLUGIN_CONTINUE
}
public remove_bombsites() {
        if (get_cvar_num("amx_zombie_mode") != 1)
                return PLUGIN_CONTINUE
        new bombsite_ents[MAX_BOMBSITES]
        new ent = find_ent_by_class(-1, "func_bomb_target")
        bombsites = 0
        while (ent > 0) {
                entity_get_vector(ent, EV_VEC_mins, bsite_min[bombsites])
                entity_get_vector(ent, EV_VEC_maxs, bsite_max[bombsites])
                entity_get_vector(ent, EV_VEC_origin, bsite_origin[bombsites])
                bombsites++
                bombsite_ents[bombsites] = ent
                if (bombsites >= MAX_BOMBSITES) break
                ent = find_ent_by_class(ent, "func_bomb_target")
        }
        for (new i = 0; i < bombsites; i++)
                remove_entity(bombsite_ents[i])
        return PLUGIN_CONTINUE
}
public replace_bombsites() {
        for (new i = 0; i < bombsites; i++) {
                new ent = create_entity("func_bomb_target")
                if (ent) {
                        DispatchKeyValue(ent, "classname", "func_bomb_target")
                        DispatchSpawn(ent)
                        entity_set_size(ent, bsite_min[i], bsite_max[i])
                        entity_set_string(ent, EV_SZ_classname, "func_bomb_target")
                        entity_set_origin(ent, bsite_origin[i])
                        bsite_min[i] = Float:{0, 0, 0}
                        bsite_origin[i] = Float:{0, 0, 0}
                        bsite_max[i] = Float:{0, 0, 0}
                }
        }
        bombsites = 0
        return PLUGIN_CONTINUE
}
public random_spawns() {
        if (get_cvar_num("amx_zombie_mode") != 1)
                return PLUGIN_CONTINUE

        new ent
        new x = 0
        if (rand_set == 1) {
                for (new i = 0; i < (MAX_SPAWNS + MAX_SPAWNS); i++) {
                        if (buy_zones[i] > 0)
                                remove_entity(buy_zones[i])
                        buy_zones[i] = 0
                }
        } else {
                ent = find_ent_by_class(-1, "func_buyzone")
                while (ent > 0) {
                        entity_get_vector(ent, EV_VEC_origin, old_buyzones[x])
                        old_buyzone_ent[x] = ent
                        entity_set_origin(ent, Float:{-9999.0, -9999.0, -9999.0})
                        x++
                        if (x <= MAX_BUYZONES) break;
                        ent = find_ent_by_class(ent, "func_buyzone")
                }
                x = 0
        }
        ent = find_ent_by_class(-1, "info_player_deathmatch")
        while (ent > 0) {
                if (rand_set == 0) {
                        entity_get_vector(ent, EV_VEC_origin, old_player_deathmatch[x])
                        old_player_deathmatch_ent[x] = ent
                }
                entity_set_origin(ent, rand_pos[x])
                make_buyzone(rand_pos[x], x)
                x++
                ent = find_ent_by_class(ent, "info_player_deathmatch")
                if (x > (MAX_SPAWNS - 1)) break;
        }
        new y = 0
        ent = find_ent_by_class(-1, "info_player_start")
        while (ent > 0) {
                if (rand_set == 0) {
                        entity_get_vector(ent, EV_VEC_origin, old_player_start[y])
                        old_player_start_ent[y] = ent
                }
                entity_set_origin(ent, rand_pos[x+y])
                make_buyzone(rand_pos[x+y], x+y)
                y++
                ent = find_ent_by_class(ent, "info_player_start")
                if (y > (MAX_SPAWNS - 1)) break;
        }

        return PLUGIN_CONTINUE
}
public do_say(id) {
        if (get_cvar_num("amx_zombie_mode") != 1)
                return PLUGIN_CONTINUE

        new message[129]
        read_argv(1,message,128)
        if ((strlen(message) < 1) || equal(message,"") || equal(message,"["))
                return PLUGIN_CONTINUE

        if (equali(message, "/zombies")) {
                client_print(0, print_chat, "Zombies: %d", zombie_count())
        } else if (equali(message, "/flashlight") && is_user_alive(id)) {
                if (flashlight[id] > 0)
                        flashlight[id] = 0
                else
                        flashlight[id] = 1

                return PLUGIN_HANDLED
        }
        else if ((zombies[id] == 1) && (is_user_alive(id) == 1)) {
                if (equali(message, "/fixcontrols")) {
                        fakedamage(id, "worldspawn", 2.6, 1)
                } else {
                        new name[32]
                        get_user_name(id,name,31)
                        new player_count = get_playersnum()
                        new players[32]
                        get_players(players, player_count, "c")
       
                        format(message, 127, "^2*UNDEAD*%s :    %s^n", name, message)       
                        message_begin(MSG_ALL,gmsgSayText,{0,0,0},0)
                        write_byte(id)
                        write_string(message)
                        message_end()
                }
                return PLUGIN_HANDLED
        }
        return PLUGIN_CONTINUE
}
public do_teamsay(id) {
        if (get_cvar_num("amx_zombie_mode") != 1)
                return PLUGIN_CONTINUE

        new message[129]
        read_argv(1,message,128)
        if (strlen(message) < 1) return PLUGIN_HANDLED
        new name[32]
        get_user_name(id,name,31)
        new player_count = get_playersnum()
        new players[32]
        get_players(players, player_count, "c")

        format(message, 127, "*TEAM*%s :    %s^n", name, message)
        for (new i = 0; i < player_count; i++) {
                if (zombies[players[i]] == zombies[id]) {
                        message_begin(MSG_ONE,gmsgSayText,{0,0,0},players[i])
                        write_byte(id)
                        write_string(message)
                        message_end()
                }
        }
        return PLUGIN_HANDLED
}
public client_PreThink(id) {
        if (get_cvar_num("amx_zombie_mode") != 1)
                return

        new alive = is_user_alive(id)
        if ((alive == 1) && (zombies[id] == 1))
                set_user_maxspeed(id, get_cvar_float("amx_zombie_speed"))
        if ((get_cvar_num("amx_zombie_specnv") == 1) && (get_cvar_num("amx_zombie_customspecnv") == 1) && (alive == 0)) {
                new pos[3]
                get_user_origin(id, pos)

                new tmpcvar[16]
                new r[4],g[4],b[4]
                get_cvar_string("amx_zombie_specnvcolor", tmpcvar, 15)
                if (parse(tmpcvar, r, 3, g, 3, b, 3) != 3) {
                        copy(r, 3, "0")
                        copy(g, 3, "200")
                        copy(b, 3, "0")
                }

                message_begin(MSG_ONE, SVC_TEMPENTITY, {0,0,0}, id)
                write_byte(TE_DLIGHT)
                write_coord(pos[0])
                write_coord(pos[1])
                write_coord(pos[2])
                write_byte(110)
                write_byte(str_to_num(r))
                write_byte(str_to_num(g))
                write_byte(str_to_num(b))
                write_byte(5)
                write_byte(10)
                message_end()
        } else if ((get_cvar_num("amx_zombie_defaultnvg") == 0) && (zombies[id] == 1) && (alive == 1)) {
                new pos[3]
                get_user_origin(id, pos)
           
                new tmpcvar[16]
                new r[4],g[4],b[4]
                get_cvar_string("amx_zombie_nvcolor", tmpcvar, 15)
                if (parse(tmpcvar, r, 3, g, 3, b, 3) != 3) {
                        copy(r, 3, "255")
                        copy(g, 3, "0")
                        copy(b, 3, "0")
                }

                message_begin(MSG_ONE, SVC_TEMPENTITY, {0,0,0}, id)
                  write_byte(TE_DLIGHT)
                  write_coord(pos[0])
                  write_coord(pos[1])
                  write_coord(pos[2])
                  write_byte(95)
                  write_byte(str_to_num(r))
                  write_byte(str_to_num(g))
                  write_byte(str_to_num(b))
                  write_byte(5)
                  write_byte(10)
                  message_end()
        } else if ((get_cvar_num("amx_zombie_flashlight") == 1) && (flashlight[id] > 0) && (zombies[id] == 0) && (alive == 1)) {
                /*new Float:origin[3], Float:angles[3]
                entity_get_vector(id, EV_VEC_origin, origin)
                entity_get_vector(id, EV_VEC_angles, angles)
                entity_set_vector(flashlight[id], EV_VEC_origin, origin)
                entity_set_vector(flashlight[id], EV_VEC_angles, angles)*/
                new aiming[3], pos[3], dist[3], maxv
                get_user_origin(id, aiming, 2)
                get_user_origin(id, pos)

                dist[0] = abs(pos[0]-aiming[0])
                dist[1] = abs(pos[1]-aiming[1])
                dist[2] = abs(pos[2]-aiming[2])
                if (dist[0] > dist[1]) {
                        if (dist[0] > dist[2])
                                maxv = dist[0]
                        else
                                maxv = dist[2]
                } else if (dist[1] > dist[2])
                        maxv = dist[1]
                else
                        maxv = dist[2]
                maxv /= 800
                maxv += 8

                new tmpcvar[16]
                new r[4],g[4],b[4]
                get_cvar_string("amx_zombie_flashlightcolor", tmpcvar, 15)
                if (parse(tmpcvar, r, 3, g, 3, b, 3) != 3) {
                        copy(r, 3, "200")
                        copy(g, 3, "1")
                        copy(b, 3, "0")
                }

 
                message_begin(MSG_PAS,SVC_TEMPENTITY, aiming)
                write_byte(TE_DLIGHT)
                write_coord(aiming[0]) // x
                write_coord(aiming[1]) // y
                write_coord(aiming[2]) // z
                write_byte(maxv) // radius * 0.1
                write_byte(str_to_num(r)) // r
                write_byte(str_to_num(g)) // g
                write_byte(str_to_num(b)) // b
                write_byte(2) // life in time * 10
                write_byte(2) // decay * 0.1
                message_end()
        }
        return
}
public block(id) {
        if (get_cvar_num("amx_zombie_mode") == 1)
                return PLUGIN_HANDLED
        return PLUGIN_CONTINUE
}
public shield_check(id) {
        if ((get_cvar_num("amx_zombie_mode") != 1) || (zombies[id] != 1))
                return PLUGIN_CONTINUE
        new user = (read_data(0))
        new stat = (read_data(1))
        if (stat == 64)
                engclient_cmd(user, "drop", "weapon_shield")

        return PLUGIN_CONTINUE
}
public block_zombie(id) {
        if ((get_cvar_num("amx_zombie_mode") == 1) && (zombies[id] == 1))
                return PLUGIN_HANDLED
        return PLUGIN_CONTINUE
}
public add_frag(ids[]) {
        new killer = ids[0]
        new frags = get_user_frags(killer)
        frags += ids[1]
        set_user_frags(killer, frags)
        message_begin(MSG_BROADCAST,gmsgScoreInfo)
        write_byte(killer)
        write_short(frags)
        write_short(get_user_deaths(killer))
        write_short(0)
        write_short(get_user_team(killer))
        message_end()
}
public player_death() {
        if (get_cvar_num("amx_zombie_mode") != 1)
                return PLUGIN_CONTINUE
        new killer = read_data( 1 );
        new id = read_data( 2 );
        new killer_team = get_user_team(killer)
        new id_team = get_user_team(id)

        if ((killer != id) && (killer > 0) && (zombies[id] > 0) && (killer < 34) && (killer_team == id_team)) {
                new ids[2]
                ids[0] = killer
                ids[1] = 2
                set_task(0.1, "add_frag", 0, ids, 2)
        }
        if (zombies[id] == 1) {
                new ids[1]
                ids[0] = id
                set_task(0.2, "zombie_die", 0, ids, 1)
        }
        return PLUGIN_CONTINUE
}

public zombie_die(ids[]) {
        entity_set_int(ids[0], EV_INT_sequence, 73)
        new origin[3]
        get_user_origin(ids[0], origin)
        origin[2] -= 30
        set_user_origin(ids[0], origin)
        remove_zombie(ids[0])
}
public remove_zombie(id) {
        zombies[id] = 0
        set_user_maxspeed(id, 320.0)
        fake_nightvision(id, 0)
        return PLUGIN_CONTINUE
}
public pfn_touch(ptr, ptd) {
        if (zombie_enabled != 1)
                return PLUGIN_CONTINUE
        if (ptd > 0 && ptd <= maxplayers && is_user_connected(ptd) && ptr > maxplayers) {
                new model[32]
                new class[32]
                entity_get_string(ptr, EV_SZ_model, model, 31)
                entity_get_string(ptr, EV_SZ_classname, class, 31)
                if ((equal(model, "models/w_", 9) || (containi(model, "shield") > -1)) && (zombies[ptd]==1)) {
                        return PLUGIN_HANDLED
                } else if (equal(model, "models/w_backpack", 17)) {
                        return PLUGIN_HANDLED
                } else if (equal(model, "models/w_scout", 14)||equal(model, "models/w_aug",12)||equal(model, "models/w_sg550",14)||
                        equal(model, "models/w_galil",14)||equal(model, "models/w_famas",14)||equal(model, "models/w_awp",12)||
                        equal(model, "models/w_m249",13)||equal(model, "models/w_m4a1",13)||equal(model, "models/w_g3gs1",14)||
                        equal(model, "models/w_sg552",14)||equal(model, "models/w_ak47",13)) {
                        return PLUGIN_HANDLED
                }
        }
       
        return PLUGIN_CONTINUE
}

public toggle_zombies(id,level,cid){
  if (!cmd_access(id,level,cid,1))
        return PLUGIN_HANDLED
  new toggle = 2
  if (read_argc() > 1) {
        new arg[2]
        read_argv(1,arg,1)
        toggle = str_to_num(arg)
  }
  set_hudmessage(200, 100, 0, -1.0, 0.25, 0, 1.0, 5.0, 0.1, 0.2, 2)
  if ((get_cvar_num("amx_zombie_mode") == 0) && (toggle != 0)) {
        randzombie = 0
        zombie_on()
        console_print(id, "[AMXx] Zombie mode has been turned on")
        show_hudmessage(0, "Zombie mode is now on. One person will randomly become a zombie and they have to infect others.")
  } else if ((get_cvar_num("amx_zombie_mode") == 1) && (toggle != 1)) {
        zombie_off()
        console_print(id, "[AMXx] Zombie mode has been turned off")
        show_hudmessage(0, "Zombie mode has been turned off")
  }
  return PLUGIN_HANDLED
}
public zombie_on() {
        zombie_enabled = 1
        set_cvar_string("ZombieMod", "2.0.1 (on)")
        set_cvar_num("amx_zombie_mode", 1)
        old_ff = get_cvar_num("mp_friendlyfire")
        old_roundtime = get_cvar_num("mp_roundtime")
        set_cvar_num("mp_friendlyfire", 1)
        set_cvar_num("mp_roundtime", 5)
        set_msg_block(gmsgRadar,BLOCK_SET)
        set_lights("a")
        server_cmd("amx_pausecfg pause gore")
        server_cmd("amx_restrict on flash nvgs rifle rifles m249")
        set_task(1.0, "check_brainvision", 23499432)
        set_task(1.3, "new_round")
        set_cvar_num("sv_restartround", 1)
        remove_bombsites()
        round_over = 0
        return PLUGIN_CONTINUE
}
public zombie_off() {
        server_cmd("amx_restrict off flash nvgs rifle rifles m249")
        set_lights("m")
        set_msg_block(gmsgRadar,BLOCK_NOT)
        //set_user_hitzones(0, 0, 255)
        set_cvar_num("amx_zombie_mode", 0)
        zombie_enabled = 0
        set_cvar_string("ZombieMod", "2.0.1 (off)")
        set_cvar_num("mp_friendlyfire", old_ff)
        set_cvar_num("mp_roundtime", old_roundtime)
        remove_task(23499432)
        new i
        if (get_cvar_num("amx_zombie_randomspawn") == 1) {
        for (i = 0; i < MAX_SPAWNS; i++) {
                if (old_player_deathmatch_ent[i] > 0) {
                        entity_set_origin(old_player_deathmatch_ent[i], old_player_deathmatch[i])
                        old_player_deathmatch_ent[i] = 0
                        old_player_deathmatch[i] = Float:{0.0,0.0,0.0}
                }
                if (old_player_start_ent[i] > 0) {
                        entity_set_origin(old_player_start_ent[i], old_player_start[i])
                        old_player_start_ent[i] = 0
                        old_player_start[i] = Float:{0.0,0.0,0.0}
                }
        }
        for (i = 0; i < (MAX_SPAWNS + MAX_SPAWNS); i++) {
                if (buy_zones[i] > 0) {
                        remove_entity(buy_zones[i])
                        buy_zones[i] = 0
                }
        }
        for (i = 0; i < MAX_BUYZONES; i++) {
                if (old_buyzone_ent[i] > 0) {
                        entity_set_origin(old_buyzone_ent[i], old_buyzones[i])
                        old_buyzone_ent[i] = 0
                        old_buyzones[i] = Float:{0.0,0.0,0.0}
                }
        }
        rand_set = 0
        }
        for (i = 1; i <= maxplayers; i++) {
                if (zombies[i] > 0) zombies[i] = 0
                if (is_user_connected(i)) {
                        set_user_maxspeed(i, 320.0)
                        cs_reset_user_model(i)
                        if (get_cvar_num("amx_zombie_defaultnvg") == 1)
                                fake_nightvision(i, 0)
                        if (get_user_health(i) > 100)
                                set_user_health(i, 100)
                }
        }
        replace_bombsites()
        set_cvar_num("sv_restartround", 1)
        return PLUGIN_CONTINUE
}
 
public end_round() {
        if (zombie_enabled != 1)
                return PLUGIN_CONTINUE
        randzombie = 0
        for (new i = 1; i <= maxplayers; i++) {
                if (is_user_connected(i)) {
                        if (zombies[i] > 0) {
                                remove_zombie(i)
                        }
                        if (old_team[i] > CsTeams:0) {
                                cs_set_user_team(i, old_team[i])
                                old_team[i] = CsTeams:0
                        }
                }
        }
        if ((get_cvar_num("amx_zombie_randomspawn") == 1) && (randpos_max >= (MAX_SPAWNS + MAX_SPAWNS - 1))) {
                random_spawns()
                rand_set = 1
        }
        round_over = 1
        remove_task(87134833)
        return PLUGIN_CONTINUE
}

public spawn_event(id) {
        if (get_cvar_num("amx_zombie_randomspawn") == 1) {
                new ids[1]
                ids[0] = id
                set_task(random_float(30.0, 40.0), "set_rand_pos", id + 183, ids, 1)
        }
        if (zombie_enabled != 1)
                return PLUGIN_CONTINUE

        if (zombies[id] == 1) {
                new ids[2]
                ids[0] = id
                ids[1] = 0
                set_task(0.1, "do_zombie", 0, ids, 2)
                return PLUGIN_HANDLED
        }
        round_over = 0
        cs_reset_user_model(id)
        cs_set_user_money(id, 16000)
        return PLUGIN_CONTINUE
}
public set_rand_pos(ids[]) {
        new id = ids[0]
        if (is_user_alive(id) != 1)
                return PLUGIN_CONTINUE

        new fl = entity_get_int(id, EV_INT_flags)
        if ((round_over == 0) && !(entity_get_int(id, EV_INT_button) & (IN_JUMP|IN_DUCK)) && (fl & FL_ONGROUND) && !(fl & FL_FLY) && !(fl & FL_DUCKING) && !(fl & FL_ONTRAIN) && !(fl & FL_INWATER) && (entity_get_int(id, EV_INT_bInDuck) == 0)) {
                new Float:origin[3]
                entity_get_vector(id, EV_VEC_origin, origin)
                new n_ent, class[32]
                new ent = find_ent_in_sphere(33, origin, 15.0)
                while (ent > 0) {
                        n_ent = find_ent_in_sphere(ent, origin, 15.0)
                        entity_get_string(ent, EV_SZ_classname, class, 31)
                        if (containi(class, "door")!=-1 || containi(class, "rotating")!=-1 || containi(class, "ladder")!=-1 || containi(class, "breakable")!=-1) {
                                set_task(random_float(10.0, 40.0), "set_rand_pos", id + 183, ids, 1)
                                return PLUGIN_CONTINUE
                        }
                        ent = n_ent
                }
                for (new x = 0; x < (MAX_SPAWNS + MAX_SPAWNS); x++) {
                        if ((floatabs(origin[0]-rand_pos[x][0]) < 30.0) &&
                                (floatabs(origin[1]-rand_pos[x][1]) < 30.0) &&
                                (floatabs(origin[2]-rand_pos[x][2]) < 30.0)) {
                                        set_task(random_float(10.0, 40.0), "set_rand_pos", id + 183, ids, 1)
                                        return PLUGIN_CONTINUE
                        }
                }
                if (randpos_max < (MAX_SPAWNS + MAX_SPAWNS - 1)) {
                        rand_pos[randpos_max] = origin
                        randpos_max++
                } else {
                        rand_pos[random_num(0, (MAX_SPAWNS + MAX_SPAWNS - 1))] = origin
                }
        }
        set_task(random_float(10.0, 40.0), "set_rand_pos", id + 183, ids, 1)
        return PLUGIN_CONTINUE
}
public switch_weapon(id) {
        if (zombie_enabled != 1)
                return PLUGIN_CONTINUE

        new tclip, tammo
        new weapon = get_user_weapon(id,tclip,tammo)
        if (zombies[id] == 1) {
                entity_set_string(id, EV_SZ_viewmodel, "")
                entity_set_string(id, EV_SZ_weaponmodel, "")
                if ((weapon > 0) && (weapon < 31) && (weapon != 2) && (weapon != CSW_KNIFE)) {
                        new wstr[32]
                        get_weaponname(weapon, wstr, 31)
                        engclient_cmd(id, "drop", wstr)
                        engclient_cmd(id, "weapon_knife")
                }
        } else if ((weapon == CSW_C4)||(weapon == CSW_SCOUT)||(weapon == CSW_AUG)||(weapon == CSW_SG550)||(weapon == CSW_GALIL)
                ||(weapon == CSW_FAMAS)||(weapon == CSW_AWP)||(weapon == CSW_M249)||(weapon == CSW_G3SG1)||(weapon == CSW_SCOUT)
                ||(weapon == CSW_SG552)||(weapon == CSW_AK47)||(weapon == CSW_M4A1)) {
                new wstr[32]
                get_weaponname(weapon, wstr, 31)
                if (weapon == CSW_C4)
                        engclient_cmd(id, "drop")
                else
                        engclient_cmd(id, "drop", wstr)
        }
        return PLUGIN_CONTINUE
}
public weapon_string(w, str[]) {
        switch (w) {
                case CSW_P228: copy(str, 31, "p228")
                case CSW_SCOUT: copy(str, 31, "scout")
                case CSW_HEGRENADE: copy(str, 31, "hegrenade")
                case CSW_XM1014: copy(str, 31, "xm1014")
                case CSW_C4: copy(str, 31, "c4")
                case CSW_MAC10: copy(str, 31, "mac10")
                case CSW_AUG: copy(str, 31, "aug")
                case CSW_SMOKEGRENADE: copy(str, 31, "smokegrenade")
                case CSW_ELITE: copy(str, 31, "elite")
                case CSW_FIVESEVEN: copy(str, 31, "fiveseven")
                case CSW_UMP45: copy(str, 31, "ump45")
                case CSW_SG550: copy(str, 31, "sg550")
                case CSW_GALIL: copy(str, 31, "galil")
                case CSW_FAMAS: copy(str, 31, "famas")
                case CSW_USP: copy(str, 31, "usp")
                case CSW_GLOCK18: copy(str, 31, "glock18")
                case CSW_AWP: copy(str, 31, "awp")
                case CSW_MP5NAVY: copy(str, 31, "mp5navy")
                case CSW_M249: copy(str, 31, "m249")
                case CSW_M3: copy(str, 31, "m3")
                case CSW_M4A1: copy(str, 31, "m4a1")
                case CSW_TMP: copy(str, 31, "tmp")
                case CSW_G3SG1: copy(str, 31, "g3sg1")
                case CSW_FLASHBANG: copy(str, 31, "flashbang")
                case CSW_DEAGLE: copy(str, 31, "deagle")
                case CSW_SG552: copy(str, 31, "sg552")
                case CSW_AK47: copy(str, 31, "ak47")
                case CSW_KNIFE: copy(str, 31, "knife")
                case CSW_P90: copy(str, 31, "p90")
        }
}
public do_team_dmg(ids[]) {
        new tid = ids[0]
        new id = ids[1]
        if (!is_user_alive(tid))
                return PLUGIN_CONTINUE
        new tbody = ids[3]
        new weap = ids[4]
        new health = get_user_health(tid)
        health -= ids[2]
        if (health > 0) {
                set_user_health(tid, health)
        } else {
                message_begin(MSG_ALL, gmsgDeathMsg,{0,0,0},0)
                write_byte( id )
                write_byte( tid )
                if (tbody == HIT_HEAD) {
                        write_byte(1)
                } else {
                        write_byte(0)
                }
                new weapon_str[32]
                weapon_string(weap, weapon_str)
                write_string(weapon_str)
                message_end()

                new fr = get_user_frags(id)+1
                message_begin(MSG_BROADCAST, gmsgScoreInfo)
                write_byte(id)
                write_short(fr)
                write_short(get_user_deaths(id))
                write_short(0)
                write_short(get_user_team(id))
                message_end()
                set_user_frags(id, fr)

                new deaths = get_user_deaths(tid)+1
                message_begin(MSG_BROADCAST, gmsgScoreInfo)
                write_byte(tid)
                write_short(get_user_frags(tid))
                write_short(deaths)
                write_short(0)
                write_short(get_user_team(tid))
                message_end()
       
                cs_set_user_deaths(tid, deaths)
                set_msg_block(gmsgDeathMsg,BLOCK_SET)
                user_kill(tid,1)
                set_msg_block(gmsgDeathMsg,BLOCK_NOT)
        }
        return PLUGIN_CONTINUE
}
public do_health() {
        if (zombie_enabled != 1)
                return PLUGIN_CONTINUE

        new id = read_data(0)
        new health = read_data(1)
        if (zombies[id] == 1) {
                set_hudmessage( 255, 255, 255, -2.00, -2.00, 2, 0.05, 1000.0, 0.01, 3.0, 1);
                show_hudmessage(id, "    Health: %d", health)
        }
        return PLUGIN_CONTINUE
}

public event_damage() {
        if (zombie_enabled != 1)
                return PLUGIN_CONTINUE
        new id = read_data(0)
        new damage = read_data(1)
        new attacker

        if ((!id) || !is_user_connected(id))
                return PLUGIN_CONTINUE

        new weapon,body
        attacker = get_user_attacker(id,weapon,body)
        if ((!attacker) || (attacker == id))
                return PLUGIN_CONTINUE
        if ((zombies[attacker] == 1) && (weapon == CSW_HEGRENADE))
                return PLUGIN_CONTINUE
        if (zombies[attacker] != 1) {
                if (zombies[id] != 1) {
                        set_user_health(id,get_user_health(id)+damage)
                        return PLUGIN_CONTINUE
                } else {
                        new ids[5]
                        ids[0] = id
                        ids[1] = attacker
                        ids[2] = damage
                        ids[3] = body
                        ids[4] = weapon
                        set_task(0.1, "do_team_dmg", 0, ids, 5)
                }
        }
        if (zombies[id] == 1) {
                entity_set_vector(id, EV_VEC_velocity, Float:{0.0, 0.0, 0.0})
                return PLUGIN_CONTINUE
        }
        new health = get_user_health(attacker)
        health += 15
        if (health < get_cvar_num("amx_zombie_health"))
                set_user_health(attacker, health)
        if ((id > 0) && (id < 34) && (zombies[id] == 0) && (weapon == CSW_KNIFE)) {
                zombies[id] = 2
                new ids[2]
                ids[0] = id
                ids[1] = attacker
                set_task(get_cvar_float("amx_zombie_infecttime"), "start_zombie", 0, ids, 2)
                client_print(attacker, print_chat, "You have consumed the brains of a human!")
        }

        return PLUGIN_CONTINUE
}

public start_zombie(ids[]) {
        new id = ids[0]
        new attacker = ids[1]
        if ((round_over == 1) || (is_user_alive(id) == 0) || (zombie_enabled != 1)) {
                zombies[id] = 0
                return PLUGIN_CONTINUE
        }

        if (zombies[id] == 2) {
                emit_sound(id, CHAN_VOICE, "scientist/c1a0_sci_catscream.wav", 1.0, ATTN_NORM, 0, PITCH_NORM)
                set_user_health(id, 400)
                new frags = get_user_frags(id)
                frags -= 1
                set_user_frags(id, frags)
                message_begin(MSG_BROADCAST,gmsgScoreInfo)
                write_byte(id)
                write_short(frags)
                write_short(get_user_deaths(id))
                write_short(0)
                write_short(get_user_team(id))
                message_end()
        }
        if (zombies[id] < 4) {
                zombies[id]++
                if (is_user_alive(id)) {
                        if (zombies[id] == 3) {
                                if (get_cvar_num("amx_zombie_model") == 1)
                                        cs_set_user_model(id, "zombie")
                                entity_set_int(id, EV_INT_sequence, 7)
                        }
                        set_task(0.2, "start_zombie", 0, ids, 2)
                } else {
                        zombies[id] = 0
                }
        } else {
                new frags = get_user_frags(attacker)
                frags += 1
                set_user_frags(attacker, frags)
                message_begin(MSG_BROADCAST,gmsgScoreInfo)
                write_byte(attacker)
                write_short(frags)
                write_short(get_user_deaths(attacker))
                write_short(0)
                write_short(get_user_team(attacker))
                message_end()
                ids[1] = 0
                set_task(0.1, "do_zombie", 0, ids, 2)
        }
        return PLUGIN_CONTINUE
}

public zombie_count() {
        new z = 0
        for (new i = 1; i <= maxplayers; i++)
                if (is_user_alive(i) && (zombies[i] > 0))
                        z++
        return z
}

public client_disconnect(id) {
        if (zombie_enabled != 1)
                return PLUGIN_CONTINUE
        zombies[id] = 0
        flashlight[id] = 0
        old_team[id] = CsTeams:0
        if (get_playersnum() == 0) {
                zombie_off()
                return PLUGIN_CONTINUE
        }
        if (randzombie!=id)
                return PLUGIN_CONTINUE
        if (zombie_count() == 0) {
                randzombie = 0
                random_zombie()
        }
        return PLUGIN_CONTINUE
}
public client_connect(id) {
        if (zombie_enabled != 1)
                return PLUGIN_CONTINUE
        zombies[id] = 0
        return PLUGIN_CONTINUE
}

public send_team_msg(id, team) {
        message_begin(MSG_ALL, gmsgTeamInfo, {0,0,0}, 0)
        write_byte(id)
        write_string((team == 1) ? "TERRORIST" : "CT")
        message_end()
}

public check_zombies() {
        if (get_cvar_num("amx_zombie_mode") != 1) {
                if (zombie_enabled == 1)
                        zombie_off()
                set_task(1.0, "check_zombies", 4578294)
                return PLUGIN_CONTINUE
        } else if (zombie_enabled == 0) {
                randzombie = 0
                zombie_on()
                set_task(1.0, "check_zombies", 4578294)
                return PLUGIN_CONTINUE
        }
        if ((get_playersnum() < 2) || (round_over == 1)) {
                set_task(1.0, "check_zombies", 4578294)
                return PLUGIN_CONTINUE
        }
        new c = zombie_count()
        for (new x = 1; x <= maxplayers; x++) {
                if (is_user_alive(x)) {
                        if (zombies[x] == 1) {
                                set_user_maxspeed(x, get_cvar_float("amx_zombie_speed"))
                                if (entity_get_int(x, EV_INT_effects) == 8)
                                        client_cmd(x, "impulse 100")
                                if (random_num(0, 40) == 5) {
                                        emit_sound(x, CHAN_VOICE, zombie_sounds[random_num(1, sound_count-1)], 1.0, ATTN_NORM, 0, PITCH_NORM)
                                }
                                send_team_msg(x, 1)
                        } else {
                                send_team_msg(x, 2)
                        }
                } else {
                        if (zombies[x] > 0)
                                zombies[x] = 0
                        if ((is_user_connected(x) == 1) && (get_cvar_num("amx_zombie_specnv") == 1) && (get_cvar_num("amx_zombie_customspecnv") != 1))
                                fake_nightvision(x, 1)
                }
        }
        if ((randzombie != 0) && (c == 0)) {
                randzombie = 0
                set_hudmessage(200, 100, 0, -1.0, 0.25, 0, 1.0, 5.0, 0.1, 0.2, 2)
                show_hudmessage(0, "All of the zombies have been killed.")
                client_print(0, print_chat, "All of the zombies have been killed.")
                finish_round(CsTeams:CS_TEAM_T)
        } else {
                new players[32],  i = 0
                get_players(players, i, "a")
                if (i == c) {
                        randzombie = 0
                        set_hudmessage(200, 100, 0, -1.0, 0.25, 0, 1.0, 5.0, 0.1, 0.2, 2)
                        show_hudmessage(0, "Zombies have taken over the world.")
                        client_print(0, print_chat, "Zombies have taken over the world.")
                        finish_round(CsTeams:CS_TEAM_CT)
                }
        }
        if (get_cvar_num("amx_zombie_lightning") == 1) {
                if (random_num(0,7) == 1) {
                        lastlights = 1
                        new rand = random_num(1,5)
                        switch (rand) {
                                case 1: set_lights("aaaaaaaaabcdefdbaa")
                                case 2: set_lights("aaaaaagcdaaaaaa")
                                case 3: set_lights("aaacdefdbaaaa")
                                case 4: set_lights("aaaabbbaaaa")
                                case 5: set_lights("aaaacbbcaaaab")
                        }
                } else if (lastlights == 1) {
                        lastlights = 0
                        set_lights("aaaaaaaaaaaaaaaaaaabbbaaaa")
                }
        } else {
                set_lights("a")
        }
        set_task(1.0, "check_zombies", 4578294)
        return PLUGIN_CONTINUE
}
public check_brainvision() {
        if ((get_cvar_num("amx_zombie_mode") != 1) || (get_cvar_num("amx_zombie_brainvision") != 1)) return PLUGIN_CONTINUE
        new b_players = 0
        new b_coord[32][3]
        for (new x = 1; x <= maxplayers; x++) {
                if (is_user_alive(x) && (zombies[x] == 0)) {
                        b_players++
                        get_user_origin(x, b_coord[x - 1])
                }
        }
        for (new x = 1; x <= maxplayers; x++) {
                if (is_user_alive(x) && (zombies[x] == 1)) {
                        for (new m = 0; m < b_players; m++) {
                                message_begin(MSG_ONE,SVC_TEMPENTITY,b_coord[m],x)
                                write_byte(21)
                                write_coord(b_coord[m][0])      // x  center
                                write_coord(b_coord[m][1])      // y  position
                                write_coord(b_coord[m][2] + 16)  // z
                                write_coord(b_coord[m][0])      // x  axis and
                                write_coord(b_coord[m][1])      // y  radius
                                write_coord(b_coord[m][2] + 500) // z
                                write_short(spriteBrainVision) // sprite index
                                write_byte(0) // starting frame
                                write_byte(1) // frame rate in 0.1's
                                write_byte(8) // life in 0.1's
                                write_byte(5) // line width in 0.1's
                                write_byte(1) // noise amplitude in 0.01's
                                write_byte(111) // r
                                write_byte(0) // g
                                write_byte(0) // b
                                write_byte(200) // brightness
                                write_byte(0) // scroll speed in 0.1's
                                message_end()
                        }
                }
        }
        set_task(4.0, "check_brainvision", 23499432)
        return PLUGIN_CONTINUE
}
public finish_round(CsTeams:team) {
        if (round_over == 1) return PLUGIN_CONTINUE
        new players[32], i
        new z = 0
        new kill_players = 0
        new CsTeams:not_team = ((team == CS_TEAM_CT) ? CS_TEAM_T : CS_TEAM_CT)
        get_players(players, i, "b")
        for (new x = 0; x < i; x++) {
                new CsTeams:user_team = cs_get_user_team(players[x])
                if ((user_team == CS_TEAM_CT) || (user_team == CS_TEAM_T)) z++
                if (cs_get_user_team(players[x]) == not_team) {
                        old_team[players[x]] = not_team
                        cs_set_user_team(players[x], team)
                        z = players[x]
                }
        }
        if (z == 0) kill_players = 1
        z = 0
        get_players(players, i, "a")
        set_msg_block(gmsgDeathMsg,BLOCK_SET)
        for (new x = 0; x < i; x++) {
                if (cs_get_user_team(players[x]) == team) {
                        if (kill_players == 1) {
                                user_kill(players[x],1)
                        } else {
                                old_team[players[x]] = team
                                cs_set_user_team(players[x], not_team)
                                z = players[x]
                        }
                }
        }
        if ((z > 0) && (kill_players == 0)) {
                user_kill(z,1)
        }
        set_msg_block(gmsgDeathMsg,BLOCK_NOT)
        return PLUGIN_CONTINUE
}

public do_zombie(ids[]) {
        if ((zombie_enabled != 1) || !is_user_alive(ids[0]))
                return PLUGIN_CONTINUE

        new id = ids[0]
        zombies[id] = 1
        new sethealth = get_cvar_num("amx_zombie_health")
        entity_set_string(id, EV_SZ_viewmodel, "")
        entity_set_string(id, EV_SZ_weaponmodel, "")
        if (entity_get_int(id, EV_INT_effects) & 8) // EF_DIMLIGHT
                client_cmd(id, "impulse 100")
        cs_set_user_bpammo(id, CSW_HEGRENADE, 0)
        cs_set_user_bpammo(id, CSW_SMOKEGRENADE, 0)
        cs_set_user_bpammo(id, CSW_FLASHBANG, 0)
        new wpns[32], weapon_name[32], num
        get_user_weapons(id, wpns, num)
        for (new i = 0; i < num; i++) {
                if (wpns[i] == CSW_KNIFE) continue;
                if (wpns[i] == CSW_C4) {
                        engclient_cmd(id, "drop")
                        engclient_cmd(id, "drop")
                        engclient_cmd(id, "drop")
                } else {
                        get_weaponname(wpns[i], weapon_name, 31)
                        engclient_cmd(id, "drop", weapon_name)
                }
        }
        engclient_cmd(id, "weapon_knife")
        if (get_cvar_num("amx_zombie_defaultnvg") == 1) {
                fake_nightvision(id, 1)
                client_cmd(id, "nightvision")
        }
        if (get_cvar_num("amx_zombie_model") == 1)
                cs_set_user_model(id, "zombie")
        if (ids[1] == 1)
                set_user_health(id, sethealth * 2)
        else
                set_user_health(id, sethealth)
        set_user_maxspeed(id, 140.0)
        user_slap(id, 2, 1)
        //set_user_hitzones(0, id, get_cvar_num("amx_zombie_hitzones"))

        client_print(id, print_chat, "You are a zombie. Stab humans once to turn them into the undead or kill them and eat their delicious brains.")
        return PLUGIN_CONTINUE
}
public random_zombie() {
        if ((zombie_enabled != 1) || (randzombie > 0))
                return PLUGIN_CONTINUE

        new players[32]
        new i = 0

        get_players(players, i, "ac")
        if (i == 0)
                return 0
        randzombie = players[random_num(0,i-1)]
        new ids[2]
        ids[0] = randzombie
        ids[1] = 1
        do_zombie(ids)
       
        return randzombie
}


psm1991 04-21-2007 04:27

Re: zombie mod ?
 
1 Attachment(s)
um.. Maybe, edited very well..

ps : I cant very well speaking english, too

neogeo 04-21-2007 05:30

Re: zombie mod ?
 
thx i will try

neogeo 04-21-2007 06:59

Re: zombie mod ?
 
ok it works but there are few problems :
-zombie can attack zombie and humans can attack humans
==> i don't want that
-we can't disabled the nightvison :(
==> i want the possibility to disabled it

thanks

ps : the dark is removed , it's good like that

Samurai [/] 04-21-2007 07:12

Re: zombie mod ?
 
Quote:

Originally Posted by neogeo (Post 467874)
ok it works but there are few problems :
-zombie can attack zombie and humans can attack humans
==> i don't want that
-we can't disabled the nightvison :(
==> i want the possibility to disabled it

thanks

ps : the dark is removed , it's good like that

Make separate plugin for nightvision.

psm1991 04-22-2007 07:25

Re: zombie mod ?
 
1 Attachment(s)
-we can't disabled the nightvison :(
==> i want the possibility to disabled it

Please using this command :
amx_zombie_defaultnvg 1

and team damage is fixed. Download now! :)

PS :Can you understanding my english??
I dont know english grammar very well. T_T;

neogeo 04-22-2007 11:13

Re: zombie mod ?
 
yes , i unserstand
i will try
thanks

neogeo 04-22-2007 11:36

Re: zombie mod ?
 
ok i test your new version.
there are some problem :
-we can't disabled nightvision.
-zombie can attack zombie and humans can attack humans but there are no damage ==> i just want the ability to can't HURT team mate.
thanks

psm1991 04-24-2007 09:57

Re: zombie mod ?
 
Second asking is so hard that I can't do it..
I am operate to zombie server but it is cant fixed

Sorry about that i cant help you T_T

neogeo 04-24-2007 11:40

Re: zombie mod ?
 
ok
no problem :D


All times are GMT -4. The time now is 08:46.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.