Jump to content

help


Recommended Posts

It's the last ( just 2 version of stealth ) https://community.multitheftauto.com/index.php?p= ... ails&id=29

client :

addEventHandler("onClientPlayerWeaponFire",root,function(_, _, _, _, _, _,mine) 
    if isElement(localPlayer) then
        if mine and getElementModel(mine) == 1510 then
            triggerServerEvent("destroy",root,mine)
        end
    end
end)
function choosethegadget () --GETS THE GADGET TYPE ON SPAWN
    player = getLocalPlayer ()
    local x, y = guiGetScreenSize()
    x = x * 0.052
    y = y * 0.695
    if (gadgeticon) then
        destroyElement (gadgeticon)
        gadgeticon = nil
    end
    setElementData ( getLocalPlayer(), "armor", false )
    if spygadgetSelection == "prox mine" then
        chosengadget = "mines"
        gadgetuses = 1
        gadgeticon = guiCreateStaticImage (x, y, 40, 40, "images/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 = 10
        gadgeticon = guiCreateStaticImage (x, y, 40, 40, "images/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 = 2
        gadgeticon = guiCreateStaticImage (x, y, 40, 40, "images/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 = 2
        gadgeticon = guiCreateStaticImage (x, y, 40, 40, "images/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, "images/goggles.png", false)
        gadgetlabel = guiCreateLabel ( 0.05, .62, 40, 20, "", true, gadgeticon )
        guiLabelSetColor ( gadgetlabel, 1, 1, 1 )
    end
    if spygadgetSelection == "gas mask" then
        chosengadget = "gas mask"   
        gadgetuses = nil
        gadgeticon = guiCreateStaticImage (x, y, 40, 40, "images/mask.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, "images/armor.png", false)
        setElementData ( getLocalPlayer(), "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, "images/shield.png", false)
        gadgetlabel = guiCreateLabel ( 0.05, .62, 40, 20, "", true, gadgeticon )
        guiLabelSetColor ( gadgetlabel, 1, 1, 1 )
    end
    if spygadgetSelection == "test" then
        chosengadget = "test"   
        gadgetuses = nil
        gadgeticon = guiCreateStaticImage (x, y, 40, 40, "images/shield.png", false)
        gadgetlabel = guiCreateLabel ( 0.05, .62, 40, 20, "", true, gadgeticon )
        guiLabelSetColor ( gadgetlabel, 1, 1, 1 )
    end
    guiSetText ( gadgetlabel, gadgetuses )
    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", getLocalPlayer(), choosethegadget )
 
function playerkilled ()
    if (gadgeticon) then
        destroyElement (gadgeticon)
        gadgeticon = nil
    end
end
 
addEventHandler ( "onClientPlayerWasted", getLocalPlayer(), playerkilled )
 
addEventHandler ( "onClientPlayerDamage", getRootElement(),
    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 ( getLocalPlayer () )
    if inacar == false then
        local isDead = isPlayerDead(getLocalPlayer ())
        if (isDead == false) then
            if chosengadget == "mines" then
                if gadgetuses >0 then
                    player = getLocalPlayer ()
                    if ( isPedDucked ( player) ) then
                        triggerServerEvent ("poopoutthemine", getLocalPlayer (), player )
                        gadgetuses = gadgetuses-1
                        guiSetText ( gadgetlabel, gadgetuses )
                        playSoundFrontEnd(42)
                    else
                        outputChatBox("You need to crouch to place a landmine.",player, 255, 69, 0)
                    end
                else
                    outputChatBox ( "You are out of Mines", getLocalPlayer (), 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 ( getLocalPlayer (), "stealthmode" )
                    if (iscloaked ~= "on") then
                        local thisplayer = getLocalPlayer ()
                        triggerServerEvent ("cloaktheplayer", getLocalPlayer (), thisplayer )
                        cloakoff = setTimer ( makecloakstop, 10000, 1, thisplayer )
                        gadgetuses = gadgetuses-1
                        guiSetText ( gadgetlabel, gadgetuses )
                    else
                        outputChatBox ( "You are already currently cloaked.", getLocalPlayer (), 255, 69, 0)
                    end
                else
                    outputChatBox ( "You are out of Cloaks", getLocalPlayer (), 255, 69, 0)
                end
            elseif chosengadget == "goggles" then
                goggletoggle()
            elseif chosengadget == "shield" then
                shieldup()
            end
        end
    end
end
 
 
--CLOAK
 
function makecloakstop (thisplayer)
    local thisplayer = getLocalPlayer ()
    triggerServerEvent ("uncloaktheplayer", getLocalPlayer (), thisplayer )
end
 
function teargasdmg(attacker, weapon, bodypart, loss)
    if chosengadget == "gas mask" then
        if weapon == 17 then
            cancelEvent()
        end
    end
end
addEventHandler("onClientPlayerDamage", getLocalPlayer(),teargasdmg)
 
 
 
 
 
 
--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", getRootElement(), cloakaperson)
 
function setalpha(thisplayer)
    setElementAlpha ( thisplayer, 20)
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", getRootElement(), 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 == getLocalPlayer () then
        if (hitElement) then
            if ( getElementData ( hitElement, "type" ) == "proximity" ) then
                if minedelay ~= 1 then
                    minedelay = 1
                    triggerServerEvent ("destroylandmine", getLocalPlayer (), hitElement )
                    endminedelay = setTimer ( minedelaystop, 400, 1, player )
                end
            end
        end
    end
end
 
addEventHandler ( "onClientPlayerWeaponFire", getRootElement(), weaponfired )
 
function minedelaystop()
    minedelay =
Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...