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

Wysłany: 2022-01-07, 01:21


ButlaPiwa







Wiek: 30
Na forum: 2285 dni
Posty: 2
Nick w MP: ButlaPiwa



Respekt: 50

Witam, mam pytanie. Jak zrobi? w skrypcie lamp policyjnych tak aby one mruga?y i po jakim? czasie obie lampy zapali?y by si? zgas?y znowu zapali?y i zgas?y. Jak mo?na wola?bym o zrobion? prac? wynagrodz? si? respektem i zimnym piwkiem.

- Simple Police-Lights by MuLTi!

p_lights = {}
p_timer = {}
p_lvar = {}
p_pvar = {}
p_lvar2 = {}
p_lvar3 = {}
p_lvar4 = {}






function toggleLights(thePlayer, cmd)
    local veh = getPedOccupiedVehicle(thePlayer)
    if getElementData(veh,"vehicle:police") or getElementData(veh,"vehicle:ARMY") or getElementData(veh,"vehicle:id") == 47 or getElementData(veh,"vehicle:id") == 185 then 
            if(p_lights[veh] == 0) or(p_lights[veh] == nil) then
                p_pvar[veh] = 1
                p_lights[veh] = 1
                setVehicleOverrideLights ( veh, 2 )
                p_timer[veh] = setTimer(
                function()
                    if(p_lvar[veh] == 0) or (p_lvar[veh] == nil) then
                        p_lvar[veh] = 1
                        setVehicleLightState ( veh, 1, 0)
                        setVehicleLightState ( veh, 2, 0)
                        setVehicleLightState ( veh, 0, 1)
                        setVehicleLightState ( veh, 3, 0)
                        setVehicleHeadLightColor(veh, 255, 255, 255)
                    else
                        setVehicleLightState ( veh, 3, 0)
                        setVehicleLightState ( veh, 0, 0)
                        setVehicleLightState ( veh, 1, 1)
                        setVehicleLightState ( veh, 2, 1)    
                        setVehicleHeadLightColor(veh, 255, 255, 255)
                        p_lvar[veh] = 0
                    end
                end, 160, 0)
                else
                    p_lights[veh] = 0
                    killTimer(p_timer[veh])
                    setVehicleLightState ( veh, 0, 0)
                    setVehicleLightState ( veh, 1, 0)
                    setVehicleLightState ( veh, 2, 0)
                    setVehicleLightState ( veh, 3, 0)    
                    setVehicleHeadLightColor(veh, 255, 255, 255)
                    setVehicleOverrideLights ( veh, 2 )
                end
        end
                
            end

for key, value in ipairs(getElementsByType("player")) do
bindKey(value,"n","down",toggleLights)
end

addEventHandler("onPlayerJoin",root,function ()
bindKey(source,"n","down",toggleLights)
end)



addEventHandler ( "onVehicleExplode", getRootElement(), 
function()
    if(p_lights[source] == 1) then
        killTimer(p_timer[source])    
    end
end )

addEventHandler ( "onVehicleRespawn", getRootElement(), 
function()
    if(p_lights[source] == 1) then
        killTimer(p_timer[source])    
    end
end )

addEventHandler("onElementDestroy", getRootElement(), 
function ()
    if getElementType(source) == "vehicle" then
        if(p_lights[source] == 1) then
            killTimer(p_timer[source])
        end
    end
end)


Ostatnio zmieniony przez NotPaladyn 2022-01-07, 01:48, w całości zmieniany 2 razy  
Postaw piwo autorowi tego posta
 

 
Wysłany: 2022-01-13, 10:07


MartinPanZycia

Zielony w LUA






Wiek: 27
Na forum: 3869 dni
Posty: 477
Nick w MP: Rodzaje

Piwa: 877

Respekt: 70,5

Ostrzeżeń: 40%
"ButlaPiwa" napisał/a:

Witam, mam pytanie. Jak zrobi? w skrypcie lamp policyjnych tak aby one mruga?y i po jakim? czasie obie lampy zapali?y by si? zgas?y znowu zapali?y i zgas?y. Jak mo?na wola?bym o zrobion? prac? wynagrodz? si? respektem i zimnym piwkiem.

- Simple Police-Lights by MuLTi!

p_lights = {}
p_timer = {}
p_lvar = {}
p_pvar = {}
p_lvar2 = {}
p_lvar3 = {}
p_lvar4 = {}






function toggleLights(thePlayer, cmd)
    local veh = getPedOccupiedVehicle(thePlayer)
    if getElementData(veh,"vehicle:police") or getElementData(veh,"vehicle:ARMY") or getElementData(veh,"vehicle:id") == 47 or getElementData(veh,"vehicle:id") == 185 then 
            if(p_lights[veh] == 0) or(p_lights[veh] == nil) then
                p_pvar[veh] = 1
                p_lights[veh] = 1
                setVehicleOverrideLights ( veh, 2 )
                p_timer[veh] = setTimer(
                function()
                    if(p_lvar[veh] == 0) or (p_lvar[veh] == nil) then
                        p_lvar[veh] = 1
                        setVehicleLightState ( veh, 1, 0)
                        setVehicleLightState ( veh, 2, 0)
                        setVehicleLightState ( veh, 0, 1)
                        setVehicleLightState ( veh, 3, 0)
                        setVehicleHeadLightColor(veh, 255, 255, 255)
                    else
                        setVehicleLightState ( veh, 3, 0)
                        setVehicleLightState ( veh, 0, 0)
                        setVehicleLightState ( veh, 1, 1)
                        setVehicleLightState ( veh, 2, 1)    
                        setVehicleHeadLightColor(veh, 255, 255, 255)
                        p_lvar[veh] = 0
                    end
                end, 160, 0)
                else
                    p_lights[veh] = 0
                    killTimer(p_timer[veh])
                    setVehicleLightState ( veh, 0, 0)
                    setVehicleLightState ( veh, 1, 0)
                    setVehicleLightState ( veh, 2, 0)
                    setVehicleLightState ( veh, 3, 0)    
                    setVehicleHeadLightColor(veh, 255, 255, 255)
                    setVehicleOverrideLights ( veh, 2 )
                end
        end
                
            end

for key, value in ipairs(getElementsByType("player")) do
bindKey(value,"n","down",toggleLights)
end

addEventHandler("onPlayerJoin",root,function ()
bindKey(source,"n","down",toggleLights)
end)



addEventHandler ( "onVehicleExplode", getRootElement(), 
function()
    if(p_lights[source] == 1) then
        killTimer(p_timer[source])    
    end
end )

addEventHandler ( "onVehicleRespawn", getRootElement(), 
function()
    if(p_lights[source] == 1) then
        killTimer(p_timer[source])    
    end
end )

addEventHandler("onElementDestroy", getRootElement(), 
function ()
    if getElementType(source) == "vehicle" then
        if(p_lights[source] == 1) then
            killTimer(p_timer[source])
        end
    end
end)

je?li nie da si? tego osi?gn?c przez setVehicleLightState, mo?esz u?y? tego oto skryptu https://gtao.pl/skrypt-emergency-light-system-vt135544.htm#836629

Podpis
Cześć w MTA jestem jako Rodzaje.
Wszystko jest po staremu nie zamierzam stawiać RPG.
Postaw piwo autorowi tego posta
 

 
Tagi: lampy :: policyjne
Anonymous





Na forum: 245 dni
Posty: 1



Anonymous Koniecznie zajrzyj na:






Skocz do:  
Wyświetl posty z ostatnich:   
GTAONLINE.PL » JĘZYKI PROGRAMOWANIA » LUA » Lampy Policyjne Odpowiedz do tematu

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