------------------------------------------------------------------------ -- Zombie Survival gametype -- -- Coding: JetBoom -- -- You can use any of my code, as long as you clearly give me credit! -- ------------------------------------------------------------------------ -- Mappper guidelines for making ZS_ maps -- -- Only the 1st, 3rd and 4th flag should be checked in gmod_gamemode entity -- -- All humans should start together, with the BLUE TEAM flag checked -- -- All zombie spawns should be GREEN TEAM -- -- Ammo, health ect. should not be near the human spawn. This just causes camping -- -- tools/toolsplayerclip textured brushes should be used to stop fast zombie -- -- players from climbing / leaping out of the map. -- -- Chokepoints should be used and wide open areas should be avoided -- -- Res files are now automaticly created. (V3) -- -- Setting up NPCs -- -- All npc_makers should be named "npc_maker" -- -- Squad for npc_makers should be named "zombies" -- -- Map must have info_nodes and info_climbnodes if using fast zombies -- -- set up throughout map for NPCs. -- -- Setting a map up for arcade mode -- -- First of all, you must have a gmod_runfunction entity to run: ArcadeMode -- -- It should be hooked up to a logic_auto, so when the map starts it's activated -- -- To place a SWEP create a weapon_swep entity and in the properties put in the -- -- script to the weapon you will use. ex: weapons/zombiesurvival/uzi.lua -- -- << WEAPONS WILL <> RESPAWN!! UNLESS BY TRIGGERS! >> -- -- Server Options -- RoundTime = 16 -- Time in minutes how long humans must survive IntermissionTime = 30 -- Time in seconds after the round ends before the map is reset ZombieWinMusic = "npc/stalker/go_alert2a.wav" -- Music/sound used when zombies win HumanWinMusic = "zombiesurvival/humanvictory.mp3" -- Music/sound used when humans survive LastHumanMusic = "zombiesurvival/lasthuman_v3.mp3" -- Music/sound used when 1 human is left. ONLY works when atleast 4 players in server HalfLifeMusic = "zombiesurvival/halflife_v3.mp3" -- Music/sound played when "Half-Life" has been reached. DeathMusic = "music/stingers/HL1_stinger_song8.mp3" -- Music/sound played to a person when they turn to The Undead HumanDeadline = 0.25 -- Percent of round time before no one can join as a human RandomStartZom = true -- If set to true, one random person becomes a zombie at start EnableDeadline = true -- If set to true, people automaticly join undead if HumanDeadline*RoundTime is reached. EXTREMEDIFFICULTY = true -- V3 Night of the Living Dead difficulty -- Headshots do mega damage -- Body shots do less damage -->> Zombies killed by not getting shot in the head will revive 2 seconds later -- NPC zombies do more damage -- NPC zombies have more health -- This is so damn messy. When GMod 10 is out, and I recode it, I'll make it more efficient. I just don't feel like rebuilding it all. --------------------------- -- Don't edit below this -- --------------------------- PlayerInfo = {} for i=1, _MaxPlayers() do PlayerInfo[i] = {} PlayerInfo[i].isUndead = 0 PlayerInfo[i].Class = "zombie" PlayerInfo[i].LastChange = 0 end JoinTheUndeadFirstTimer = 0 CurrentPlayers = 0 bEndRound = false bLastHuman = false bHalfLife = false bQuarterLife = false bFirstDied = false bArcadeMode = false RoundEndedAt = 0 StartingZombieName = "" LastHumanName = "" InflictionRate = 0.01 disp1 = 0 disp2 = 0 disp3 = 0 disp4 = 0 disp5 = 0 disp6 = 0 disp7 = 0 disp8 = 0 Timer = {} TimeDisplay = {} for i=1, _MaxPlayers() do TimeDisplay[i] = 0 end function GetPlayerDamageScale(hitgroup) if EXTREMEDIFFICULTY then if hitgroup == HITGROUP_HEAD then return 4.0 end return 0.75 else if hitgroup == HITGROUP_HEAD then return 3.0 end return 1.0 end end -- I could have just made it so it resets their speed, but this is funnier function eventKeyPressed (userid, in_key) if in_key == IN_WALK and _PlayerInfo(userid, "team") == TEAM_GREEN then _PlayerKill(userid) _PrintMessage(userid, 4, "LoL!!") end end function gamerulesThink() for i=1, _MaxPlayers() do if _PlayerInfo(i, "team") == TEAM_GREEN and _player.GetFlashlight(i) then _PlayerSetFlashlight(i, false) end end end function SpawnDisp() disp1 = _EntCreate( "ai_relationship" ) if disp1 > 0 then _EntSetKeyValue( disp1, "subject", "npc_headcrab") _EntSetKeyValue( disp1, "target", "zombieplayer") _EntSetKeyValue( disp1, "disposition", 3) _EntSetKeyValue( disp1, "Radius for subject", 99999) _EntSetKeyValue( disp1, "rank", 99) _EntSetKeyValue( disp1, "Reciprocal", 1) _EntSetPos(disp1, vector3(0, 0, 0)) _EntSpawn(disp1) end disp2 = _EntCreate( "ai_relationship" ) if disp2 > 0 then _EntSetKeyValue( disp2, "subject", "npc_headcrab_fast") _EntSetKeyValue( disp2, "target", "zombieplayer") _EntSetKeyValue( disp2, "disposition", 3) _EntSetKeyValue( disp2, "Radius for subject", 99999) _EntSetKeyValue( disp2, "rank", 99) _EntSetKeyValue( disp2, "Reciprocal", 1) _EntSetPos(disp2, vector3(0, 0, 0)) _EntSpawn(disp2) end disp3 = _EntCreate( "ai_relationship" ) if (disp3 > 0) then _EntSetKeyValue( disp3, "subject", "npc_headcrab_black") _EntSetKeyValue( disp3, "target", "zombieplayer") _EntSetKeyValue( disp3, "disposition", 3) _EntSetKeyValue( disp3, "Radius for subject", 99999) _EntSetKeyValue( disp3, "rank", 99) _EntSetKeyValue( disp3, "Reciprocal", 1) _EntSetPos(disp3, vector3(0, 0, 0)) _EntSpawn(disp3) end disp4 = _EntCreate( "ai_relationship" ) if disp4 > 0 then _EntSetKeyValue( disp4, "subject", "npc_fastzombie") _EntSetKeyValue( disp4, "target", "zombieplayer") _EntSetKeyValue( disp4, "disposition", 3) _EntSetKeyValue( disp4, "Radius for subject", 99999) _EntSetKeyValue( disp4, "rank", 99) _EntSetKeyValue( disp4, "Reciprocal", 1) _EntSetPos(disp4, vector3(0, 0, 0)) _EntSpawn(disp4) end disp5 = _EntCreate( "ai_relationship" ) if disp5 > 0 then _EntSetKeyValue( disp5, "subject", "npc_zombie") _EntSetKeyValue( disp5, "target", "zombieplayer") _EntSetKeyValue( disp5, "disposition", 3) _EntSetKeyValue( disp5, "Radius for subject", 99999) _EntSetKeyValue( disp5, "rank", 99) _EntSetKeyValue( disp5, "Reciprocal", 1) _EntSetPos(disp5, vector3(0, 0, 0)) _EntSpawn(disp5) end disp6 = _EntCreate( "ai_relationship" ) if disp6 > 0 then _EntSetKeyValue( disp6, "subject", "npc_poisonzombie") _EntSetKeyValue( disp6, "target", "zombieplayer") _EntSetKeyValue( disp6, "disposition", 3) _EntSetKeyValue( disp6, "Radius for subject", 99999) _EntSetKeyValue( disp6, "rank", 99) _EntSetKeyValue( disp6, "Reciprocal", 1) _EntSetPos(disp6, vector3(0, 0, 0)) _EntSpawn(disp6) end disp7 = _EntCreate( "ai_relationship" ) if disp7 > 0 then _EntSetKeyValue( disp7, "subject", "npc_poisonzombie") _EntSetKeyValue( disp7, "target", "zombieplayer") _EntSetKeyValue( disp7, "disposition", 3) _EntSetKeyValue( disp7, "Radius for subject", 99999) _EntSetKeyValue( disp7, "rank", 99) _EntSetKeyValue( disp7, "Reciprocal", 1) _EntSetPos(disp7, vector3(0, 0, 0)) _EntSpawn(disp7) end disp8 = _EntCreate( "ai_relationship" ) if disp8 > 0 then _EntSetKeyValue( disp8, "subject", "npc_zombie_torso") _EntSetKeyValue( disp8, "target", "zombieplayer") _EntSetKeyValue( disp8, "disposition", 3) _EntSetKeyValue( disp8, "Radius for subject", 99999) _EntSetKeyValue( disp8, "rank", 99) _EntSetKeyValue( disp8, "Reciprocal", 1) _EntSetPos(disp8, vector3(0, 0, 0)) _EntSpawn(disp8) end end function ApplyDisp() _EntFire(disp1, "ApplyRelationship", "", 0) _EntFire(disp2, "ApplyRelationship", "", 0.1) _EntFire(disp3, "ApplyRelationship", "", 0.2) _EntFire(disp4, "ApplyRelationship", "", 0.3) _EntFire(disp5, "ApplyRelationship", "", 0.4) _EntFire(disp6, "ApplyRelationship", "", 0.5) _EntFire(disp7, "ApplyRelationship", "", 0.6) _EntFire(disp8, "ApplyRelationship", "", 0.7) end function PickDefaultSpawnTeam(userid) _PlayerChangeTeam(userid, TEAM_BLUE) return true end function eventPlayerActive(name, userid, steamid) _GModRect_Start( "models/props_lab/Tank_Glass001" ) _GModRect_SetPos(0.0, 0.0, 0.05, 0.05) _GModRect_SetColor(200, 255, 255, 1) _GModRect_SetTime(0.25, 0, 0) _GModRect_SetDelay(1) _GModRect_Send(userid, 1337) if _CurTime() > (RoundTime*60)*HumanDeadline or bLastHuman and EnableDeadline then JoinTheUndead(userid) _PlayerRespawn(userid) end AddTimer(3, 1, Splash, userid) if(TimeDisplay[userid] <= 0) then TimeDisplay[userid] = AddTimer(1, 0, DisplayTime, userid) end CurrentPlayers = CurrentPlayers+1 drawInfliction(userid) end function ArcadeMode() bArcadeMode=true end function EndRound(winner) if bEndRound then return end bEndRound = true RoundEndedAt = _CurTime() AddTimer(IntermissionTime, 1, _StartNextLevel) if winner == 1 then CenterPrintMessageAll("The remaining humans have survived...\nNext round in "..IntermissionTime.." seconds.", 20, 20, 255, 255) _PlaySound(HumanWinMusic) for i=1, _MaxPlayers() do if _PlayerInfo(i, "connected") then if _PlayerInfo(i, "team") == TEAM_BLUE then _PlayerGod(i, true) BottomPrintMessage(i, "You have won the match.", 20, 20, 255, 255) else BottomPrintMessage(i, "You have lost the match.", 255, 20, 20, 255) end end end elseif winner == 2 then local TheWinner = 0 for i=1, _MaxPlayers() do if _PlayerInfo(i, "networkid") == StartingZombieName then TheWinner = i end end if StartingZombieName == "" or TheWinner == 0 then CenterPrintMessageAll("The Undead have conquered...\n Next round in "..IntermissionTime.." seconds.", 255, 0, 0, 255) else CenterPrintMessageAll(" The Undead have conquered.\n".._PlayerInfo(TheWinner, "name").." has spread their evil...\n Next round in "..IntermissionTime.." seconds.", 255, 0, 0, 255) for i=1, _MaxPlayers() do if StartingZombieName ~= _PlayerInfo(i, "networkid") then BottomPrintMessage(i, "You have lost the match.", 255, 20, 20, 255) else BottomPrintMessage(i, "You have won the match.", 20, 20, 255, 255) end end end _PlaySound(ZombieWinMusic) end end function drawInfliction(userid) _GModRect_Start("gmod/white") _GModRect_SetPos(0.4, 0.95, 0.2, 0.1) _GModRect_SetColor(0, 0, 0, 200) _GModRect_SetTime(9999, 0, 0) _GModRect_Send(userid, 899) _GModText_Start("Default") _GModText_SetColor(255, 0, 0, 255) _GModText_SetTime(9999, 0, 0) _GModText_SetText("Infliction") _GModText_SetPos(-1, 0.93) _GModText_Send( userid, 900) _GModRect_Start("gmod/white") _GModRect_SetPos(0.41, 0.96, (InflictionRate)*0.18, 0.05) _GModRect_SetColor( math.floor(InflictionRate*255), 0, math.floor(255-(InflictionRate*255)), 255 ) _GModRect_SetTime(9999, 1, 1) _GModRect_Send(userid, 901) end function drawInflictionAll() drawInfliction(0) end function CalculateInfliction() local PlayerCount=_TeamNumPlayers(TEAM_BLUE) + _TeamNumPlayers(TEAM_GREEN) local ZombieCount=_TeamNumPlayers(TEAM_GREEN) InflictionRate = ZombieCount/PlayerCount if InflictionRate>=1.0 and not bEndRound then EndRound(2) elseif InflictionRate >= 0.5 and not bHalfLife then HalfLife() elseif InflictionRate >= 0.75 and not bQuarterLife then QuarterLife() elseif ZombieCount >= PlayerCount-1 and PlayerCount > 3 and not bLastHuman then LastHuman() end drawInflictionAll() end function CenterPrintMessage(userid, msg, r, g, b, a) _GModRect_Start( "gmod/white" ) _GModRect_SetPos( 0.37, 0.37, 0.325, 0.1 ) _GModRect_SetColor( 0, 0, 0, 100 ) _GModRect_SetTime( 7.5, 1, 1 ) _GModRect_Send( userid, 500 ) _GModText_Start( "Default" ) _GModText_SetPos( 0.39, 0.4 ) _GModText_SetColor( r, g, b, a ) _GModText_SetTime( 7.5, 1, 1 ) _GModText_SetText( msg ) _GModText_Send( userid, 501 ) end function BottomPrintMessage(userid, msg, r, g, b, a) _GModRect_Start( "gmod/white" ) _GModRect_SetPos( 0.37, 0.77, 0.325, 0.1 ) _GModRect_SetColor( 0, 0, 0, 100 ) _GModRect_SetTime( 7.5, 1, 1 ) _GModRect_Send( userid, 520 ) _GModText_Start( "Default" ) _GModText_SetPos( 0.39, 0.8 ) _GModText_SetColor( r, g, b, a ) _GModText_SetTime( 7.5, 1, 1 ) _GModText_SetText( msg ) _GModText_Send( userid, 521 ) end function SidePrintMessage(userid, msg, r, g, b, a) _GModRect_Start( "gmod/white" ) _GModRect_SetPos( 0.77, 0.37, 0.325, 0.1 ) _GModRect_SetColor( 0, 0, 0, 100 ) _GModRect_SetTime( 7.5, 1, 1 ) _GModRect_Send( userid, 520 ) _GModText_Start( "Default" ) _GModText_SetPos( 0.79, 0.4 ) _GModText_SetColor( r, g, b, a ) _GModText_SetTime( 7.5, 1, 1 ) _GModText_SetText( msg ) _GModText_Send( userid, 521 ) end function CenterPrintMessageAll(msg, r, g, b, a) CenterPrintMessage(0, msg, r, g, b, a) end function BottomPrintMessageAll(msg, r, g, b, a) BottomPrintMessage(0, msg, r, g, b, a) end function SidePrintMessageAll(msg, r, g, b, a) SidePrintMessage(0, msg, r, g, b, a) end function GiveDefaultItems(playerid) _player.ShouldDropWeapon(playerid, false) if PlayerInfo[playerid].isUndead < 1 then _PlayerGiveSWEP( playerid, "weapons/zombiesurvival/weapon_swissarmyknife.lua" ) _PlayerGiveSWEP( playerid, "weapons/zombiesurvival/weapon_battleaxe.lua" ) elseif PlayerInfo[playerid].isUndead > 0 and PlayerInfo[playerid].Class == "zombie" then _PlayerGiveSWEP( playerid, "weapons/zombiesurvival/weapon_zombieknife.lua" ) elseif(PlayerInfo[playerid].Class == "fastzombie") then _PlayerGiveSWEP( playerid, "weapons/zombiesurvival/weapon_fastzombieknife.lua" ) elseif(PlayerInfo[playerid].Class == "poisonzombie") then _PlayerGiveSWEP( playerid, "weapons/zombiesurvival/weapon_poisonzombieknife.lua" ) elseif(PlayerInfo[playerid].Class == "headcrab") then _PlayerGiveSWEP( playerid, "weapons/zombiesurvival/weapon_headcrabknife.lua" ) elseif(PlayerInfo[playerid].Class == "fastheadcrab") then _PlayerGiveSWEP( playerid, "weapons/zombiesurvival/weapon_headcrabknife.lua" ) elseif(PlayerInfo[playerid].Class == "poisonheadcrab") then _PlayerGiveSWEP( playerid, "weapons/zombiesurvival/weapon_headcrabknife.lua" ) end end function CheckGiveWeapon( playerid ) if PlayerInfo[playerid].isUndead == 1 or bArcadeMode then return end if _PlayerInfo(playerid,"kills") == 10 then _PlayerGiveSWEP( playerid, "weapons/zombiesurvival/weapon_deagle.lua" ) elseif _PlayerInfo(playerid,"kills") == 30 then _PlayerGiveSWEP( playerid, "weapons/zombiesurvival/weapon_uzi.lua" ) elseif _PlayerInfo(playerid,"kills") == 50 then _PlayerGiveSWEP( playerid, "weapons/zombiesurvival/weapon_sweepershotgunmk2.lua" ) elseif _PlayerInfo(playerid,"kills") == 75 then _PlayerGiveSWEP( playerid, "weapons/zombiesurvival/weapon_rifle.lua" ) elseif _PlayerInfo(playerid,"kills") == 100 then _PlayerGiveSWEP( playerid, "weapons/zombiesurvival/weapon_ak47.lua" ) elseif _PlayerInfo(playerid,"kills") == 130 then _PlayerGiveItem( playerid, "weapon_physcannon" ) elseif _PlayerInfo(playerid,"kills") == 150 then _PlayerGiveSWEP( playerid, "weapons/zombiesurvival/weapon_rocketlauncher.lua" ) end end function canPlayerHaveItem(playerid, itemname) if _PlayerInfo(playerid, "team") > TEAM_BLUE then if itemname ~= "weapon_fastzombieknife" and itemname ~= "weapon_poisonzombieknife" and itemname ~= "weapon_zombieknife" and itemname ~= "weapon_headcrabknife" and itemname ~= "weapon_poisonzombieknife" then return false end return true end return true end function gamerulesStartMap() _ServerCommand("exec ZS.cfg\n") PlayerFreezeAll( false ) _TeamSetName( 2, "Survivors" ) _TeamSetName( 4, "The Undead" ) _TeamSetName( 3, "Warning: bad team" ) _TeamSetName( 5, "Warning: bad team" ) _GameSetTargetIDRules(3) --[[_EntPrecacheModel( "models/player/gman_high.mdl" ) _EntPrecacheModel( "models/player/barney.mdl" ) _EntPrecacheModel( "models/player/alyx.mdl") _EntPrecacheModel( "models/player/breen.mdl") _EntPrecacheModel( "models/player/combine_soldier.mdl") _EntPrecacheModel( "models/player/combine_soldier_prisonguard.mdl") _EntPrecacheModel( "models/player/combine_super_soldier.mdl") _EntPrecacheModel( "models/player/eli.mdl") _EntPrecacheModel( "models/player/female_04.mdl") _EntPrecacheModel( "models/player/female_06.mdl") _EntPrecacheModel( "models/player/male_02.mdl") _EntPrecacheModel( "models/player/male_03.mdl") _EntPrecacheModel( "models/player/male_08.mdl") _EntPrecacheModel( "models/player/monk.mdl") _EntPrecacheModel( "models/player/mossman.mdl") _EntPrecacheModel( "models/player/odessa.mdl") _EntPrecacheModel( "models/player/stripped.mdl") _EntPrecacheModel( "models/player/stalker.mdl") _EntPrecacheModel( "models/player/kleiner.mdl") _EntPrecacheModel( "models/player/female_07.mdl") _EntPrecacheModel( "models/player/Police.mdl") ]] _EntPrecacheModel( "models/player/classic.mdl") _EntPrecacheModel( "models/player/corpse1.mdl") _EntPrecacheModel( "models/player/charple01.mdl") _EntPrecacheModel( "models/headcrabclassic.mdl") _EntPrecacheModel( "models/Player/gordon_classic.mdl") -- If a person uses zombie model on spawn _EntPrecacheModel( "models/headcrabblack.mdl" ) _EntPrecacheModel( "models/headcrab.mdl" ) _EntPrecacheModel( "models/weapons/w_knife_t.mdl") _EntPrecacheModel( "models/weapons/v_knife_t.mdl") _EntPrecacheModel( "models/weapons/w_rif_ak47.mdl") _EntPrecacheModel( "models/weapons/v_rif_ak47.mdl") _EntPrecacheModel( "models/weapons/w_alyx_gun.mdl.mdl") _EntPrecacheModel( "models/weapons/v_357.mdl") _EntPrecacheModel( "models/weapons/w_357.mdl") _EntPrecacheModel( "models/weapons/w_pist_deagle.mdl") _EntPrecacheModel( "models/weapons/v_pist_deagle.mdl") _EntPrecacheModel( "models/weapons/w_shot_xm1014.mdl") _EntPrecacheModel( "models/weapons/v_shot_xm1014.mdl") _EntPrecacheModel( "models/weapons/w_rocket_launcher.mdl") _EntPrecacheModel( "models/weapons/v_rpg.mdl") _EntPrecacheModel( "models/weapons/v_shot_m3super90.mdl") _EntPrecacheModel( "models/weapons/w_shot_m3super90.mdl") _EntPrecacheModel( "models/weapons/w_annabelle.mdl") _EntPrecacheModel( "models/weapons/w_smg_mac10.mdl") _EntPrecacheModel( "models/weapons/v_smg_mac10.mdl") if RoundTime > 300 then AddTimer((RoundTime*60)-300, 1, FiveMinuteWarning) end AddTimer(1, 1, SpawnDisp) JoinTheUndeadFirstTimer = AddTimer(20, 0, JoinTheUndeadFirst) AddTimer(RoundTime*60, 1, EndRound, 1) if EXTREMEDIFFICULTY then _ServerCommand("sk_zombie_health 100\n") _ServerCommand("sk_zombie_dmg_both_slash 20\n") _ServerCommand("sk_zombie_dmg_one_slash 15\n") else _ServerCommand("sk_zombie_health 75\n") _ServerCommand("sk_zombie_dmg_both_slash 15\n") _ServerCommand("sk_zombie_dmg_one_slash 10\n") end if not RandomStartZom then bFirstDied = true end CreateResFile() _Msg("- Zombie Survival V3.1 -\n") _Msg(" - By JetBoom -\n") end function CreateResFileString() local str = '"resources"\r\n' .."{\r\n" --..'"sound/'..ZombieWinMusic..'" "file"\r\n' --..'"sound/'..HumanWinMusic..'" "file"\r\n' --..'"sound/'..LastHumanMusic..'" "file"\r\n' --..'"sound/'..HalfLifeMusic..'" "file"\r\n' --..'"sound/'..DeathMusic..'" "file"\r\n' ..'"sound/zombiesurvival/minutes.mp3" "file"\r\n' ..'"sound/zombiesurvival/remaining.mp3" "file"\r\n' ..'"materials/zombiesurvival/zssplash_v3.vmt" "file"\r\n' ..'"materials/zombiesurvival/zssplash_v3.vtf" "file"\r\n' ..'"materials/zombiesurvival/zsicon.vmt" "file"\r\n' ..'"materials/zombiesurvival/zsicon.vtf" "file"\r\n' ..'"materials/deathnotify/d_brains.vmt" "file"\r\n' ..'"materials/deathnotify/d_brains.vtf" "file"\r\n' .."}" return str end function CreateResFile() _file.Write("maps/".._GetCurrentMap()..".res", CreateResFileString()) end function FiveMinuteWarning() BottomPrintMessageAll(" - 5 Minute Warning -", 255, 20, 50, 200) _PlaySound("HL1/fvox/five.wav") AddTimer(0.8, 1, _PlaySound, "zombiesurvival/minutes.mp3") AddTimer(1.53, 1, _PlaySound, "zombiesurvival/remaining.mp3") end function PlayerSpawnChooseModel ( playerid ) if _PlayerPreferredModel( playerid ) == "" then if _EntGetModel(playerid) == DEFAULT_PLAYER_MODEL then _PlayerSetModel( playerid, _PlayerGetRandomAllowedModel() ) end else _PlayerSetModel( playerid, _PlayerPreferredModel( playerid ) ) end if(PlayerInfo[playerid].isUndead == 1 and PlayerInfo[playerid].Class == "zombie") then _PlayerSetModel( playerid, "models/Player/classic.mdl") elseif(PlayerInfo[playerid].Class == "fastzombie") then _PlayerSetModel( playerid, "models/Player/corpse1.mdl") elseif(PlayerInfo[playerid].Class == "poisonzombie") then _PlayerSetModel( playerid, "models/Player/charple01.mdl") elseif(PlayerInfo[playerid].Class == "headcrab") then _EntSetModel( playerid, "models/headcrabclassic.mdl") elseif(PlayerInfo[playerid].Class == "fastheadcrab") then _EntSetModel( playerid, "models/headcrab.mdl") elseif(PlayerInfo[playerid].Class == "poisonheadcrab") then _EntSetModel( playerid, "models/headcrabblack.mdl") end if(_PlayerInfo(playerid, "model") == "models/Player/classic.mdl" and PlayerInfo[playerid].isUndead == 0) then _PlayerSetModel( playerid, "models/Player/gordon_classic.mdl") end if(_PlayerInfo(playerid, "model") == "models/Player/corpse1.mdl" and PlayerInfo[playerid].Class ~= "fastzombie") then _PlayerSetModel( playerid, "models/Player/gordon_classic.mdl") end if(_PlayerInfo(playerid, "model") == "models/Player/charple01.mdl" and PlayerInfo[playerid].Class ~= "poisonzombie") then _PlayerSetModel( playerid, "models/Player/gordon_classic.mdl") end end function eventPlayerDisconnect(name, userid, address, steamid, reason) if _PlayerInfo(userid, "connected") then PlayerInfo[userid].isUndead = 0 PlayerInfo[userid].Class = "zombie" PlayerInfo[userid].LastChange = 0 CalculateInfliction() end HaltTimer(TimeDisplay[userid]) end function SecondWind(userid) local lastvec = _EntGetPos(userid) AddTimer(2.0, 1, _PlayerRespawn, userid) AddTimer(2.05, 1, _EntFire, userid, "sethealth", "25", 0) AddTimer(2.05, 1, _EntSetPos, userid, lastvec) AddTimer(2.1, 1, _EntSetVelocity, userid, vector3(0,0,0)) AddTimer(2.05, 1, _EntEmitSound, userid, "npc/zombie/zombie_voice_idle"..math.random( 1, 14 )..".wav") end function eventPlayerKilled(killed, attacker, weapon) _PlayerAddDeath( killed, 1 ) local secondw = false if not bEndRound then if PlayerInfo[killed].isUndead == 1 then if PlayerInfo[killed].Class == "zombie" then _EntEmitSound(killed, "npc/zombie/zombie_die"..math.random( 1, 3 )..".wav") if EXTREMEDIFFICULTY then if _player.LastHitGroup(killed) > HITGROUP_HEAD and attacker <= _MaxPlayers() and attacker ~= killed and weapon ~= "sweepershotgunmk2" and bFirstDied and attacker > 0 and weapon ~= "frag" then SecondWind(killed) secondw = true end end elseif PlayerInfo[killed].Class == "fastzombie" then _EntEmitSound(killed, "npc/fast_zombie/fz_alert_close1.wav") elseif PlayerInfo[killed].Class == "poisonzombie" then _EntEmitSound(killed, "npc/zombie_poison/pz_die"..math.random(1,2)..".wav") elseif PlayerInfo[killed].Class == "headcrab" or PlayerInfo[killed].Class == "fastheadcrab" then _EntEmitSound(killed, "npc/headcrab/die"..math.random(1,2)..".wav") elseif PlayerInfo[killed].Class == "poisonheadcrab" then _EntEmitSound(killed, "npc/headcrab_poison/ph_rattle"..math.random(1,3)..".wav") end if not secondw then _PlayerAddScore( attacker, 1 ) if attacker <= _MaxPlayers() then drawScore(attacker) CheckGiveWeapon( attacker ) end end elseif PlayerInfo[killed].isUndead == 0 then _PlaySound("npc/stalker/go_alert2a.wav") JoinTheUndead( killed ) _PlayerSetScore( killed, 0 ) for i=1, _MaxPlayers() do if _PlayerInfo(i, "connected") and PlayerInfo[i].isUndead == 1 then StartingZombieName = _PlayerInfo(i, "networkid") break end end end end bFirstDied = true end function HalfLife() _PlaySound(HalfLifeMusic) bHalfLife = true BottomPrintMessageAll("'Half-Life' has been reached!\n 50% Infliction Rate\n Undead Benefits Unlocked!", 255, 255, 255, 200) end function QuarterLife() bQuarterLife = true BottomPrintMessageAll("'Quarter-Life' has been reached!\n 75% Infliction Rate\n More Benefits Unlocked!", 255, 255, 255, 200) end function LastHuman() _PlaySound(LastHumanMusic) bLastHuman = true for i=1, _MaxPlayers() do if _PlayerInfo(i, "connected") then if _PlayerInfo(i, "team") == TEAM_GREEN then BottomPrintMessage(i, "Kill the last human!", 255, 255, 255, 255) elseif _PlayerInfo(i, "team") == TEAM_BLUE then BottomPrintMessage(i, "You are the last human alive!\n R U N ! !", 255, 255, 255, 255) LastHumanName=_PlayerInfo(i, "name") end end end end function JoinTheUndead( playerid ) _PlayerSetModel( playerid, "models/player/classic.mdl") PlayerInfo[playerid].isUndead=1 _PlayerChangeTeam(playerid, 4) CenterPrintMessage(playerid, "You are dead.", 255, 0, 0, 200) _PlaySoundPlayer(playerid, DeathMusic) DrawUndeadOverlay(playerid) CalculateInfliction() end function JoinTheUndeadFirst() if _TeamNumPlayers(TEAM_GREEN) + _TeamNumPlayers(TEAM_BLUE) < 4 then return end local playerid = 0 while not bFirstDied do playerid = math.random(1, _MaxPlayers()) if _PlayerInfo(playerid, "connected") then _PlayerSetModel( playerid, "models/player/classic.mdl") PlayerInfo[playerid].isUndead=1 _PlayerChangeTeam(playerid, 4) CenterPrintMessage(playerid, "You have been randomly selected\n to be The Undead first!", 255, 0, 0, 200) DrawUndeadOverlay(playerid) StartingZombieName=_PlayerInfo(playerid, "networkid") _PlayerKill( playerid ) bFirstDied = true end end HaltTimer(JoinTheUndeadFirstTimer) end function PlayerSetMaxSpeed(userid, speed) AddTimer(0.1, 1, _PlayerSetMaxSpeed, userid, speed) end function eventPlayerSpawn ( userid ) AddTimer(0.1, 1, _PlayerEnableSprint, userid, false) if PlayerInfo[userid].isUndead > 0 then ApplyDisp() if PlayerInfo[userid].Class == "zombie" then _PlayerSetHealth(userid, 150) DrawUndeadOverlay(userid) _PlayerSetModel( userid, "models/Player/classic.mdl") _PlayerChangeTeam(userid, 4) _EntSetName(userid, "zombieplayer") _EntSetMaxHealth(userid, 1) _PlayerSetVecView(userid, vector3(0, 0, 64)) _PlayerSetVecDuck(userid, vector3(0, 0, 24)) if EXTREMEDIFFICULTY then PlayerSetMaxSpeed(userid, 130) else PlayerSetMaxSpeed(userid, 125) end elseif PlayerInfo[userid].Class == "fastzombie" then _PlayerSetHealth(userid, 75) DrawUndeadOverlay(userid) _PlayerSetModel( userid, "models/Player/corpse1.mdl") _PlayerChangeTeam(userid, 4) _EntSetName(userid, "zombieplayer") _EntSetMaxHealth(userid, 1) _PlayerSetVecView(userid, vector3(0, 0, 64)) _PlayerSetVecDuck(userid, vector3(0, 0, 24)) PlayerSetMaxSpeed(userid, 220) elseif PlayerInfo[userid].Class == "poisonzombie" then _PlayerSetHealth(userid, 225) DrawUndeadOverlay(userid) _PlayerSetModel( userid, "models/Player/charple01.mdl") _PlayerChangeTeam(userid, 4) _EntSetName(userid, "zombieplayer") _EntSetMaxHealth(userid, 1) _PlayerSetVecView(userid, vector3(0, 0, 64)) _PlayerSetVecDuck(userid, vector3(0, 0, 24)) if EXTREMEDIFFICULTY then PlayerSetMaxSpeed(userid, 115) else PlayerSetMaxSpeed(userid, 100) end elseif PlayerInfo[userid].Class == "headcrab" then _PlayerSetHealth(userid, 25) DrawUndeadOverlay(userid) _EntSetModel( userid, "models/headcrabclassic.mdl") _PlayerChangeTeam(userid, 4) _EntSetName(userid, "zombieplayer") _EntSetMaxHealth(userid, 1) _PlayerSetVecView(userid, vector3(0, 0, 20)) _PlayerSetVecDuck(userid, vector3(0, 0, 20)) if EXTREMEDIFFICULTY then PlayerSetMaxSpeed(userid, 155) else PlayerSetMaxSpeed(userid, 145) end elseif PlayerInfo[userid].Class == "fastheadcrab" then _PlayerSetHealth(userid, 25) DrawUndeadOverlay(userid) _EntSetModel( userid, "models/headcrab.mdl") _PlayerChangeTeam(userid, 4) _EntSetName(userid, "zombieplayer") _EntSetMaxHealth(userid, 1) _PlayerSetVecView(userid, vector3(0, 0, 20)) _PlayerSetVecDuck(userid, vector3(0, 0, 20)) if EXTREMEDIFFICULTY then PlayerSetMaxSpeed(userid, 250) else PlayerSetMaxSpeed(userid, 225) end end end if PlayerInfo[userid].isUndead < 1 then _PlayerChangeTeam(userid, TEAM_BLUE) _PlayerSetDrawViewModel(userid, true) else _PlayerSetDrawViewModel(userid, false) end drawScore(userid) end function DrawUndeadOverlay( userid ) _GModRect_Start( "gmod/scope" ) _GModRect_SetPos( 0, 0, 1, 1 ) _GModRect_SetColor( 255, 200, 180, 100 ) _GModRect_SetTime( 9999, 0, 0 ) _GModRect_Send( userid, 22 ) end function drawScore(userid) if PlayerInfo[userid].isUndead == 1 then _GModRect_Hide( userid, 101 ) return end _GModText_Start("ImpactMassive") _GModText_SetPos(0.025, 0.80) _GModText_SetColor(255, 0, 0, 255) _GModText_SetTime(99999, 0, 0) _GModText_SetText(_PlayerInfo(userid,"kills").." kills") _GModText_Send(userid, 101) end function eventNPCKilled ( killerid, killed ) if _PlayerInfo(killerid, "alive") and PlayerInfo[killerid].isUndead == 0 then _PlayerAddScore( killerid, 1 ) CheckGiveWeapon( killerid ) drawScore( killerid ) end end function Splash( userid ) _GModRect_Start( "zombiesurvival/zssplash_v3" ) _GModRect_SetPos( 0.21, 0.095, 0.6, 0.35 ) _GModRect_SetColor( 255, 255, 255, 210 ) _GModRect_SetTime( 10, 1, 1 ) _GModRect_Send( userid, 245 ) _GModRect_Start( "zombiesurvival/zsicon" ) _GModRect_SetPos( 0.475, 0.015, 0.075, 0.05 ) _GModRect_SetColor( 255, 255, 255, 200 ) _GModRect_SetTime( 9999, 2, 2 ) _GModRect_Send( userid, 955 ) _GModText_Start( "Default" ) _GModText_SetPos( -1.0, 0.4 ) _GModText_SetColor( 255, 255, 255, 255 ) _GModText_SetTime( 10, 1, 1 ) if EXTREMEDIFFICULTY then _GModText_SetText("Extreme Difficulty: ON") else _GModText_SetText("Extreme Difficulty: OFF") end _GModText_Send( userid, 246 ) end function onShowHelp ( userid ) _GModRect_Start( "gmod/white" ) _GModRect_SetPos( 0.2, 0.3, 0.0, 0.0 ) _GModRect_SetColor( 0, 0, 0, 100 ) _GModRect_SetTime( 15, 0, 1 ) _GModRect_Send( userid, 50 ) _GModRect_Start( "gmod/white" ) _GModRect_SetPos( 0.198, 0.298, 0.604, 0.154 ) _GModRect_SetColor( 0, 0, 0, 150 ) _GModRect_SetTime( 15, 0, 1 ) _GModRect_SendAnimate( userid, 50, 1, 0.2 ) _GModRect_Start( "gmod/white" ) _GModRect_SetPos( 0.2, 0.3, 0.0, 0.0 ) _GModRect_SetColor( 0, 0, 0, 10 ) _GModRect_SetTime( 15, 0, 1 ) _GModRect_Send( userid, 51 ) _GModRect_Start( "gmod/white" ) _GModRect_SetPos( 0.2, 0.3, 0.6, 0.15 ) _GModRect_SetColor( 0, 0, 0, 50 ) _GModRect_SetTime( 15, 0, 1 ) _GModRect_SendAnimate( userid, 51, 1, 0.2 ) if PlayerInfo[userid].isUndead == 0 then _GModText_Start( "Default" ) _GModText_SetPos( 0.21, 0.36 ) _GModText_SetColor( 255, 255, 255, 0 ) _GModText_SetTime( 15, 1, 1 ) _GModText_SetText( "Kill the undead to increase your score. You get weapons at certain score levels.\nDie and you will become an Undead! Humans must survive for the time set to win!" ) _GModText_Send( userid, 50 ) else _GModText_Start( "Default" ) _GModText_SetPos( 0.21, 0.36 ) _GModText_SetColor( 255, 255, 255, 0 ) _GModText_SetTime( 15, 1, 1 ) _GModText_SetText( "You are part of The Undead. Kill all of the remaining humans to win the round.\nYou may die as many times as it takes, but do it before the time limit! \n F4=Class Change") _GModText_Send( userid, 50 ) end _GModText_Start( "Default" ) _GModText_SetPos( 0.21, 0.36 ) _GModText_SetColor( 255, 255, 255, 255 ) _GModText_SetTime( 15, 1, 1 ) _GModText_SendAnimate( userid, 50, 2, 0.2 ) _GModText_Start( "ImpactMassive" ) _GModText_SetPos( 0.41, 0.295 ) _GModText_SetColor( 255, 255, 255, 0 ) _GModText_SetTime( 15, 1, 1 ) _GModText_SetText( "[HELP]" ) _GModText_Send( userid, 51 ) _GModText_Start( "ImpactMassive" ) _GModText_SetPos( 0.41, 0.295 ) _GModText_SetColor( 255, 255, 255, 255 ) _GModText_SetTime( 15, 1, 1 ) _GModText_SendAnimate( userid, 51, 2, 0.2 ) end function onShowTeam ( userid ) if PlayerInfo[userid].isUndead < 1 then CenterPrintMessage(userid, "Killing yourself might just work...", 255, 255, 255, 200) else CenterPrintMessage(userid, "You'll havto wait till next round...", 255, 255, 255, 200) end end function onShowSpare2(userid) if PlayerInfo[userid].isUndead == 0 then BottomPrintMessage(userid, "This button is for Undead only.", 255, 255, 255, 200) return end if _CurTime() < PlayerInfo[userid].LastChange+60.0 then CenterPrintMessage(userid, "You must wait a moment \n before switching classes!", 255, 255, 255, 200) return end DisplayClassMenu(userid) end function DisplayClassMenu(userid) _PlayerOption(userid, "ChooseClass", 99999) _GModRect_Start( "gmod/white" ) _GModRect_SetPos( 0.77, 0.37, 0.325, 0.25 ) _GModRect_SetColor( 0, 0, 0, 100 ) _GModRect_SetTime( 7.5, 1, 1 ) _GModRect_Send( userid, 750 ) if not bHalfLife then _GModText_Start( "Default" ) _GModText_SetPos( 0.79, 0.4 ) _GModText_SetColor( 255, 255, 255, 255 ) _GModText_SetTime( 7.5, 1, 1 ) _GModText_SetText( "Choose a Class:\n1. Zombie\n2. Headcrab\n\n3. Cancel" ) _GModText_Send( userid, 751 ) return end if bHalfLife and not bQuarterLife then _GModText_Start( "Default" ) _GModText_SetPos( 0.79, 0.4 ) _GModText_SetColor( 255, 255, 255, 255 ) _GModText_SetTime( 7.5, 1, 1 ) _GModText_SetText( "Choose a Class:\n1. Zombie\n2. Fast Zombie\n3. Headcrab\n4. Fast Headcrab\n\n5. Cancel" ) _GModText_Send( userid, 751 ) return end if bHalfLife and bQuarterLife then _GModText_Start( "Default" ) _GModText_SetPos( 0.79, 0.4 ) _GModText_SetColor( 255, 255, 255, 255 ) _GModText_SetTime( 7.5, 1, 1 ) _GModText_SetText( "Choose a Class:\n1. Zombie\n2. Fast Zombie\n3. Poison Zombie\n4. Headcrab\n5. Fast Headcrab\n\n6. Cancel" ) _GModText_Send( userid, 751 ) return end end function ChooseClass(playerid, num, seconds) _GModRect_Hide(playerid, 750, 0.25) _GModText_Hide(playerid, 751, 0.25) if not bHalfLife then if num == 1 and PlayerInfo[playerid].Class ~= "zombie" then CenterPrintMessage(playerid, "You are now a normal Zombie...\n 2nd Fire: Zombie cry", 255, 255, 255, 200) PlayerInfo[playerid].Class = "zombie" _PlayerSilentKill( playerid, 2, true ) PlayerInfo[playerid].LastChange = _CurTime() return elseif num == 2 and PlayerInfo[playerid].Class ~= "headcrab" then CenterPrintMessage(playerid, "You are now a Headcrab...\n 2nd Fire: Headcrab hop", 255, 255, 255, 200) PlayerInfo[playerid].Class = "headcrab" _PlayerSilentKill( playerid, 2, true ) PlayerInfo[playerid].LastChange = _CurTime() return end elseif bHalfLife and not bQuarterLife then if num == 1 and PlayerInfo[playerid].Class ~= "zombie" then CenterPrintMessage(playerid, "You are now a normal Zombie...\n 2nd Fire: Zombie cry", 255, 255, 255, 200) PlayerInfo[playerid].Class = "zombie" _PlayerSilentKill( playerid, 2, true ) PlayerInfo[playerid].LastChange = _CurTime() return elseif(num == 2 and PlayerInfo[playerid].Class ~= "fastzombie") then CenterPrintMessage(playerid, "You are now a Fast Zombie...\n 2nd Fire: Zombie leap 2nd Fire on Wall: Climb", 255, 255, 255, 200) PlayerInfo[playerid].Class = "fastzombie" _PlayerSilentKill( playerid, 2, true ) PlayerInfo[playerid].LastChange = _CurTime() return elseif(num == 3 and PlayerInfo[playerid].Class ~= "headcrab") then CenterPrintMessage(playerid, "You are now a Headcrab...\n 2nd Fire: Headcrab hop", 255, 255, 255, 200) PlayerInfo[playerid].Class = "headcrab" _PlayerSilentKill( playerid, 2, true ) PlayerInfo[playerid].LastChange = _CurTime() return elseif(num == 4 and PlayerInfo[playerid].Class ~= "fastheadcrab") then CenterPrintMessage(playerid, "You are now a Fast Headcrab...\n 2nd Fire: Headcrab hop", 255, 255, 255, 200) PlayerInfo[playerid].Class = "fastheadcrab" _PlayerSilentKill( playerid, 2, true ) PlayerInfo[playerid].LastChange = _CurTime() return end elseif bHalfLife and bQuarterLife then if(num == 1 and PlayerInfo[playerid].Class ~= "zombie") then CenterPrintMessage(playerid, "You are now a Zombie...\n 2nd Fire: Zombie cry", 255, 255, 255, 200) PlayerInfo[playerid].Class = "zombie" _PlayerSilentKill( playerid, 2, true ) PlayerInfo[playerid].LastChange = _CurTime() return elseif(num == 2 and PlayerInfo[playerid].Class ~= "fastzombie") then CenterPrintMessage(playerid, "You are now a Fast Zombie...\n 2nd Fire: Zombie leap 2nd Fire on Wall: Climb", 255, 255, 255, 200) PlayerInfo[playerid].Class = "fastzombie" _PlayerSilentKill( playerid, 2, true ) PlayerInfo[playerid].LastChange = _CurTime() return elseif num == 3 and PlayerInfo[playerid].Class ~= "poisonzombie" then CenterPrintMessage(playerid, "You are now a Poison Zombie...\n 2nd Fire: Throw headcrab", 255, 255, 255, 200) PlayerInfo[playerid].Class = "poisonzombie" _PlayerSilentKill( playerid, 2, true ) PlayerInfo[playerid].LastChange = _CurTime() return elseif num == 4 and PlayerInfo[playerid].Class ~= "headcrab" then CenterPrintMessage(playerid, "You are now a Headcrab...\n 2nd Fire: Headcrab hop", 255, 255, 255, 200) PlayerInfo[playerid].Class = "headcrab" _PlayerSilentKill( playerid, 2, true ) PlayerInfo[playerid].LastChange = _CurTime() return elseif num == 5 and PlayerInfo[playerid].Class ~= "fastheadcrab" then CenterPrintMessage(playerid, "You are now a Fast Headcrab...\n 2nd Fire: Headcrab hop", 255, 255, 255, 200) PlayerInfo[playerid].Class = "fastheadcrab" _PlayerSilentKill( playerid, 2, true ) PlayerInfo[playerid].LastChange = _CurTime() return end end end function DisplayTime( userid ) if _PlayerInfo(userid, "connected") then local msg = "" if PlayerInfo[userid].isUndead==1 then msg = "Kill Humans" else msg = "Survive" end _GModRect_Start( "gmod/white" ) _GModRect_SetPos( 0.023, 0.023, 0.13, 0.03 ) _GModRect_SetColor( 0, 0, 0, 100 ) _GModRect_SetTime( 3, 0, 0 ) _GModRect_Send( userid, 665 ) if not bEndRound then _GModText_Start( "Default" ) _GModText_SetPos( 0.025, 0.025 ) _GModText_SetColor( 0, 255, 0, 255 ) _GModText_SetTime( 9999, 0, 0 ) _GModText_SetText( msg..": "..ToMinutesSeconds(RoundTime*60-_CurTime())) _GModText_Send( userid, 666 ) else _GModText_Start( "Default" ) _GModText_SetPos( 0.025, 0.025 ) _GModText_SetColor( 0, 255, 0, 255 ) _GModText_SetTime( 9999, 0, 0 ) _GModText_SetText( "Next Round: "..ToMinutesSeconds(RoundEndedAt+IntermissionTime-_CurTime())) _GModText_Send( userid, 666 ) end end end function ThrowHeadCrab(userid) AddTimer(2.0, 1, DoThrowHeadCrab, userid) end function DoThrowHeadCrab(userid) if PlayerInfo[userid].isUndead == 0 or PlayerInfo[userid].Class ~= "poisonzombie" or not _PlayerInfo(userid, "alive") then return end _EntEmitSound(userid, "npc/headcrab_poison/ph_jump"..math.random(1,3)..".wav") local headcrab = _EntCreate( "npc_headcrab_black") if headcrab > 0 then local angle = _PlayerGetShootAng(userid) angle.z = 0 local pos = _PlayerGetShootPos(userid) pos.z = pos.z+5 _EntSetPos(headcrab, vecAdd(pos, vecMul(angle, vector3(55,55,55)))) _EntSetAng(headcrab, _EntGetAng(userid)) local fireforce = vecMul(_PlayerGetShootAng(userid), vector3(600, 600, 600*1.25)) _EntSpawn(headcrab) _EntSetVelocity(headcrab, fireforce) ApplyDisp() end end function PlayerUnlock(userid) AddTimer(2.5, 1, _PlayerLockInPlace, userid, false) end