Zaloguj się by uzyskać pełen dostęp. Nie masz jeszcze konta? Założ je już teraz w kilka sekund.

Wysłany: 2018-04-28, 22:59


Drediks

Developer LUA






Wiek: 30
Na forum: 3352 dni
Posty: 44
Nick w MP: Trojka

Piwa: 66

Respekt: 50

Czo?em ostatnio zacz??em bawi? si? paczk? owla. Spodoba?y mi si? syreny i chcia?bym ich doda? wi?cej pod bindami etc a za bardzo nie wiem jak to zrobi? kto? doradzi?

(kod z pd-system c_sirens.lua)
local sounds = { }

-- Bind Keys required
function bindKeys(res)
    bindKey("n""down"toggleSirens)
    
    for keyvalue in ipairs(getElementsByType("vehicle")) do
        if isElementStreamedIn(valuethen
            if getElementData(value"lspd:siren"then
                sounds[value] = playSound3D("siren.wav"000true)
                attachElementssounds[value], value )
                setSoundVolume(sounds[value], 0.4)
                setSoundMaxDistance(sounds[value], 180)
                setElementDimension(sounds[value], getElementDimension(value))
                setElementInterior(sounds[value], getElementInterior(value))

            end
        end
    end
end
addEventHandler("onClientResourceStart"getResourceRootElement(), bindKeys)

function toggleSirens()
    local theVehicle getPedOccupiedVehicle(getLocalPlayer())
    if (theVehiclethen
        local occupants getVehicleOccupants(theVehicle)
        if occupants[0]==getLocalPlayer() then
            triggerServerEvent("lspd:setSirenState"theVehicle)
        end
    end
end
addCommandHandler("togglesirens"toggleSirensfalse)

function streamIn()
    if getElementTypesource ) == "vehicle" and getElementDatasource"lspd:siren" ) and not soundssource then
        sounds[source] = playSound3D("siren.wav"000true)
        attachElementssounds[source], source )
        setSoundVolume(sounds[source], 0.4)
        setSoundMaxDistance(sounds[source], 180)
        setElementDimension(sounds[source], getElementDimension(source))
        setElementInterior(sounds[source], getElementInterior(source))
    end
end
addEventHandler("onClientElementStreamIn"getRootElement(), streamIn)

function streamOut()
    if getElementTypesource ) == "vehicle" and sounds[sourcethen
        destroyElementsoundssource ] )
        soundssource ] = nil
    end
end
addEventHandler("onClientElementStreamOut"getRootElement(), streamOut)

function updateSirensname )
    if name == "lspd:siren" and isElementStreamedInsource ) and getElementTypesource ) == "vehicle" then
        local attached getAttachedElementssource )
        if attached then
            for keyvalue in ipairsattached ) do
                if getElementTypevalue ) == "sound" and value ~= soundssource then
                    destroyElementvalue )
                end
            end
        end
        
        if not getElementDatasourcename then
            if soundssource then
                destroyElementsoundssource ] )
                soundssource ] = nil
            end
        else
            if not soundssource then
                sounds[source] = playSound3D("siren.wav"000true)
                attachElementssounds[source], source )
                setSoundVolume(sounds[source], 0.4)
                setSoundMaxDistance(sounds[source], 180)
                setElementDimension(sounds[source], getElementDimension(source))
                setElementInterior(sounds[source], getElementInterior(source))
            end
        end
    end
end
addEventHandler("onClientElementDataChange"getRootElement(), updateSirens)


(kod z pd-system s_sirens.lua)
function vehicleBlown()
    exports.anticheat:changeProtectedElementDataEx(source"lspd:siren"false)
    setVehicleSirensOn source false )
end
addEventHandler("onVehicleRespawn"getRootElement(), vehicleBlown)

function setSirenState()
    if exports.global:hasItem(source85then -- sirens
        local curState getElementData(source"lspd:siren")
        exports.anticheat:changeProtectedElementDataEx(source"lspd:siren"not curState)
        setVehicleSirensOn source not curState )
    end
end
addEvent"lspd:setSirenState"true )
addEventHandler"lspd:setSirenState"getRootElement(), setSirenState )

function isOwnedByFactionType(vehiclefactiontypes)
    local vehicleFactionID getElementData(vehicle"faction")
    local vehicleFactionElement exports.pool:getElement("team"vehicleFactionID)
    if vehicleFactionElement then
        local vehicleFactionType getElementData(vehicleFactionElement"type")
        for keyfactionType in ipairs(factiontypes) do
            if factionType == vehicleFactionType then
                return true
            end
        end
    end
    return false
end

function addSirens (playerseat)
    if player and (seat==0then
        if ( getVehicleNamesource ) == 'Police LV' ) or  ( getVehicleNamesource ) == 'Police SF' ) or  ( getVehicleNamesource ) == 'FBI rancher' ) or ( getVehicleNamesource ) == 'Police LS' then
            addVehicleSirens(source,8,2falsetruetruetrue)
            --vehiclesirenPointxyzrgbalphaminAlpha
            setVehicleSirens(source10.5, -0.3100255255255)
            setVehicleSirens(source20, -0.31255255255255255)
            setVehicleSirens(source3, -0.5, -0.3125500255255)
            setVehicleSirens(source4, -0.3, -1.90.425500255255)
            setVehicleSirens(source50.3, -1.90.400255255255)
            setVehicleSirens(source60.0, -2.95, -0.12552150100100)
            setVehicleSirens(source7, -0.32.70.025500255255)
            setVehicleSirens(source80.32.70.000255255255)
        elseif(getVehicleNamesource ) == 'Ambulance'then
            addVehicleSirens(source,7,2falsetruetruetrue)
            --vehiclesirenPointxyzrgbalphaminAlpha
            --lightbar
            setVehicleSirens(source10.50.91.325500255255)
            setVehicleSirens(source200.91.3255255255255255)
            setVehicleSirens(source3, -0.50.91.325500255255)
            --right side
            setVehicleSirens(source41.30.21.525500255255)
            setVehicleSirens(source51.3, -3.31.525500255255)
            --left side
            setVehicleSirens(source6, -1.30.21.525500255255)
            setVehicleSirens(source7, -1.3, -3.31.525500255255)
        elseif(getVehicleNamesource ) == 'Fire Truck'then
            addVehicleSirens(source,7,2falsetruetruetrue)
            --lightbar
            setVehicleSirens(source10.63.21.425500255255)
            setVehicleSirens(source203.21.4255255255255255)
            setVehicleSirens(source3, -0.63.21.425500255255)
            --rear
            setVehicleSirens(source40.4, -3.70.425500255255)
            setVehicleSirens(source5, -0.4, -3.70.425500255255)
            --grill
            setVehicleSirens(source60.64.20.125500255255)
            setVehicleSirens(source7, -0.64.20.125500255255)
        elseif(getVehicleNamesource ) == 'Fire Truck Ladder'then    
            --not working (vehicle is probably one of the few models that does not support sirens)        
        elseif(getVehicleNamesource ) == 'Towtruck'then
            addVehicleSirens(source34truetruetruetrue)
            setVehicleSirens(source1, -0.7, -0.351.5250904560089255002550)
            setVehicleSirens(source20, -0.351.5250904560089255198102550)
            setVehicleSirens(source30.7, -0.351.5250904560089255002550)
        end
    end
end
addEventHandler("onVehicleEnter"getRootElement(), addSirens)


Postaw piwo autorowi tego posta
 

 
Tagi: syreny :: owlgaming
Anonymous





Na forum: 245 dni
Posty: 1



Anonymous Koniecznie zajrzyj na:






Skocz do:  
Wyświetl posty z ostatnich:   
GTAONLINE.PL » JĘZYKI PROGRAMOWANIA » LUA Ten temat jest zablokowany bez możliwości zmiany postów lub pisania odpowiedzi

Nie możesz pisać nowych tematów
Nie możesz odpowiadać w tematach
Nie możesz zmieniać swoich postów
Nie możesz usuwać swoich postów
Nie możesz głosować w ankietach
Dodaj temat do Ulubionych
Wersja do druku