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 @@ - + + + + + + + - -