-- Area51 Attack v1 [coded by: Alpha Team] -- Members: [TDH]Boss, Au{R}oN team1Name = "Defence Team" team2Name = "Attack Team" DefenceSpawns = { {"270.93069458008", "1859.2591552734", "9.3328037261963", "358.70962524414"}, {"274.20526123047", "1869.39550781252", "9.318675994873", "358.81970214844"}, {"297.66668701172", "1846.2193603516", "8.2936549186707", "358.71731567383"}, {"246.67984008789", "1859.6311035156", "14.655439376831", "358.95761108398"} } AttackSpawns = { {"-1384.2723388672", "506.41329956055", "4.0390625", "46.67303466796"}, {"-1361.82421875", "502.85372924805", "12.1953125", "43.505950927734"}, {"-1318.5229492188", "493.16229248047", "19.234375", "86.401550292969"}, {"-1346.9020996094", "493.81335449219", "12.202690124512", "252.5794219970"} } Weapons = { {"3", "1"}, {"24", "250"}, {"25", "400"}, {"31", "500"}, {"45", "1"} } DefenceSkins = { "163", "164", "276", "71" } AttackSkins = { "254", "103", "242", "116" } function spawnAsDefence(source,key,keystate) -- randomSP = randInt(1,#DefenceSpawns) randomSK = randInt(1,#DefenceSkins) -- spawnPlayer(source,DefenceSpawns[randomSP][1],DefenceSpawns[randomSP][2],DefenceSpawns[randomSP][3],DefenceSpawns[randomSP][4],DefenceSkins[randomSK]) setCameraMode(source,"player") addPlayerToTeam(source,DEFENCE_TEAM) end function spawnAsAttack(source,key,keystate) -- randomSP = randInt(1,#AttackSpawns) randomSK = randInt(1,#AttackSkins) -- spawnPlayer(source,AttackSpawns[randomSP][1],AttackSpawns[randomSP][2],AttackSpawns[randomSP][3],AttackSpawns[randomSP][4],AttackSkins[randomSK]) setCameraMode(source,"player") addPlayerToTeam(source,ATTACK_TEAM) end function selTeam(player) setElementPosition(player,0,0,0) spawnScreen(player) end function spawnScreen(source) spawnPlayer(source,210.99076843262, 1927.8041992188, 19.2421875, 180.181503295) textDisplayAddObserver(spawnDisplay,source) setCameraMode(source,"fixed") setTimer(setCameraPosition, 1000,1,source,214.07446289063,1902.7843017578,17.640625) setTimer(setCameraLookAt, 1000,1,source,213.81455993652,1875.5883789063,13.14695930481) bindKey(source,"F1","down","Spawn Defence",spawnAsDefence) bindKey(source,"F2","down","Spawn Attack",spawnAsAttack) bindKey(source,"F3","down","Choose Team",selTeam) hudDisplay(source,false) end function onArea51Start(name) if name == getThisResource() then --startResource("site",false) --startResource("damage",false) createBlip(274.79473876953, 1881.7620849609, -28.80006980896, 23, 2, 0, 0, 0, 255) createBlip(-1287.5788574219, 492.76049804688, 11.1953125, 23, 2, 0, 0, 0, 255) DEFENCE_TEAM = createTeam(team1Name) ATTACK_TEAM = createTeam(team2Name) checkA = createMarker ( 273.13500976563, 1881.8089599609, -30.390625, "cylinder", 3, 0, 255, 0, 100 ) addEventHandler("onPlayerMarkerHit", checkA, markHit) --Fixed by AlienX SpawnGameText() statusDisplay = textCreateDisplay() outputChatBox("Current gamemode: Area 51 Attack v1",255, 140, 0) outputChatBox("[coded by: [TDH]Boss, Au{R}oN]-",255, 140, 0) for index,player in ipairs(getElementsByType("player")) do fadeCamera(player,false,1.0,0,0,0) setTimer(fadeCamera,1000,1,player,true,1) setTimer(spawnScreen,1000,1,player) textDisplayAddObserver(statusDisplay,player) end end end function onPlayerJoin () fadeCamera(source,false,1.0,0,0,0) setTimer(fadeCamera,2000,1,source,true,1) setTimer(spawnScreen,2000,1,source) textDisplayAddObserver(statusDisplay,source) end function onPlayerQuit () unbindKey(source,"F1","down",spawnAsDefence) unbindKey(source,"F2","down",spawnAsAttack) unbindKey(source,"F2","down",selTeam) destroyBlipsAttachedTo(source) removePlayerFromTeam(source) end function SpawnGameText() spawnDisplay = textCreateDisplay () local stext = textCreateTextItem("Select your spawn", 0.502, 0.302, "low", 250, 0, 0, 255, 1.8) local stext2 = textCreateTextItem("Press F1 to spawn in the " ..team1Name.. "", 0.501, 0.501, "low", 250, 0, 0, 255, 1) local stext3 = textCreateTextItem("Press F2 to spawn in the " ..team2Name.. "", 0.501, 0.551, "low", 250, 0, 0, 255, 1) local stext4 = textCreateTextItem("Press F3 to return to the spawn screen", 0.501, 0.601, "low", 250, 0, 0, 255, 1) textDisplayAddText(spawnDisplay,stext) textDisplayAddText(spawnDisplay,stext2) textDisplayAddText(spawnDisplay,stext3) textDisplayAddText(spawnDisplay,stext4) end function onPlayerWasted( ammo, attacker, weapon, bodypart ) if (getElementData( source, "couldRespawn" ) == true) then setElementData( source, "couldRespawn", false ) else local team = getPlayerTeam( source ) if (team == DEFENCE_TEAM) then setCameraMode( source, "fixed" ) setTimer("wait", 1000, 1, source, true, 1 ) hudDisplay( source, false ) setTimer("respawnDefense", 5000, 1, source, true, 1 ) elseif (team == ATTACK_TEAM) then outputChatBox( "ok2" ) end end end function wait( source ) outputChatBox( "wait" ) spawnzDisplay = textCreateDisplay () local sstext = textCreateTextItem ( "10 secs until respawn..", 0.502, 0.302, "low", 0, 0, 0, 255, 1.8 ) local ttext = textCreateTextItem ( "10 secs until respawn..", 0.5, 0.3, "low", 255, 255, 255, 255, 1.8 ) textDisplayAddText ( spawnzDisplay, sstext ) textDisplayAddText ( spawnzDisplay, ttext ) setCameraPosition( source, 214.07446289063, 1902.7843017578, 17.640625 ) setCameraLookAt( source, 213.81455993652, 1875.5883789063, 13.14695930481 ) end function respawnDefense(source) spawnAsDefence(source) end function onPlayerSpawn(spawnpoint,team) textDisplayRemoveObserver(spawnDisplay,source) textDestroyDisplay(spawnDisplay) local team = getPlayerTeam(source) giveWeapon(source,Weapons[1][1],Weapons[1][2]) giveWeapon(source,Weapons[2][1],Weapons[2][2]) giveWeapon(source,Weapons[3][1],Weapons[3][2]) giveWeapon(source,Weapons[4][1],Weapons[4][2]) giveWeapon(source,Weapons[5][1],Weapons[5][2]) unbindKey(source,"F1","down",spawnAsDefence) unbindKey(source,"F2","down",spawnAsAttack) unbindKey(source,"F3","down",selTeam) hudDisplay(source,true) end function hudDisplay ( player, bool ) showPlayerHudComponent ( player, "ammo", bool ) showPlayerHudComponent ( player, "area_name", bool ) showPlayerHudComponent ( player, "armour", bool ) showPlayerHudComponent ( player, "breath", bool ) showPlayerHudComponent ( player, "health", bool ) showPlayerHudComponent ( player, "money", bool ) showPlayerHudComponent ( player, "radar", bool ) showPlayerHudComponent ( player, "vehicle_name", bool ) showPlayerHudComponent ( player, "weapon", bool ) end function showTextForAll ( time, red, green, blue, scale, text, vertical ) if (vertical == nil) then local vertical = 0.3 end local textDisplay = textCreateDisplay () local textItem = textCreateTextItem ( text, 0.5, vertical, 2, red, green, blue, 255, scale ) textDisplayAddText ( textDisplay, textItem ) for k,v in ipairs(getElementsByType("player")) do textDisplayAddObserver ( textDisplay, v ) end setTimer("textDestroyTextItem", time, 1, textItem) setTimer("textDestroyDisplay", time, 1, textDisplay) end function markHit(player) outputChatBox("mark ok") end addEventHandler("onResourceStart",getRootElement(),onArea51Start) addEventHandler("onPlayerJoin",getRootElement(),onPlayerJoin) addEventHandler("onPlayerQuit",getRootElement(),onPlayerQuit) addEventHandler("onPlayerWasted",getRootElement(),onPlayerWasted) addEventHandler("onPlayerSpawn",getRootElement(),onPlayerSpawn)