diff --git a/[gamemodes]/[stealth]/stealth/ricochet1.mp3 b/[gamemodes]/[stealth]/stealth/client/audio/ricochet1.mp3
similarity index 100%
rename from [gamemodes]/[stealth]/stealth/ricochet1.mp3
rename to [gamemodes]/[stealth]/stealth/client/audio/ricochet1.mp3
diff --git a/[gamemodes]/[stealth]/stealth/ricochet2.mp3 b/[gamemodes]/[stealth]/stealth/client/audio/ricochet2.mp3
similarity index 100%
rename from [gamemodes]/[stealth]/stealth/ricochet2.mp3
rename to [gamemodes]/[stealth]/stealth/client/audio/ricochet2.mp3
diff --git a/[gamemodes]/[stealth]/stealth/ricochet3.mp3 b/[gamemodes]/[stealth]/stealth/client/audio/ricochet3.mp3
similarity index 100%
rename from [gamemodes]/[stealth]/stealth/ricochet3.mp3
rename to [gamemodes]/[stealth]/stealth/client/audio/ricochet3.mp3
diff --git a/[gamemodes]/[stealth]/stealth/gadgets_client.lua b/[gamemodes]/[stealth]/stealth/client/gadgets_client.lua
similarity index 96%
rename from [gamemodes]/[stealth]/stealth/gadgets_client.lua
rename to [gamemodes]/[stealth]/stealth/client/gadgets_client.lua
index 56d7034e6..b127b4f69 100644
--- a/[gamemodes]/[stealth]/stealth/gadgets_client.lua
+++ b/[gamemodes]/[stealth]/stealth/client/gadgets_client.lua
@@ -1,679 +1,679 @@
-function choosethegadget () --GETS THE GADGET TYPE ON SPAWN
- player = localPlayer
- local x, y = guiGetScreenSize()
- x = x * 0.052
- y = y * 0.695
- if (gadgeticon) then
- destroyElement (gadgeticon)
- gadgeticon = nil
- end
- setElementData ( localPlayer, "armor", false )
- if spygadgetSelection == "prox mine" then
- chosengadget = "mines"
- gadgetuses = 6
- gadgeticon = guiCreateStaticImage (x, y, 40, 40, "mine.png", false)
- gadgetlabel = guiCreateLabel ( 0.05, .62, 40, 20, "", true, gadgeticon )
- guiLabelSetColor ( gadgetlabel, 1, 1, 1 )
- end
- if spygadgetSelection == "radar burst" then
- chosengadget = "burst"
- gadgetuses = 5
- gadgeticon = guiCreateStaticImage (x, y, 40, 40, "radar.png", false)
- gadgetlabel = guiCreateLabel ( 0.05, .62, 40, 20, "", true, gadgeticon )
- guiLabelSetColor ( gadgetlabel, 1, 1, 1 )
- end
- if spygadgetSelection == "camera" then
- chosengadget = "camera"
- gadgetuses = 3
- gadgeticon = guiCreateStaticImage (x, y, 40, 40, "camera.png", false)
- gadgetlabel = guiCreateLabel ( 0.05, .62, 40, 20, "", true, gadgeticon )
- guiLabelSetColor ( gadgetlabel, 1, 1, 1 )
- end
- if spygadgetSelection == "cloak" then
- chosengadget = "cloak"
- gadgetuses = 3
- gadgeticon = guiCreateStaticImage (x, y, 40, 40, "cloak.png", false)
- gadgetlabel = guiCreateLabel ( 0.05, .62, 40, 20, "", true, gadgeticon )
- guiLabelSetColor ( gadgetlabel, 1, 1, 1 )
- end
- if spygadgetSelection == "goggles" then
- chosengadget = "goggles"
- gadgetuses = nil
- gadgeticon = guiCreateStaticImage (x, y, 40, 40, "goggles.png", false)
- gadgetlabel = guiCreateLabel ( 0.05, .62, 40, 20, "", true, gadgeticon )
- guiLabelSetColor ( gadgetlabel, 1, 1, 1 )
- end
- if spygadgetSelection == "armor" then
- chosengadget = "armor"
- gadgetuses = nil
- gadgeticon = guiCreateStaticImage (x, y, 40, 40, "armor.png", false)
- setElementData ( localPlayer, "armor", true )
- gadgetlabel = guiCreateLabel ( 0.05, .62, 40, 20, "", true, gadgeticon )
- guiLabelSetColor ( gadgetlabel, 1, 1, 1 )
- end
- if spygadgetSelection == "shield" then
- chosengadget = "shield"
- gadgetuses = nil
- gadgeticon = guiCreateStaticImage (x, y, 40, 40, "shield.png", false)
- gadgetlabel = guiCreateLabel ( 0.05, .62, 40, 20, "", true, gadgeticon )
- guiLabelSetColor ( gadgetlabel, 1, 1, 1 )
- end
- guiSetText ( gadgetlabel, gadgetuses or "" )
- if goggleson == 1 then
- hideGogglesGUI()
- goggleson = 0
- end
- burstinprogress = 0
- cameraplaced = 0
- toggleControl ("fire", true )
- toggleControl ("aim_weapon", true )
- toggleControl ("enter_exit", true )
- toggleControl ("crouch", true )
- toggleControl ("jump", true )
- toggleControl ("right", true )
- toggleControl ("left", true )
- toggleControl ("forwards", true )
- toggleControl ("backwards", true )
- toggleControl ("enter_passenger", true )
- toggleControl ("sprint", true )
- if lookingthroughcamera == 1 then
- toggleSpyCam()
- end
- lookingthroughcamera = 0
-end
-
-addEventHandler ( "onClientPlayerSpawn", localPlayer, choosethegadget )
-
-function playerkilled ()
- if (gadgeticon) then
- destroyElement (gadgeticon)
- gadgeticon = nil
- end
-end
-
-addEventHandler ( "onClientPlayerWasted", localPlayer, playerkilled )
-
-addEventHandler ( "onClientPlayerDamage", root,
- function(attacker,weapon,bodypart)
- -- local slot = getSlotFromWeapon(weapon)
- if getElementData ( source, "armor" ) then
- if bodypart == 7 or bodypart == 8 or bodypart == 9 then
- local sound = playSound3D( "ricochet"..tostring(math.random(1,3))..".mp3", getElementPosition(source) )
- setSoundMinDistance ( sound, 2 )
- setSoundMaxDistance ( sound, 18 )
- end
- end
- end
-)
-
-
-function activategadget () --TRIGGERS WHEN GADGET BUTTON IS PRESSED, DECIDES WHICH FUNCTION TO TRIGGER
- local inacar = isPedInVehicle ( localPlayer )
- if inacar == false then
- local isDead = isPedDead(localPlayer)
- if (isDead == false) then
- if chosengadget == "mines" then
- if gadgetuses >0 then
- player = localPlayer
- if ( isPedDucked ( player) ) then
- triggerServerEvent ("poopoutthemine", localPlayer, player )
- gadgetuses = gadgetuses-1
- guiSetText ( gadgetlabel, gadgetuses )
- playSoundFrontEnd(42)
- else
- outputChatBox("You need to crouch to place a landmine.", 255, 69, 0)
- end
- else
- outputChatBox ( "You are out of Mines", 255, 69, 0)
- end
- elseif chosengadget == "burst" then
- radarblipburst()
- elseif chosengadget == "camera" then
- camerastart()
- elseif chosengadget == "cloak" then
- if gadgetuses >0 then
- local iscloaked = getElementData ( localPlayer, "stealthmode" )
- if (iscloaked ~= "on") then
- local thisplayer = localPlayer
- triggerServerEvent ("cloaktheplayer", localPlayer, thisplayer )
- cloakoff = setTimer ( makecloakstop, 20000, 1, thisplayer )
- gadgetuses = gadgetuses-1
- guiSetText ( gadgetlabel, gadgetuses )
- else
- outputChatBox ( "You are already currently cloaked.", 255, 69, 0)
- end
- else
- outputChatBox ( "You are out of Cloaks", 255, 69, 0)
- end
- elseif chosengadget == "goggles" then
- goggletoggle()
- elseif chosengadget == "shield" then
- shieldup()
- end
- end
- end
-end
-
-
---CLOAK
-
-function makecloakstop ()
- triggerServerEvent ("uncloaktheplayer", localPlayer, localPlayer )
-end
-
-
---TRIGGER WHEN SOMEONE IS CLOAKED
-addEvent("cloaksomeoneelse", true)
-
-function cloakaperson (thisplayer)
- if goggleson ~= 1 then
- setElementModel ( thisplayer, 164 )
- alphachangedelay = setTimer ( setalpha, 100, 1, thisplayer )
- end
-end
-
-addEventHandler("cloaksomeoneelse", root, cloakaperson)
-
-function setalpha(thisplayer)
- setElementAlpha ( thisplayer, 10 )
-end
-
-
---TRIGGER WHEN SOMEONE IS UNCLOAKED
-addEvent("uncloaksomeoneelse", true)
-
-function uncloakaperson (thisplayer)
- local oldskin = getElementData ( thisplayer, "playerskin" )
- setElementModel ( thisplayer, oldskin )
- setElementAlpha ( thisplayer, 255 ) --- NECCESARY???
-end
-
-addEventHandler("uncloaksomeoneelse", root, uncloakaperson)
-
-
---LANDMINES
-
---TRIGGERS THE SERVER EVENT TO DESTROY A LAND MINE ONCE IT'S SHOT
-function weaponfired (weapon, ammo, ammoInClip, hitX, hitY, hitZ, hitElement )
- if source == localPlayer then
- if (hitElement) then
- if ( getElementData ( hitElement, "type" ) == "proximity" ) then
- if minedelay ~= 1 then
- minedelay = 1
- triggerServerEvent ("destroylandmine", localPlayer, hitElement )
- endminedelay = setTimer ( minedelaystop, 400, 1, player )
- end
- end
- end
- end
-end
-
-addEventHandler ( "onClientPlayerWeaponFire", root, weaponfired )
-
-function minedelaystop()
- minedelay = 0
-end
-
-
---GOGGLES
-
---DETECTS IF ITS THE GOGGLES IN THE PERSONS HANDS
-function triggerpulled()
- if lookingthroughcamera == 1 then
- if gadgetuses >0 then
- ejectSmokeGrenade(0)
- gadgetuses = gadgetuses-1
- guiSetText ( gadgetlabel, gadgetuses )
- else
- outputChatBox ( "You are out of Camera Smokes.", 255, 69, 0)
- end
- else
- local weapon = getPedWeapon (localPlayer)
- if weapon == 44 then
- gogglecheckdelay = setTimer ( goggletaskcheck, 200, 1 )
- end
- if weapon == 45 then
- gogglecheckdelay = setTimer ( goggletaskcheck, 200, 1 )
- end
- end
-end
-
---CHECKS IF THE PERSON IS PUTTING ON OR TAKING OFF GOGGLES
-function goggletaskcheck ()
- if ( isPedDoingTask ( localPlayer, "TASK_SIMPLE_GOGGLES_ON" ) ) then
- if goggleson == 0 then
- goggleson = 1
- local gogglestype = getPedWeapon (localPlayer)
- if gogglestype == 44 then
- showNightvisionGUI()
- end
- if gogglestype == 45 then
- showInfraredGUI()
- end
- local tableofplayers = getElementsByType("player")
- for tableKey, tableValue in pairs(tableofplayers) do
- iscloaked = getElementData ( tableValue, "stealthmode" )
- if iscloaked == "on" then
- setElementAlpha ( tableValue, 255 )
- end
- end
- end
- end
- if ( isPedDoingTask ( localPlayer, "TASK_SIMPLE_GOGGLES_OFF" ) ) then
- if goggleson == 1 then
- goggleson = 0
- hideGogglesGUI()
- local tableofplayers = getElementsByType("player")
- for tableKey, tableValue in pairs(tableofplayers) do
- iscloaked = getElementData ( tableValue, "stealthmode" )
- if iscloaked == "on" then
- local player = tableValue
- alphachangedelay = setTimer ( setalpha, 100, 1, player )
- end
- end
- end
- end
-end
-
-function goggletoggle()
- local isDead = isPedDead(localPlayer)
- if (isDead == false) then
- if goggleson == 0 then
- player = localPlayer
- triggerServerEvent ("goggleswap", localPlayer, player )
- else
- outputChatBox ( "Take off the goggles to toggle their mode.", 255, 69, 0)
- end
- end
-end
-
---STARTUP SETUP
-
-function clientsetup (resource)
- if resource ~= getThisResource() then return end
- notblockingTasks = { TASK_SIMPLE_GET_UP=false, TASK_SIMPLE_SWIM=false, TASK_SIMPLE_LAND=false, TASK_SIMPLE_TIRED=false, TASK_SIMPLE_IN_AIR=true, TASK_SIMPLE_JUMP=true, TASK_SIMPLE_JETPACK=true, TASK_SIMPLE_FALL=true, TASK_SIMPLE_EVASIVE_DIVE=true, TASK_SIMPLE_CLIMB=true, TASK_SIMPLE_CHOKING=true, TASK_SIMPLE_CAR_SLOW_BE_DRAGGED_OUT=true, TASK_SIMPLE_CAR_SLOW_DRAG_PED_OUT=true, TASK_SIMPLE_CAR_QUICK_BE_DRAGGED_OUT=true, TASK_SIMPLE_CAR_QUICK_DRAG_PED_OUT=true, TASK_SIMPLE_CAR_GET_IN=true, TASK_SIMPLE_CAR_GET_OUT=true, TASK_SIMPLE_CAR_JUMP_OUT=true, TASK_SIMPLE_CAR_DRIVE=true, TASK_SIMPLE_BIKE_JACKED=true }
- bindKey ("fire", "down", triggerpulled )
- bindKey ("r", "down", "Use Gadget/Spectate Next", "" )
- bindKey ("r", "up", "Use Gadget/Spectate Next", "0" )
- setElementData ( localPlayer, "stealthmode", "off" )
- goggleson = 0
- burstinprogress = 0
- cameraplaced = 0
- lookingthroughcamera = 0
- loadtheshield = setTimer ( shieldload, 3000, 1 )
-end
-
-addCommandHandler ( "Use Gadget/Spectate Next",
- function ( command, state )
- if state == "0" then
- deactivategadget()
- else
- activategadget()
- end
- end
-)
-
-addEventHandler ( "onClientResourceStart",root , clientsetup)
-
-addEvent("Clientshieldload",true)
-function shieldload ()
- txd_shield = engineLoadTXD("riot_shield.txd")
- engineImportTXD(txd_shield,1631)
- col_shield = engineLoadCOL("riot_shield.col")
- dff_shield = engineLoadDFF("riot_shield.dff", 0 )
- engineReplaceCOL(col_shield,1631)
- engineReplaceModel(dff_shield,1631)
-end
-
-addEventHandler( "Clientshieldload", root, shieldload )
-
---RADAR BURST
-
-function radarblipburst()
- if gadgetuses >0 then
- gadgetuses = gadgetuses-1
- guiSetText ( gadgetlabel, gadgetuses )
- playSoundFrontEnd ( 40 )
- team1 = getTeamFromName("RED")
- team2 = getTeamFromName("BLUE")
- local allplayers = getElementsByType("player")
- for pkey, playerv in pairs(allplayers) do
- local revealedguysteam = getPlayerTeam (playerv)
- if revealedguysteam == team1 then
- local isDead = isPedDead(playerv)
- if (isDead == false) then
- local blipX, blipY, blipZ = getElementPosition ( playerv )
- local theblip = createBlip ( blipX, blipY, blipZ, 0, 2, 255, 0, 0, 75)
- stoptheburst = setTimer ( stopblipburst, 10000, 1, theblip )
- end
- end
- if revealedguysteam == team2 then
- local isDead = isPedDead(playerv)
- if (isDead == false) then
- local blipX, blipY, blipZ = getElementPosition ( playerv )
- local theblip = createBlip ( blipX, blipY, blipZ, 0, 2, 0, 0, 255, 75)
- stoptheburst = setTimer ( stopblipburst, 10000, 1, theblip )
- end
- end
- end
- else
- outputChatBox ( "You are out of Bursts.", localPlayer, 255, 69, 0)
- end
-end
-
-function stopblipburst(theblip)
- destroyElement (theblip)
-end
-
-
---SPYCAMERA
-
-function camerastart()
- if cameraplaced == 0 then
- triggerServerEvent ("placethecam", localPlayer, localPlayer )
- else
- if lookingthroughcamera == 0 then
- if isElementWithinColShape (localPlayer, cameracol) then
- removeSpyCam()
- playSoundFrontEnd(37)
- cameraplaced = 0
- camera = nil
- triggerServerEvent ("killcameraobject", localPlayer, localPlayer )
- else
- lookingthroughcamera = 1
- toggleControl ("fire", false )
- toggleControl ("aim_weapon", false )
- toggleControl ("enter_exit", false )
- toggleControl ("crouch", false )
- toggleControl ("jump", false )
- toggleControl ("right", false )
- toggleControl ("left", false )
- toggleControl ("forwards", false )
- toggleControl ("backwards", false )
- toggleControl ("enter_passenger", false )
- toggleControl ("sprint", false )
- toggleSpyCam()
- playSoundFrontEnd(38)
- end
- else
- toggleSpyCam()
- playSoundFrontEnd(38)
- lookingthroughcamera = 0
- toggleControl ("fire", true )
- toggleControl ("aim_weapon", true )
- toggleControl ("enter_exit", true )
- toggleControl ("crouch", true )
- toggleControl ("jump", true )
- toggleControl ("right", true )
- toggleControl ("left", true )
- toggleControl ("forwards", true )
- toggleControl ("backwards", true )
- toggleControl ("enter_passenger", true )
- toggleControl ("sprint", true )
- end
- end
-end
-
-
-addEvent("findcamerapos", true)
-
-function findthespot (rot)
- radRot = math.rad ( rot )
- local radius = 1
- local px,py,pz = getElementPosition( localPlayer )
- local tx = px + radius * math.sin(radRot)
- local ty = py + -(radius) * math.cos(radRot)
- local tz = pz
- local touching, x, y, z, object = processLineOfSight ( px, py, pz, tx, ty, tz, true, false, false, true, false, true, false, false )
- if (touching) then
- cameraplaced = 1
- player = localPlayer
- if ( isPedDucked ( player) ) then
- z = z-0.7
- end
- triggerServerEvent ("cameraobject", x, y, z, player )
- placeSpyCam ( x, y, z, rot )
- playSoundFrontEnd(37)
- camerax = x
- cameray = y
- cameraz = z
- cameracol = createColSphere ( x, y, z, 1.4 )
- else
- outputChatBox ( "You need to place the cam on a wall", 255, 69, 0)
- end
-end
-
-addEventHandler("findcamerapos", root , findthespot)
-
---SHIELD
-
-function shieldup ()
- toggleControl ("right", false )
- toggleControl ("left", false )
- toggleControl ("forwards", false )
- toggleControl ("backwards", false )
- toggleControl ("enter_exit", false )
- if (isPedDucked ( localPlayer ) == false ) then
- toggleControl ("fire", false )
- toggleControl ("aim_weapon", false )
- toggleControl ("jump", false )
- setPedControlState ( "aim_weapon", true )
- setPedControlState ( "jump", true )
- else
- toggleControl ("jump", false )
- toggleControl ("sprint", false )
- end
- blockcheck = setTimer ( shieldingyet, 300, 0, player )
-end
-
-
-function shieldingyet ()
- if isElementInWater(localPlayer) == false then
- if sheildon ~= 1 then
- currenttask = getPedSimplestTask ( localPlayer )
- if not notblockingTasks[currenttask] then
- killTimer ( blockcheck )
- blockcheck = nil
- shieldon = 1
- stopblockcheck = setTimer ( inturuptshield, 300, 0, player )
- local player = localPlayer
- triggerServerEvent ("shieldup", localPlayer, player )
- currentweapon = getPedWeapon (localPlayer)
- end
- end
- end
-end
-
-function inturuptshield ()
- newcurrenttask = getPedSimplestTask ( localPlayer )
- if notblockingTasks[newcurrenttask] then
- killTimer ( stopblockcheck )
- stopblockcheck = nil
- deactivategadget()
- end
- if isElementInWater(localPlayer) then
- if (stopblockcheck) then
- killTimer ( stopblockcheck )
- stopblockcheck = nil
- deactivategadget()
- end
- end
-end
-
-
-function deactivategadget ()
- if chosengadget == "shield" then
- if (blockcheck) then
- killTimer ( blockcheck )
- blockcheck = nil
- end
- if (stopblockcheck) then
- killTimer ( stopblockcheck )
- stopblockcheck = nil
- end
- toggleControl ("right", true )
- toggleControl ("left", true )
- toggleControl ("forwards", true )
- toggleControl ("backwards", true )
- toggleControl ("enter_exit", true )
- toggleControl ("fire", true )
- toggleControl ("aim_weapon", true )
- toggleControl ("jump", true )
- toggleControl ("sprint", true )
- setPedControlState ( "aim_weapon", false )
- setPedControlState ( "jump", false )
- if shieldon == 1 then
- local player = localPlayer
- triggerServerEvent ("shielddown", localPlayer, player, currentweapon )
- shieldon = 0
- end
- end
-end
-
-
----NIGHTVISION CODE
-function showNightvisionGUI()
- addEventHandler ( "onClientRender", root, updateNightvisionGUI )
- mineRefreshTimer = setTimer ( refreshNightvisionGoggles, 1000, 0, localPlayer)
-end
---addCommandHandler ( "shownightvision", showNightvisionGUI )
-
-function hideGogglesGUI()
- removeEventHandler ( "onClientRender", root, updateNightvisionGUI )
- removeEventHandler ( "onClientRender", root, updateInfraredGUI )
- killTimer ( mineRefreshTimer )
- clearAllGogglesGUI()
-end
---addCommandHandler ( "hide", hideGogglesGUI )
-
-local nightvisionGUI = {}
-local infraredGUI = {}
-function addNightvisionGUI(element, name)
- nightvisionGUI[element] = guiCreateLabel ( 0, 0, 100, 20, name, false )
- guiLabelSetColor ( nightvisionGUI[element], 255, 255, 255 )
- guiSetVisible ( nightvisionGUI[element], false )
-end
-
-function removeNightvisionGUI(element)
- guiSetVisible ( nightvisionGUI[element], false )
- destroyElement ( nightvisionGUI[element] )
- nightvisionGUI[element] = nil
-end
-
-function clearAllGogglesGUI()
- for element,label in pairs(nightvisionGUI) do
- guiSetVisible ( label, false )
- destroyElement ( label )
- end
- nightvisionGUI = {}
- for element,label in pairs(infraredGUI) do
- guiSetVisible ( label, false )
- destroyElement ( label )
- end
- infraredGUI = {}
-end
-
-function refreshNightvisionGoggles ()
- local itemlist = getElementsByType ( "colshape" )
- for index, item in ipairs(itemlist) do
- if ( getElementData ( item, "type" ) == "alandmine" ) then
- if not nightvisionGUI[item] then
- addNightvisionGUI(item, "MINE")
- end
- elseif ( getElementData ( item, "type" ) == "acamera" ) then
- if not nightvisionGUI[item] then
- addNightvisionGUI(item, "CAMERA")
- end
- end
- end
- for element,label in pairs(nightvisionGUI) do
- if not isElement(element) then
- removeNightvisionGUI(element)
- end
- end
-end
-
-local drawDistance = 25
-
-function updateNightvisionGUI ()
- for item,label in pairs(nightvisionGUI) do
- if isElement ( item ) then
- -- outputDebugString ( "Element type: "..getElementType (item) )
- local itemx, itemy, itemz = getElementPosition( item )
- if ( getElementData(item,"type") == "alandmine" ) then itemz = itemz - 1 end
- local playerx,playery,playerz = getElementPosition ( localPlayer )
- local screenX, screenY = getScreenFromWorldPosition ( itemx, itemy, itemz )
- if (screenX) then
- if getDistanceBetweenPoints3D ( playerx, playery, playerz, itemx, itemy, itemz ) < drawDistance then
- guiSetVisible ( label, true )
- guiSetPosition ( label, screenX, screenY, false )
- else
- guiSetVisible ( label, false )
- end
- else
- guiSetVisible ( label, false )
- end
- end
- end
-end
-
----INFRARED CODE
-function showInfraredGUI()
- addEventHandler ( "onClientRender", root, updateInfraredGUI )
- mineRefreshTimer = setTimer ( refreshInfraredGoggles, 1000, 0, localPlayer)
-end
---addCommandHandler ( "showinfrared", showInfraredGUI )
-
-function addInfraredGUI(element, name)
- infraredGUI[element] = guiCreateLabel ( 0, 0, 100, 20, name, false )
- guiLabelSetColor ( infraredGUI[element], 255, 255, 255 )
- guiSetVisible ( infraredGUI[element], false )
-end
-
-function removeInfraredGUI(element)
- guiSetVisible ( infraredGUI[element], false )
- destroyElement ( infraredGUI[element] )
- infraredGUI[element] = nil
-end
-
-
-function refreshInfraredGoggles ()
- local itemlist = getElementsByType ( "player" )
- for index, item in ipairs(itemlist) do
- if item ~= localPlayer then
- if not infraredGUI[item] then
- if getPlayerTeam(item) ~= getPlayerTeam(localPlayer) then
- addInfraredGUI(item, "ENEMY")
- else
- addInfraredGUI(item, "TEAM")
- end
- end
- end
- end
- for element,label in pairs(infraredGUI) do
- if not isElement(element) then
- removeInfraredGUI(element)
- end
- end
-end
-
-function updateInfraredGUI ()
- for item,label in pairs(infraredGUI) do
- if isElement ( item ) then
- -- outputDebugString ( "Element type: "..getElementType (item) )
- local itemx, itemy, itemz = getElementPosition( item )
- local playerx,playery,playerz = getElementPosition ( localPlayer )
- local screenX, screenY = getScreenFromWorldPosition ( itemx, itemy, itemz )
- if (screenX) then
- if getDistanceBetweenPoints3D ( playerx, playery, playerz, itemx, itemy, itemz ) < drawDistance then
- guiSetVisible ( label, true )
- guiSetPosition ( label, screenX, screenY, false )
- else
- guiSetVisible ( label, false )
- end
- else
- guiSetVisible ( label, false )
- end
- end
- end
-end
+function choosethegadget () --GETS THE GADGET TYPE ON SPAWN
+ player = localPlayer
+ local x, y = guiGetScreenSize()
+ x = x * 0.052
+ y = y * 0.695
+ if (gadgeticon) then
+ destroyElement (gadgeticon)
+ gadgeticon = nil
+ end
+ setElementData ( localPlayer, "armor", false )
+ if spygadgetSelection == "prox mine" then
+ chosengadget = "mines"
+ gadgetuses = 6
+ gadgeticon = guiCreateStaticImage (x, y, 40, 40, "mine.png", false)
+ gadgetlabel = guiCreateLabel ( 0.05, .62, 40, 20, "", true, gadgeticon )
+ guiLabelSetColor ( gadgetlabel, 1, 1, 1 )
+ end
+ if spygadgetSelection == "radar burst" then
+ chosengadget = "burst"
+ gadgetuses = 5
+ gadgeticon = guiCreateStaticImage (x, y, 40, 40, "radar.png", false)
+ gadgetlabel = guiCreateLabel ( 0.05, .62, 40, 20, "", true, gadgeticon )
+ guiLabelSetColor ( gadgetlabel, 1, 1, 1 )
+ end
+ if spygadgetSelection == "camera" then
+ chosengadget = "camera"
+ gadgetuses = 3
+ gadgeticon = guiCreateStaticImage (x, y, 40, 40, "camera.png", false)
+ gadgetlabel = guiCreateLabel ( 0.05, .62, 40, 20, "", true, gadgeticon )
+ guiLabelSetColor ( gadgetlabel, 1, 1, 1 )
+ end
+ if spygadgetSelection == "cloak" then
+ chosengadget = "cloak"
+ gadgetuses = 3
+ gadgeticon = guiCreateStaticImage (x, y, 40, 40, "cloak.png", false)
+ gadgetlabel = guiCreateLabel ( 0.05, .62, 40, 20, "", true, gadgeticon )
+ guiLabelSetColor ( gadgetlabel, 1, 1, 1 )
+ end
+ if spygadgetSelection == "goggles" then
+ chosengadget = "goggles"
+ gadgetuses = nil
+ gadgeticon = guiCreateStaticImage (x, y, 40, 40, "goggles.png", false)
+ gadgetlabel = guiCreateLabel ( 0.05, .62, 40, 20, "", true, gadgeticon )
+ guiLabelSetColor ( gadgetlabel, 1, 1, 1 )
+ end
+ if spygadgetSelection == "armor" then
+ chosengadget = "armor"
+ gadgetuses = nil
+ gadgeticon = guiCreateStaticImage (x, y, 40, 40, "armor.png", false)
+ setElementData ( localPlayer, "armor", true )
+ gadgetlabel = guiCreateLabel ( 0.05, .62, 40, 20, "", true, gadgeticon )
+ guiLabelSetColor ( gadgetlabel, 1, 1, 1 )
+ end
+ if spygadgetSelection == "shield" then
+ chosengadget = "shield"
+ gadgetuses = nil
+ gadgeticon = guiCreateStaticImage (x, y, 40, 40, "shield.png", false)
+ gadgetlabel = guiCreateLabel ( 0.05, .62, 40, 20, "", true, gadgeticon )
+ guiLabelSetColor ( gadgetlabel, 1, 1, 1 )
+ end
+ guiSetText ( gadgetlabel, gadgetuses or "" )
+ if goggleson == 1 then
+ hideGogglesGUI()
+ goggleson = 0
+ end
+ burstinprogress = 0
+ cameraplaced = 0
+ toggleControl ("fire", true )
+ toggleControl ("aim_weapon", true )
+ toggleControl ("enter_exit", true )
+ toggleControl ("crouch", true )
+ toggleControl ("jump", true )
+ toggleControl ("right", true )
+ toggleControl ("left", true )
+ toggleControl ("forwards", true )
+ toggleControl ("backwards", true )
+ toggleControl ("enter_passenger", true )
+ toggleControl ("sprint", true )
+ if lookingthroughcamera == 1 then
+ toggleSpyCam()
+ end
+ lookingthroughcamera = 0
+end
+
+addEventHandler ( "onClientPlayerSpawn", localPlayer, choosethegadget )
+
+function playerkilled ()
+ if (gadgeticon) then
+ destroyElement (gadgeticon)
+ gadgeticon = nil
+ end
+end
+
+addEventHandler ( "onClientPlayerWasted", localPlayer, playerkilled )
+
+addEventHandler ( "onClientPlayerDamage", root,
+ function(attacker,weapon,bodypart)
+ -- local slot = getSlotFromWeapon(weapon)
+ if getElementData ( source, "armor" ) then
+ if bodypart == 7 or bodypart == 8 or bodypart == 9 then
+ local sound = playSound3D( "ricochet"..tostring(math.random(1,3))..".mp3", getElementPosition(source) )
+ setSoundMinDistance ( sound, 2 )
+ setSoundMaxDistance ( sound, 18 )
+ end
+ end
+ end
+)
+
+
+function activategadget () --TRIGGERS WHEN GADGET BUTTON IS PRESSED, DECIDES WHICH FUNCTION TO TRIGGER
+ local inacar = isPedInVehicle ( localPlayer )
+ if inacar == false then
+ local isDead = isPedDead(localPlayer)
+ if (isDead == false) then
+ if chosengadget == "mines" then
+ if gadgetuses >0 then
+ player = localPlayer
+ if ( isPedDucked ( player) ) then
+ triggerServerEvent ("poopoutthemine", localPlayer, player )
+ gadgetuses = gadgetuses-1
+ guiSetText ( gadgetlabel, gadgetuses )
+ playSoundFrontEnd(42)
+ else
+ outputChatBox("You need to crouch to place a landmine.", 255, 69, 0)
+ end
+ else
+ outputChatBox ( "You are out of Mines", 255, 69, 0)
+ end
+ elseif chosengadget == "burst" then
+ radarblipburst()
+ elseif chosengadget == "camera" then
+ camerastart()
+ elseif chosengadget == "cloak" then
+ if gadgetuses >0 then
+ local iscloaked = getElementData ( localPlayer, "stealthmode" )
+ if (iscloaked ~= "on") then
+ local thisplayer = localPlayer
+ triggerServerEvent ("cloaktheplayer", localPlayer, thisplayer )
+ cloakoff = setTimer ( makecloakstop, 20000, 1, thisplayer )
+ gadgetuses = gadgetuses-1
+ guiSetText ( gadgetlabel, gadgetuses )
+ else
+ outputChatBox ( "You are already currently cloaked.", 255, 69, 0)
+ end
+ else
+ outputChatBox ( "You are out of Cloaks", 255, 69, 0)
+ end
+ elseif chosengadget == "goggles" then
+ goggletoggle()
+ elseif chosengadget == "shield" then
+ shieldup()
+ end
+ end
+ end
+end
+
+
+--CLOAK
+
+function makecloakstop ()
+ triggerServerEvent ("uncloaktheplayer", localPlayer, localPlayer )
+end
+
+
+--TRIGGER WHEN SOMEONE IS CLOAKED
+addEvent("cloaksomeoneelse", true)
+
+function cloakaperson (thisplayer)
+ if goggleson ~= 1 then
+ setElementModel ( thisplayer, 164 )
+ alphachangedelay = setTimer ( setalpha, 100, 1, thisplayer )
+ end
+end
+
+addEventHandler("cloaksomeoneelse", root, cloakaperson)
+
+function setalpha(thisplayer)
+ setElementAlpha ( thisplayer, 10 )
+end
+
+
+--TRIGGER WHEN SOMEONE IS UNCLOAKED
+addEvent("uncloaksomeoneelse", true)
+
+function uncloakaperson (thisplayer)
+ local oldskin = getElementData ( thisplayer, "playerskin" )
+ setElementModel ( thisplayer, oldskin )
+ setElementAlpha ( thisplayer, 255 ) --- NECCESARY???
+end
+
+addEventHandler("uncloaksomeoneelse", root, uncloakaperson)
+
+
+--LANDMINES
+
+--TRIGGERS THE SERVER EVENT TO DESTROY A LAND MINE ONCE IT'S SHOT
+function weaponfired (weapon, ammo, ammoInClip, hitX, hitY, hitZ, hitElement )
+ if source == localPlayer then
+ if (hitElement) then
+ if ( getElementData ( hitElement, "type" ) == "proximity" ) then
+ if minedelay ~= 1 then
+ minedelay = 1
+ triggerServerEvent ("destroylandmine", localPlayer, hitElement )
+ endminedelay = setTimer ( minedelaystop, 400, 1, player )
+ end
+ end
+ end
+ end
+end
+
+addEventHandler ( "onClientPlayerWeaponFire", root, weaponfired )
+
+function minedelaystop()
+ minedelay = 0
+end
+
+
+--GOGGLES
+
+--DETECTS IF ITS THE GOGGLES IN THE PERSONS HANDS
+function triggerpulled()
+ if lookingthroughcamera == 1 then
+ if gadgetuses >0 then
+ ejectSmokeGrenade(0)
+ gadgetuses = gadgetuses-1
+ guiSetText ( gadgetlabel, gadgetuses )
+ else
+ outputChatBox ( "You are out of Camera Smokes.", 255, 69, 0)
+ end
+ else
+ local weapon = getPedWeapon (localPlayer)
+ if weapon == 44 then
+ gogglecheckdelay = setTimer ( goggletaskcheck, 200, 1 )
+ end
+ if weapon == 45 then
+ gogglecheckdelay = setTimer ( goggletaskcheck, 200, 1 )
+ end
+ end
+end
+
+--CHECKS IF THE PERSON IS PUTTING ON OR TAKING OFF GOGGLES
+function goggletaskcheck ()
+ if ( isPedDoingTask ( localPlayer, "TASK_SIMPLE_GOGGLES_ON" ) ) then
+ if goggleson == 0 then
+ goggleson = 1
+ local gogglestype = getPedWeapon (localPlayer)
+ if gogglestype == 44 then
+ showNightvisionGUI()
+ end
+ if gogglestype == 45 then
+ showInfraredGUI()
+ end
+ local tableofplayers = getElementsByType("player")
+ for tableKey, tableValue in pairs(tableofplayers) do
+ iscloaked = getElementData ( tableValue, "stealthmode" )
+ if iscloaked == "on" then
+ setElementAlpha ( tableValue, 255 )
+ end
+ end
+ end
+ end
+ if ( isPedDoingTask ( localPlayer, "TASK_SIMPLE_GOGGLES_OFF" ) ) then
+ if goggleson == 1 then
+ goggleson = 0
+ hideGogglesGUI()
+ local tableofplayers = getElementsByType("player")
+ for tableKey, tableValue in pairs(tableofplayers) do
+ iscloaked = getElementData ( tableValue, "stealthmode" )
+ if iscloaked == "on" then
+ local player = tableValue
+ alphachangedelay = setTimer ( setalpha, 100, 1, player )
+ end
+ end
+ end
+ end
+end
+
+function goggletoggle()
+ local isDead = isPedDead(localPlayer)
+ if (isDead == false) then
+ if goggleson == 0 then
+ player = localPlayer
+ triggerServerEvent ("goggleswap", localPlayer, player )
+ else
+ outputChatBox ( "Take off the goggles to toggle their mode.", 255, 69, 0)
+ end
+ end
+end
+
+--STARTUP SETUP
+
+function clientsetup (resource)
+ if resource ~= getThisResource() then return end
+ notblockingTasks = { TASK_SIMPLE_GET_UP=false, TASK_SIMPLE_SWIM=false, TASK_SIMPLE_LAND=false, TASK_SIMPLE_TIRED=false, TASK_SIMPLE_IN_AIR=true, TASK_SIMPLE_JUMP=true, TASK_SIMPLE_JETPACK=true, TASK_SIMPLE_FALL=true, TASK_SIMPLE_EVASIVE_DIVE=true, TASK_SIMPLE_CLIMB=true, TASK_SIMPLE_CHOKING=true, TASK_SIMPLE_CAR_SLOW_BE_DRAGGED_OUT=true, TASK_SIMPLE_CAR_SLOW_DRAG_PED_OUT=true, TASK_SIMPLE_CAR_QUICK_BE_DRAGGED_OUT=true, TASK_SIMPLE_CAR_QUICK_DRAG_PED_OUT=true, TASK_SIMPLE_CAR_GET_IN=true, TASK_SIMPLE_CAR_GET_OUT=true, TASK_SIMPLE_CAR_JUMP_OUT=true, TASK_SIMPLE_CAR_DRIVE=true, TASK_SIMPLE_BIKE_JACKED=true }
+ bindKey ("fire", "down", triggerpulled )
+ bindKey ("r", "down", "Use Gadget/Spectate Next", "" )
+ bindKey ("r", "up", "Use Gadget/Spectate Next", "0" )
+ setElementData ( localPlayer, "stealthmode", "off" )
+ goggleson = 0
+ burstinprogress = 0
+ cameraplaced = 0
+ lookingthroughcamera = 0
+ loadtheshield = setTimer ( shieldload, 3000, 1 )
+end
+
+addCommandHandler ( "Use Gadget/Spectate Next",
+ function ( command, state )
+ if state == "0" then
+ deactivategadget()
+ else
+ activategadget()
+ end
+ end
+)
+
+addEventHandler ( "onClientResourceStart",root , clientsetup)
+
+addEvent("Clientshieldload",true)
+function shieldload ()
+ txd_shield = engineLoadTXD("riot_shield.txd")
+ engineImportTXD(txd_shield,1631)
+ col_shield = engineLoadCOL("riot_shield.col")
+ dff_shield = engineLoadDFF("riot_shield.dff", 0 )
+ engineReplaceCOL(col_shield,1631)
+ engineReplaceModel(dff_shield,1631)
+end
+
+addEventHandler( "Clientshieldload", root, shieldload )
+
+--RADAR BURST
+
+function radarblipburst()
+ if gadgetuses >0 then
+ gadgetuses = gadgetuses-1
+ guiSetText ( gadgetlabel, gadgetuses )
+ playSoundFrontEnd ( 40 )
+ team1 = getTeamFromName("RED")
+ team2 = getTeamFromName("BLUE")
+ local allplayers = getElementsByType("player")
+ for pkey, playerv in pairs(allplayers) do
+ local revealedguysteam = getPlayerTeam (playerv)
+ if revealedguysteam == team1 then
+ local isDead = isPedDead(playerv)
+ if (isDead == false) then
+ local blipX, blipY, blipZ = getElementPosition ( playerv )
+ local theblip = createBlip ( blipX, blipY, blipZ, 0, 2, 255, 0, 0, 75)
+ stoptheburst = setTimer ( stopblipburst, 10000, 1, theblip )
+ end
+ end
+ if revealedguysteam == team2 then
+ local isDead = isPedDead(playerv)
+ if (isDead == false) then
+ local blipX, blipY, blipZ = getElementPosition ( playerv )
+ local theblip = createBlip ( blipX, blipY, blipZ, 0, 2, 0, 0, 255, 75)
+ stoptheburst = setTimer ( stopblipburst, 10000, 1, theblip )
+ end
+ end
+ end
+ else
+ outputChatBox ( "You are out of Bursts.", localPlayer, 255, 69, 0)
+ end
+end
+
+function stopblipburst(theblip)
+ destroyElement (theblip)
+end
+
+
+--SPYCAMERA
+
+function camerastart()
+ if cameraplaced == 0 then
+ triggerServerEvent ("placethecam", localPlayer, localPlayer )
+ else
+ if lookingthroughcamera == 0 then
+ if isElementWithinColShape (localPlayer, cameracol) then
+ removeSpyCam()
+ playSoundFrontEnd(37)
+ cameraplaced = 0
+ camera = nil
+ triggerServerEvent ("killcameraobject", localPlayer, localPlayer )
+ else
+ lookingthroughcamera = 1
+ toggleControl ("fire", false )
+ toggleControl ("aim_weapon", false )
+ toggleControl ("enter_exit", false )
+ toggleControl ("crouch", false )
+ toggleControl ("jump", false )
+ toggleControl ("right", false )
+ toggleControl ("left", false )
+ toggleControl ("forwards", false )
+ toggleControl ("backwards", false )
+ toggleControl ("enter_passenger", false )
+ toggleControl ("sprint", false )
+ toggleSpyCam()
+ playSoundFrontEnd(38)
+ end
+ else
+ toggleSpyCam()
+ playSoundFrontEnd(38)
+ lookingthroughcamera = 0
+ toggleControl ("fire", true )
+ toggleControl ("aim_weapon", true )
+ toggleControl ("enter_exit", true )
+ toggleControl ("crouch", true )
+ toggleControl ("jump", true )
+ toggleControl ("right", true )
+ toggleControl ("left", true )
+ toggleControl ("forwards", true )
+ toggleControl ("backwards", true )
+ toggleControl ("enter_passenger", true )
+ toggleControl ("sprint", true )
+ end
+ end
+end
+
+
+addEvent("findcamerapos", true)
+
+function findthespot (rot)
+ radRot = math.rad ( rot )
+ local radius = 1
+ local px,py,pz = getElementPosition( localPlayer )
+ local tx = px + radius * math.sin(radRot)
+ local ty = py + -(radius) * math.cos(radRot)
+ local tz = pz
+ local touching, x, y, z, object = processLineOfSight ( px, py, pz, tx, ty, tz, true, false, false, true, false, true, false, false )
+ if (touching) then
+ cameraplaced = 1
+ player = localPlayer
+ if ( isPedDucked ( player) ) then
+ z = z-0.7
+ end
+ triggerServerEvent ("cameraobject", x, y, z, player )
+ placeSpyCam ( x, y, z, rot )
+ playSoundFrontEnd(37)
+ camerax = x
+ cameray = y
+ cameraz = z
+ cameracol = createColSphere ( x, y, z, 1.4 )
+ else
+ outputChatBox ( "You need to place the cam on a wall", 255, 69, 0)
+ end
+end
+
+addEventHandler("findcamerapos", root , findthespot)
+
+--SHIELD
+
+function shieldup ()
+ toggleControl ("right", false )
+ toggleControl ("left", false )
+ toggleControl ("forwards", false )
+ toggleControl ("backwards", false )
+ toggleControl ("enter_exit", false )
+ if (isPedDucked ( localPlayer ) == false ) then
+ toggleControl ("fire", false )
+ toggleControl ("aim_weapon", false )
+ toggleControl ("jump", false )
+ setPedControlState ( "aim_weapon", true )
+ setPedControlState ( "jump", true )
+ else
+ toggleControl ("jump", false )
+ toggleControl ("sprint", false )
+ end
+ blockcheck = setTimer ( shieldingyet, 300, 0, player )
+end
+
+
+function shieldingyet ()
+ if isElementInWater(localPlayer) == false then
+ if sheildon ~= 1 then
+ currenttask = getPedSimplestTask ( localPlayer )
+ if not notblockingTasks[currenttask] then
+ killTimer ( blockcheck )
+ blockcheck = nil
+ shieldon = 1
+ stopblockcheck = setTimer ( inturuptshield, 300, 0, player )
+ local player = localPlayer
+ triggerServerEvent ("shieldup", localPlayer, player )
+ currentweapon = getPedWeapon (localPlayer)
+ end
+ end
+ end
+end
+
+function inturuptshield ()
+ newcurrenttask = getPedSimplestTask ( localPlayer )
+ if notblockingTasks[newcurrenttask] then
+ killTimer ( stopblockcheck )
+ stopblockcheck = nil
+ deactivategadget()
+ end
+ if isElementInWater(localPlayer) then
+ if (stopblockcheck) then
+ killTimer ( stopblockcheck )
+ stopblockcheck = nil
+ deactivategadget()
+ end
+ end
+end
+
+
+function deactivategadget ()
+ if chosengadget == "shield" then
+ if (blockcheck) then
+ killTimer ( blockcheck )
+ blockcheck = nil
+ end
+ if (stopblockcheck) then
+ killTimer ( stopblockcheck )
+ stopblockcheck = nil
+ end
+ toggleControl ("right", true )
+ toggleControl ("left", true )
+ toggleControl ("forwards", true )
+ toggleControl ("backwards", true )
+ toggleControl ("enter_exit", true )
+ toggleControl ("fire", true )
+ toggleControl ("aim_weapon", true )
+ toggleControl ("jump", true )
+ toggleControl ("sprint", true )
+ setPedControlState ( "aim_weapon", false )
+ setPedControlState ( "jump", false )
+ if shieldon == 1 then
+ local player = localPlayer
+ triggerServerEvent ("shielddown", localPlayer, player, currentweapon )
+ shieldon = 0
+ end
+ end
+end
+
+
+---NIGHTVISION CODE
+function showNightvisionGUI()
+ addEventHandler ( "onClientRender", root, updateNightvisionGUI )
+ mineRefreshTimer = setTimer ( refreshNightvisionGoggles, 1000, 0, localPlayer)
+end
+--addCommandHandler ( "shownightvision", showNightvisionGUI )
+
+function hideGogglesGUI()
+ removeEventHandler ( "onClientRender", root, updateNightvisionGUI )
+ removeEventHandler ( "onClientRender", root, updateInfraredGUI )
+ killTimer ( mineRefreshTimer )
+ clearAllGogglesGUI()
+end
+--addCommandHandler ( "hide", hideGogglesGUI )
+
+local nightvisionGUI = {}
+local infraredGUI = {}
+function addNightvisionGUI(element, name)
+ nightvisionGUI[element] = guiCreateLabel ( 0, 0, 100, 20, name, false )
+ guiLabelSetColor ( nightvisionGUI[element], 255, 255, 255 )
+ guiSetVisible ( nightvisionGUI[element], false )
+end
+
+function removeNightvisionGUI(element)
+ guiSetVisible ( nightvisionGUI[element], false )
+ destroyElement ( nightvisionGUI[element] )
+ nightvisionGUI[element] = nil
+end
+
+function clearAllGogglesGUI()
+ for element,label in pairs(nightvisionGUI) do
+ guiSetVisible ( label, false )
+ destroyElement ( label )
+ end
+ nightvisionGUI = {}
+ for element,label in pairs(infraredGUI) do
+ guiSetVisible ( label, false )
+ destroyElement ( label )
+ end
+ infraredGUI = {}
+end
+
+function refreshNightvisionGoggles ()
+ local itemlist = getElementsByType ( "colshape" )
+ for index, item in ipairs(itemlist) do
+ if ( getElementData ( item, "type" ) == "alandmine" ) then
+ if not nightvisionGUI[item] then
+ addNightvisionGUI(item, "MINE")
+ end
+ elseif ( getElementData ( item, "type" ) == "acamera" ) then
+ if not nightvisionGUI[item] then
+ addNightvisionGUI(item, "CAMERA")
+ end
+ end
+ end
+ for element,label in pairs(nightvisionGUI) do
+ if not isElement(element) then
+ removeNightvisionGUI(element)
+ end
+ end
+end
+
+local drawDistance = 25
+
+function updateNightvisionGUI ()
+ for item,label in pairs(nightvisionGUI) do
+ if isElement ( item ) then
+ -- outputDebugString ( "Element type: "..getElementType (item) )
+ local itemx, itemy, itemz = getElementPosition( item )
+ if ( getElementData(item,"type") == "alandmine" ) then itemz = itemz - 1 end
+ local playerx,playery,playerz = getElementPosition ( localPlayer )
+ local screenX, screenY = getScreenFromWorldPosition ( itemx, itemy, itemz )
+ if (screenX) then
+ if getDistanceBetweenPoints3D ( playerx, playery, playerz, itemx, itemy, itemz ) < drawDistance then
+ guiSetVisible ( label, true )
+ guiSetPosition ( label, screenX, screenY, false )
+ else
+ guiSetVisible ( label, false )
+ end
+ else
+ guiSetVisible ( label, false )
+ end
+ end
+ end
+end
+
+---INFRARED CODE
+function showInfraredGUI()
+ addEventHandler ( "onClientRender", root, updateInfraredGUI )
+ mineRefreshTimer = setTimer ( refreshInfraredGoggles, 1000, 0, localPlayer)
+end
+--addCommandHandler ( "showinfrared", showInfraredGUI )
+
+function addInfraredGUI(element, name)
+ infraredGUI[element] = guiCreateLabel ( 0, 0, 100, 20, name, false )
+ guiLabelSetColor ( infraredGUI[element], 255, 255, 255 )
+ guiSetVisible ( infraredGUI[element], false )
+end
+
+function removeInfraredGUI(element)
+ guiSetVisible ( infraredGUI[element], false )
+ destroyElement ( infraredGUI[element] )
+ infraredGUI[element] = nil
+end
+
+
+function refreshInfraredGoggles ()
+ local itemlist = getElementsByType ( "player" )
+ for index, item in ipairs(itemlist) do
+ if item ~= localPlayer then
+ if not infraredGUI[item] then
+ if getPlayerTeam(item) ~= getPlayerTeam(localPlayer) then
+ addInfraredGUI(item, "ENEMY")
+ else
+ addInfraredGUI(item, "TEAM")
+ end
+ end
+ end
+ end
+ for element,label in pairs(infraredGUI) do
+ if not isElement(element) then
+ removeInfraredGUI(element)
+ end
+ end
+end
+
+function updateInfraredGUI ()
+ for item,label in pairs(infraredGUI) do
+ if isElement ( item ) then
+ -- outputDebugString ( "Element type: "..getElementType (item) )
+ local itemx, itemy, itemz = getElementPosition( item )
+ local playerx,playery,playerz = getElementPosition ( localPlayer )
+ local screenX, screenY = getScreenFromWorldPosition ( itemx, itemy, itemz )
+ if (screenX) then
+ if getDistanceBetweenPoints3D ( playerx, playery, playerz, itemx, itemy, itemz ) < drawDistance then
+ guiSetVisible ( label, true )
+ guiSetPosition ( label, screenX, screenY, false )
+ else
+ guiSetVisible ( label, false )
+ end
+ else
+ guiSetVisible ( label, false )
+ end
+ end
+ end
+end
diff --git a/[gamemodes]/[stealth]/stealth/help.xml b/[gamemodes]/[stealth]/stealth/client/help.xml
similarity index 98%
rename from [gamemodes]/[stealth]/stealth/help.xml
rename to [gamemodes]/[stealth]/stealth/client/help.xml
index 57989120f..fcda0a3ee 100644
--- a/[gamemodes]/[stealth]/stealth/help.xml
+++ b/[gamemodes]/[stealth]/stealth/client/help.xml
@@ -1,21 +1,21 @@
-
-STEALTH
-The object of this game is to eliminate all the members of the opposite team each round. Performing actions that make noise will cause you to be revealed on other players radar.
-At the beginning of each round you choose your weapons and a special gadget.
-
-GADGETS
-CLOAK: Press R to make yourself nearly invisible.
-PROX MINE: Press R while crouching to place a mine that explodes when an enemy moves close to it.
-RADAR BURST: R reveals all players current positions.
-ARMOR: Protects from headshots and limping untill it is used up.
-SHIELD: R to hold up a bullet proof protective shield.
-CAMERA: Press R to place, pick up, or view through your camera, press fire while in camera mode to drop a smoke grenade.
-GOGGLES: R toggle between heatvision and infrared, reveals locations of players while in infrared, mines and cameras while in night vision.
-
-You can change the 'Use Gadget' key from "R" by accessing the "Binds" tab in your MTA Settings menu.
-
-CREDITS
-Concept/Design:Slothman Scripting:Slothman and Talidan
-Shield:Johnline Icons:Slothman Timer:AlienX
-Thanks To all the QA and MTA team members who helped.
-
+
+STEALTH
+The object of this game is to eliminate all the members of the opposite team each round. Performing actions that make noise will cause you to be revealed on other players radar.
+At the beginning of each round you choose your weapons and a special gadget.
+
+GADGETS
+CLOAK: Press R to make yourself nearly invisible.
+PROX MINE: Press R while crouching to place a mine that explodes when an enemy moves close to it.
+RADAR BURST: R reveals all players current positions.
+ARMOR: Protects from headshots and limping untill it is used up.
+SHIELD: R to hold up a bullet proof protective shield.
+CAMERA: Press R to place, pick up, or view through your camera, press fire while in camera mode to drop a smoke grenade.
+GOGGLES: R toggle between heatvision and infrared, reveals locations of players while in infrared, mines and cameras while in night vision.
+
+You can change the 'Use Gadget' key from "R" by accessing the "Binds" tab in your MTA Settings menu.
+
+CREDITS
+Concept/Design:Slothman Scripting:Slothman and Talidan
+Shield:Johnline Icons:Slothman Timer:AlienX
+Thanks To all the QA and MTA team members who helped.
+
diff --git a/[gamemodes]/[stealth]/stealth/armor.png b/[gamemodes]/[stealth]/stealth/client/images/armor.png
similarity index 100%
rename from [gamemodes]/[stealth]/stealth/armor.png
rename to [gamemodes]/[stealth]/stealth/client/images/armor.png
diff --git a/[gamemodes]/[stealth]/stealth/camera.png b/[gamemodes]/[stealth]/stealth/client/images/camera.png
similarity index 100%
rename from [gamemodes]/[stealth]/stealth/camera.png
rename to [gamemodes]/[stealth]/stealth/client/images/camera.png
diff --git a/[gamemodes]/[stealth]/stealth/cloak.png b/[gamemodes]/[stealth]/stealth/client/images/cloak.png
similarity index 100%
rename from [gamemodes]/[stealth]/stealth/cloak.png
rename to [gamemodes]/[stealth]/stealth/client/images/cloak.png
diff --git a/[gamemodes]/[stealth]/stealth/goggles.png b/[gamemodes]/[stealth]/stealth/client/images/goggles.png
similarity index 100%
rename from [gamemodes]/[stealth]/stealth/goggles.png
rename to [gamemodes]/[stealth]/stealth/client/images/goggles.png
diff --git a/[gamemodes]/[stealth]/stealth/mine.png b/[gamemodes]/[stealth]/stealth/client/images/mine.png
similarity index 100%
rename from [gamemodes]/[stealth]/stealth/mine.png
rename to [gamemodes]/[stealth]/stealth/client/images/mine.png
diff --git a/[gamemodes]/[stealth]/stealth/radar.png b/[gamemodes]/[stealth]/stealth/client/images/radar.png
similarity index 100%
rename from [gamemodes]/[stealth]/stealth/radar.png
rename to [gamemodes]/[stealth]/stealth/client/images/radar.png
diff --git a/[gamemodes]/[stealth]/stealth/shield.png b/[gamemodes]/[stealth]/stealth/client/images/shield.png
similarity index 100%
rename from [gamemodes]/[stealth]/stealth/shield.png
rename to [gamemodes]/[stealth]/stealth/client/images/shield.png
diff --git a/[gamemodes]/[stealth]/stealth/noisebar.lua b/[gamemodes]/[stealth]/stealth/client/noisebar.lua
similarity index 97%
rename from [gamemodes]/[stealth]/stealth/noisebar.lua
rename to [gamemodes]/[stealth]/stealth/client/noisebar.lua
index da401bd64..e0342bc59 100644
--- a/[gamemodes]/[stealth]/stealth/noisebar.lua
+++ b/[gamemodes]/[stealth]/stealth/client/noisebar.lua
@@ -1,252 +1,252 @@
-function setupstuff ()
- blipshowing = 0
- soundlevel = 0
- local x, y = guiGetScreenSize()
- x = x * 0.092
- y = y * 0.71
- thesoundbar = guiCreateProgressBar ( x, y, 100, 20, false )
- SoundText = guiCreateLabel ( .35 , 0, 100, 20, "Sound", true, thesoundbar )
- guiLabelSetColor ( SoundText, 1, 1, 1 )
- fadesoundout = setTimer ( reducesoundlevel, 1000, 0 )
- casualcheck = setTimer ( noisecheck, 1000, 0 )
- watchedTasks = { TASK_SIMPLE_TIRED=true, TASK_SIMPLE_IN_AIR=true, TASK_SIMPLE_PLAYER_ON_FIRE=true, TASK_SIMPLE_JUMP=true, TASK_SIMPLE_JETPACK=true, TASK_SIMPLE_HIT_FRONT=true, TASK_SIMPLE_HIT_HEAD=true, TASK_SIMPLE_HIT_LEFT=true, TASK_SIMPLE_HIT_RIGHT=true, TASK_SIMPLE_HIT_WALL=true, TASK_SIMPLE_HIT_BACK=true, TASK_SIMPLE_HIT_BEHIND=true, TASK_SIMPLE_HIT_BY_GUN_BACK=true, TASK_SIMPLE_HIT_BY_GUN_FRONT=true, TASK_SIMPLE_HIT_BY_GUN_LEFT=true, TASK_SIMPLE_HIT_BY_GUN_RIGHT=true, TASK_SIMPLE_FALL=true, TASK_SIMPLE_FIGHT=true, TASK_SIMPLE_FIGHT_CTRL=true, TASK_SIMPLE_EVASIVE_DIVE=true, TASK_SIMPLE_EVASIVE_STEP=true, TASK_SIMPLE_DROWN=true, TASK_SIMPLE_DROWN_IN_CAR=true, TASK_SIMPLE_DRIVEBY_SHOOT=true, TASK_SIMPLE_DIE=true, TASK_SIMPLE_DIE_IN_CAR=true, TASK_SIMPLE_DETONATE=true, TASK_SIMPLE_CLIMB=true, TASK_SIMPLE_CHOKING=true, TASK_SIMPLE_CAR_SLOW_BE_DRAGGED_OUT=true, TASK_SIMPLE_CAR_SLOW_DRAG_PED_OUT=true, TASK_SIMPLE_CAR_QUICK_BE_DRAGGED_OUT=true, TASK_SIMPLE_CAR_QUICK_DRAG_PED_OUT=true, TASK_SIMPLE_CAR_GET_IN=true, TASK_SIMPLE_CAR_GET_OUT=true, TASK_SIMPLE_CAR_JUMP_OUT=true, TASK_SIMPLE_CAR_DRIVE=true, TASK_SIMPLE_BIKE_JACKED=true, TASK_SIMPLE_BE_DAMAGED=true, TASK_SIMPLE_BE_HIT=true, TASK_SIMPLE_BE_HIT_WHILE_MOVING=true, TASK_SIMPLE_GOGGLES_OFF=true, TASK_SIMPLE_GOGGLES_ON=true }
- controls = { "fire", "next_weapon", "previous_weapon", "jump", "forwards","backwards","left","right","sprint","enter_exit","vehicle_fire","vehicle_secondary_fire","steer_forwards","steer_back","accelerate","brake_reverse","horn","handbrake","special_control_left","special_control_right","special_control_down","special_control_up" }
- for k,v in pairs(controls) do
- bindKey (v, "both", noisecheck )
- end
- guiSetVisible ( thesoundbar, false )
- bindKey ("forwards", "down", walksoundstart )
- bindKey ("backwards", "down", walksoundstart )
- bindKey ("left", "down", walksoundstart )
- bindKey ("right", "down", walksoundstart )
- bindKey ("forwards", "up", walksoundstop )
- bindKey ("backwards", "up", walksoundstop )
- bindKey ("left", "up", walksoundstop )
- bindKey ("right", "up", walksoundstop )
-end
-
---THIS RESETS THE PLAYERS SOUNDLEVEL, BINDS THE KEYS, AND TRIGGERS ALL THE FUNCTIONS THAT DETECT SOUND
-function setupsoundstuff ( source )
- blipshowing = 0
- soundlevel = 0
- alreadylimping = 0
- toggleControl ("right", true )
- toggleControl ("left", true )
- toggleControl ("forwards", true )
- toggleControl ("backwards", true )
- guiSetVisible ( thesoundbar, true )
-end
-
---THIS CHECKS IF THE PLAYER IS DOING CERTAIN THINGS THAT ARE KNOWN TO MAKE NOISE
-function noisecheck ( source, key, keystate )
- thetask = getPedSimplestTask(localPlayer)
- if watchedTasks[thetask] then
- soundlevel = soundlevel+1
- end
-end
-
---THIS IS THE TIMER TO BRING THE SOUNDLEVEL BACK DOWN AND UPDATE THE PLAYERS NOISELEVEL
-function reducesoundlevel ()
- if soundlevel > 0 then
- soundlevel = soundlevel-1
- end
- if soundlevel > 10 then --THIS CAPS THE MAX SOUND LEVEL AT 10
- soundlevel = 10
- end
- barlevel = soundlevel * 10
- guiProgressBarSetProgress ( thesoundbar, barlevel )
--- guiSetVisible ( thesoundbar, true )
- smoothfade = setTimer ( smoothreduce, 100, 9 )
- setElementData ( getLocalPlayer (), "noiselevel", soundlevel )
- if soundlevel > 0 then
- if blipshowing == 0 then
- local isDead = isPedDead(getLocalPlayer ())
- if (isDead == false) then
- blipshowing = 1
- end
- end
- end
- if soundlevel == 0 then
- if blipshowing == 1 then
- blipshowing = 0
- end
- end
- updateRemoteSoundLevels()
-end
---THIS REDUCES THE BAR VISUALLY WITHOUT EFFECTING THE ACTUAL VALUES
-function smoothreduce ()
- local newprobar = guiProgressBarGetProgress (thesoundbar)
- guiProgressBarSetProgress ( thesoundbar, newprobar-1 )
--- guiSetVisible ( thesoundbar, true )
-end
-
-
---THIS PART MAKES NOISE WHEN A PLAYER GETS HURT
-bodyPartAnim = {
- [7] = { "DAM_LegL_frmBK", 42 },
- [8] = { "DAM_LegR_frmBK", 52 },
-}
-
-function damagenoise ( attacker, weapon, bodypart, loss )
- soundlevel = soundlevel+2
- restartdamagedetect = setTimer ( readddamage, 1000, 1 )
- --Only continue if our bodypart is one of the legs
- if ( bodypart ~= 7 ) and ( bodypart ~= 8 ) then
- return
- end
- local isplayerlimping = getElementData ( getLocalPlayer (), "legdamage" )
- if isplayerlimping ~= 1 then
- if (attacker) then
- local attackerteam = getPlayerTeam (attacker)
- local yourteam = getPlayerTeam (getLocalPlayer ())
- if attackerteam == yourteam then
- if getTeamFriendlyFire ( yourteam ) == false then
- --do nothing
- return
- end
- end
- if not getElementData ( source, "armor" ) then
- --outputChatBox("You've been hit in the leg.", 255, 69, 0)
- setPedAnimation ( localPlayer, "ped", bodyPartAnim[bodypart][1], true, true, false )
- setTimer ( setPedAnimation, 600, 1, localPlayer )
- setElementData ( getLocalPlayer (), "legdamage", 1 )
- --Blood stuff
- local function blood()
- local boneX,boneY,boneZ = getPedBonePosition(localPlayer, bodyPartAnim[bodypart][2])
- local rot = math.rad(getPedRotation ( localPlayer ))
- fxAddBlood ( boneX,boneY,boneZ, -math.sin(rot), math.cos(rot), -0.1, 500, 1.0 )
- end
- blood()
- setTimer(blood,50,50)
- --
- local makeplayerlimp = setTimer ( limpeffect, 1000, 1, source, key, state )
- end
- end
- end
-end
-
-function readddamage ()
- -- addEventHandler ( "onClientPedDamage", getLocalPlayer (), damagenoise )
-end
-
-
---THIS PART MAKES SHOOTING A WEAPON MAKE NOISE
-function shootingnoise ( weapon )
- if weapon == 22 then
- soundlevel = soundlevel +1
- elseif weapon == 24 then
- soundlevel = soundlevel +2
- elseif weapon == 25 then
- soundlevel = soundlevel +2
- elseif weapon == 27 then
- soundlevel = soundlevel +2
- elseif weapon == 28 then
- soundlevel = soundlevel +1
- elseif weapon == 29 then
- soundlevel = soundlevel +1
- elseif weapon == 30 then
- soundlevel = soundlevel +1
- elseif weapon == 31 then
- soundlevel = soundlevel +1
- elseif weapon == 32 then
- soundlevel = soundlevel +1
- elseif weapon == 33 then
- soundlevel = soundlevel +2
- elseif weapon == 34 then
- soundlevel = soundlevel +3
- end
-end
-
---THIS PART CAUSES PLAYERS TO MAKE NOISE IF THEY DONT CROUCH OR SLOW WALK
-function walksoundstart (source, key, keystate)
- if isplayermoving ~= 1 then
- movementsound = setTimer ( movementcheck, 900, 0 )
- isplayermoving = 1
- end
-end
-
-
---LIMP TIMING
-
-function limpeffect ( source, key, keystate )
- if isPedInVehicle (getLocalPlayer ()) then
- return
- else
- islimping = getElementData ( getLocalPlayer (), "legdamage" )
- if islimping == 1 then
- local makeplayerlimp = setTimer ( limpeffectparttwo , 200, 1, source, key, state )
- if lookingthroughcamera ~= 1 then
- toggleControl ("right", false )
- toggleControl ("left", false )
- toggleControl ("forwards", false )
- toggleControl ("backwards", false )
- end
- end
- end
-end
-
-function limpeffectparttwo ( source, key, keystate )
- if isPedInVehicle (getLocalPlayer ()) then
- return
- else
- islimping = getElementData ( getLocalPlayer (), "legdamage" )
- if islimping == 1 then
- local makeplayerlimp = setTimer ( limpeffect, 500, 1, source, key, state )
- if lookingthroughcamera ~= 1 then
- if shieldon ~= 1 then
- toggleControl ("right", true )
- toggleControl ("left", true )
- toggleControl ("forwards", true )
- toggleControl ("backwards", true )
- end
- end
- end
- end
-end
-
-function startalimp ()
- local theplayer = getLocalPlayer ()
- if (getPedArmor ( theplayer )) == 0 then
- setElementData ( getLocalPlayer (), "legdamage", 1 )
- local makeplayerlimp = setTimer ( limpeffect, 300, 1, source, key, state )
- end
-end
-
-addCommandHandler ( "crippleme", startalimp )
-
-
-function movementcheck ( source, key, keystate )
- if ( isPedDucked ( getLocalPlayer () ) ) == false then
- if ( getPedControlState ( "sprint" ) ) then
- soundlevel = soundlevel +1
- end
- if ( getPedControlState ( "walk" ) ) == false then
- soundlevel = soundlevel +1
- end
- end
-end
-
-function walksoundstop ( source, key, keystate )
- if isplayermoving == 1 then
- if ( getPedControlState ( "forwards" ) ) == false and ( getPedControlState ( "backwards" ) ) == false and ( getPedControlState ( "left" ) ) == false and ( getPedControlState ( "right" ) ) == false then
- killTimer ( movementsound )
- isplayermoving = 0
- end
- end
-end
-
-function setuptrigger ( theresource )
- if theresource == getThisResource() then
- setupstuff()
- end
-end
-
-function hidesoundbar ( theresource )
- guiSetVisible ( thesoundbar, false )
-end
-
-addEventHandler ( "onClientPlayerWasted", getLocalPlayer (), hidesoundbar )
-addEventHandler ( "onClientPlayerDamage", getLocalPlayer (), damagenoise )
-addEventHandler ( "onClientPlayerWeaponFire", getLocalPlayer (), shootingnoise )
-addEventHandler ( "onClientPlayerSpawn", getLocalPlayer (), setupsoundstuff )
-addEventHandler ( "onClientResourceStart", resourceRoot, setuptrigger)
+function setupstuff ()
+ blipshowing = 0
+ soundlevel = 0
+ local x, y = guiGetScreenSize()
+ x = x * 0.092
+ y = y * 0.71
+ thesoundbar = guiCreateProgressBar ( x, y, 100, 20, false )
+ SoundText = guiCreateLabel ( .35 , 0, 100, 20, "Sound", true, thesoundbar )
+ guiLabelSetColor ( SoundText, 1, 1, 1 )
+ fadesoundout = setTimer ( reducesoundlevel, 1000, 0 )
+ casualcheck = setTimer ( noisecheck, 1000, 0 )
+ watchedTasks = { TASK_SIMPLE_TIRED=true, TASK_SIMPLE_IN_AIR=true, TASK_SIMPLE_PLAYER_ON_FIRE=true, TASK_SIMPLE_JUMP=true, TASK_SIMPLE_JETPACK=true, TASK_SIMPLE_HIT_FRONT=true, TASK_SIMPLE_HIT_HEAD=true, TASK_SIMPLE_HIT_LEFT=true, TASK_SIMPLE_HIT_RIGHT=true, TASK_SIMPLE_HIT_WALL=true, TASK_SIMPLE_HIT_BACK=true, TASK_SIMPLE_HIT_BEHIND=true, TASK_SIMPLE_HIT_BY_GUN_BACK=true, TASK_SIMPLE_HIT_BY_GUN_FRONT=true, TASK_SIMPLE_HIT_BY_GUN_LEFT=true, TASK_SIMPLE_HIT_BY_GUN_RIGHT=true, TASK_SIMPLE_FALL=true, TASK_SIMPLE_FIGHT=true, TASK_SIMPLE_FIGHT_CTRL=true, TASK_SIMPLE_EVASIVE_DIVE=true, TASK_SIMPLE_EVASIVE_STEP=true, TASK_SIMPLE_DROWN=true, TASK_SIMPLE_DROWN_IN_CAR=true, TASK_SIMPLE_DRIVEBY_SHOOT=true, TASK_SIMPLE_DIE=true, TASK_SIMPLE_DIE_IN_CAR=true, TASK_SIMPLE_DETONATE=true, TASK_SIMPLE_CLIMB=true, TASK_SIMPLE_CHOKING=true, TASK_SIMPLE_CAR_SLOW_BE_DRAGGED_OUT=true, TASK_SIMPLE_CAR_SLOW_DRAG_PED_OUT=true, TASK_SIMPLE_CAR_QUICK_BE_DRAGGED_OUT=true, TASK_SIMPLE_CAR_QUICK_DRAG_PED_OUT=true, TASK_SIMPLE_CAR_GET_IN=true, TASK_SIMPLE_CAR_GET_OUT=true, TASK_SIMPLE_CAR_JUMP_OUT=true, TASK_SIMPLE_CAR_DRIVE=true, TASK_SIMPLE_BIKE_JACKED=true, TASK_SIMPLE_BE_DAMAGED=true, TASK_SIMPLE_BE_HIT=true, TASK_SIMPLE_BE_HIT_WHILE_MOVING=true, TASK_SIMPLE_GOGGLES_OFF=true, TASK_SIMPLE_GOGGLES_ON=true }
+ controls = { "fire", "next_weapon", "previous_weapon", "jump", "forwards","backwards","left","right","sprint","enter_exit","vehicle_fire","vehicle_secondary_fire","steer_forwards","steer_back","accelerate","brake_reverse","horn","handbrake","special_control_left","special_control_right","special_control_down","special_control_up" }
+ for k,v in pairs(controls) do
+ bindKey (v, "both", noisecheck )
+ end
+ guiSetVisible ( thesoundbar, false )
+ bindKey ("forwards", "down", walksoundstart )
+ bindKey ("backwards", "down", walksoundstart )
+ bindKey ("left", "down", walksoundstart )
+ bindKey ("right", "down", walksoundstart )
+ bindKey ("forwards", "up", walksoundstop )
+ bindKey ("backwards", "up", walksoundstop )
+ bindKey ("left", "up", walksoundstop )
+ bindKey ("right", "up", walksoundstop )
+end
+
+--THIS RESETS THE PLAYERS SOUNDLEVEL, BINDS THE KEYS, AND TRIGGERS ALL THE FUNCTIONS THAT DETECT SOUND
+function setupsoundstuff ( source )
+ blipshowing = 0
+ soundlevel = 0
+ alreadylimping = 0
+ toggleControl ("right", true )
+ toggleControl ("left", true )
+ toggleControl ("forwards", true )
+ toggleControl ("backwards", true )
+ guiSetVisible ( thesoundbar, true )
+end
+
+--THIS CHECKS IF THE PLAYER IS DOING CERTAIN THINGS THAT ARE KNOWN TO MAKE NOISE
+function noisecheck ( source, key, keystate )
+ thetask = getPedSimplestTask(localPlayer)
+ if watchedTasks[thetask] then
+ soundlevel = soundlevel+1
+ end
+end
+
+--THIS IS THE TIMER TO BRING THE SOUNDLEVEL BACK DOWN AND UPDATE THE PLAYERS NOISELEVEL
+function reducesoundlevel ()
+ if soundlevel > 0 then
+ soundlevel = soundlevel-1
+ end
+ if soundlevel > 10 then --THIS CAPS THE MAX SOUND LEVEL AT 10
+ soundlevel = 10
+ end
+ barlevel = soundlevel * 10
+ guiProgressBarSetProgress ( thesoundbar, barlevel )
+-- guiSetVisible ( thesoundbar, true )
+ smoothfade = setTimer ( smoothreduce, 100, 9 )
+ setElementData ( getLocalPlayer (), "noiselevel", soundlevel )
+ if soundlevel > 0 then
+ if blipshowing == 0 then
+ local isDead = isPedDead(getLocalPlayer ())
+ if (isDead == false) then
+ blipshowing = 1
+ end
+ end
+ end
+ if soundlevel == 0 then
+ if blipshowing == 1 then
+ blipshowing = 0
+ end
+ end
+ updateRemoteSoundLevels()
+end
+--THIS REDUCES THE BAR VISUALLY WITHOUT EFFECTING THE ACTUAL VALUES
+function smoothreduce ()
+ local newprobar = guiProgressBarGetProgress (thesoundbar)
+ guiProgressBarSetProgress ( thesoundbar, newprobar-1 )
+-- guiSetVisible ( thesoundbar, true )
+end
+
+
+--THIS PART MAKES NOISE WHEN A PLAYER GETS HURT
+bodyPartAnim = {
+ [7] = { "DAM_LegL_frmBK", 42 },
+ [8] = { "DAM_LegR_frmBK", 52 },
+}
+
+function damagenoise ( attacker, weapon, bodypart, loss )
+ soundlevel = soundlevel+2
+ restartdamagedetect = setTimer ( readddamage, 1000, 1 )
+ --Only continue if our bodypart is one of the legs
+ if ( bodypart ~= 7 ) and ( bodypart ~= 8 ) then
+ return
+ end
+ local isplayerlimping = getElementData ( getLocalPlayer (), "legdamage" )
+ if isplayerlimping ~= 1 then
+ if (attacker) then
+ local attackerteam = getPlayerTeam (attacker)
+ local yourteam = getPlayerTeam (getLocalPlayer ())
+ if attackerteam == yourteam then
+ if getTeamFriendlyFire ( yourteam ) == false then
+ --do nothing
+ return
+ end
+ end
+ if not getElementData ( source, "armor" ) then
+ --outputChatBox("You've been hit in the leg.", 255, 69, 0)
+ setPedAnimation ( localPlayer, "ped", bodyPartAnim[bodypart][1], true, true, false )
+ setTimer ( setPedAnimation, 600, 1, localPlayer )
+ setElementData ( getLocalPlayer (), "legdamage", 1 )
+ --Blood stuff
+ local function blood()
+ local boneX,boneY,boneZ = getPedBonePosition(localPlayer, bodyPartAnim[bodypart][2])
+ local rot = math.rad(getPedRotation ( localPlayer ))
+ fxAddBlood ( boneX,boneY,boneZ, -math.sin(rot), math.cos(rot), -0.1, 500, 1.0 )
+ end
+ blood()
+ setTimer(blood,50,50)
+ --
+ local makeplayerlimp = setTimer ( limpeffect, 1000, 1, source, key, state )
+ end
+ end
+ end
+end
+
+function readddamage ()
+ -- addEventHandler ( "onClientPedDamage", getLocalPlayer (), damagenoise )
+end
+
+
+--THIS PART MAKES SHOOTING A WEAPON MAKE NOISE
+function shootingnoise ( weapon )
+ if weapon == 22 then
+ soundlevel = soundlevel +1
+ elseif weapon == 24 then
+ soundlevel = soundlevel +2
+ elseif weapon == 25 then
+ soundlevel = soundlevel +2
+ elseif weapon == 27 then
+ soundlevel = soundlevel +2
+ elseif weapon == 28 then
+ soundlevel = soundlevel +1
+ elseif weapon == 29 then
+ soundlevel = soundlevel +1
+ elseif weapon == 30 then
+ soundlevel = soundlevel +1
+ elseif weapon == 31 then
+ soundlevel = soundlevel +1
+ elseif weapon == 32 then
+ soundlevel = soundlevel +1
+ elseif weapon == 33 then
+ soundlevel = soundlevel +2
+ elseif weapon == 34 then
+ soundlevel = soundlevel +3
+ end
+end
+
+--THIS PART CAUSES PLAYERS TO MAKE NOISE IF THEY DONT CROUCH OR SLOW WALK
+function walksoundstart (source, key, keystate)
+ if isplayermoving ~= 1 then
+ movementsound = setTimer ( movementcheck, 900, 0 )
+ isplayermoving = 1
+ end
+end
+
+
+--LIMP TIMING
+
+function limpeffect ( source, key, keystate )
+ if isPedInVehicle (getLocalPlayer ()) then
+ return
+ else
+ islimping = getElementData ( getLocalPlayer (), "legdamage" )
+ if islimping == 1 then
+ local makeplayerlimp = setTimer ( limpeffectparttwo , 200, 1, source, key, state )
+ if lookingthroughcamera ~= 1 then
+ toggleControl ("right", false )
+ toggleControl ("left", false )
+ toggleControl ("forwards", false )
+ toggleControl ("backwards", false )
+ end
+ end
+ end
+end
+
+function limpeffectparttwo ( source, key, keystate )
+ if isPedInVehicle (getLocalPlayer ()) then
+ return
+ else
+ islimping = getElementData ( getLocalPlayer (), "legdamage" )
+ if islimping == 1 then
+ local makeplayerlimp = setTimer ( limpeffect, 500, 1, source, key, state )
+ if lookingthroughcamera ~= 1 then
+ if shieldon ~= 1 then
+ toggleControl ("right", true )
+ toggleControl ("left", true )
+ toggleControl ("forwards", true )
+ toggleControl ("backwards", true )
+ end
+ end
+ end
+ end
+end
+
+function startalimp ()
+ local theplayer = getLocalPlayer ()
+ if (getPedArmor ( theplayer )) == 0 then
+ setElementData ( getLocalPlayer (), "legdamage", 1 )
+ local makeplayerlimp = setTimer ( limpeffect, 300, 1, source, key, state )
+ end
+end
+
+addCommandHandler ( "crippleme", startalimp )
+
+
+function movementcheck ( source, key, keystate )
+ if ( isPedDucked ( getLocalPlayer () ) ) == false then
+ if ( getPedControlState ( "sprint" ) ) then
+ soundlevel = soundlevel +1
+ end
+ if ( getPedControlState ( "walk" ) ) == false then
+ soundlevel = soundlevel +1
+ end
+ end
+end
+
+function walksoundstop ( source, key, keystate )
+ if isplayermoving == 1 then
+ if ( getPedControlState ( "forwards" ) ) == false and ( getPedControlState ( "backwards" ) ) == false and ( getPedControlState ( "left" ) ) == false and ( getPedControlState ( "right" ) ) == false then
+ killTimer ( movementsound )
+ isplayermoving = 0
+ end
+ end
+end
+
+function setuptrigger ( theresource )
+ if theresource == getThisResource() then
+ setupstuff()
+ end
+end
+
+function hidesoundbar ( theresource )
+ guiSetVisible ( thesoundbar, false )
+end
+
+addEventHandler ( "onClientPlayerWasted", getLocalPlayer (), hidesoundbar )
+addEventHandler ( "onClientPlayerDamage", getLocalPlayer (), damagenoise )
+addEventHandler ( "onClientPlayerWeaponFire", getLocalPlayer (), shootingnoise )
+addEventHandler ( "onClientPlayerSpawn", getLocalPlayer (), setupsoundstuff )
+addEventHandler ( "onClientResourceStart", resourceRoot, setuptrigger)
diff --git a/[gamemodes]/[stealth]/stealth/noiseblip.lua b/[gamemodes]/[stealth]/stealth/client/noiseblip.lua
similarity index 96%
rename from [gamemodes]/[stealth]/stealth/noiseblip.lua
rename to [gamemodes]/[stealth]/stealth/client/noiseblip.lua
index b39d3734b..9fb6fc669 100644
--- a/[gamemodes]/[stealth]/stealth/noiseblip.lua
+++ b/[gamemodes]/[stealth]/stealth/client/noiseblip.lua
@@ -1,92 +1,92 @@
-local getEnemyTeam = { RED = "BLUE", BLUE = "RED" }
-local blipColors = { RED = {255,0,0}, BLUE = {0,0,255} }
-local playerBlips = {}
-local blipInfo = {}
-
---Setup our playerblips
-addEventHandler ( "onClientPlayerSpawn", root,
- function()
- if isElement ( playerBlips[source] ) then
- destroyElement ( playerBlips[source] )
- end
- playerBlips[source] = createBlip ( 0, 0, 0, 0, 2, 255, 0, 0, 0 )
- attachElements ( playerBlips[source], source )
- end
-)
-
-addEventHandler ( "onClientPlayerQuit", root,
- function()
- destroyElement ( playerBlips[source] )
- playerBlips[source] = nil
- end
-)
-
-addEventHandler ( "onClientPlayerWasted", root,
- function()
- destroyElement ( playerBlips[source] )
- playerBlips[source] = nil
- end
-)
----
-
-function updateRemoteSoundLevels ()
- local localTeam = getPlayerTeam ( thisplayer )
- if not localTeam then return end
- local localTeamName = getTeamName(localTeam)
- local enemyTeam = getTeamFromName( getEnemyTeam[localTeamName] )
- local enemyTeamName = getEnemyTeam[localTeamName]
- --
- for i,player in ipairs(getElementsByType"player") do
- local soundlevel = getElementData ( player, "noiselevel" )
- local playerTeam = getPlayerTeam(player)
- if ( playerTeam ) then
- local teamName = getTeamName ( playerTeam )
- --Sort out our nametags
- if playerTeam == localTeam then
- setPlayerNametagShowing(player,true)
- if isElement ( playerBlips[player] ) then
- if soundlevel == 0 then
- setBlipColor ( playerBlips[player], blipColors[teamName][1],blipColors[teamName][2],blipColors[teamName][3], 255 )
- setBlipSize ( playerBlips[player], 1 )
- else
- setBlipSize ( playerBlips[player], 2 )
- setBlipColor ( playerBlips[player], blipColors[teamName][1],blipColors[teamName][2],blipColors[teamName][3], 255*(soundlevel/10) )
- end
- end
- else
- if soundlevel == 0 then
- setPlayerNametagShowing(player,false)
- else
- setPlayerNametagShowing(player,true)
- end
- if isElement ( playerBlips[player] ) then
- setBlipColor ( playerBlips[player], blipColors[teamName][1],blipColors[teamName][2],blipColors[teamName][3], 255*(soundlevel/10) )
- end
- end
- end
- end
-end
-
-
-function table.find ( theTable, value )
- for i,v in pairs(theTable) do
- if v == value then
- return
- end
- end
- return false
-end
-
-
-function destroyBlipsAttachedTo(player)
- if not isElement(player) then return false end
- --
- local attached = getAttachedElements ( player )
- if not attached then return false end
- for k,element in ipairs(attached) do
- if getElementType ( element ) == "blip" then
- destroyElement ( element )
- end
- end
- return true
-end
+local getEnemyTeam = { RED = "BLUE", BLUE = "RED" }
+local blipColors = { RED = {255,0,0}, BLUE = {0,0,255} }
+local playerBlips = {}
+local blipInfo = {}
+
+--Setup our playerblips
+addEventHandler ( "onClientPlayerSpawn", root,
+ function()
+ if isElement ( playerBlips[source] ) then
+ destroyElement ( playerBlips[source] )
+ end
+ playerBlips[source] = createBlip ( 0, 0, 0, 0, 2, 255, 0, 0, 0 )
+ attachElements ( playerBlips[source], source )
+ end
+)
+
+addEventHandler ( "onClientPlayerQuit", root,
+ function()
+ destroyElement ( playerBlips[source] )
+ playerBlips[source] = nil
+ end
+)
+
+addEventHandler ( "onClientPlayerWasted", root,
+ function()
+ destroyElement ( playerBlips[source] )
+ playerBlips[source] = nil
+ end
+)
+---
+
+function updateRemoteSoundLevels ()
+ local localTeam = getPlayerTeam ( thisplayer )
+ if not localTeam then return end
+ local localTeamName = getTeamName(localTeam)
+ local enemyTeam = getTeamFromName( getEnemyTeam[localTeamName] )
+ local enemyTeamName = getEnemyTeam[localTeamName]
+ --
+ for i,player in ipairs(getElementsByType"player") do
+ local soundlevel = getElementData ( player, "noiselevel" )
+ local playerTeam = getPlayerTeam(player)
+ if ( playerTeam ) then
+ local teamName = getTeamName ( playerTeam )
+ --Sort out our nametags
+ if playerTeam == localTeam then
+ setPlayerNametagShowing(player,true)
+ if isElement ( playerBlips[player] ) then
+ if soundlevel == 0 then
+ setBlipColor ( playerBlips[player], blipColors[teamName][1],blipColors[teamName][2],blipColors[teamName][3], 255 )
+ setBlipSize ( playerBlips[player], 1 )
+ else
+ setBlipSize ( playerBlips[player], 2 )
+ setBlipColor ( playerBlips[player], blipColors[teamName][1],blipColors[teamName][2],blipColors[teamName][3], 255*(soundlevel/10) )
+ end
+ end
+ else
+ if soundlevel == 0 then
+ setPlayerNametagShowing(player,false)
+ else
+ setPlayerNametagShowing(player,true)
+ end
+ if isElement ( playerBlips[player] ) then
+ setBlipColor ( playerBlips[player], blipColors[teamName][1],blipColors[teamName][2],blipColors[teamName][3], 255*(soundlevel/10) )
+ end
+ end
+ end
+ end
+end
+
+
+function table.find ( theTable, value )
+ for i,v in pairs(theTable) do
+ if v == value then
+ return
+ end
+ end
+ return false
+end
+
+
+function destroyBlipsAttachedTo(player)
+ if not isElement(player) then return false end
+ --
+ local attached = getAttachedElements ( player )
+ if not attached then return false end
+ for k,element in ipairs(attached) do
+ if getElementType ( element ) == "blip" then
+ destroyElement ( element )
+ end
+ end
+ return true
+end
diff --git a/[gamemodes]/[stealth]/stealth/riot_shield.col b/[gamemodes]/[stealth]/stealth/client/riot_shield.col
similarity index 100%
rename from [gamemodes]/[stealth]/stealth/riot_shield.col
rename to [gamemodes]/[stealth]/stealth/client/riot_shield.col
diff --git a/[gamemodes]/[stealth]/stealth/riot_shield.dff b/[gamemodes]/[stealth]/stealth/client/riot_shield.dff
similarity index 100%
rename from [gamemodes]/[stealth]/stealth/riot_shield.dff
rename to [gamemodes]/[stealth]/stealth/client/riot_shield.dff
diff --git a/[gamemodes]/[stealth]/stealth/riot_shield.txd b/[gamemodes]/[stealth]/stealth/client/riot_shield.txd
similarity index 100%
rename from [gamemodes]/[stealth]/stealth/riot_shield.txd
rename to [gamemodes]/[stealth]/stealth/client/riot_shield.txd
diff --git a/[gamemodes]/[stealth]/stealth/spycam.lua b/[gamemodes]/[stealth]/stealth/client/spycam.lua
similarity index 96%
rename from [gamemodes]/[stealth]/stealth/spycam.lua
rename to [gamemodes]/[stealth]/stealth/client/spycam.lua
index 22fa4a4b8..e363ce639 100644
--- a/[gamemodes]/[stealth]/stealth/spycam.lua
+++ b/[gamemodes]/[stealth]/stealth/client/spycam.lua
@@ -1,187 +1,187 @@
---this was heavilly based on freecam, thanks eAi
---max rots are half the distance either way
-local buttonStates = {}
-local maxRot = 90
-local maxRotX = 90
-local moveSpeed = 2
-local rotX,rotY,rotZ = 0,0,0
-local spyCamX, spyCamY, spyCamZ= false,false,false
-local spyCamTargetX, spyCamTargetY, spyCamTargetZ = false,false,false
-local camFixed = false
-local minXBound, maxXBound
-local firstTime
-
-function spyCamFrame ()
- aX = 0
- aY = 0
- if buttonStates["right"] == true then
- aX = moveSpeed
- end
- if buttonStates["left"] == true then
- aX = -moveSpeed
- end
- if buttonStates["forwards"] == true then
- aY = -moveSpeed
- end
- if buttonStates["backwards"] == true then
- aY = moveSpeed
- end
- rotX = rotX + aX
- rotY = rotY - aY
- -- limit the camera to stop it going too far up or down, left or right
- if rotY < -maxRot then
- rotY = -maxRot
- elseif rotY > maxRot then
- rotY = maxRot
- end
- if rotX < minXBound then
- rotX = minXBound
- elseif rotX > maxXBound then
- rotX = maxXBound
- end
-
- -- work out an angle in radians based on the number of pixels the cursor has moved (ever)
- local cameraAngleX = rotX / 120
- local cameraAngleY = rotY / 120
-
- local freeModeAngleX = math.sin(cameraAngleX / 2)
- local freeModeAngleY = math.cos(cameraAngleX / 2)
- local yangle = cameraAngleY / 1.5 -- the 1.5 limits the ammount the camera can rotate, decrease it to increase the amount
-
- local freeModeAngleZ = math.sin(yangle)
- local camPosX, camPosY, camPosZ = spyCamX,spyCamY,spyCamZ
-
- -- calculate a target based on the current position and an offset based on the angle
- local camTargetX = camPosX + freeModeAngleX * 100
- local camTargetY = camPosY + freeModeAngleY * 100
- local camTargetZ = camPosZ + freeModeAngleZ * 100
-
-
- -- Work out the distance between the target and the camera (should be 100 units)
- local camAngleX = camPosX - camTargetX
- local camAngleY = camPosY - camTargetY
- local camAngleZ = camPosZ - camTargetZ
-
- -- Calulcate the length of the vector
- local angleLength = math.sqrt(camAngleX*camAngleX+camAngleY*camAngleY+camAngleZ*camAngleZ)
-
- -- Update the target based on the new camera position (again, otherwise the camera kind of sways as the target is out by a frame)
- camTargetX = camPosX + freeModeAngleX * 100
- camTargetY = camPosY + freeModeAngleY * 100
- camTargetZ = camPosZ + freeModeAngleZ * 100
- if firstTime == true then
- camTargetX,camTargetY,camTargetZ = spyCamTargetX, spyCamTargetY, spyCamTargetZ
- firstTime = false
- end
- -- Set the new camera position and target
- --setCameraLookAt ( camTargetX, camTargetY, camTargetZ )
- setCameraMatrix(camPosX, camPosY, camPosZ, camTargetX, camTargetY, camTargetZ)
-end
-
-addEvent ("setcamerapos", true )
-
-function placeSpyCam ( x,y,z, rot )
- if ( not tonumber(rot) ) then return false end
- if not getZoneName ( x,y,z ) then return false end
- rotX = rot * -4
-
- minXBound = rotX - ( (maxRotX/2) * 4 )
- maxXBound = rotX + ( (maxRotX/2) * 4 )
-
- rot = math.rad ( rot )
-
- spyCamTargetX,spyCamTargetY,spyCamTargetZ = x,y,z
- spyCamX = spyCamTargetX
- spyCamY = spyCamTargetY
- spyCamZ = spyCamTargetZ
- --set it to look straight ahead
- spyCamTargetX = spyCamTargetX + ( -1000000 * math.sin(rot) )
- spyCamTargetY = spyCamTargetY + ( 1000000 * math.cos(rot) )
- --
- --make the camera level
- return true
-end
-
-addEventHandler ( "setcamerapos", root, placeSpyCam )
-
-function removeSpyCam()
- spyCamX = false
- spyCamY = false
- spyCamZ = false
- spyCamTargetX = false
- spyCamTargetY = false
- spyCamTargetZ = false
- camFixed = false
- --toggleCameraFixedMode ( false )
- setCameraTarget(localPlayer)
- return true
-end
-
-function toggleSpyCam()
- if camFixed == false then
- --if the spy cam hasnt been placed yet
- if ( spyCamX == false ) or ( spyCamY == false ) or ( spyCamZ == false ) or ( spyCamTargetX == false ) or ( spyCamTargetY == false ) or ( spyCamTargetZ == false ) then
- return false
- end
- --setCameraPosition ( spyCamX,spyCamY,spyCamZ )
- --setCameraLookAt ( spyCamTargetX, spyCamTargetY, spyCamTargetZ )
- --toggleCameraFixedMode ( true )
- setCameraMatrix(spyCamX, spyCamY, spyCamZ, spyCamTargetX, spyCamTargetY, spyCamTargetZ)
- firstTime = true
- camFixed = true
- fadeSpyCam ( true )
- return addEventHandler ( "onClientRender", root, spyCamFrame )
- else
- --toggleCameraFixedMode ( false )
- setCameraTarget(localPlayer)
- camFixed = false
- --bindCamKeys ( false )
- fadeSpyCam ( false )
- return removeEventHandler ( "onClientRender", root, spyCamFrame )
- end
-end
-
-function ejectSmokeGrenade ( throwPower )
- if camFixed == false then return false end
- local x,y,z = spyCamX, spyCamY, spyCamZ
- local returnValue = createProjectile ( localPlayer, 17, x, y, z, throwPower )
- return returnValue
-end
-
---this is to create a green look
-function fadeSpyCam ( state )
- if state == true then
- fadeCamera ( false, 1.0, 0,255,0 )
- setTimer ( fadeCamera, 250, 1, true, 9999999, 0, 255, 0 )
- else
- fadeCamera ( true, 0, 0,255,0 )
- end
-end
-
-
---this replaces getControlState as keys are toggled
-function bindCamKeys ( state )
- if ( state == true ) then
- bindKey ( "right", "both", setButtonState )
- bindKey ( "left", "both", setButtonState )
- bindKey ( "forwards", "both", setButtonState )
- bindKey ( "backwards", "both", setButtonState )
- else
- unbindKey ( "right", "both", setButtonState )
- unbindKey ( "left", "both", setButtonState )
- unbindKey ( "forwards", "both", setButtonState )
- unbindKey ( "backwards", "both", setButtonState )
- end
-end
-
-function setButtonState ( key, keyState )
- local state
- if keyState == "down" then
- state = true
- elseif keyState == "up" then
- state = false
- end
- buttonStates[key] = state
-end
-
-bindCamKeys ( true )
+--this was heavilly based on freecam, thanks eAi
+--max rots are half the distance either way
+local buttonStates = {}
+local maxRot = 90
+local maxRotX = 90
+local moveSpeed = 2
+local rotX,rotY,rotZ = 0,0,0
+local spyCamX, spyCamY, spyCamZ= false,false,false
+local spyCamTargetX, spyCamTargetY, spyCamTargetZ = false,false,false
+local camFixed = false
+local minXBound, maxXBound
+local firstTime
+
+function spyCamFrame ()
+ aX = 0
+ aY = 0
+ if buttonStates["right"] == true then
+ aX = moveSpeed
+ end
+ if buttonStates["left"] == true then
+ aX = -moveSpeed
+ end
+ if buttonStates["forwards"] == true then
+ aY = -moveSpeed
+ end
+ if buttonStates["backwards"] == true then
+ aY = moveSpeed
+ end
+ rotX = rotX + aX
+ rotY = rotY - aY
+ -- limit the camera to stop it going too far up or down, left or right
+ if rotY < -maxRot then
+ rotY = -maxRot
+ elseif rotY > maxRot then
+ rotY = maxRot
+ end
+ if rotX < minXBound then
+ rotX = minXBound
+ elseif rotX > maxXBound then
+ rotX = maxXBound
+ end
+
+ -- work out an angle in radians based on the number of pixels the cursor has moved (ever)
+ local cameraAngleX = rotX / 120
+ local cameraAngleY = rotY / 120
+
+ local freeModeAngleX = math.sin(cameraAngleX / 2)
+ local freeModeAngleY = math.cos(cameraAngleX / 2)
+ local yangle = cameraAngleY / 1.5 -- the 1.5 limits the ammount the camera can rotate, decrease it to increase the amount
+
+ local freeModeAngleZ = math.sin(yangle)
+ local camPosX, camPosY, camPosZ = spyCamX,spyCamY,spyCamZ
+
+ -- calculate a target based on the current position and an offset based on the angle
+ local camTargetX = camPosX + freeModeAngleX * 100
+ local camTargetY = camPosY + freeModeAngleY * 100
+ local camTargetZ = camPosZ + freeModeAngleZ * 100
+
+
+ -- Work out the distance between the target and the camera (should be 100 units)
+ local camAngleX = camPosX - camTargetX
+ local camAngleY = camPosY - camTargetY
+ local camAngleZ = camPosZ - camTargetZ
+
+ -- Calulcate the length of the vector
+ local angleLength = math.sqrt(camAngleX*camAngleX+camAngleY*camAngleY+camAngleZ*camAngleZ)
+
+ -- Update the target based on the new camera position (again, otherwise the camera kind of sways as the target is out by a frame)
+ camTargetX = camPosX + freeModeAngleX * 100
+ camTargetY = camPosY + freeModeAngleY * 100
+ camTargetZ = camPosZ + freeModeAngleZ * 100
+ if firstTime == true then
+ camTargetX,camTargetY,camTargetZ = spyCamTargetX, spyCamTargetY, spyCamTargetZ
+ firstTime = false
+ end
+ -- Set the new camera position and target
+ --setCameraLookAt ( camTargetX, camTargetY, camTargetZ )
+ setCameraMatrix(camPosX, camPosY, camPosZ, camTargetX, camTargetY, camTargetZ)
+end
+
+addEvent ("setcamerapos", true )
+
+function placeSpyCam ( x,y,z, rot )
+ if ( not tonumber(rot) ) then return false end
+ if not getZoneName ( x,y,z ) then return false end
+ rotX = rot * -4
+
+ minXBound = rotX - ( (maxRotX/2) * 4 )
+ maxXBound = rotX + ( (maxRotX/2) * 4 )
+
+ rot = math.rad ( rot )
+
+ spyCamTargetX,spyCamTargetY,spyCamTargetZ = x,y,z
+ spyCamX = spyCamTargetX
+ spyCamY = spyCamTargetY
+ spyCamZ = spyCamTargetZ
+ --set it to look straight ahead
+ spyCamTargetX = spyCamTargetX + ( -1000000 * math.sin(rot) )
+ spyCamTargetY = spyCamTargetY + ( 1000000 * math.cos(rot) )
+ --
+ --make the camera level
+ return true
+end
+
+addEventHandler ( "setcamerapos", root, placeSpyCam )
+
+function removeSpyCam()
+ spyCamX = false
+ spyCamY = false
+ spyCamZ = false
+ spyCamTargetX = false
+ spyCamTargetY = false
+ spyCamTargetZ = false
+ camFixed = false
+ --toggleCameraFixedMode ( false )
+ setCameraTarget(localPlayer)
+ return true
+end
+
+function toggleSpyCam()
+ if camFixed == false then
+ --if the spy cam hasnt been placed yet
+ if ( spyCamX == false ) or ( spyCamY == false ) or ( spyCamZ == false ) or ( spyCamTargetX == false ) or ( spyCamTargetY == false ) or ( spyCamTargetZ == false ) then
+ return false
+ end
+ --setCameraPosition ( spyCamX,spyCamY,spyCamZ )
+ --setCameraLookAt ( spyCamTargetX, spyCamTargetY, spyCamTargetZ )
+ --toggleCameraFixedMode ( true )
+ setCameraMatrix(spyCamX, spyCamY, spyCamZ, spyCamTargetX, spyCamTargetY, spyCamTargetZ)
+ firstTime = true
+ camFixed = true
+ fadeSpyCam ( true )
+ return addEventHandler ( "onClientRender", root, spyCamFrame )
+ else
+ --toggleCameraFixedMode ( false )
+ setCameraTarget(localPlayer)
+ camFixed = false
+ --bindCamKeys ( false )
+ fadeSpyCam ( false )
+ return removeEventHandler ( "onClientRender", root, spyCamFrame )
+ end
+end
+
+function ejectSmokeGrenade ( throwPower )
+ if camFixed == false then return false end
+ local x,y,z = spyCamX, spyCamY, spyCamZ
+ local returnValue = createProjectile ( localPlayer, 17, x, y, z, throwPower )
+ return returnValue
+end
+
+--this is to create a green look
+function fadeSpyCam ( state )
+ if state == true then
+ fadeCamera ( false, 1.0, 0,255,0 )
+ setTimer ( fadeCamera, 250, 1, true, 9999999, 0, 255, 0 )
+ else
+ fadeCamera ( true, 0, 0,255,0 )
+ end
+end
+
+
+--this replaces getControlState as keys are toggled
+function bindCamKeys ( state )
+ if ( state == true ) then
+ bindKey ( "right", "both", setButtonState )
+ bindKey ( "left", "both", setButtonState )
+ bindKey ( "forwards", "both", setButtonState )
+ bindKey ( "backwards", "both", setButtonState )
+ else
+ unbindKey ( "right", "both", setButtonState )
+ unbindKey ( "left", "both", setButtonState )
+ unbindKey ( "forwards", "both", setButtonState )
+ unbindKey ( "backwards", "both", setButtonState )
+ end
+end
+
+function setButtonState ( key, keyState )
+ local state
+ if keyState == "down" then
+ state = true
+ elseif keyState == "up" then
+ state = false
+ end
+ buttonStates[key] = state
+end
+
+bindCamKeys ( true )
diff --git a/[gamemodes]/[stealth]/stealth/stealthmain_client.lua b/[gamemodes]/[stealth]/stealth/client/stealthmain_client.lua
similarity index 97%
rename from [gamemodes]/[stealth]/stealth/stealthmain_client.lua
rename to [gamemodes]/[stealth]/stealth/client/stealthmain_client.lua
index f87851bc2..f05307cd3 100644
--- a/[gamemodes]/[stealth]/stealth/stealthmain_client.lua
+++ b/[gamemodes]/[stealth]/stealth/client/stealthmain_client.lua
@@ -1,493 +1,493 @@
-local screenX,screenY = guiGetScreenSize()
-local spectateButton
-addEvent("swaptoggle", true )
-
-function swaptheteams(thisplayer, teamswap)
- aretheyswapped = teamswap
-end
-
-addEventHandler("swaptoggle", root, swaptheteams)
-
-addEvent("showSpectateText",true)
-function showSpectateText(text,show)
- if not spectateButton then
- spectateButton = guiCreateButton ( 0,0,1,1,"",false)
- guiSetEnabled ( spectateButton, false )
- guiSetFont ( spectateButton, "clear-normal-normal" )
- end
- local tempText = guiCreateLabel ( 0,0,1000,18,text,false)
- guiSetFont ( tempText, "clear-normalnormal" )
- local length = guiLabelGetTextExtent ( tempText )
- destroyElement ( tempText )
- local buttonLength = length + 40
- local x = (screenX - buttonLength)/2
- guiSetPosition ( spectateButton,x, 0.75 * screenY, false )
- guiSetSize ( spectateButton,buttonLength, 30, false )
- guiSetText ( spectateButton, text )
- guiSetVisible ( spectateButton, show )
--- showCursor ( true )
-end
-addEventHandler ( "showSpectateText",root,showSpectateText )
-
-
-addEvent("cameramode", true)
-
-function movetocam()
- showSpectateText("",false)
- local cams = getElementsByType ("camera")
- if #cams > 0 then
- local random = math.random( 1, #cams )
- if ( cams[random] ) then
- local x = getElementData ( cams[random], "posX" )
- local y = getElementData ( cams[random], "posY" )
- local z = getElementData ( cams[random], "posZ" )
- local a = getElementData ( cams[random], "targetX" )
- local b = getElementData ( cams[random], "targetY" )
- local c = getElementData ( cams[random], "targetZ" )
- setCameraMatrix(x, y, z, a, b, c)
- end
- else --Most likely a setting
- local cameraData = getElementData(resourceRoot,"camera")
- if cameraData then
- local x,y,z = unpack(cameraData[1])
- local a,b,c = unpack(cameraData[2])
- setCameraMatrix(x, y, z, a, b, c)
- end
- end
-end
-
-addEventHandler("cameramode", root, movetocam)
-
-
-function updateCam (data)
- if data ~= "camera" then return end
- if not getElementData(source,data) then return end
- movetocam()
-end
-addEventHandler ( "onClientElementDataChange", resourceRoot, updateCam )
-
-addEvent("Startround",true)
-
-function starttheround(player)
- outputChatBox("Round Started", 255, 69, 0)
- sitthisoneout = setTimer ( idlethisround, 30000, 1, player )
- team = getPlayerTeam ( player )
- showCursor ( true )
- if (team) then
- teamname = getTeamName ( team )
- if teamname == "RED" then
- if aretheyswapped == 0 then
- guiSetVisible ( spiesMenu, true )
- else
- guiSetVisible ( mercenariesMenu, true )
- end
- end
- if teamname == "BLUE" then
- if aretheyswapped == 0 then
- guiSetVisible ( mercenariesMenu, true )
- else
- guiSetVisible ( spiesMenu, true )
- end
- end
- end
- if goggleson == 1 then
- local tableofplayers = getElementsByType("player")
- for tableKey, tableValue in pairs(tableofplayers) do
- iscloaked = getElementData ( tableValue, "stealthmode" )
- if iscloaked == "on" then
- setElementModel ( tableValue, 111 )
- player = tableValue
- alphachangedelay = setTimer ( setalpha, 100, 1, player )
- end
- end
- end
-end
-
-addEventHandler("Startround", root, starttheround)
-
-function idlethisround (player)
- sitthisoneout = nil
- guiSetVisible ( spiesMenu, false )
- guiSetVisible ( mercenariesMenu, false )
- outputChatBox ( "Sitting out this round", 255, 69, 0)
-end
-
-
-function confirmSelections ( button, state, absoluteX, absoluteY, worldX, worldY, worldZ, clicked )
- --work out the team name judging by what OK button they hit, and the menu they''re using so we know which one to hide.
- local teamName
- if source == mercenariesOK then
- teamName = "mercenaries" --if its the mercernariesOK it must be the mercenaries team
- elseif source == spiesOK then
- teamName = "spies"
- else --if it wasnt either, for some reason, just stop the function.
- return
- end
- showCursor (false)
- primarySelection = getSelectedWeapon ( teamName, "primary" )
- secondarySelection = getSelectedWeapon ( teamName, "secondary" )
- throwableSelection = getSelectedWeapon ( teamName, "throwable" )
- spygadgetSelection = getSelectedWeapon ( teamName, "spygadget" )
-
- --now lets check that they have selected all their weapons, and not left any blank
-
- if primarySelection == false then
- if source == mercenariesOK then
- local randID = math.random ( 1,#mercenariesWeapons.primary) - 1
- setSelectedWeapon ( teamName, "primary", randID )
- elseif source == spiesOK then
- local randID = math.random ( 1,#spiesWeapons.primary) - 1
- setSelectedWeapon ( teamName, "primary", randID )
- end
- end
- --repeat the process
- if secondarySelection == false then
- if source == mercenariesOK then
- local randID = math.random ( 1,#mercenariesWeapons.secondary) - 1
- setSelectedWeapon ( teamName, "secondary", randID )
- elseif source == spiesOK then
- local randID = math.random ( 1,#spiesWeapons.secondary) - 1
- setSelectedWeapon ( teamName, "secondary", randID )
- end
- end
- if throwableSelection == false then
- if source == mercenariesOK then
- local randID = math.random ( 1,#mercenariesWeapons.throwable) - 1
- setSelectedWeapon ( teamName, "throwable", randID )
- elseif source == spiesOK then
- local randID = math.random ( 1,#spiesWeapons.throwable) - 1
- setSelectedWeapon ( teamName, "throwable", randID )
- end
- end
- if spygadgetSelection == false then
- if source == mercenariesOK then
- local randID = math.random ( 1,#mercenariesWeapons.spygadget) - 1
- setSelectedWeapon ( teamName, "spygadget", randID )
- elseif source == spiesOK then
- local randID = math.random ( 1,#spiesWeapons.spygadget) - 1
- setSelectedWeapon ( teamName, "spygadget", randID )
- end
- end
-
- --now we retrieve the new selections, incase they have changed
- primarySelection = getSelectedWeapon ( teamName, "primary" )
- secondarySelection = getSelectedWeapon ( teamName, "secondary" )
- throwableSelection = getSelectedWeapon ( teamName, "throwable" )
- spygadgetSelection = getSelectedWeapon ( teamName, "spygadget" )
-
- ---now do whatever you want with these selections. ive left outputChatBox as an example. remember to use guiSetVisible to hide the menu.
- if (sitthisoneout) then
- killTimer (sitthisoneout)
- sitthisoneout = nil
- end
- if teamName == "mercenaries" then
- guiSetVisible ( mercenariesMenu, false )
- triggerServerEvent ("domercspawn", localPlayer, localPlayer )
- end
-
- if teamName == "spies" then
- guiSetVisible ( spiesMenu, false )
- triggerServerEvent ("dospyspawn", localPlayer, localPlayer )
- end
- setTimer (triggerServerEvent, 1000, 1, "givetheguns", localPlayer, localPlayer, primarySelection, secondarySelection, throwableSelection, spygadgetSelection )
-
-end
-
-addEvent("onClientGamemodeMapStop",true)
-
-function stealthmapstop ()
- if (sitthisoneout) then
- killTimer (sitthisoneout)
- sitthisoneout = nil
- end
- guiSetVisible ( spiesMenu, false )
- guiSetVisible ( mercenariesMenu, false )
-end
-
-addEventHandler( "onClientGamemodeMapStop", root, stealthmapstop )
-
-
---EVERYTHING AFTER THIS IS IS THE GEARSELECT GUI
-
-
---[[-------------------------------------------------------------------------
-To hide or show your menu, use
-guiSetVisible ( spiesMenu, bool showing )
-or
-guiSetVisible ( mercenariesMenu, bool showing )
-
-Where bool showing can be true or false appropriately.
-
-Remember, this script hides the menus by default and leaves them to you to display. If you just want to test, you can comment out lines 161 & 162 where
-i use guiSetVisible to hide it.
-----
-To retrieve what item is selected in a certain category, use
-getSelectedWeapon ( string teamName, string category )
-* teamName: This can either be "spies" or "mercenaries"
-* category: This is the selection category. Can either be "primary", "secondary", "throwable", "spygadget"
-
-This will return the exact string of the item they selected (see appropriate values in the table below) in that category.
-If they didnt select one, or an invalid team or category was input, it will return false.
-
-----
-To forcefully set an item in a certain category, use
-setSelectedWeapon ( string teamName, string category, int row )
-* teamName: This can either be "spies" or "mercenaries"
-* category: This is the selection category. Can either be "primary", "secondary", "throwable", "spygadget"
-* row: An integer representing which row of the item list should be selected. This starts from 0
-
-It will return true if successful, false otherwise. Passing too high or low numbers will just deselect the item.
-
----
-Lastly, ive left some code in the confirmSelections function below, which is commented. You should find this useful.
------------------------------------------------------------------------------]]
-
---set the weapons you want here. Easilly change the names or add new ones, so long as syntax is correct
-mercenariesWeapons = {
-["primary"] = {
- "spaz-12",
- "m4",
- "shotgun"
- },
-["secondary"] = {
- "desert eagle",
- "pistols",
- "uzis"
- },
-["throwable"] = {
- "grenade",
- "satchel",
- "teargas"
- },
-["spygadget"] = {
- "radar burst",
- "goggles",
- "prox mine",
- "camera",
- "shield"
- }
-}
-spiesWeapons = {
-["primary"] = {
- "sniper",
- "ak47",
- "rifle"
- },
-["secondary"] = {
- "pistols",
- "tec-9s",
- "silenced"
- },
-["throwable"] = {
- "molotov",
- "satchel",
- "teargas"
- },
-["spygadget"] = {
- "cloak",
- "radar burst",
- "prox mine",
- "camera",
- "armor"
- }
-}
---lua cant tell the order of tables which have strings as keys. so you have to define what order categories should be created in the menu
-catOrder = {
-["primary"] = 0,
-["secondary"] = 1,
-["throwable"] = 2,
-["spygadget"] = 3
-}
-
-
-local menuX = 0.15
-local menuY = 0.33
-local menuWidth = 0.7
-local menuHeight = 0.34
-
-local gridlistGap = 0.05
-
----------------------I dont suggest you edit anything below this line unless you know what you''re doing-----------------
-
-function setupStealthMenus ( name )
- if name ~= getThisResource() then return end
- --create our windows
- mercenariesMenu = guiCreateWindow ( menuX, menuY, menuWidth, menuHeight, "Mercenaries", true )
- spiesMenu = guiCreateWindow ( menuX, menuY, menuWidth, menuHeight, "Spies", true )
- --call the setup menu selections function, which will setup the menu items according to the tables configured above
- setupMenuSelections ( mercenariesMenu, mercenariesWeapons, "mercenaries" )
- setupMenuSelections ( spiesMenu, spiesWeapons, "spies" )
- --create our OK buttons
- spiesOK = guiCreateButton ( 0.4, 0.85, 0.20, 0.15, "OK", true, spiesMenu )
- mercenariesOK = guiCreateButton ( 0.4, 0.85, 0.20, 0.15, "OK", true, mercenariesMenu )
-
- --make it so they cant be moved or sized
--- guiWindowSetMovable ( spiesMenu, false )
--- guiWindowSetMovable ( mercenariesMenu, false )
--- guiWindowSetSizable ( spiesMenu, false )
--- guiWindowSetSizable ( mercenariesMenu, false )
-
- --hide them by default
- guiSetVisible ( mercenariesMenu, false )
- guiSetVisible ( spiesMenu, false )
-
- addEventHandler ( "onClientGUIClick", mercenariesOK, confirmSelections )
- addEventHandler ( "onClientGUIClick", spiesOK, confirmSelections )
-end
-addEventHandler ( "onClientResourceStart", root, setupStealthMenus )
-
-local retrieveGridList = {}
-retrieveGridList["mercenaries"] = {}
-retrieveGridList["spies"] = {}
-
-function setupMenuSelections ( window, weapons, teamName )
- --work out how many columns we have
- local categories = 0
- for k,v in pairs(weapons) do
- categories = categories + 1
- end
- --first we work out how many gaps we have to make, which is the number of weapon selections - 1
- local gapWidth = gridlistGap * ( categories - 1 )
- --we equally divide the remaining space between the number of required weapon selections
- local gridlistWidth = ( 1.0 - gapWidth ) / categories
- --now we create our gridlists
- for category,weaponsTable in pairs(weapons) do
- local position = catOrder[category]
- local x = position * ( gridlistWidth + gridlistGap )
- local gridList = guiCreateGridList ( x, 0.1, gridlistWidth, 0.75, true, window )
- guiGridListAddColumn ( gridList, category, 0.7 )
- retrieveGridList[teamName][category] = gridList
- local row = 0
- for key, weaponName in pairs ( weaponsTable ) do
- guiGridListAddRow ( gridList )
- guiGridListSetItemText ( gridList, row, 1, weaponName, false, false )
- row = row + 1
- end
- end
-end
-
-function getSelectedWeapon ( teamName, category )
- if teamName ~= "mercenaries" and teamName ~= "spies" then return false end
- if retrieveGridList[teamName][category] == nil then return false end
- local gridList = retrieveGridList[teamName][category]
- local row = guiGridListGetSelectedItem ( gridList )
- if row == -1 then return false end
- local selectedWeapon = guiGridListGetItemText ( gridList, row, 1 )
- return selectedWeapon
-end
-
-function setSelectedWeapon ( teamName, category, row )
- if teamName ~= "mercenaries" and teamName ~= "spies" then return false end
- if retrieveGridList[teamName][category] == nil then return end
- local gridList = retrieveGridList[teamName][category]
- local returnValue = guiGridListSetSelectedItem ( gridList, row, 1 )
- return returnValue
-end
-
-
-function cleanup (theresource)
- thisone = getThisResource()
- if theresource == thisone then
- setElementAlpha ( getLocalPlayer (), 255 )
- timers = getTimers()
- for timerKey, timerValue in ipairs(timers) do
- killTimer ( timerValue )
- end
- unbindKey ("fire", "down", triggerpulled )
- unbindKey ("r", "down", "Use Gadget/Spectate Next" )
- unbindKey ("forwards", "down", walksoundstart )
- unbindKey ("backwards", "down", walksoundstart )
- unbindKey ("left", "down", walksoundstart )
- unbindKey ("right", "down", walksoundstart )
- unbindKey ("forwards", "up", walksoundstop )
- unbindKey ("backwards", "up", walksoundstop )
- unbindKey ("left", "up", walksoundstop )
- unbindKey ("right", "up", walksoundstop )
- end
-end
-
-addEventHandler("onClientResourceStop", root, cleanup)
-
-
---Code for Laser sight on weapons. Currently only for sniper and M4 weapons
-local laserWeapons = {}
-function drawLasers()
- for k,player in ipairs(getElementsByType"player") do
- local playerWeapon = getPedWeapon ( player )
- if ( laserWeapons[playerWeapon] ) then
- local startX,startY,startZ,targetX,targetY,targetZ
- local boneX,boneY,boneZ = getPedBonePosition ( player, 25 )
- startX,startY,startZ = getPedWeaponMuzzlePosition ( player )
- if boneX and startX then
- if getPedControlState(player, "aim_weapon") then
- targetX, targetY, targetZ = getPedTargetEnd(player)
- else
- targetX,targetY,targetZ = extendLine ( boneX,boneY,boneZ,startX,startY,startZ - 0.1,500 )
- end
-
- local bool,hitX,hitY,hitZ = processLineOfSight ( startX,startY,startZ,targetX,targetY,targetZ, true, true, true, true, true, false, false, true )
- if not bool or not hitX then
- hitX,hitY,hitZ = targetX,targetY,targetZ
- end
- dxDrawLine3D ( startX,startY,startZ, hitX,hitY,hitZ, tocolor(255,0,0,50), 1, false, 1 )
- end
- end
- end
-end
-
-function TeamSelected ( button, state, absoluteX, absoluteY, worldX, worldY, worldZ, clicked )
- if source == TeamSelect_Red then
- showCursor ( false )
- triggerServerEvent ("dojoinTeam1", localPlayer, localPlayer )
- guiSetVisible ( TeamSelect_Window[1], false )
- elseif source == TeamSelect_Blue then
- showCursor ( false )
- triggerServerEvent ("dojoinTeam2", localPlayer, localPlayer )
- guiSetVisible ( TeamSelect_Window[1], false )
- end
-end
-
-addEventHandler ( "onClientResourceStart", resourceRoot,
- function()
- movetocam(localPlayer)
- local weaponsTable = getElementData(root,"lasersight")
- if type(weaponsTable) == "table" and #weaponsTable > 0 then
- for k,weaponID in ipairs(weaponsTable) do
- laserWeapons[weaponID] = true
- end
- addEventHandler("onClientRender",root,drawLasers)
- end
- showCursor ( true )
- TeamSelect_Window = {}
- TeamSelect_Button = {}
- TeamSelect_Label = {}
- TeamSelect_Window[1] = guiCreateWindow(0.25,0.35,0.5,0.25,"Choose your Team",true)
- TeamSelect_Red = guiCreateButton(0.04,0.2189,0.4244,0.4852,"RED",true,TeamSelect_Window[1])
- TeamSelect_Blue = guiCreateButton(0.5222,0.2189,0.4244,0.4852,"BLUE",true,TeamSelect_Window[1])
- TeamSelect_Label[2] = guiCreateLabel(0.3422,0.7988,0.5111,0.1183,"F3 to return to this menu",true,TeamSelect_Window[1])
- guiLabelSetVerticalAlign(TeamSelect_Label[2],"top")
- guiLabelSetHorizontalAlign(TeamSelect_Label[2],"left",false)
- addEventHandler ( "onClientGUIClick", TeamSelect_Red, TeamSelected)
- addEventHandler ( "onClientGUIClick", TeamSelect_Blue, TeamSelected)
- guiSetVisible(TeamSelect_Window[1], false)
- end
-)
-
-addEvent("doshowTeamWindow",true)
-function showTeamWindow ()
- guiSetVisible ( TeamSelect_Window[1], true )
- showCursor ( true )
-end
-addEventHandler ( "doshowTeamWindow",root, showTeamWindow )
-
-function extendLine ( x,y,z,x2,y2,z2,length )
- local vx = x2 - x
- local vy = y2 - y
- local vz = z2 - z
- local ratio = length/(getDistanceBetweenPoints3D ( x,y,z,x2,y2,z2 ))
- vx = vx*ratio
- vy = vy*ratio
- vz = vz*ratio
- return (x + vx),(y + vy),(z + vz)
-end
-
+local screenX,screenY = guiGetScreenSize()
+local spectateButton
+addEvent("swaptoggle", true )
+
+function swaptheteams(thisplayer, teamswap)
+ aretheyswapped = teamswap
+end
+
+addEventHandler("swaptoggle", root, swaptheteams)
+
+addEvent("showSpectateText",true)
+function showSpectateText(text,show)
+ if not spectateButton then
+ spectateButton = guiCreateButton ( 0,0,1,1,"",false)
+ guiSetEnabled ( spectateButton, false )
+ guiSetFont ( spectateButton, "clear-normal-normal" )
+ end
+ local tempText = guiCreateLabel ( 0,0,1000,18,text,false)
+ guiSetFont ( tempText, "clear-normalnormal" )
+ local length = guiLabelGetTextExtent ( tempText )
+ destroyElement ( tempText )
+ local buttonLength = length + 40
+ local x = (screenX - buttonLength)/2
+ guiSetPosition ( spectateButton,x, 0.75 * screenY, false )
+ guiSetSize ( spectateButton,buttonLength, 30, false )
+ guiSetText ( spectateButton, text )
+ guiSetVisible ( spectateButton, show )
+-- showCursor ( true )
+end
+addEventHandler ( "showSpectateText",root,showSpectateText )
+
+
+addEvent("cameramode", true)
+
+function movetocam()
+ showSpectateText("",false)
+ local cams = getElementsByType ("camera")
+ if #cams > 0 then
+ local random = math.random( 1, #cams )
+ if ( cams[random] ) then
+ local x = getElementData ( cams[random], "posX" )
+ local y = getElementData ( cams[random], "posY" )
+ local z = getElementData ( cams[random], "posZ" )
+ local a = getElementData ( cams[random], "targetX" )
+ local b = getElementData ( cams[random], "targetY" )
+ local c = getElementData ( cams[random], "targetZ" )
+ setCameraMatrix(x, y, z, a, b, c)
+ end
+ else --Most likely a setting
+ local cameraData = getElementData(resourceRoot,"camera")
+ if cameraData then
+ local x,y,z = unpack(cameraData[1])
+ local a,b,c = unpack(cameraData[2])
+ setCameraMatrix(x, y, z, a, b, c)
+ end
+ end
+end
+
+addEventHandler("cameramode", root, movetocam)
+
+
+function updateCam (data)
+ if data ~= "camera" then return end
+ if not getElementData(source,data) then return end
+ movetocam()
+end
+addEventHandler ( "onClientElementDataChange", resourceRoot, updateCam )
+
+addEvent("Startround",true)
+
+function starttheround(player)
+ outputChatBox("Round Started", 255, 69, 0)
+ sitthisoneout = setTimer ( idlethisround, 30000, 1, player )
+ team = getPlayerTeam ( player )
+ showCursor ( true )
+ if (team) then
+ teamname = getTeamName ( team )
+ if teamname == "RED" then
+ if aretheyswapped == 0 then
+ guiSetVisible ( spiesMenu, true )
+ else
+ guiSetVisible ( mercenariesMenu, true )
+ end
+ end
+ if teamname == "BLUE" then
+ if aretheyswapped == 0 then
+ guiSetVisible ( mercenariesMenu, true )
+ else
+ guiSetVisible ( spiesMenu, true )
+ end
+ end
+ end
+ if goggleson == 1 then
+ local tableofplayers = getElementsByType("player")
+ for tableKey, tableValue in pairs(tableofplayers) do
+ iscloaked = getElementData ( tableValue, "stealthmode" )
+ if iscloaked == "on" then
+ setElementModel ( tableValue, 111 )
+ player = tableValue
+ alphachangedelay = setTimer ( setalpha, 100, 1, player )
+ end
+ end
+ end
+end
+
+addEventHandler("Startround", root, starttheround)
+
+function idlethisround (player)
+ sitthisoneout = nil
+ guiSetVisible ( spiesMenu, false )
+ guiSetVisible ( mercenariesMenu, false )
+ outputChatBox ( "Sitting out this round", 255, 69, 0)
+end
+
+
+function confirmSelections ( button, state, absoluteX, absoluteY, worldX, worldY, worldZ, clicked )
+ --work out the team name judging by what OK button they hit, and the menu they''re using so we know which one to hide.
+ local teamName
+ if source == mercenariesOK then
+ teamName = "mercenaries" --if its the mercernariesOK it must be the mercenaries team
+ elseif source == spiesOK then
+ teamName = "spies"
+ else --if it wasnt either, for some reason, just stop the function.
+ return
+ end
+ showCursor (false)
+ primarySelection = getSelectedWeapon ( teamName, "primary" )
+ secondarySelection = getSelectedWeapon ( teamName, "secondary" )
+ throwableSelection = getSelectedWeapon ( teamName, "throwable" )
+ spygadgetSelection = getSelectedWeapon ( teamName, "spygadget" )
+
+ --now lets check that they have selected all their weapons, and not left any blank
+
+ if primarySelection == false then
+ if source == mercenariesOK then
+ local randID = math.random ( 1,#mercenariesWeapons.primary) - 1
+ setSelectedWeapon ( teamName, "primary", randID )
+ elseif source == spiesOK then
+ local randID = math.random ( 1,#spiesWeapons.primary) - 1
+ setSelectedWeapon ( teamName, "primary", randID )
+ end
+ end
+ --repeat the process
+ if secondarySelection == false then
+ if source == mercenariesOK then
+ local randID = math.random ( 1,#mercenariesWeapons.secondary) - 1
+ setSelectedWeapon ( teamName, "secondary", randID )
+ elseif source == spiesOK then
+ local randID = math.random ( 1,#spiesWeapons.secondary) - 1
+ setSelectedWeapon ( teamName, "secondary", randID )
+ end
+ end
+ if throwableSelection == false then
+ if source == mercenariesOK then
+ local randID = math.random ( 1,#mercenariesWeapons.throwable) - 1
+ setSelectedWeapon ( teamName, "throwable", randID )
+ elseif source == spiesOK then
+ local randID = math.random ( 1,#spiesWeapons.throwable) - 1
+ setSelectedWeapon ( teamName, "throwable", randID )
+ end
+ end
+ if spygadgetSelection == false then
+ if source == mercenariesOK then
+ local randID = math.random ( 1,#mercenariesWeapons.spygadget) - 1
+ setSelectedWeapon ( teamName, "spygadget", randID )
+ elseif source == spiesOK then
+ local randID = math.random ( 1,#spiesWeapons.spygadget) - 1
+ setSelectedWeapon ( teamName, "spygadget", randID )
+ end
+ end
+
+ --now we retrieve the new selections, incase they have changed
+ primarySelection = getSelectedWeapon ( teamName, "primary" )
+ secondarySelection = getSelectedWeapon ( teamName, "secondary" )
+ throwableSelection = getSelectedWeapon ( teamName, "throwable" )
+ spygadgetSelection = getSelectedWeapon ( teamName, "spygadget" )
+
+ ---now do whatever you want with these selections. ive left outputChatBox as an example. remember to use guiSetVisible to hide the menu.
+ if (sitthisoneout) then
+ killTimer (sitthisoneout)
+ sitthisoneout = nil
+ end
+ if teamName == "mercenaries" then
+ guiSetVisible ( mercenariesMenu, false )
+ triggerServerEvent ("domercspawn", localPlayer, localPlayer )
+ end
+
+ if teamName == "spies" then
+ guiSetVisible ( spiesMenu, false )
+ triggerServerEvent ("dospyspawn", localPlayer, localPlayer )
+ end
+ setTimer (triggerServerEvent, 1000, 1, "givetheguns", localPlayer, localPlayer, primarySelection, secondarySelection, throwableSelection, spygadgetSelection )
+
+end
+
+addEvent("onClientGamemodeMapStop",true)
+
+function stealthmapstop ()
+ if (sitthisoneout) then
+ killTimer (sitthisoneout)
+ sitthisoneout = nil
+ end
+ guiSetVisible ( spiesMenu, false )
+ guiSetVisible ( mercenariesMenu, false )
+end
+
+addEventHandler( "onClientGamemodeMapStop", root, stealthmapstop )
+
+
+--EVERYTHING AFTER THIS IS IS THE GEARSELECT GUI
+
+
+--[[-------------------------------------------------------------------------
+To hide or show your menu, use
+guiSetVisible ( spiesMenu, bool showing )
+or
+guiSetVisible ( mercenariesMenu, bool showing )
+
+Where bool showing can be true or false appropriately.
+
+Remember, this script hides the menus by default and leaves them to you to display. If you just want to test, you can comment out lines 161 & 162 where
+i use guiSetVisible to hide it.
+----
+To retrieve what item is selected in a certain category, use
+getSelectedWeapon ( string teamName, string category )
+* teamName: This can either be "spies" or "mercenaries"
+* category: This is the selection category. Can either be "primary", "secondary", "throwable", "spygadget"
+
+This will return the exact string of the item they selected (see appropriate values in the table below) in that category.
+If they didnt select one, or an invalid team or category was input, it will return false.
+
+----
+To forcefully set an item in a certain category, use
+setSelectedWeapon ( string teamName, string category, int row )
+* teamName: This can either be "spies" or "mercenaries"
+* category: This is the selection category. Can either be "primary", "secondary", "throwable", "spygadget"
+* row: An integer representing which row of the item list should be selected. This starts from 0
+
+It will return true if successful, false otherwise. Passing too high or low numbers will just deselect the item.
+
+---
+Lastly, ive left some code in the confirmSelections function below, which is commented. You should find this useful.
+-----------------------------------------------------------------------------]]
+
+--set the weapons you want here. Easilly change the names or add new ones, so long as syntax is correct
+mercenariesWeapons = {
+["primary"] = {
+ "spaz-12",
+ "m4",
+ "shotgun"
+ },
+["secondary"] = {
+ "desert eagle",
+ "pistols",
+ "uzis"
+ },
+["throwable"] = {
+ "grenade",
+ "satchel",
+ "teargas"
+ },
+["spygadget"] = {
+ "radar burst",
+ "goggles",
+ "prox mine",
+ "camera",
+ "shield"
+ }
+}
+spiesWeapons = {
+["primary"] = {
+ "sniper",
+ "ak47",
+ "rifle"
+ },
+["secondary"] = {
+ "pistols",
+ "tec-9s",
+ "silenced"
+ },
+["throwable"] = {
+ "molotov",
+ "satchel",
+ "teargas"
+ },
+["spygadget"] = {
+ "cloak",
+ "radar burst",
+ "prox mine",
+ "camera",
+ "armor"
+ }
+}
+--lua cant tell the order of tables which have strings as keys. so you have to define what order categories should be created in the menu
+catOrder = {
+["primary"] = 0,
+["secondary"] = 1,
+["throwable"] = 2,
+["spygadget"] = 3
+}
+
+
+local menuX = 0.15
+local menuY = 0.33
+local menuWidth = 0.7
+local menuHeight = 0.34
+
+local gridlistGap = 0.05
+
+---------------------I dont suggest you edit anything below this line unless you know what you''re doing-----------------
+
+function setupStealthMenus ( name )
+ if name ~= getThisResource() then return end
+ --create our windows
+ mercenariesMenu = guiCreateWindow ( menuX, menuY, menuWidth, menuHeight, "Mercenaries", true )
+ spiesMenu = guiCreateWindow ( menuX, menuY, menuWidth, menuHeight, "Spies", true )
+ --call the setup menu selections function, which will setup the menu items according to the tables configured above
+ setupMenuSelections ( mercenariesMenu, mercenariesWeapons, "mercenaries" )
+ setupMenuSelections ( spiesMenu, spiesWeapons, "spies" )
+ --create our OK buttons
+ spiesOK = guiCreateButton ( 0.4, 0.85, 0.20, 0.15, "OK", true, spiesMenu )
+ mercenariesOK = guiCreateButton ( 0.4, 0.85, 0.20, 0.15, "OK", true, mercenariesMenu )
+
+ --make it so they cant be moved or sized
+-- guiWindowSetMovable ( spiesMenu, false )
+-- guiWindowSetMovable ( mercenariesMenu, false )
+-- guiWindowSetSizable ( spiesMenu, false )
+-- guiWindowSetSizable ( mercenariesMenu, false )
+
+ --hide them by default
+ guiSetVisible ( mercenariesMenu, false )
+ guiSetVisible ( spiesMenu, false )
+
+ addEventHandler ( "onClientGUIClick", mercenariesOK, confirmSelections )
+ addEventHandler ( "onClientGUIClick", spiesOK, confirmSelections )
+end
+addEventHandler ( "onClientResourceStart", root, setupStealthMenus )
+
+local retrieveGridList = {}
+retrieveGridList["mercenaries"] = {}
+retrieveGridList["spies"] = {}
+
+function setupMenuSelections ( window, weapons, teamName )
+ --work out how many columns we have
+ local categories = 0
+ for k,v in pairs(weapons) do
+ categories = categories + 1
+ end
+ --first we work out how many gaps we have to make, which is the number of weapon selections - 1
+ local gapWidth = gridlistGap * ( categories - 1 )
+ --we equally divide the remaining space between the number of required weapon selections
+ local gridlistWidth = ( 1.0 - gapWidth ) / categories
+ --now we create our gridlists
+ for category,weaponsTable in pairs(weapons) do
+ local position = catOrder[category]
+ local x = position * ( gridlistWidth + gridlistGap )
+ local gridList = guiCreateGridList ( x, 0.1, gridlistWidth, 0.75, true, window )
+ guiGridListAddColumn ( gridList, category, 0.7 )
+ retrieveGridList[teamName][category] = gridList
+ local row = 0
+ for key, weaponName in pairs ( weaponsTable ) do
+ guiGridListAddRow ( gridList )
+ guiGridListSetItemText ( gridList, row, 1, weaponName, false, false )
+ row = row + 1
+ end
+ end
+end
+
+function getSelectedWeapon ( teamName, category )
+ if teamName ~= "mercenaries" and teamName ~= "spies" then return false end
+ if retrieveGridList[teamName][category] == nil then return false end
+ local gridList = retrieveGridList[teamName][category]
+ local row = guiGridListGetSelectedItem ( gridList )
+ if row == -1 then return false end
+ local selectedWeapon = guiGridListGetItemText ( gridList, row, 1 )
+ return selectedWeapon
+end
+
+function setSelectedWeapon ( teamName, category, row )
+ if teamName ~= "mercenaries" and teamName ~= "spies" then return false end
+ if retrieveGridList[teamName][category] == nil then return end
+ local gridList = retrieveGridList[teamName][category]
+ local returnValue = guiGridListSetSelectedItem ( gridList, row, 1 )
+ return returnValue
+end
+
+
+function cleanup (theresource)
+ thisone = getThisResource()
+ if theresource == thisone then
+ setElementAlpha ( getLocalPlayer (), 255 )
+ timers = getTimers()
+ for timerKey, timerValue in ipairs(timers) do
+ killTimer ( timerValue )
+ end
+ unbindKey ("fire", "down", triggerpulled )
+ unbindKey ("r", "down", "Use Gadget/Spectate Next" )
+ unbindKey ("forwards", "down", walksoundstart )
+ unbindKey ("backwards", "down", walksoundstart )
+ unbindKey ("left", "down", walksoundstart )
+ unbindKey ("right", "down", walksoundstart )
+ unbindKey ("forwards", "up", walksoundstop )
+ unbindKey ("backwards", "up", walksoundstop )
+ unbindKey ("left", "up", walksoundstop )
+ unbindKey ("right", "up", walksoundstop )
+ end
+end
+
+addEventHandler("onClientResourceStop", root, cleanup)
+
+
+--Code for Laser sight on weapons. Currently only for sniper and M4 weapons
+local laserWeapons = {}
+function drawLasers()
+ for k,player in ipairs(getElementsByType"player") do
+ local playerWeapon = getPedWeapon ( player )
+ if ( laserWeapons[playerWeapon] ) then
+ local startX,startY,startZ,targetX,targetY,targetZ
+ local boneX,boneY,boneZ = getPedBonePosition ( player, 25 )
+ startX,startY,startZ = getPedWeaponMuzzlePosition ( player )
+ if boneX and startX then
+ if getPedControlState(player, "aim_weapon") then
+ targetX, targetY, targetZ = getPedTargetEnd(player)
+ else
+ targetX,targetY,targetZ = extendLine ( boneX,boneY,boneZ,startX,startY,startZ - 0.1,500 )
+ end
+
+ local bool,hitX,hitY,hitZ = processLineOfSight ( startX,startY,startZ,targetX,targetY,targetZ, true, true, true, true, true, false, false, true )
+ if not bool or not hitX then
+ hitX,hitY,hitZ = targetX,targetY,targetZ
+ end
+ dxDrawLine3D ( startX,startY,startZ, hitX,hitY,hitZ, tocolor(255,0,0,50), 1, false, 1 )
+ end
+ end
+ end
+end
+
+function TeamSelected ( button, state, absoluteX, absoluteY, worldX, worldY, worldZ, clicked )
+ if source == TeamSelect_Red then
+ showCursor ( false )
+ triggerServerEvent ("dojoinTeam1", localPlayer, localPlayer )
+ guiSetVisible ( TeamSelect_Window[1], false )
+ elseif source == TeamSelect_Blue then
+ showCursor ( false )
+ triggerServerEvent ("dojoinTeam2", localPlayer, localPlayer )
+ guiSetVisible ( TeamSelect_Window[1], false )
+ end
+end
+
+addEventHandler ( "onClientResourceStart", resourceRoot,
+ function()
+ movetocam(localPlayer)
+ local weaponsTable = getElementData(root,"lasersight")
+ if type(weaponsTable) == "table" and #weaponsTable > 0 then
+ for k,weaponID in ipairs(weaponsTable) do
+ laserWeapons[weaponID] = true
+ end
+ addEventHandler("onClientRender",root,drawLasers)
+ end
+ showCursor ( true )
+ TeamSelect_Window = {}
+ TeamSelect_Button = {}
+ TeamSelect_Label = {}
+ TeamSelect_Window[1] = guiCreateWindow(0.25,0.35,0.5,0.25,"Choose your Team",true)
+ TeamSelect_Red = guiCreateButton(0.04,0.2189,0.4244,0.4852,"RED",true,TeamSelect_Window[1])
+ TeamSelect_Blue = guiCreateButton(0.5222,0.2189,0.4244,0.4852,"BLUE",true,TeamSelect_Window[1])
+ TeamSelect_Label[2] = guiCreateLabel(0.3422,0.7988,0.5111,0.1183,"F3 to return to this menu",true,TeamSelect_Window[1])
+ guiLabelSetVerticalAlign(TeamSelect_Label[2],"top")
+ guiLabelSetHorizontalAlign(TeamSelect_Label[2],"left",false)
+ addEventHandler ( "onClientGUIClick", TeamSelect_Red, TeamSelected)
+ addEventHandler ( "onClientGUIClick", TeamSelect_Blue, TeamSelected)
+ guiSetVisible(TeamSelect_Window[1], false)
+ end
+)
+
+addEvent("doshowTeamWindow",true)
+function showTeamWindow ()
+ guiSetVisible ( TeamSelect_Window[1], true )
+ showCursor ( true )
+end
+addEventHandler ( "doshowTeamWindow",root, showTeamWindow )
+
+function extendLine ( x,y,z,x2,y2,z2,length )
+ local vx = x2 - x
+ local vy = y2 - y
+ local vz = z2 - z
+ local ratio = length/(getDistanceBetweenPoints3D ( x,y,z,x2,y2,z2 ))
+ vx = vx*ratio
+ vy = vy*ratio
+ vz = vz*ratio
+ return (x + vx),(y + vy),(z + vz)
+end
+
diff --git a/[gamemodes]/[stealth]/stealth/meta.xml b/[gamemodes]/[stealth]/stealth/meta.xml
index 421286108..4dab274c1 100644
--- a/[gamemodes]/[stealth]/stealth/meta.xml
+++ b/[gamemodes]/[stealth]/stealth/meta.xml
@@ -1,60 +1,69 @@
-
+
+
+
+
+
+
+
-
-
-
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/[gamemodes]/[stealth]/stealth/gadgets_server.lua b/[gamemodes]/[stealth]/stealth/server/gadgets_server.lua
similarity index 96%
rename from [gamemodes]/[stealth]/stealth/gadgets_server.lua
rename to [gamemodes]/[stealth]/stealth/server/gadgets_server.lua
index a9d85f16c..7a106f420 100644
--- a/[gamemodes]/[stealth]/stealth/gadgets_server.lua
+++ b/[gamemodes]/[stealth]/stealth/server/gadgets_server.lua
@@ -1,170 +1,170 @@
-
---TRIGGERS THE CLOAKING CLIENT FUNCTIONS
-addEvent ("cloaktheplayer", true )
-
-function cloakstart(thisplayer)
- setElementData ( thisplayer, "stealthmode", "on" )
- playSoundFrontEnd ( thisplayer, 34 )
- setElementAlpha ( thisplayer, 10 )
-end
-
-addEventHandler("cloaktheplayer",root,cloakstart)
-
---TRIGGERS THE UNCLOAKING CLIENT FUNCTIONS
-addEvent ("uncloaktheplayer", true )
-
-function cloakstop(thisplayer)
- if (cloakoff) then
- killTimer (cloakoff)
- cloakoff= nil
- end
- setElementData ( thisplayer, "stealthmode", "off" )
- playSoundFrontEnd ( thisplayer, 35 )
- setElementAlpha ( thisplayer, 255 )
-end
-addEventHandler("uncloaktheplayer",root,cloakstop)
-
-
---GOGGLES
-
-addEvent ("goggleswap", true )
-
-function changegoggles(player)
- local currentgoggles = getPedWeapon ( player, 11 )
- if currentgoggles == 44 then
- giveWeapon ( player, 45, 1 )
- outputChatBox("Infrared.",player, 255, 69, 0)
- elseif currentgoggles == 45 then
- giveWeapon ( player, 44, 1 )
- outputChatBox("Nightvision.",player, 255, 69, 0)
- end
-end
-
-addEventHandler("goggleswap",root,changegoggles)
-
-
---PROXY MINES
-
---LAYS THE MINE AND SETS THE COL
-
-addEvent ("poopoutthemine", true )
-
-function laymine(player)
- local posx, posy, posz = getElementPosition ( player )
- local landmine = createObject ( 1510, posx, posy, posz - .999, 0, 0, 3.18 )
- local landminecol = createColSphere ( posx, posy, posz, 3 )
- setElementData ( landminecol, "type", "alandmine" )
- setElementData ( landminecol, "owner", player )
- setElementData ( landmine, "type", "proximity" )
- setElementParent ( landmine, landminecol )
-end
-
-addEventHandler("poopoutthemine",root,laymine)
-
---DETECTS THE HIT
-function landminehit ( player, matchingDimension )
- if ( getElementData ( source, "type" ) == "alandmine" ) then
- if ( getElementData ( player, "stealthmode" ) ~= "on" ) then
- local mineowner = getElementData ( source, "owner" )
- local ownersteam = getPlayerTeam ( mineowner )
- local victimteam = getPlayerTeam ( player )
- if ownersteam ~= victimteam then --IS THIS PLAYER ON THE SAME TEAM AS THE GUY WHO PUT IT THERE?
- local posx, posy, posz = getElementPosition ( source )
- createExplosion (posx, posy, posz, 8, mineowner )
- setElementData ( source, "type", nil )
- destroyElement ( source )
- end
- end
- end
-end
-
-addEventHandler ( "onColShapeHit", root, landminehit )
-
-
---KILLS THE MINE WHEN SHOT
-
-addEvent ("destroylandmine", true )
-
-function destroymine(hitElement)
- if (hitElement) then
- local damagedmine = getElementParent ( hitElement )
- destroyElement ( damagedmine )
- end
-end
-
-addEventHandler("destroylandmine",root,destroymine)
-
-
---SPYCAMERA
-
-addEvent ("placethecam", true )
-
-function dropcamera(player)
- local playerrot = getPedRotation ( player )
- local rot = playerrot-180
- triggerClientEvent(player,"findcamerapos",root,rot )
-end
-
-addEventHandler("placethecam",root,dropcamera)
-
-
-addEvent ("cameraobject", true )
-
-function placecamball(x, y, z, player)
- local camball = createObject ( 3106, x, y, z )
- local camcol = createColSphere ( x, y, z, 1 )
- setElementData ( camcol, "camowner", player )
- setElementData ( camcol, "type", "acamera" )
- setElementParent ( camball, camcol )
-end
-
-addEventHandler("cameraobject",root,placecamball)
-
-addEvent ("killcameraobject", true )
-
-function removecamball(player)
- coltable = getElementsByType ( "colshape" )
- for theKey,thecol in ipairs(coltable) do
- if getElementData ( thecol, "camowner" ) == player then
- setElementData ( thecol, "type", nil )
- destroyElement ( thecol )
- end
- end
-end
-
-addEventHandler("killcameraobject",root,removecamball)
-
-
---SHIELD
-
-addEvent ("shieldup", true )
-
-function maketheshield (player)
- local x, y, z = getElementPosition( player )
- shield = createObject ( 1631, x, y, z, 0, 0, 0 )
- setElementData ( shield, "type", "ashield" )
- if isPedDucked ( player ) then
- attachElements( shield, player, .2, .5, -.6, 0, 90, 0 )
- else
- giveWeapon ( player, 0, 0, true )
- attachElements( shield, player, .2, .5, .2 )
- end
-end
-
-addEventHandler("shieldup", root , maketheshield)
-
-
-addEvent ("shielddown", true )
-
-function killtheshield (player, currentweapon )
- stuckstuff = getAttachedElements ( player )
- for ElementKey, ElementValue in ipairs(stuckstuff) do
- if ( getElementData ( ElementValue, "type" ) == "ashield" ) then
- theshield = ElementValue
- end
- end
- destroyElement ( theshield )
- giveWeapon ( player, currentweapon, 0, true )
-end
-
-addEventHandler("shielddown", root , killtheshield)
+
+--TRIGGERS THE CLOAKING CLIENT FUNCTIONS
+addEvent ("cloaktheplayer", true )
+
+function cloakstart(thisplayer)
+ setElementData ( thisplayer, "stealthmode", "on" )
+ playSoundFrontEnd ( thisplayer, 34 )
+ setElementAlpha ( thisplayer, 10 )
+end
+
+addEventHandler("cloaktheplayer",root,cloakstart)
+
+--TRIGGERS THE UNCLOAKING CLIENT FUNCTIONS
+addEvent ("uncloaktheplayer", true )
+
+function cloakstop(thisplayer)
+ if (cloakoff) then
+ killTimer (cloakoff)
+ cloakoff= nil
+ end
+ setElementData ( thisplayer, "stealthmode", "off" )
+ playSoundFrontEnd ( thisplayer, 35 )
+ setElementAlpha ( thisplayer, 255 )
+end
+addEventHandler("uncloaktheplayer",root,cloakstop)
+
+
+--GOGGLES
+
+addEvent ("goggleswap", true )
+
+function changegoggles(player)
+ local currentgoggles = getPedWeapon ( player, 11 )
+ if currentgoggles == 44 then
+ giveWeapon ( player, 45, 1 )
+ outputChatBox("Infrared.",player, 255, 69, 0)
+ elseif currentgoggles == 45 then
+ giveWeapon ( player, 44, 1 )
+ outputChatBox("Nightvision.",player, 255, 69, 0)
+ end
+end
+
+addEventHandler("goggleswap",root,changegoggles)
+
+
+--PROXY MINES
+
+--LAYS THE MINE AND SETS THE COL
+
+addEvent ("poopoutthemine", true )
+
+function laymine(player)
+ local posx, posy, posz = getElementPosition ( player )
+ local landmine = createObject ( 1510, posx, posy, posz - .999, 0, 0, 3.18 )
+ local landminecol = createColSphere ( posx, posy, posz, 3 )
+ setElementData ( landminecol, "type", "alandmine" )
+ setElementData ( landminecol, "owner", player )
+ setElementData ( landmine, "type", "proximity" )
+ setElementParent ( landmine, landminecol )
+end
+
+addEventHandler("poopoutthemine",root,laymine)
+
+--DETECTS THE HIT
+function landminehit ( player, matchingDimension )
+ if ( getElementData ( source, "type" ) == "alandmine" ) then
+ if ( getElementData ( player, "stealthmode" ) ~= "on" ) then
+ local mineowner = getElementData ( source, "owner" )
+ local ownersteam = getPlayerTeam ( mineowner )
+ local victimteam = getPlayerTeam ( player )
+ if ownersteam ~= victimteam then --IS THIS PLAYER ON THE SAME TEAM AS THE GUY WHO PUT IT THERE?
+ local posx, posy, posz = getElementPosition ( source )
+ createExplosion (posx, posy, posz, 8, mineowner )
+ setElementData ( source, "type", nil )
+ destroyElement ( source )
+ end
+ end
+ end
+end
+
+addEventHandler ( "onColShapeHit", root, landminehit )
+
+
+--KILLS THE MINE WHEN SHOT
+
+addEvent ("destroylandmine", true )
+
+function destroymine(hitElement)
+ if (hitElement) then
+ local damagedmine = getElementParent ( hitElement )
+ destroyElement ( damagedmine )
+ end
+end
+
+addEventHandler("destroylandmine",root,destroymine)
+
+
+--SPYCAMERA
+
+addEvent ("placethecam", true )
+
+function dropcamera(player)
+ local playerrot = getPedRotation ( player )
+ local rot = playerrot-180
+ triggerClientEvent(player,"findcamerapos",root,rot )
+end
+
+addEventHandler("placethecam",root,dropcamera)
+
+
+addEvent ("cameraobject", true )
+
+function placecamball(x, y, z, player)
+ local camball = createObject ( 3106, x, y, z )
+ local camcol = createColSphere ( x, y, z, 1 )
+ setElementData ( camcol, "camowner", player )
+ setElementData ( camcol, "type", "acamera" )
+ setElementParent ( camball, camcol )
+end
+
+addEventHandler("cameraobject",root,placecamball)
+
+addEvent ("killcameraobject", true )
+
+function removecamball(player)
+ coltable = getElementsByType ( "colshape" )
+ for theKey,thecol in ipairs(coltable) do
+ if getElementData ( thecol, "camowner" ) == player then
+ setElementData ( thecol, "type", nil )
+ destroyElement ( thecol )
+ end
+ end
+end
+
+addEventHandler("killcameraobject",root,removecamball)
+
+
+--SHIELD
+
+addEvent ("shieldup", true )
+
+function maketheshield (player)
+ local x, y, z = getElementPosition( player )
+ shield = createObject ( 1631, x, y, z, 0, 0, 0 )
+ setElementData ( shield, "type", "ashield" )
+ if isPedDucked ( player ) then
+ attachElements( shield, player, .2, .5, -.6, 0, 90, 0 )
+ else
+ giveWeapon ( player, 0, 0, true )
+ attachElements( shield, player, .2, .5, .2 )
+ end
+end
+
+addEventHandler("shieldup", root , maketheshield)
+
+
+addEvent ("shielddown", true )
+
+function killtheshield (player, currentweapon )
+ stuckstuff = getAttachedElements ( player )
+ for ElementKey, ElementValue in ipairs(stuckstuff) do
+ if ( getElementData ( ElementValue, "type" ) == "ashield" ) then
+ theshield = ElementValue
+ end
+ end
+ destroyElement ( theshield )
+ giveWeapon ( player, currentweapon, 0, true )
+end
+
+addEventHandler("shielddown", root , killtheshield)
diff --git a/[gamemodes]/[stealth]/stealth/mission_timer.lua b/[gamemodes]/[stealth]/stealth/server/mission_timer.lua
similarity index 96%
rename from [gamemodes]/[stealth]/stealth/mission_timer.lua
rename to [gamemodes]/[stealth]/stealth/server/mission_timer.lua
index 1f1a731de..5449c894b 100644
--- a/[gamemodes]/[stealth]/stealth/mission_timer.lua
+++ b/[gamemodes]/[stealth]/stealth/server/mission_timer.lua
@@ -1,160 +1,160 @@
---Mission timer by AlienX
-
---Usage:
---In your scripts you need to have added an event handle that the timer will call once the time is up...
---The event call will also have its own ID, so you will be able to use the same timer script, on more than 1 mission at one point in time
---Here goes!
-
-missionTimers = {}
-
-function misTmrStart ( name )
- if ( name ~= getThisResource() ) then return end
- addEvent ( "missionTimerActivated", true )
- keytimer = setTimer ( missionTimerTick, 1000, 0 )
-end
-addEventHandler ( "onResourceStart", resourceRoot, misTmrStart )
-
-function createMissionTimer ( player, timeSeconds, direction, textSize, textPosX, textPosY, textRed, textGreen, textBlue, showForAll )
- local missionTimersCount = #missionTimers + 1
- missionTimers[missionTimersCount] = {}
- missionTimers[missionTimersCount]["defaultTime"] = timeSeconds
- missionTimers[missionTimersCount]["started"] = false
- missionTimers[missionTimersCount]["player"] = player
- missionTimers[missionTimersCount]["id"] = missionTimersCount
- missionTimers[missionTimersCount]["showforall"] = showForAll
-
- if ( direction == ">" ) then
- missionTimers[missionTimersCount]["time"] = "0"
- elseif ( direction == "<" ) then
- missionTimers[missionTimersCount]["time"] = timeSeconds
- else
- missionTimers[missionTimersCount]["time"] = timeSeconds
- end
-
- missionTimers[missionTimersCount]["direction"] = direction
- missionTimers[missionTimersCount]["textDisplay"] = 0
- missionTimers[missionTimersCount]["textItem"] = 0
-
- if ( timeSeconds < 1 ) then
- return false
- else
- missionTimers[missionTimersCount]["timeString"] = calcTime ( timeSeconds )
- showMisTextForPlayer ( player, missionTimersCount, time, textPosX, textPosY, textRed, textGreen, textBlue, textSize, missionTimers[missionTimersCount]["timeString"], showForAll )
- return missionTimersCount
- end
-end
-
-function startTimer ( timerID )
- missionTimers[timerID]["started"] = true
-end
-
-function stopTimer ( timerID )
- missionTimers[timerID]["started"] = false
-end
-
-function restartTimer ( timerID )
- missionTimers[timerID]["started"] = true
- missionTimers[timerID]["time"] = missionTimers[timerID]["defaultTime"]
-end
-
-function destroyMissionTimer ( timerID )
- --outputDebugString ( "Attempting to delete mission timer for id " .. timerID )
- for k,theTimer in ipairs(missionTimers) do
- if ( tostring(k) == tostring(timerID) ) then
- textDestroyTextItem ( theTimer["textItem"] )
- textDestroyDisplay ( theTimer["textDisplay"] )
- theTimer["started"] = false
- end
- end
-end
-
-function showMisTextForPlayer ( player, timerID, time, posx, posy, red, green, blue, scale, text, showForAll )
- textDisplay = textCreateDisplay ()
- local textItem = textCreateTextItem ( text, posx, posy, 2, red, green, blue, 255, scale )
- textDisplayAddText ( textDisplay, textItem )
- if ( showForAll ) then
- local players = getElementsByType( "player" )
- for k,v in ipairs(players) do
- textDisplayAddObserver ( textDisplay, v )
- end
- else
- textDisplayAddObserver ( textDisplay, player )
- end
- missionTimers[timerID]["textDisplay"] = textDisplay
- missionTimers[timerID]["textItem"] = textItem
-end
-
-function setTimerText ( timerID )
- textItemSetText ( timerID["textItem"], timerID["timeString"] )
-end
-
-function calcTime ( timeLeft )
- local calcString = ""
- local timeHours
- local timeMins
- local timeSecs
-
- timeLeft = tonumber(timeLeft)
- ----outputDebugString ( "timeLeft = " .. timeLeft )
-
- timeSecs = math.mod(timeLeft, 60)
- ----outputDebugString ( "timeSeconds = " .. timeSecs )
-
- timeMins = math.mod((timeLeft / 60), 60)
- ----outputDebugString ( "timeMins = " .. timeMins )
-
- timeHours = (timeLeft / 3600)
- ----outputDebugString ( "timeHours = " .. timeHours )
-
- if ( timeHours >= 1 ) then
- ----outputDebugString ( "Time hours is above or equal too 1" )
- calcString = formatStr(tostring(timeHours)) .. ":"
- end
- calcString = calcString .. formatStr(string.format("%.0d", tostring(timeMins))) .. ":" .. formatStr(tostring(timeSecs))
-
- ----outputDebugString ( "calcString = " .. calcString )
- return calcString
-end
-
-function formatStr ( formatString )
- local aString = tostring(formatString)
-
- if ( #aString == 1 ) then
- aString = "0" .. aString
- end
-
- if ( #aString == 0 ) then
- aString = "00"
- end
-
- return aString
-end
-
-function missionTimerTick()
- for k,theTimer in ipairs(missionTimers) do
- if ( theTimer["started"] ) then
- if ( theTimer["direction"] == "<" ) then
- --Counting Down
- theTimer["time"] = ( tonumber(theTimer["time"]) - 1 )
- theTimer["timeString"] = calcTime ( theTimer["time"] )
- setTimerText ( theTimer )
- if ( theTimer["time"] == 0 ) then
- --Counter has finished, set it to not be started and start the thread
- --outputDebugString ( "MISSION TIMER HAS GOT TO 0!" )
- triggerEvent ( "missionTimerActivated", root, tostring(theTimer["id"]), theTimer["player"] )
- theTimer["started"] = false
- end
- elseif ( theTimer["direction"] ~= ">" ) then
- --Set a default value of Down.
- theTimer["direction"] = "<"
- end
- end
- end
-end
-
-
-function onNewPlayerJoin ()
- textDisplayAddObserver ( textDisplay, source )
-end
-
-addEventHandler ( "onPlayerJoin", root, onNewPlayerJoin )
+--Mission timer by AlienX
+
+--Usage:
+--In your scripts you need to have added an event handle that the timer will call once the time is up...
+--The event call will also have its own ID, so you will be able to use the same timer script, on more than 1 mission at one point in time
+--Here goes!
+
+missionTimers = {}
+
+function misTmrStart ( name )
+ if ( name ~= getThisResource() ) then return end
+ addEvent ( "missionTimerActivated", true )
+ keytimer = setTimer ( missionTimerTick, 1000, 0 )
+end
+addEventHandler ( "onResourceStart", resourceRoot, misTmrStart )
+
+function createMissionTimer ( player, timeSeconds, direction, textSize, textPosX, textPosY, textRed, textGreen, textBlue, showForAll )
+ local missionTimersCount = #missionTimers + 1
+ missionTimers[missionTimersCount] = {}
+ missionTimers[missionTimersCount]["defaultTime"] = timeSeconds
+ missionTimers[missionTimersCount]["started"] = false
+ missionTimers[missionTimersCount]["player"] = player
+ missionTimers[missionTimersCount]["id"] = missionTimersCount
+ missionTimers[missionTimersCount]["showforall"] = showForAll
+
+ if ( direction == ">" ) then
+ missionTimers[missionTimersCount]["time"] = "0"
+ elseif ( direction == "<" ) then
+ missionTimers[missionTimersCount]["time"] = timeSeconds
+ else
+ missionTimers[missionTimersCount]["time"] = timeSeconds
+ end
+
+ missionTimers[missionTimersCount]["direction"] = direction
+ missionTimers[missionTimersCount]["textDisplay"] = 0
+ missionTimers[missionTimersCount]["textItem"] = 0
+
+ if ( timeSeconds < 1 ) then
+ return false
+ else
+ missionTimers[missionTimersCount]["timeString"] = calcTime ( timeSeconds )
+ showMisTextForPlayer ( player, missionTimersCount, time, textPosX, textPosY, textRed, textGreen, textBlue, textSize, missionTimers[missionTimersCount]["timeString"], showForAll )
+ return missionTimersCount
+ end
+end
+
+function startTimer ( timerID )
+ missionTimers[timerID]["started"] = true
+end
+
+function stopTimer ( timerID )
+ missionTimers[timerID]["started"] = false
+end
+
+function restartTimer ( timerID )
+ missionTimers[timerID]["started"] = true
+ missionTimers[timerID]["time"] = missionTimers[timerID]["defaultTime"]
+end
+
+function destroyMissionTimer ( timerID )
+ --outputDebugString ( "Attempting to delete mission timer for id " .. timerID )
+ for k,theTimer in ipairs(missionTimers) do
+ if ( tostring(k) == tostring(timerID) ) then
+ textDestroyTextItem ( theTimer["textItem"] )
+ textDestroyDisplay ( theTimer["textDisplay"] )
+ theTimer["started"] = false
+ end
+ end
+end
+
+function showMisTextForPlayer ( player, timerID, time, posx, posy, red, green, blue, scale, text, showForAll )
+ textDisplay = textCreateDisplay ()
+ local textItem = textCreateTextItem ( text, posx, posy, 2, red, green, blue, 255, scale )
+ textDisplayAddText ( textDisplay, textItem )
+ if ( showForAll ) then
+ local players = getElementsByType( "player" )
+ for k,v in ipairs(players) do
+ textDisplayAddObserver ( textDisplay, v )
+ end
+ else
+ textDisplayAddObserver ( textDisplay, player )
+ end
+ missionTimers[timerID]["textDisplay"] = textDisplay
+ missionTimers[timerID]["textItem"] = textItem
+end
+
+function setTimerText ( timerID )
+ textItemSetText ( timerID["textItem"], timerID["timeString"] )
+end
+
+function calcTime ( timeLeft )
+ local calcString = ""
+ local timeHours
+ local timeMins
+ local timeSecs
+
+ timeLeft = tonumber(timeLeft)
+ ----outputDebugString ( "timeLeft = " .. timeLeft )
+
+ timeSecs = math.mod(timeLeft, 60)
+ ----outputDebugString ( "timeSeconds = " .. timeSecs )
+
+ timeMins = math.mod((timeLeft / 60), 60)
+ ----outputDebugString ( "timeMins = " .. timeMins )
+
+ timeHours = (timeLeft / 3600)
+ ----outputDebugString ( "timeHours = " .. timeHours )
+
+ if ( timeHours >= 1 ) then
+ ----outputDebugString ( "Time hours is above or equal too 1" )
+ calcString = formatStr(tostring(timeHours)) .. ":"
+ end
+ calcString = calcString .. formatStr(string.format("%.0d", tostring(timeMins))) .. ":" .. formatStr(tostring(timeSecs))
+
+ ----outputDebugString ( "calcString = " .. calcString )
+ return calcString
+end
+
+function formatStr ( formatString )
+ local aString = tostring(formatString)
+
+ if ( #aString == 1 ) then
+ aString = "0" .. aString
+ end
+
+ if ( #aString == 0 ) then
+ aString = "00"
+ end
+
+ return aString
+end
+
+function missionTimerTick()
+ for k,theTimer in ipairs(missionTimers) do
+ if ( theTimer["started"] ) then
+ if ( theTimer["direction"] == "<" ) then
+ --Counting Down
+ theTimer["time"] = ( tonumber(theTimer["time"]) - 1 )
+ theTimer["timeString"] = calcTime ( theTimer["time"] )
+ setTimerText ( theTimer )
+ if ( theTimer["time"] == 0 ) then
+ --Counter has finished, set it to not be started and start the thread
+ --outputDebugString ( "MISSION TIMER HAS GOT TO 0!" )
+ triggerEvent ( "missionTimerActivated", root, tostring(theTimer["id"]), theTimer["player"] )
+ theTimer["started"] = false
+ end
+ elseif ( theTimer["direction"] ~= ">" ) then
+ --Set a default value of Down.
+ theTimer["direction"] = "<"
+ end
+ end
+ end
+end
+
+
+function onNewPlayerJoin ()
+ textDisplayAddObserver ( textDisplay, source )
+end
+
+addEventHandler ( "onPlayerJoin", root, onNewPlayerJoin )
diff --git a/[gamemodes]/[stealth]/stealth/stealthmain_server.lua b/[gamemodes]/[stealth]/stealth/server/stealthmain_server.lua
similarity index 97%
rename from [gamemodes]/[stealth]/stealth/stealthmain_server.lua
rename to [gamemodes]/[stealth]/stealth/server/stealthmain_server.lua
index 70c34a43c..ccda7bcdd 100644
--- a/[gamemodes]/[stealth]/stealth/stealthmain_server.lua
+++ b/[gamemodes]/[stealth]/stealth/server/stealthmain_server.lua
@@ -1,782 +1,782 @@
-local spectators = {}
-local getPlayerSpectatee = {}
-
-function teamstealthgamestart()
- killmessageRes = getResourceFromName"killmessages"
- call(getResourceFromName("scoreboard"), "addScoreboardColumn", "Score")
- call(getResourceFromName("scoreboard"), "addScoreboardColumn", "kills")
- call(getResourceFromName("scoreboard"), "addScoreboardColumn", "deaths")
- playingaround = 0
- redwinsdisplay = textCreateDisplay()
- local redtext = textCreateTextItem ( "RED Team Wins the Match!", 0.5, 0.5, "low", 255, 0, 0, 255, 3, "center", "center" )
- textDisplayAddText ( redwinsdisplay, redtext )
- bluewinsdisplay = textCreateDisplay()
- local bluetext = textCreateTextItem ( "BLUE Team Wins the Match!", 0.5, 0.5, "low", 0, 0, 255, 255, 3, "center", "center" )
- textDisplayAddText ( bluewinsdisplay, bluetext )
- tiegamedisplay = textCreateDisplay()
- local tietext = textCreateTextItem ( "The Match was a Tie!", 0.5, 0.5, "low", 255, 255, 255, 255, 3, "center", "center" )
- textDisplayAddText ( tiegamedisplay, tietext )
- waitDisplay = textCreateDisplay()
- local waittext = textCreateTextItem ( "Wait for next round to spawn.", 0.5, 0.9, "low", 255, 255, 255, 255, 1.6, "center", "center" )
- textDisplayAddText ( waitDisplay, waittext )
- team1 = createTeam("RED",255,0,0)
- team2 = createTeam("BLUE",0,0,255)
- teamprotect = get("stealth.teamdamage")
- if teamprotect == 1 then
- setTeamFriendlyFire( team1, false )
- setTeamFriendlyFire( team2, false )
- elseif teamprotect == 0 then
- setTeamFriendlyFire( team1, true )
- setTeamFriendlyFire( team2, true )
- end
- setElementData ( team1, "Score", 0 )
- setElementData ( team2, "Score", 0 )
- teamswap = 0
- local players = getElementsByType("player")
- for k,v in ipairs(players) do
- killPed(v)
- fadeCamera(v,true)
- thisplayer = v
- triggerClientEvent(v,"swaptoggle",root, thisplayer, teamswap)
- setElementData ( v, "kills", 0 )
- setElementData ( v, "deaths", 0 )
- setPlayerNametagShowing ( v, false )
- spectators[v] = true
- bindKey ( v, "F3", "down", selectTeamKey )
- end
- --Enable laser sight
- setElementData(root,"lasersight",get("stealth.lasersight"))
-end
-
-addEventHandler( "onGamemodeStart", resourceRoot, teamstealthgamestart )
-
-function joinTeam( player, team )
- setPlayerTeam(player, team)
- if team == team1 then
- setPlayerNametagColor ( player, 255, 0, 0 )
- elseif team == team2 then
- setPlayerNametagColor ( player, 0, 0, 255 )
- end
-end
-
-addEvent("dojoinTeam1",true )
-function joinTeam1( source )
- if (countPlayersInTeam(team1) - countPlayersInTeam(team2) > balanceamount) then
- outputChatBox("Can't join RED too many players", source, 255, 69, 0)
- triggerClientEvent(source,"doshowTeamWindow",source)
- else
- joinTeam(source, team1)
- end
-end
-addEventHandler ( "dojoinTeam1", root, joinTeam1 )
-
-addEvent("dojoinTeam2",true )
-function joinTeam2( source )
- if (countPlayersInTeam(team2) - countPlayersInTeam(team1) > balanceamount) then
- outputChatBox("Can't join BLUE too many players", source, 255, 69, 0)
- triggerClientEvent(source,"doshowTeamWindow",source)
- else
- joinTeam(source, team2)
- end
-end
-addEventHandler ( "dojoinTeam2", root, joinTeam2 )
-
-function selectTeam( player )
- setPlayerTeam(player, nil)
- local thisplayer = player
- triggerClientEvent(player,"doshowTeamWindow",root)
- setCameraFixed(player,"cameramode",root, thisplayer)
- balanceamount = get("stealth.teambalance")
- tonumber(balanceamount)
-end
-
-function selectTeamKey(source)
- ishespawning = getElementData ( source, "cantchangespawns" )
- if ( isPedDead ( source ) ) and (ishespawning == 0) then
- selectTeam( source )
- getPlayerSpectatee[source] = nil
- triggerClientEvent(source,"showSpectateText",source,"",false)
- unbindKey ( source, "r", "down", spectateNext )
- setPlayerTeam(source, nil)
- else
- outputChatBox("You can only change teams when your dead.", source, 255, 69, 0)
- end
-end
-
-function onStealthPlayerJoin ()
- playersin = getPlayerCount()
- if playersin < 3 then
- if playingaround == 1 then
- outputChatBox("Not enough active players, restarting round.", player, 255, 69, 0)
- roundend = setTimer ( stealthroundended, 10000, 1, roundfinish, thisplayer )
- destroyMissionTimer ( roundfinish )
- end
- end
- selectTeam (source)
- setElementData ( source, "kills", 0 )
- setElementData ( source, "deaths", 0 )
- setPlayerNametagShowing ( source, false )
- spectators[source] = true
- bindKey ( source, "F3", "down", selectTeamKey )
- thisplayer = source
- setCameraFixed(source,"cameramode",root, thisplayer)
- destroyshield = setTimer ( function (shield) if isElement ( shield ) then destroyElement ( shield ) end end, 3000, 1, dummyshield )
- setCameraFixed(source,"cameramode",root, thisplayer)
- triggerClientEvent(source,"swaptoggle",root, thisplayer, teamswap)
- textDisplayAddObserver ( waitDisplay, thisplayer )
- fadeCamera(thisplayer,true)
-end
-
-addEventHandler ( "onPlayerJoin", root, onStealthPlayerJoin )
-
-function teamstealthmapstart(startedMap)
- mapRoot = source
- roundstart = setTimer ( startstealthround, 15000, 1, player )
- setElementData ( team1, "Score", 0 )
- setElementData ( team2, "Score", 0 )
- round_count = 0
- local teams = {team1,team2}
- local stealthplayers = getElementsByType("player")
- for index, thisplayer in ipairs(stealthplayers) do
- fadeCamera(thisplayer,true)
- setElementData ( thisplayer, "kills", 0 )
- setElementData ( thisplayer, "deaths", 0 )
- setCameraFixed(thisplayer,"cameramode",root, thisplayer)
- selectTeam (thisplayer)
- end
- teamprotect = get("stealth.teamprotect")
- if teamprotect == 1 then
- setTeamFriendlyFire( team1, false )
- setTeamFriendlyFire( team2, false )
- elseif teamprotect == 0 then
- setTeamFriendlyFire( team1, true )
- setTeamFriendlyFire( team2, true )
- end
- setElementData ( team1, "Score", 0 )
- setElementData ( team2, "Score", 0 )
- currentmap = startedMap
- local maptime = get(getResourceName(currentmap)..".#time")
- if maptime then
- local splitString = split(maptime, string.byte(':'))
- setTime(tonumber(splitString[1]),tonumber(splitString[2]))
- end
- local mapweather = get(getResourceName(currentmap)..".#weather")
- if mapweather then
- setWeather (mapweather)
- end
- local mapwaves = get(getResourceName(currentmap)..".#waveheight")
- if mapwaves then
- setWaveHeight ( mapwaves )
- end
- local mapspeed = get(getResourceName(currentmap)..".#gamespeed")
- if mapspeed then
- setGameSpeed ( mapspeed )
- end
- local mapgravity = get(getResourceName(currentmap)..".#gravity")
- if mapgravity then
- setGravity ( mapgravity )
- end
- --Create our camera element (if settings system was used)
- if ( not getElementsByType"camera"[1] ) and ( get(getResourceName(currentmap)..".camera") ) then
- local cameraInfo = get(getResourceName(currentmap)..".camera")
- if not cameraInfo then
- local xi, yi, zi = 0, 0, 0
- local spawns = table.merge(getElementsByType("spawnpoint",mapRoot),getElementsByType("spyspawn",mapRoot),getElementsByType("mercenaryspawn",mapRoot))
- for i,spawnpoint in ipairs(spawns) do
- xi = xi + getElementData( spawnpoint, "posX" )
- yi = yi + getElementData( spawnpoint, "posY" )
- zi = zi + getElementData( spawnpoint, "posZ" )
- end
- xi = xi/spawns
- yi = yi/spawns
- zi = zi/spawns
- cameraInfo = { {xi, yi, zi}, {xi, yi, zi} }
- end
- setElementData ( resourceRoot, "camera", cameraInfo )
- local camera = createElement("camera")
- setElementData ( camera, "posX", cameraInfo[1][1] )
- setElementData ( camera, "posY", cameraInfo[1][2] )
- setElementData ( camera, "posZ", cameraInfo[1][3] )
- setElementData ( camera, "targetX", cameraInfo[2][1] )
- setElementData ( camera, "targetY", cameraInfo[2][2] )
- setElementData ( camera, "targetZ", cameraInfo[2][3] )
- end
-end
-
-addEventHandler( "onGamemodeMapStart", root, teamstealthmapstart )
-
-function teamstealthmapstop(startedMap)
- local alltheplayers = getElementsByType("player")
- playingaround = 0
- for index, thisplayer in ipairs(alltheplayers) do
- triggerClientEvent(thisplayer,"onClientGamemodeMapStop",root)
- setElementData ( thisplayer, "waitingtospawn", "nope" )
- local isplayercloaked = getElementData ( thisplayer, "stealthmode" )
- if isplayercloaked == "on" then
- local player = thisplayer
- cloakstop(player)
- end
- end
- local timers = getTimers()
- for timerKey, timerValue in ipairs(timers) do
- if timerValue ~= keytimer then
- killTimer ( timerValue )
- end
- end
- removeEventHandler ( "missionTimerActivated", root, stealthroundended )
- destroyMissionTimer ( roundfinish )
- local objectlist = getElementsByType ( "object" )
- for index, object in ipairs(objectlist) do
- if ( getElementData ( object, "renew" ) == "1" ) then
- destroyElement(object)
- end
- end
-end
-
-addEventHandler( "onGamemodeMapStop", root, teamstealthmapstop )
-
-function startstealthround()
- local alltheplayers = getElementsByType("player")
- for index, thisplayer in ipairs(alltheplayers) do
- triggerClientEvent(thisplayer,"swaptoggle",root, thisplayer, teamswap)
- textDisplayRemoveObserver( redwinsdisplay, thisplayer )
- textDisplayRemoveObserver( bluewinsdisplay, thisplayer )
- textDisplayRemoveObserver( tiegamedisplay, thisplayer )
- textDisplayRemoveObserver( waitDisplay, thisplayer )
- end
- currentmap = call(getResourceFromName"mapmanager","getRunningGamemodeMap")
- local maptime = get(getResourceName(currentmap)..".#time")
- if maptime then
- local splitString = split(maptime, string.byte(':'))
- setTime(tonumber(splitString[1]),tonumber(splitString[2]))
- end
- playingaround = 1
- local players = getElementsByType("player")
- for index, player in ipairs(players) do
- setElementData ( player, "waitingtospawn", "indeed" )
- setElementData ( player, "cantchangespawns", 1 )
- triggerClientEvent(player,"Startround",root,player)
- end
- stoptheidlers = setTimer ( idleblockstop, 30000, 1, player )
- rawroundlength = get("stealth.roundlimit")
- roundlength= rawroundlength*60
- if (roundfinish) then
- destroyMissionTimer ( roundfinish )
- end
- roundfinish = createMissionTimer ( player, roundlength, "<", 1.5, 0.5, 0.03, 255, 255, 255, true )
- addEventHandler ( "missionTimerActivated", root, stealthroundended )
- startTimer ( roundfinish )
- freshround = 1
- moldyround = setTimer ( agetheround, 30000, 1 )
- roundnotover = 1
-end
-
-function agetheround()
- freshround = 0
- local everyone = getElementsByType("player")
- local playerCount = #everyone
- if playerCount > 1 then
- playerleftcount ()
- end
-end
-
-addEvent ("domercspawn", true )
-
-function mercspawn(thisplayer)
- currentmap = call(getResourceFromName"mapmanager","getRunningGamemodeMap")
- local mapinterior = get(getResourceName(currentmap)..".#interior")
- if mapinterior == false then
- mapinterior = 0
- end
- mercteamspawns = getElementByID("mercspawns")
- local mercpoints
- if mercteamspawns then
- mercpoints = getElementsByType ( "spawnpoint", mercteamspawns )
- else
- mercpoints = getElementsByType ( "mercenaryspawn", mapRoot or root )
- end
- local random = math.random ( 1, table.getn ( mercpoints ) )
- local posX = getElementData(mercpoints[random], "posX")
- local posY = getElementData(mercpoints[random], "posY")
- local posZ = getElementData(mercpoints[random], "posZ")
- local rot = getElementData(mercpoints[random], "rot") or getElementData(mercpoints[random], "rotZ") or 0
- spawnPlayer ( thisplayer, posX, posY, posZ, rot, 285, mapinterior )
- --setCameraMode ( thisplayer, "player" )
- setCameraTarget ( thisplayer, thisplayer )
- setElementData ( thisplayer, "waitingtospawn", "nope" )
- getPlayerSpectatee[thisplayer] = nil
- triggerClientEvent(source,"showSpectateText",source,"",false)
- spectators[source] = nil
- giveWeapon ( thisplayer, 3, 1 )
- setPedFightingStyle ( thisplayer, 7 )
-end
-
-addEventHandler ( "domercspawn", root, mercspawn )
-
-addEvent ("dospyspawn", true )
-
-function spyspawn(thisplayer)
- currentmap = call(getResourceFromName"mapmanager","getRunningGamemodeMap")
- local mapinterior = get(getResourceName(currentmap)..".#interior")
- if mapinterior == false then
- mapinterior = 0
- end
- spyteamspawns = getElementByID("spyspawns")
- local spypoints
- if spyteamspawns then
- spypoints = getElementsByType ( "spawnpoint", spyteamspawns )
- else
- spypoints = getElementsByType ( "spyspawn", mapRoot or root )
- end
- local random = math.random ( 1, table.getn ( spypoints ) )
- local posX = getElementData(spypoints[random], "posX")
- local posY = getElementData(spypoints[random], "posY")
- local posZ = getElementData(spypoints[random], "posZ")
- local rot = getElementData(spypoints[random], "rot") or getElementData(spypoints[random], "rotZ") or 0
- spawnPlayer ( thisplayer, posX, posY, posZ, rot, 163, mapinterior )
- setCameraTarget( thisplayer, thisplayer )
- --setCameraMode ( thisplayer, "player" )
- setElementData ( thisplayer, "waitingtospawn", "nope" )
- getPlayerSpectatee[source] = nil
- triggerClientEvent(source,"showSpectateText",source,"",false)
- spectators[source] = nil
- giveWeapon ( thisplayer, 4, 1 )
- setPedFightingStyle ( thisplayer, 6 )
-end
-
-addEventHandler ( "dospyspawn", root, spyspawn )
-
-addEvent ( "givetheguns",true )
-
-function gearup (thisplayer, primarySelection, secondarySelection, throwableSelection, spygadgetSelection)
- setPedStat ( thisplayer, 69, 999 )
- setPedStat ( thisplayer, 70, 999 )
- setPedStat ( thisplayer, 71, 999 )
- setPedStat ( thisplayer, 72, 999 )
- setPedStat ( thisplayer, 74, 200 )
- setPedStat ( thisplayer, 75, 999 )
- setPedStat ( thisplayer, 76, 500 )
- setPedStat ( thisplayer, 77, 999 )
- setPedStat ( thisplayer, 78, 200 )
- setPedStat ( thisplayer, 79, 999 )
- setPedStat ( thisplayer, 225, 999 )
- local sx,sy,sz = getElementPosition( thisplayer )
- setElementAlpha ( thisplayer, 255 )
- local dummyshield = createObject ( 1631, sx, sy, -60 )
- triggerClientEvent(thisplayer,"Clientshieldload",root, thisplayer)
- spazammo = get("stealth.spazammo")
- m4ammo = get("stealth.m4ammo")
- shotgunammo = get("stealth.shotgunammo")
- sniperammo = get("stealth.sniperammo")
- ak47ammo = get("stealth.ak47ammo")
- rifleammo = get("stealth.rifleammo")
- deserteagleammo = get("stealth.deserteagleammo")
- pistolammo = get("stealth.pistolammo")
- uziammo = get("stealth.uziammo")
- tec9ammo = get("stealth.tec9ammo")
- silencedammo = get("stealth.silencedammo")
- grenadeammo = get("stealth.grenadeammo")
- satchelammo = get("stealth.satchelammo")
- teargasammo = get("stealth.teargasammo")
- molatovammo = get("stealth.molatovammo")
- local skinnumber = getElementModel ( thisplayer )
- setElementData ( thisplayer, "playerskin", skinnumber )
- if primarySelection == "spaz-12" then
- teamprotect = get("stealth.teamdamage")
- giveWeapon ( thisplayer, 27, spazammo )
- end
- if primarySelection == "m4" then
- giveWeapon ( thisplayer, 31, m4ammo )
- end
- if primarySelection == "shotgun" then
- giveWeapon ( thisplayer, 25, shotgunammo )
- end
- if primarySelection == "sniper" then
- giveWeapon ( thisplayer, 34, sniperammo )
- end
- if primarySelection == "ak47" then
- giveWeapon ( thisplayer, 30, ak47ammo )
- end
- if primarySelection == "rifle" then
- giveWeapon ( thisplayer, 33, rifleammo )
- end
- if secondarySelection == "desert eagle" then
- giveWeapon ( thisplayer, 24, deserteagleammo )
- end
- if secondarySelection == "pistols" then
- giveWeapon ( thisplayer, 22, pistolammo )
- end
- if secondarySelection == "uzis" then
- giveWeapon ( thisplayer, 28, uziammo )
- end
- if secondarySelection == "tec-9s" then
- giveWeapon ( thisplayer, 32, tec9ammo )
- end
- if secondarySelection == "silenced" then
- giveWeapon ( thisplayer, 23, silencedammo )
- end
- if throwableSelection == "grenade" then
- giveWeapon ( thisplayer, 16, grenadeammo )
- end
- if throwableSelection == "satchel" then
- giveWeapon ( thisplayer, 39, satchelammo )
- end
- if throwableSelection == "teargas" then
- giveWeapon ( thisplayer, 17, teargasammo )
- end
- if throwableSelection == "molotov" then
- giveWeapon ( thisplayer, 18, molatovammo )
- end
- if spygadgetSelection == "goggles" then
- giveWeapon ( thisplayer, 44, 1 )
- end
-end
-
-addEventHandler ( "givetheguns", root, gearup )
-
-function idleblockstop ()
- local alltheplayers = getElementsByType("player")
- for index, thisplayer in ipairs(alltheplayers) do
- setElementData ( thisplayer, "waitingtospawn", "nope" )
- if ( isPedDead ( thisplayer ) ) then
- setElementData ( thisplayer, "cantchangespawns", 0 )
- end
- end
-end
-
-function stealthplayerdied ( totalAmmo, killer, killerWeapon, bodypart )
- if playingaround == 1 then
- local playerdeaths = getElementData ( source, "deaths" )
- setElementData ( source, "deaths", playerdeaths+1 )
- if (killer) then
- if killer ~= source then
- local killersscore = getElementData ( killer, "kills" )
- setElementData ( killer, "kills", killersscore+1 )
- end
- end
- end
- waittospec = setTimer ( spectateNext, 6000, 1, source )
- setElementData ( source, "cantchangespawns", 0 )
- textDisplayAddObserver ( waitDisplay, source )
- setElementData ( source, "legdamage", 0 )
- local isplayercloaked = getElementData ( source, "stealthmode" )
- if isplayercloaked == "on" then
- local player = source
- local oldskin = getElementData ( player, "playerskin" )
- setElementModel ( thisplayer, oldskin )
- setElementAlpha ( thisplayer, 255 )
- cloakstop(player)
- end
- if playingaround == 1 then
- if freshround ~= 1 then
- local deadguysteam = getPlayerTeam ( source )
- local teammates = getPlayersInTeam ( deadguysteam )
- for playerKey, playerValue in ipairs(teammates) do
- local isDead = isPedDead(playerValue)
- if (isDead == false) then return end
- end
- local thisplayer = source
- if roundnotover == 1 then
- roundnotover = 0
- roundend = setTimer ( stealthroundended, 4000, 1, roundfinish, thisplayer )
- destroyMissionTimer ( roundfinish )
- setCameraFixed(thisplayer,"cameramode",root, thisplayer)
- end
- end
- end
-end
-
-addEventHandler( "onPlayerWasted", root, stealthplayerdied )
-
-addCommandHandler ( "Use Gadget/Spectate Next",
- function ( player, command, state )
- if state ~= "0" and spectators[player] then
- spectateNext ( player )
- end
- end
-)
-
-function spectateNext (source) -- THIS IS THE FUNCTION USED TO SWICH WHO IS BEING SPECTATED BY PRESSING R
- if playingaround == 1 then -- IF A ROUND IS IN PROGRESS
- if ( isPedDead ( source ) ) then --IF THE PLAYER IS DEAD
- local specPlayer = getPlayerSpectatee[source] -- gets the spectatee player
- if not specPlayer then
- specPlayer = 1
- spectators[source] = true
- end
- local deadplayerTeam = getPlayerTeam(source)
- local playersTable = getPlayersInTeam ( deadplayerTeam )
- playersTable = filterPlayersTable ( playersTable )
- --
- local playerCount = #playersTable
- if playerCount == 0 then
- outputSpectateMessage("Nobody to Spectate",source) -- IF ITS JUST THE 1 PLAYER, SPECTATING IS IMPOSSIBLE
- else
- specPlayer = specPlayer+1
- if isElement ( playersTable[specPlayer] ) then
- while isPedDead ( playersTable[specPlayer] ) do
- specPlayer = specPlayer+1
- end
- end
- if specPlayer > playerCount then
- specPlayer = 1
- end
- --setCameraMode ( source, "player" )
- setCameraTarget ( source, playersTable[specPlayer] )
- outputSpectateMessage("Now spectating "..getPlayerName(playersTable[specPlayer]),source)
- getPlayerSpectatee[source] = specPlayer
- end
- end
- end
-end
-
-function outputSpectateMessage(text,source)
- triggerClientEvent(source,"showSpectateText",source,text,true)
-end
-
-function filterPlayersTable ( playerTable ) --this function clears out useless players from spectators table
- for k,v in ipairs(playerTable) do
- if isPedDead ( v ) then
- table.remove(playerTable,k)
- end
- end
- return playerTable
-end
-
-function stealthroundended( timerID, player )
- if playingaround == 1 then
- if ( tostring(timerID) == tostring(roundfinish) ) then
- destroyMissionTimer ( timerID )
- if (roundend) then
- killTimer (roundend)
- roundend = nil
- end
- playingaround = 0
- if teamswap == 0 then
- teamswap = 1
- else
- teamswap = 0
- end
- local leftgadgetslist = getElementsByType ( "colshape" )
- for index, gadget in ipairs(leftgadgetslist) do
- if ( getElementData ( gadget, "type" ) == "alandmine" ) then
- destroyElement ( gadget ) --DESTROYS ALL LANDMINES AT THE END OF EVERY ROUND
- elseif ( getElementData ( gadget, "type" ) == "acamera" ) then
- destroyElement ( gadget ) --DESTROYS ALL CAMERAS AT THE END OF EVERY ROUND
- end
- end
- local objectlist = getElementsByType ( "object" )
- for index, object in ipairs(objectlist) do
- if ( getElementData ( object, "renew" ) == "1" ) then
- local x,y,z = getElementPosition( object )
- local rx,ry,rz = getObjectRotation ( object )
- local obid = getElementModel ( object )
- destroyElement(object)
- local newobject = createObject ( obid, x, y, z, rx, ry, rz )
- setElementData ( newobject, "renew", "1" )
- end
- end
- local team1survivers = 0
- local team2survivers = 0
- local firstteam = getPlayersInTeam ( team1 )
- for index, thisplayer in ipairs(firstteam) do
- setElementData ( thisplayer, "waitingtospawn", "indeed" )
- setCameraFixed(thisplayer,"cameramode",root, thisplayer)
- triggerClientEvent(thisplayer,"swaptoggle",root, thisplayer, teamswap)
- local isDead = isPedDead(thisplayer)
- if (isDead == false) then
- team1survivers = team1survivers +1
- killPed(thisplayer, thisplayer, 99, 99)
- end
- end
- local secondteam = getPlayersInTeam ( team2 )
- for index, thisplayer in ipairs(secondteam) do
- setElementData ( thisplayer, "waitingtospawn", "indeed" )
- setCameraFixed(thisplayer,"cameramode",root, thisplayer)
- triggerClientEvent(thisplayer,"swaptoggle",root, thisplayer, teamswap)
- local isDead = isPedDead(thisplayer)
- if (isDead == false) then
- team2survivers = team2survivers +1
- killPed(thisplayer, thisplayer, 99, 99)
- end
- end
- local everyone = getElementsByType("player")
- for index, thisplayer in ipairs(everyone) do
- if (sitthisoneout) then
- killTimer (sitthisoneout)
- sitthisoneout = nil
- end
- end
- if team1survivers > team2survivers then
- local alltheplayers = getElementsByType("player")
- for index, thisplayer in ipairs(alltheplayers) do
- textDisplayAddObserver( redwinsdisplay, thisplayer )
- end
- local teampoints = getElementData ( team1, "Score" )
- setElementData ( team1, "Score", teampoints+1 )
- end
- if team2survivers > team1survivers then
- local alltheplayers = getElementsByType("player")
- for index, thisplayer in ipairs(alltheplayers) do
- textDisplayAddObserver( bluewinsdisplay, thisplayer )
- end
- local teampoints = getElementData ( team2, "Score" )
- setElementData ( team2, "Score", teampoints+1 )
- end
- if team2survivers == team1survivers then
- local alltheplayers = getElementsByType("player")
- for index, thisplayer in ipairs(alltheplayers) do
- textDisplayAddObserver( tiegamedisplay, thisplayer )
- end
- end
- roundstart = setTimer ( startstealthround, 7000, 1, player )
- roundcycle = setTimer ( roundtick, 3000, 1, player )
- removeEventHandler ( "missionTimerActivated", root, stealthroundended )
- end
- end
-end
-
-addEvent ( "onPlayerKillMessage", true)
-
-function checkforemokids (killer, weapon, bodypart)
- if weapon == 99 then
- cancelEvent()
- end
-end
-
-addEventHandler( "onPlayerKillMessage", root, checkforemokids )
-
-function roundtick()
- round_count = round_count+1
- round_limit = get("stealth.round_countlimit")*2
- if round_count == round_limit then
- triggerEvent("onRoundFinished", resourceRoot)
- end
-end
-
-function stealthplayerleft (source)
- countplayers = setTimer ( playerleftcount, 2000, 1 )
-end
-
-addEventHandler( "onPlayerQuit", root, stealthplayerleft )
-
-function setCameraFixed ( player )
- triggerClientEvent(player,"cameramode",root, player )
- --showSpectateText("",false)
-end
-
-function playerleftcount (source)
- if playingaround == 1 then
- livingteam1 = 0
- livingteam2 = 0
- local firstteam = getPlayersInTeam ( team1 )
- for playerKey, playerValue in ipairs(firstteam) do
- local isDead = isPedDead(playerValue)
- if (isDead == false) then
- livingteam1 = livingteam1+1
- end
- end
- local secondteam = getPlayersInTeam ( team2 )
- for playerKey, playerValue in ipairs(secondteam) do
- local isDead = isPedDead(playerValue)
- if (isDead == false) then
- livingteam2 = livingteam2+1
- end
- end
- if livingteam1 == 0 then
- roundend = setTimer ( stealthroundended, 4000, 1, roundfinish, thisplayer ) --THIS TRIGGERS THE ROUND ENDING
- destroyMissionTimer ( roundfinish )
- end
- if livingteam2 == 0 then
- roundend = setTimer ( stealthroundended, 4000, 1, roundfinish, thisplayer )
- destroyMissionTimer ( roundfinish )
- end
- end
-end
-
-function playerhurt ( attacker, weapon, bodypart, loss )--HEADSHOT INSTAKILL
- if not (getElementData(source,"armor")) then
- if ( bodypart == 9 ) then
- killPed ( source, attacker, weapon, bodypart )
- end
- end
-end
-
-addEventHandler ( "onPlayerDamage", root, playerhurt )
-
-function outputHeadshotIcon (killer, weapon, bodypart)
- if bodypart == 9 then
- cancelEvent()
- local r2,g2,b2 = getTeamColor ( getPlayerTeam(killer) )
- local r1,g1,b1 = getTeamColor ( getPlayerTeam(source) )
- exports.killmessages:outputMessage (
- {getPlayerName(killer),{"padding",width=3},{"icon",id=weapon},{"padding",width=3},{"icon",id=256},{"padding",width=3},{"color",r=r1,g=g1,b=b1},getPlayerName(source) },
- root,r2,g2,b2 )
- end
-end
-
-addEventHandler( "onPlayerKillMessage", root, outputHeadshotIcon )
-
-function teamstealthgamestop()
- call(getResourceFromName("scoreboard"), "removeScoreboardColumn", "Score")
- call(getResourceFromName("scoreboard"), "removeScoreboardColumn", "kills")
- call(getResourceFromName("scoreboard"), "removeScoreboardColumn", "deaths")
- local alltheplayers = getElementsByType("player")
- for index, thisplayer in ipairs(alltheplayers) do
- playSoundFrontEnd (thisplayer, 35 )
- setPlayerTeam(thisplayer, nil)
- setPlayerNametagShowing ( thisplayer, true )
- setPedFightingStyle ( thisplayer, 1 )
- --setCameraMode ( thisplayer, "player" )
- setCameraTarget ( thisplayer, thisplayer )
- textDisplayRemoveObserver( redwinsdisplay, thisplayer )
- textDisplayRemoveObserver( bluewinsdisplay, thisplayer )
- textDisplayRemoveObserver( tiegamedisplay, thisplayer )
- textDisplayRemoveObserver( waitDisplay, thisplayer )
- unbindKey ( thisplayer, "F3", "down", selectTeamKey )
- end
- local timers = getTimers()
- for timerKey, timerValue in ipairs(timers) do
- killTimer ( timerValue )
- end
- local objectlist = getElementsByType ( "object" )
- for index, object in ipairs(objectlist) do
- if ( getElementData ( object, "renew" ) == "1" ) then
- destroyElement(object)
- end
- end
-end
-
-addEventHandler( "onResourceStop", resourceRoot, teamstealthgamestop )
-
-
-function table.merge(appendTo, ...)
- -- table.merge(targetTable, table1, table2, ...)
- -- Append the values of one or more tables to a target table.
- --
- -- In the arguments list, a table pointer can be followed by a
- -- numeric or textual key. In that case the values in the table
- -- will be assumed to be tables, and of each of these the value
- -- corresponding to the given key will be appended instead of the
- -- subtable itself.
- local appendval
- for i=1,arg.n do
- if type(arg[i]) == 'table' then
- for k,v in pairs(arg[i]) do
- if arg[i+1] and type(arg[i+1]) ~= 'table' then
- appendval = v[arg[i+1]]
- else
- appendval = v
- end
- if appendval then
- if type(k) == 'number' then
- table.insert(appendTo, appendval)
- else
- appendTo[k] = appendval
- end
- end
- end
- end
- end
- return appendTo
-end
+local spectators = {}
+local getPlayerSpectatee = {}
+
+function teamstealthgamestart()
+ killmessageRes = getResourceFromName"killmessages"
+ call(getResourceFromName("scoreboard"), "addScoreboardColumn", "Score")
+ call(getResourceFromName("scoreboard"), "addScoreboardColumn", "kills")
+ call(getResourceFromName("scoreboard"), "addScoreboardColumn", "deaths")
+ playingaround = 0
+ redwinsdisplay = textCreateDisplay()
+ local redtext = textCreateTextItem ( "RED Team Wins the Match!", 0.5, 0.5, "low", 255, 0, 0, 255, 3, "center", "center" )
+ textDisplayAddText ( redwinsdisplay, redtext )
+ bluewinsdisplay = textCreateDisplay()
+ local bluetext = textCreateTextItem ( "BLUE Team Wins the Match!", 0.5, 0.5, "low", 0, 0, 255, 255, 3, "center", "center" )
+ textDisplayAddText ( bluewinsdisplay, bluetext )
+ tiegamedisplay = textCreateDisplay()
+ local tietext = textCreateTextItem ( "The Match was a Tie!", 0.5, 0.5, "low", 255, 255, 255, 255, 3, "center", "center" )
+ textDisplayAddText ( tiegamedisplay, tietext )
+ waitDisplay = textCreateDisplay()
+ local waittext = textCreateTextItem ( "Wait for next round to spawn.", 0.5, 0.9, "low", 255, 255, 255, 255, 1.6, "center", "center" )
+ textDisplayAddText ( waitDisplay, waittext )
+ team1 = createTeam("RED",255,0,0)
+ team2 = createTeam("BLUE",0,0,255)
+ teamprotect = get("stealth.teamdamage")
+ if teamprotect == 1 then
+ setTeamFriendlyFire( team1, false )
+ setTeamFriendlyFire( team2, false )
+ elseif teamprotect == 0 then
+ setTeamFriendlyFire( team1, true )
+ setTeamFriendlyFire( team2, true )
+ end
+ setElementData ( team1, "Score", 0 )
+ setElementData ( team2, "Score", 0 )
+ teamswap = 0
+ local players = getElementsByType("player")
+ for k,v in ipairs(players) do
+ killPed(v)
+ fadeCamera(v,true)
+ thisplayer = v
+ triggerClientEvent(v,"swaptoggle",root, thisplayer, teamswap)
+ setElementData ( v, "kills", 0 )
+ setElementData ( v, "deaths", 0 )
+ setPlayerNametagShowing ( v, false )
+ spectators[v] = true
+ bindKey ( v, "F3", "down", selectTeamKey )
+ end
+ --Enable laser sight
+ setElementData(root,"lasersight",get("stealth.lasersight"))
+end
+
+addEventHandler( "onGamemodeStart", resourceRoot, teamstealthgamestart )
+
+function joinTeam( player, team )
+ setPlayerTeam(player, team)
+ if team == team1 then
+ setPlayerNametagColor ( player, 255, 0, 0 )
+ elseif team == team2 then
+ setPlayerNametagColor ( player, 0, 0, 255 )
+ end
+end
+
+addEvent("dojoinTeam1",true )
+function joinTeam1( source )
+ if (countPlayersInTeam(team1) - countPlayersInTeam(team2) > balanceamount) then
+ outputChatBox("Can't join RED too many players", source, 255, 69, 0)
+ triggerClientEvent(source,"doshowTeamWindow",source)
+ else
+ joinTeam(source, team1)
+ end
+end
+addEventHandler ( "dojoinTeam1", root, joinTeam1 )
+
+addEvent("dojoinTeam2",true )
+function joinTeam2( source )
+ if (countPlayersInTeam(team2) - countPlayersInTeam(team1) > balanceamount) then
+ outputChatBox("Can't join BLUE too many players", source, 255, 69, 0)
+ triggerClientEvent(source,"doshowTeamWindow",source)
+ else
+ joinTeam(source, team2)
+ end
+end
+addEventHandler ( "dojoinTeam2", root, joinTeam2 )
+
+function selectTeam( player )
+ setPlayerTeam(player, nil)
+ local thisplayer = player
+ triggerClientEvent(player,"doshowTeamWindow",root)
+ setCameraFixed(player,"cameramode",root, thisplayer)
+ balanceamount = get("stealth.teambalance")
+ tonumber(balanceamount)
+end
+
+function selectTeamKey(source)
+ ishespawning = getElementData ( source, "cantchangespawns" )
+ if ( isPedDead ( source ) ) and (ishespawning == 0) then
+ selectTeam( source )
+ getPlayerSpectatee[source] = nil
+ triggerClientEvent(source,"showSpectateText",source,"",false)
+ unbindKey ( source, "r", "down", spectateNext )
+ setPlayerTeam(source, nil)
+ else
+ outputChatBox("You can only change teams when your dead.", source, 255, 69, 0)
+ end
+end
+
+function onStealthPlayerJoin ()
+ playersin = getPlayerCount()
+ if playersin < 3 then
+ if playingaround == 1 then
+ outputChatBox("Not enough active players, restarting round.", player, 255, 69, 0)
+ roundend = setTimer ( stealthroundended, 10000, 1, roundfinish, thisplayer )
+ destroyMissionTimer ( roundfinish )
+ end
+ end
+ selectTeam (source)
+ setElementData ( source, "kills", 0 )
+ setElementData ( source, "deaths", 0 )
+ setPlayerNametagShowing ( source, false )
+ spectators[source] = true
+ bindKey ( source, "F3", "down", selectTeamKey )
+ thisplayer = source
+ setCameraFixed(source,"cameramode",root, thisplayer)
+ destroyshield = setTimer ( function (shield) if isElement ( shield ) then destroyElement ( shield ) end end, 3000, 1, dummyshield )
+ setCameraFixed(source,"cameramode",root, thisplayer)
+ triggerClientEvent(source,"swaptoggle",root, thisplayer, teamswap)
+ textDisplayAddObserver ( waitDisplay, thisplayer )
+ fadeCamera(thisplayer,true)
+end
+
+addEventHandler ( "onPlayerJoin", root, onStealthPlayerJoin )
+
+function teamstealthmapstart(startedMap)
+ mapRoot = source
+ roundstart = setTimer ( startstealthround, 15000, 1, player )
+ setElementData ( team1, "Score", 0 )
+ setElementData ( team2, "Score", 0 )
+ round_count = 0
+ local teams = {team1,team2}
+ local stealthplayers = getElementsByType("player")
+ for index, thisplayer in ipairs(stealthplayers) do
+ fadeCamera(thisplayer,true)
+ setElementData ( thisplayer, "kills", 0 )
+ setElementData ( thisplayer, "deaths", 0 )
+ setCameraFixed(thisplayer,"cameramode",root, thisplayer)
+ selectTeam (thisplayer)
+ end
+ teamprotect = get("stealth.teamprotect")
+ if teamprotect == 1 then
+ setTeamFriendlyFire( team1, false )
+ setTeamFriendlyFire( team2, false )
+ elseif teamprotect == 0 then
+ setTeamFriendlyFire( team1, true )
+ setTeamFriendlyFire( team2, true )
+ end
+ setElementData ( team1, "Score", 0 )
+ setElementData ( team2, "Score", 0 )
+ currentmap = startedMap
+ local maptime = get(getResourceName(currentmap)..".#time")
+ if maptime then
+ local splitString = split(maptime, string.byte(':'))
+ setTime(tonumber(splitString[1]),tonumber(splitString[2]))
+ end
+ local mapweather = get(getResourceName(currentmap)..".#weather")
+ if mapweather then
+ setWeather (mapweather)
+ end
+ local mapwaves = get(getResourceName(currentmap)..".#waveheight")
+ if mapwaves then
+ setWaveHeight ( mapwaves )
+ end
+ local mapspeed = get(getResourceName(currentmap)..".#gamespeed")
+ if mapspeed then
+ setGameSpeed ( mapspeed )
+ end
+ local mapgravity = get(getResourceName(currentmap)..".#gravity")
+ if mapgravity then
+ setGravity ( mapgravity )
+ end
+ --Create our camera element (if settings system was used)
+ if ( not getElementsByType"camera"[1] ) and ( get(getResourceName(currentmap)..".camera") ) then
+ local cameraInfo = get(getResourceName(currentmap)..".camera")
+ if not cameraInfo then
+ local xi, yi, zi = 0, 0, 0
+ local spawns = table.merge(getElementsByType("spawnpoint",mapRoot),getElementsByType("spyspawn",mapRoot),getElementsByType("mercenaryspawn",mapRoot))
+ for i,spawnpoint in ipairs(spawns) do
+ xi = xi + getElementData( spawnpoint, "posX" )
+ yi = yi + getElementData( spawnpoint, "posY" )
+ zi = zi + getElementData( spawnpoint, "posZ" )
+ end
+ xi = xi/spawns
+ yi = yi/spawns
+ zi = zi/spawns
+ cameraInfo = { {xi, yi, zi}, {xi, yi, zi} }
+ end
+ setElementData ( resourceRoot, "camera", cameraInfo )
+ local camera = createElement("camera")
+ setElementData ( camera, "posX", cameraInfo[1][1] )
+ setElementData ( camera, "posY", cameraInfo[1][2] )
+ setElementData ( camera, "posZ", cameraInfo[1][3] )
+ setElementData ( camera, "targetX", cameraInfo[2][1] )
+ setElementData ( camera, "targetY", cameraInfo[2][2] )
+ setElementData ( camera, "targetZ", cameraInfo[2][3] )
+ end
+end
+
+addEventHandler( "onGamemodeMapStart", root, teamstealthmapstart )
+
+function teamstealthmapstop(startedMap)
+ local alltheplayers = getElementsByType("player")
+ playingaround = 0
+ for index, thisplayer in ipairs(alltheplayers) do
+ triggerClientEvent(thisplayer,"onClientGamemodeMapStop",root)
+ setElementData ( thisplayer, "waitingtospawn", "nope" )
+ local isplayercloaked = getElementData ( thisplayer, "stealthmode" )
+ if isplayercloaked == "on" then
+ local player = thisplayer
+ cloakstop(player)
+ end
+ end
+ local timers = getTimers()
+ for timerKey, timerValue in ipairs(timers) do
+ if timerValue ~= keytimer then
+ killTimer ( timerValue )
+ end
+ end
+ removeEventHandler ( "missionTimerActivated", root, stealthroundended )
+ destroyMissionTimer ( roundfinish )
+ local objectlist = getElementsByType ( "object" )
+ for index, object in ipairs(objectlist) do
+ if ( getElementData ( object, "renew" ) == "1" ) then
+ destroyElement(object)
+ end
+ end
+end
+
+addEventHandler( "onGamemodeMapStop", root, teamstealthmapstop )
+
+function startstealthround()
+ local alltheplayers = getElementsByType("player")
+ for index, thisplayer in ipairs(alltheplayers) do
+ triggerClientEvent(thisplayer,"swaptoggle",root, thisplayer, teamswap)
+ textDisplayRemoveObserver( redwinsdisplay, thisplayer )
+ textDisplayRemoveObserver( bluewinsdisplay, thisplayer )
+ textDisplayRemoveObserver( tiegamedisplay, thisplayer )
+ textDisplayRemoveObserver( waitDisplay, thisplayer )
+ end
+ currentmap = call(getResourceFromName"mapmanager","getRunningGamemodeMap")
+ local maptime = get(getResourceName(currentmap)..".#time")
+ if maptime then
+ local splitString = split(maptime, string.byte(':'))
+ setTime(tonumber(splitString[1]),tonumber(splitString[2]))
+ end
+ playingaround = 1
+ local players = getElementsByType("player")
+ for index, player in ipairs(players) do
+ setElementData ( player, "waitingtospawn", "indeed" )
+ setElementData ( player, "cantchangespawns", 1 )
+ triggerClientEvent(player,"Startround",root,player)
+ end
+ stoptheidlers = setTimer ( idleblockstop, 30000, 1, player )
+ rawroundlength = get("stealth.roundlimit")
+ roundlength= rawroundlength*60
+ if (roundfinish) then
+ destroyMissionTimer ( roundfinish )
+ end
+ roundfinish = createMissionTimer ( player, roundlength, "<", 1.5, 0.5, 0.03, 255, 255, 255, true )
+ addEventHandler ( "missionTimerActivated", root, stealthroundended )
+ startTimer ( roundfinish )
+ freshround = 1
+ moldyround = setTimer ( agetheround, 30000, 1 )
+ roundnotover = 1
+end
+
+function agetheround()
+ freshround = 0
+ local everyone = getElementsByType("player")
+ local playerCount = #everyone
+ if playerCount > 1 then
+ playerleftcount ()
+ end
+end
+
+addEvent ("domercspawn", true )
+
+function mercspawn(thisplayer)
+ currentmap = call(getResourceFromName"mapmanager","getRunningGamemodeMap")
+ local mapinterior = get(getResourceName(currentmap)..".#interior")
+ if mapinterior == false then
+ mapinterior = 0
+ end
+ mercteamspawns = getElementByID("mercspawns")
+ local mercpoints
+ if mercteamspawns then
+ mercpoints = getElementsByType ( "spawnpoint", mercteamspawns )
+ else
+ mercpoints = getElementsByType ( "mercenaryspawn", mapRoot or root )
+ end
+ local random = math.random ( 1, table.getn ( mercpoints ) )
+ local posX = getElementData(mercpoints[random], "posX")
+ local posY = getElementData(mercpoints[random], "posY")
+ local posZ = getElementData(mercpoints[random], "posZ")
+ local rot = getElementData(mercpoints[random], "rot") or getElementData(mercpoints[random], "rotZ") or 0
+ spawnPlayer ( thisplayer, posX, posY, posZ, rot, 285, mapinterior )
+ --setCameraMode ( thisplayer, "player" )
+ setCameraTarget ( thisplayer, thisplayer )
+ setElementData ( thisplayer, "waitingtospawn", "nope" )
+ getPlayerSpectatee[thisplayer] = nil
+ triggerClientEvent(source,"showSpectateText",source,"",false)
+ spectators[source] = nil
+ giveWeapon ( thisplayer, 3, 1 )
+ setPedFightingStyle ( thisplayer, 7 )
+end
+
+addEventHandler ( "domercspawn", root, mercspawn )
+
+addEvent ("dospyspawn", true )
+
+function spyspawn(thisplayer)
+ currentmap = call(getResourceFromName"mapmanager","getRunningGamemodeMap")
+ local mapinterior = get(getResourceName(currentmap)..".#interior")
+ if mapinterior == false then
+ mapinterior = 0
+ end
+ spyteamspawns = getElementByID("spyspawns")
+ local spypoints
+ if spyteamspawns then
+ spypoints = getElementsByType ( "spawnpoint", spyteamspawns )
+ else
+ spypoints = getElementsByType ( "spyspawn", mapRoot or root )
+ end
+ local random = math.random ( 1, table.getn ( spypoints ) )
+ local posX = getElementData(spypoints[random], "posX")
+ local posY = getElementData(spypoints[random], "posY")
+ local posZ = getElementData(spypoints[random], "posZ")
+ local rot = getElementData(spypoints[random], "rot") or getElementData(spypoints[random], "rotZ") or 0
+ spawnPlayer ( thisplayer, posX, posY, posZ, rot, 163, mapinterior )
+ setCameraTarget( thisplayer, thisplayer )
+ --setCameraMode ( thisplayer, "player" )
+ setElementData ( thisplayer, "waitingtospawn", "nope" )
+ getPlayerSpectatee[source] = nil
+ triggerClientEvent(source,"showSpectateText",source,"",false)
+ spectators[source] = nil
+ giveWeapon ( thisplayer, 4, 1 )
+ setPedFightingStyle ( thisplayer, 6 )
+end
+
+addEventHandler ( "dospyspawn", root, spyspawn )
+
+addEvent ( "givetheguns",true )
+
+function gearup (thisplayer, primarySelection, secondarySelection, throwableSelection, spygadgetSelection)
+ setPedStat ( thisplayer, 69, 999 )
+ setPedStat ( thisplayer, 70, 999 )
+ setPedStat ( thisplayer, 71, 999 )
+ setPedStat ( thisplayer, 72, 999 )
+ setPedStat ( thisplayer, 74, 200 )
+ setPedStat ( thisplayer, 75, 999 )
+ setPedStat ( thisplayer, 76, 500 )
+ setPedStat ( thisplayer, 77, 999 )
+ setPedStat ( thisplayer, 78, 200 )
+ setPedStat ( thisplayer, 79, 999 )
+ setPedStat ( thisplayer, 225, 999 )
+ local sx,sy,sz = getElementPosition( thisplayer )
+ setElementAlpha ( thisplayer, 255 )
+ local dummyshield = createObject ( 1631, sx, sy, -60 )
+ triggerClientEvent(thisplayer,"Clientshieldload",root, thisplayer)
+ spazammo = get("stealth.spazammo")
+ m4ammo = get("stealth.m4ammo")
+ shotgunammo = get("stealth.shotgunammo")
+ sniperammo = get("stealth.sniperammo")
+ ak47ammo = get("stealth.ak47ammo")
+ rifleammo = get("stealth.rifleammo")
+ deserteagleammo = get("stealth.deserteagleammo")
+ pistolammo = get("stealth.pistolammo")
+ uziammo = get("stealth.uziammo")
+ tec9ammo = get("stealth.tec9ammo")
+ silencedammo = get("stealth.silencedammo")
+ grenadeammo = get("stealth.grenadeammo")
+ satchelammo = get("stealth.satchelammo")
+ teargasammo = get("stealth.teargasammo")
+ molatovammo = get("stealth.molatovammo")
+ local skinnumber = getElementModel ( thisplayer )
+ setElementData ( thisplayer, "playerskin", skinnumber )
+ if primarySelection == "spaz-12" then
+ teamprotect = get("stealth.teamdamage")
+ giveWeapon ( thisplayer, 27, spazammo )
+ end
+ if primarySelection == "m4" then
+ giveWeapon ( thisplayer, 31, m4ammo )
+ end
+ if primarySelection == "shotgun" then
+ giveWeapon ( thisplayer, 25, shotgunammo )
+ end
+ if primarySelection == "sniper" then
+ giveWeapon ( thisplayer, 34, sniperammo )
+ end
+ if primarySelection == "ak47" then
+ giveWeapon ( thisplayer, 30, ak47ammo )
+ end
+ if primarySelection == "rifle" then
+ giveWeapon ( thisplayer, 33, rifleammo )
+ end
+ if secondarySelection == "desert eagle" then
+ giveWeapon ( thisplayer, 24, deserteagleammo )
+ end
+ if secondarySelection == "pistols" then
+ giveWeapon ( thisplayer, 22, pistolammo )
+ end
+ if secondarySelection == "uzis" then
+ giveWeapon ( thisplayer, 28, uziammo )
+ end
+ if secondarySelection == "tec-9s" then
+ giveWeapon ( thisplayer, 32, tec9ammo )
+ end
+ if secondarySelection == "silenced" then
+ giveWeapon ( thisplayer, 23, silencedammo )
+ end
+ if throwableSelection == "grenade" then
+ giveWeapon ( thisplayer, 16, grenadeammo )
+ end
+ if throwableSelection == "satchel" then
+ giveWeapon ( thisplayer, 39, satchelammo )
+ end
+ if throwableSelection == "teargas" then
+ giveWeapon ( thisplayer, 17, teargasammo )
+ end
+ if throwableSelection == "molotov" then
+ giveWeapon ( thisplayer, 18, molatovammo )
+ end
+ if spygadgetSelection == "goggles" then
+ giveWeapon ( thisplayer, 44, 1 )
+ end
+end
+
+addEventHandler ( "givetheguns", root, gearup )
+
+function idleblockstop ()
+ local alltheplayers = getElementsByType("player")
+ for index, thisplayer in ipairs(alltheplayers) do
+ setElementData ( thisplayer, "waitingtospawn", "nope" )
+ if ( isPedDead ( thisplayer ) ) then
+ setElementData ( thisplayer, "cantchangespawns", 0 )
+ end
+ end
+end
+
+function stealthplayerdied ( totalAmmo, killer, killerWeapon, bodypart )
+ if playingaround == 1 then
+ local playerdeaths = getElementData ( source, "deaths" )
+ setElementData ( source, "deaths", playerdeaths+1 )
+ if (killer) then
+ if killer ~= source then
+ local killersscore = getElementData ( killer, "kills" )
+ setElementData ( killer, "kills", killersscore+1 )
+ end
+ end
+ end
+ waittospec = setTimer ( spectateNext, 6000, 1, source )
+ setElementData ( source, "cantchangespawns", 0 )
+ textDisplayAddObserver ( waitDisplay, source )
+ setElementData ( source, "legdamage", 0 )
+ local isplayercloaked = getElementData ( source, "stealthmode" )
+ if isplayercloaked == "on" then
+ local player = source
+ local oldskin = getElementData ( player, "playerskin" )
+ setElementModel ( thisplayer, oldskin )
+ setElementAlpha ( thisplayer, 255 )
+ cloakstop(player)
+ end
+ if playingaround == 1 then
+ if freshround ~= 1 then
+ local deadguysteam = getPlayerTeam ( source )
+ local teammates = getPlayersInTeam ( deadguysteam )
+ for playerKey, playerValue in ipairs(teammates) do
+ local isDead = isPedDead(playerValue)
+ if (isDead == false) then return end
+ end
+ local thisplayer = source
+ if roundnotover == 1 then
+ roundnotover = 0
+ roundend = setTimer ( stealthroundended, 4000, 1, roundfinish, thisplayer )
+ destroyMissionTimer ( roundfinish )
+ setCameraFixed(thisplayer,"cameramode",root, thisplayer)
+ end
+ end
+ end
+end
+
+addEventHandler( "onPlayerWasted", root, stealthplayerdied )
+
+addCommandHandler ( "Use Gadget/Spectate Next",
+ function ( player, command, state )
+ if state ~= "0" and spectators[player] then
+ spectateNext ( player )
+ end
+ end
+)
+
+function spectateNext (source) -- THIS IS THE FUNCTION USED TO SWICH WHO IS BEING SPECTATED BY PRESSING R
+ if playingaround == 1 then -- IF A ROUND IS IN PROGRESS
+ if ( isPedDead ( source ) ) then --IF THE PLAYER IS DEAD
+ local specPlayer = getPlayerSpectatee[source] -- gets the spectatee player
+ if not specPlayer then
+ specPlayer = 1
+ spectators[source] = true
+ end
+ local deadplayerTeam = getPlayerTeam(source)
+ local playersTable = getPlayersInTeam ( deadplayerTeam )
+ playersTable = filterPlayersTable ( playersTable )
+ --
+ local playerCount = #playersTable
+ if playerCount == 0 then
+ outputSpectateMessage("Nobody to Spectate",source) -- IF ITS JUST THE 1 PLAYER, SPECTATING IS IMPOSSIBLE
+ else
+ specPlayer = specPlayer+1
+ if isElement ( playersTable[specPlayer] ) then
+ while isPedDead ( playersTable[specPlayer] ) do
+ specPlayer = specPlayer+1
+ end
+ end
+ if specPlayer > playerCount then
+ specPlayer = 1
+ end
+ --setCameraMode ( source, "player" )
+ setCameraTarget ( source, playersTable[specPlayer] )
+ outputSpectateMessage("Now spectating "..getPlayerName(playersTable[specPlayer]),source)
+ getPlayerSpectatee[source] = specPlayer
+ end
+ end
+ end
+end
+
+function outputSpectateMessage(text,source)
+ triggerClientEvent(source,"showSpectateText",source,text,true)
+end
+
+function filterPlayersTable ( playerTable ) --this function clears out useless players from spectators table
+ for k,v in ipairs(playerTable) do
+ if isPedDead ( v ) then
+ table.remove(playerTable,k)
+ end
+ end
+ return playerTable
+end
+
+function stealthroundended( timerID, player )
+ if playingaround == 1 then
+ if ( tostring(timerID) == tostring(roundfinish) ) then
+ destroyMissionTimer ( timerID )
+ if (roundend) then
+ killTimer (roundend)
+ roundend = nil
+ end
+ playingaround = 0
+ if teamswap == 0 then
+ teamswap = 1
+ else
+ teamswap = 0
+ end
+ local leftgadgetslist = getElementsByType ( "colshape" )
+ for index, gadget in ipairs(leftgadgetslist) do
+ if ( getElementData ( gadget, "type" ) == "alandmine" ) then
+ destroyElement ( gadget ) --DESTROYS ALL LANDMINES AT THE END OF EVERY ROUND
+ elseif ( getElementData ( gadget, "type" ) == "acamera" ) then
+ destroyElement ( gadget ) --DESTROYS ALL CAMERAS AT THE END OF EVERY ROUND
+ end
+ end
+ local objectlist = getElementsByType ( "object" )
+ for index, object in ipairs(objectlist) do
+ if ( getElementData ( object, "renew" ) == "1" ) then
+ local x,y,z = getElementPosition( object )
+ local rx,ry,rz = getObjectRotation ( object )
+ local obid = getElementModel ( object )
+ destroyElement(object)
+ local newobject = createObject ( obid, x, y, z, rx, ry, rz )
+ setElementData ( newobject, "renew", "1" )
+ end
+ end
+ local team1survivers = 0
+ local team2survivers = 0
+ local firstteam = getPlayersInTeam ( team1 )
+ for index, thisplayer in ipairs(firstteam) do
+ setElementData ( thisplayer, "waitingtospawn", "indeed" )
+ setCameraFixed(thisplayer,"cameramode",root, thisplayer)
+ triggerClientEvent(thisplayer,"swaptoggle",root, thisplayer, teamswap)
+ local isDead = isPedDead(thisplayer)
+ if (isDead == false) then
+ team1survivers = team1survivers +1
+ killPed(thisplayer, thisplayer, 99, 99)
+ end
+ end
+ local secondteam = getPlayersInTeam ( team2 )
+ for index, thisplayer in ipairs(secondteam) do
+ setElementData ( thisplayer, "waitingtospawn", "indeed" )
+ setCameraFixed(thisplayer,"cameramode",root, thisplayer)
+ triggerClientEvent(thisplayer,"swaptoggle",root, thisplayer, teamswap)
+ local isDead = isPedDead(thisplayer)
+ if (isDead == false) then
+ team2survivers = team2survivers +1
+ killPed(thisplayer, thisplayer, 99, 99)
+ end
+ end
+ local everyone = getElementsByType("player")
+ for index, thisplayer in ipairs(everyone) do
+ if (sitthisoneout) then
+ killTimer (sitthisoneout)
+ sitthisoneout = nil
+ end
+ end
+ if team1survivers > team2survivers then
+ local alltheplayers = getElementsByType("player")
+ for index, thisplayer in ipairs(alltheplayers) do
+ textDisplayAddObserver( redwinsdisplay, thisplayer )
+ end
+ local teampoints = getElementData ( team1, "Score" )
+ setElementData ( team1, "Score", teampoints+1 )
+ end
+ if team2survivers > team1survivers then
+ local alltheplayers = getElementsByType("player")
+ for index, thisplayer in ipairs(alltheplayers) do
+ textDisplayAddObserver( bluewinsdisplay, thisplayer )
+ end
+ local teampoints = getElementData ( team2, "Score" )
+ setElementData ( team2, "Score", teampoints+1 )
+ end
+ if team2survivers == team1survivers then
+ local alltheplayers = getElementsByType("player")
+ for index, thisplayer in ipairs(alltheplayers) do
+ textDisplayAddObserver( tiegamedisplay, thisplayer )
+ end
+ end
+ roundstart = setTimer ( startstealthround, 7000, 1, player )
+ roundcycle = setTimer ( roundtick, 3000, 1, player )
+ removeEventHandler ( "missionTimerActivated", root, stealthroundended )
+ end
+ end
+end
+
+addEvent ( "onPlayerKillMessage", true)
+
+function checkforemokids (killer, weapon, bodypart)
+ if weapon == 99 then
+ cancelEvent()
+ end
+end
+
+addEventHandler( "onPlayerKillMessage", root, checkforemokids )
+
+function roundtick()
+ round_count = round_count+1
+ round_limit = get("stealth.round_countlimit")*2
+ if round_count == round_limit then
+ triggerEvent("onRoundFinished", resourceRoot)
+ end
+end
+
+function stealthplayerleft (source)
+ countplayers = setTimer ( playerleftcount, 2000, 1 )
+end
+
+addEventHandler( "onPlayerQuit", root, stealthplayerleft )
+
+function setCameraFixed ( player )
+ triggerClientEvent(player,"cameramode",root, player )
+ --showSpectateText("",false)
+end
+
+function playerleftcount (source)
+ if playingaround == 1 then
+ livingteam1 = 0
+ livingteam2 = 0
+ local firstteam = getPlayersInTeam ( team1 )
+ for playerKey, playerValue in ipairs(firstteam) do
+ local isDead = isPedDead(playerValue)
+ if (isDead == false) then
+ livingteam1 = livingteam1+1
+ end
+ end
+ local secondteam = getPlayersInTeam ( team2 )
+ for playerKey, playerValue in ipairs(secondteam) do
+ local isDead = isPedDead(playerValue)
+ if (isDead == false) then
+ livingteam2 = livingteam2+1
+ end
+ end
+ if livingteam1 == 0 then
+ roundend = setTimer ( stealthroundended, 4000, 1, roundfinish, thisplayer ) --THIS TRIGGERS THE ROUND ENDING
+ destroyMissionTimer ( roundfinish )
+ end
+ if livingteam2 == 0 then
+ roundend = setTimer ( stealthroundended, 4000, 1, roundfinish, thisplayer )
+ destroyMissionTimer ( roundfinish )
+ end
+ end
+end
+
+function playerhurt ( attacker, weapon, bodypart, loss )--HEADSHOT INSTAKILL
+ if not (getElementData(source,"armor")) then
+ if ( bodypart == 9 ) then
+ killPed ( source, attacker, weapon, bodypart )
+ end
+ end
+end
+
+addEventHandler ( "onPlayerDamage", root, playerhurt )
+
+function outputHeadshotIcon (killer, weapon, bodypart)
+ if bodypart == 9 then
+ cancelEvent()
+ local r2,g2,b2 = getTeamColor ( getPlayerTeam(killer) )
+ local r1,g1,b1 = getTeamColor ( getPlayerTeam(source) )
+ exports.killmessages:outputMessage (
+ {getPlayerName(killer),{"padding",width=3},{"icon",id=weapon},{"padding",width=3},{"icon",id=256},{"padding",width=3},{"color",r=r1,g=g1,b=b1},getPlayerName(source) },
+ root,r2,g2,b2 )
+ end
+end
+
+addEventHandler( "onPlayerKillMessage", root, outputHeadshotIcon )
+
+function teamstealthgamestop()
+ call(getResourceFromName("scoreboard"), "removeScoreboardColumn", "Score")
+ call(getResourceFromName("scoreboard"), "removeScoreboardColumn", "kills")
+ call(getResourceFromName("scoreboard"), "removeScoreboardColumn", "deaths")
+ local alltheplayers = getElementsByType("player")
+ for index, thisplayer in ipairs(alltheplayers) do
+ playSoundFrontEnd (thisplayer, 35 )
+ setPlayerTeam(thisplayer, nil)
+ setPlayerNametagShowing ( thisplayer, true )
+ setPedFightingStyle ( thisplayer, 1 )
+ --setCameraMode ( thisplayer, "player" )
+ setCameraTarget ( thisplayer, thisplayer )
+ textDisplayRemoveObserver( redwinsdisplay, thisplayer )
+ textDisplayRemoveObserver( bluewinsdisplay, thisplayer )
+ textDisplayRemoveObserver( tiegamedisplay, thisplayer )
+ textDisplayRemoveObserver( waitDisplay, thisplayer )
+ unbindKey ( thisplayer, "F3", "down", selectTeamKey )
+ end
+ local timers = getTimers()
+ for timerKey, timerValue in ipairs(timers) do
+ killTimer ( timerValue )
+ end
+ local objectlist = getElementsByType ( "object" )
+ for index, object in ipairs(objectlist) do
+ if ( getElementData ( object, "renew" ) == "1" ) then
+ destroyElement(object)
+ end
+ end
+end
+
+addEventHandler( "onResourceStop", resourceRoot, teamstealthgamestop )
+
+
+function table.merge(appendTo, ...)
+ -- table.merge(targetTable, table1, table2, ...)
+ -- Append the values of one or more tables to a target table.
+ --
+ -- In the arguments list, a table pointer can be followed by a
+ -- numeric or textual key. In that case the values in the table
+ -- will be assumed to be tables, and of each of these the value
+ -- corresponding to the given key will be appended instead of the
+ -- subtable itself.
+ local appendval
+ for i=1,arg.n do
+ if type(arg[i]) == 'table' then
+ for k,v in pairs(arg[i]) do
+ if arg[i+1] and type(arg[i+1]) ~= 'table' then
+ appendval = v[arg[i+1]]
+ else
+ appendval = v
+ end
+ if appendval then
+ if type(k) == 'number' then
+ table.insert(appendTo, appendval)
+ else
+ appendTo[k] = appendval
+ end
+ end
+ end
+ end
+ end
+ return appendTo
+end