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

Wysłany: 2016-04-16, 11:18


olo12345







Wiek: 30
Na forum: 3716 dni
Posty: 66
Nick w MP: olo1205

Piwa: 3

Respekt: 45,3

Witam chce zrobic koguty w wozie strazackim mam kod na koguty w policyjnych ale chce dodac ambulans i firetruck
 
-- Emergency Lights resource by vovo4ka
-- please, do not remove copyright
-- Edited by #FurkanOzulus [OzulusTR]
-- Special Thanksvovo4ka for the this script :)


local strobo_interval 10        -- strobo light freq10 0.5 sec
local is_strobo_enabled enable    -- enable/disable stroboscopic lights mode
-- lamps
local flash_interval 1        -- flash freq
-- led blink mode
local blink_interval 20        -- blink interval
local blink_duration 2        -- 1..blink_interval

local car_lights_table = {
-- Enforcer
[427] = {["mode"]="lamp", 
[1]={["pos"]={0.451.11.42}, ["color"]={255,0,0}, ["size"]=0.2, ["phase"]=10.0}, 
[2]={["pos"]={-0.451.11.42}, ["color"]={255,0,0}, ["size"]=0.2, ["phase"]=10.0},
[3]={["pos"]={0.221.11.42}, ["color"]={255,0,0}, ["size"]=0.2, ["phase"]=0.0}, 
[4]={["pos"]={-0.221.11.42}, ["color"]={255,0,0}, ["size"]=0.2, ["phase"]=0.0},
[5]={["pos"]={-1.180.10.94}, ["color"]={255,0,0}, ["size"]=0.1, ["phase"]=0.0}, 
[6]={["pos"]={-1.18, -1.630.94}, ["color"]={255,0,0}, ["size"]=0.1, ["phase"]=5.0},
[7]={["pos"]={-1.18, -3.370.94}, ["color"]={255,0,0}, ["size"]=0.1, ["phase"]=10.0}, 
[8]={["pos"]={1.180.10.94}, ["color"]={255,0,0}, ["size"]=0.1, ["phase"]=0.0}, 
[9]={["pos"]={1.18, -1.630.94}, ["color"]={255,0,0}, ["size"]=0.1, ["phase"]=5.0},
[10]={["pos"]={1.18, -3.370.94}, ["color"]={255,0,0}, ["size"]=0.1, ["phase"]=10.0}
},

-- Police LS
 [596] = {["mode"]="lamp", 
[1]={["pos"]={-0.2, -0.350.95}, ["color"]={255,0,0}, ["size"]=0.18, ["phase"]=5.0}, 
[2]={["pos"]={0.2, -0.350.95}, ["color"]={0,0,255}, ["size"]=0.18, ["phase"]=5.0},
[3]={["pos"]={-0.45, -0.350.95}, ["color"]={255,0,0}, ["size"]=0.18, ["phase"]=0.0}, 
[4]={["pos"]={0.45, -0.350.95}, ["color"]={0,0,255}, ["size"]=0.18, ["phase"]=0.0},
[5]={["pos"]={-0.7, -0.350.95}, ["color"]={255,0,0}, ["size"]=0.18, ["phase"]=10.0}, 
[6]={["pos"]={0.7, -0.350.95}, ["color"]={0,0,255}, ["size"]=0.18, ["phase"]=10.0},
[7]={["pos"]={-0.252.46, -0.038}, ["color"]={255,0,0}, ["size"]=0.12, ["phase"]=0.0}, 
[8]={["pos"]={0.252.46, -0.038}, ["color"]={0,0,255}, ["size"]=0.12, ["phase"]=10.0}
},

-- Police SF
[597] = {["mode"]="lamp", 
[1]={["pos"]={-0.2, -0.350.95}, ["color"]={255,0,0}, ["size"]=0.18, ["phase"]=5.0}, 
[2]={["pos"]={0.2, -0.350.95}, ["color"]={0,0,255}, ["size"]=0.18, ["phase"]=5.0},
[3]={["pos"]={-0.45, -0.350.95}, ["color"]={255,0,0}, ["size"]=0.18, ["phase"]=0.0}, 
[4]={["pos"]={0.45, -0.350.95}, ["color"]={0,0,255}, ["size"]=0.18, ["phase"]=0.0},
[5]={["pos"]={-0.7, -0.350.95}, ["color"]={255,0,0}, ["size"]=0.18, ["phase"]=10.0}, 
[6]={["pos"]={0.7, -0.350.95}, ["color"]={0,0,255}, ["size"]=0.18, ["phase"]=10.0},
[7]={["pos"]={-0.252.46, -0.038}, ["color"]={255,0,0}, ["size"]=0.12, ["phase"]=0.0}, 
[8]={["pos"]={0.252.46, -0.038}, ["color"]={0,0,255}, ["size"]=0.12, ["phase"]=10.0}
},

-- Police SF
[597] = {["mode"]="led", 
[1]={["pos"]={-0.2, -0.350.95}, ["color"]={255,0,0}, ["size"]=0.18, ["phase"]=0.0}, 
[2]={["pos"]={0.2, -0.350.95}, ["color"]={0,0,255}, ["size"]=0.18, ["phase"]=10.0},
[3]={["pos"]={-0.45, -0.350.95}, ["color"]={255,0,0}, ["size"]=0.18, ["phase"]=0.0}, 
[4]={["pos"]={0.45, -0.350.95}, ["color"]={0,0,255}, ["size"]=0.18, ["phase"]=10.0},
[5]={["pos"]={-0.7, -0.350.95}, ["color"]={255,0,0}, ["size"]=0.18, ["phase"]=0.0}, 
[6]={["pos"]={0.7, -0.350.95}, ["color"]={0,0,255}, ["size"]=0.18, ["phase"]=10.0},
[7]={["pos"]={-0.252.46, -0.038}, ["color"]={255,0,0}, ["size"]=0.12, ["phase"]=10.0}, 
[8]={["pos"]={0.252.46, -0.038}, ["color"]={0,0,255}, ["size"]=0.12, ["phase"]=0.0}
},

-- Police LV
 [598] = {["mode"]="lamp", 
[1]={["pos"]={-0.2, -0.350.95}, ["color"]={255,0,0}, ["size"]=0.18, ["phase"]=5.0}, 
[2]={["pos"]={0.2, -0.350.95}, ["color"]={0,0,255}, ["size"]=0.18, ["phase"]=5.0},
[3]={["pos"]={-0.45, -0.350.95}, ["color"]={255,0,0}, ["size"]=0.18, ["phase"]=0.0}, 
[4]={["pos"]={0.45, -0.350.95}, ["color"]={0,0,255}, ["size"]=0.18, ["phase"]=0.0},
[5]={["pos"]={-0.7, -0.350.95}, ["color"]={255,0,0}, ["size"]=0.18, ["phase"]=10.0}, 
[6]={["pos"]={0.7, -0.350.95}, ["color"]={0,0,255}, ["size"]=0.18, ["phase"]=10.0},
[7]={["pos"]={-0.252.46, -0.038}, ["color"]={255,0,0}, ["size"]=0.12, ["phase"]=0.0}, 
[8]={["pos"]={0.252.46, -0.038}, ["color"]={0,0,255}, ["size"]=0.12, ["phase"]=10.0}
},

-- Police Ranger
[599] = {["mode"]="lamp",
[1]={["pos"]={-0.301.2}, ["color"]={255,0,0}, ["size"]=0.2, ["phase"]=10.0},
[2]={["pos"]={-0.701.2}, ["color"]={255,0,0}, ["size"]=0.2, ["phase"]=0.0}, 
[3]={["pos"]={-0.501.2}, ["color"]={255,0,0}, ["size"]=0.2, ["phase"]=5.0},
[4]={["pos"]={0.301.2}, ["color"]={0,0,255}, ["size"]=0.21, ["phase"]=5.0},
[5]={["pos"]={0.501.2}, ["color"]={0,0,255}, ["size"]=0.21, ["phase"]=0.0},
[6]={["pos"]={0.701.2}, ["color"]={0,0,255}, ["size"]=0.21, ["phase"]=10.0},
[7]={["pos"]={-0.402.46, -0.038}, ["color"]={255,0,0}, ["size"]=0.1, ["phase"]=0.0}, 
[8]={["pos"]={-0.292.46, -0.038}, ["color"]={255,0,0}, ["size"]=0.1, ["phase"]=0.0}, 
[9]={["pos"]={0.292.46, -0.038}, ["color"]={0,0,255}, ["size"]=0.1, ["phase"]=10.0},
[10]={["pos"]={0.402.46, -0.038}, ["color"]={0,0,255}, ["size"]=0.1, ["phase"]=10.0}
},
 
-- FBI Rancher
[490] = {["mode"]="lamp",
[1]={["pos"]={-0.943.3, -0.45}, ["color"]={255,0,0}, ["size"]=0.13, ["phase"]=0.0}, 
[2]={["pos"]={-0.83.3, -0.45}, ["color"]={255,0,0}, ["size"]=0.13, ["phase"]=0.0}, 
[3]={["pos"]={0.83.3, -0.45}, ["color"]={0,0,255}, ["size"]=0.13, ["phase"]=10.0},
[4]={["pos"]={0.943.3, -0.45}, ["color"]={0,0,255}, ["size"]=0.13, ["phase"]=10.0},
[5]={["pos"]={-0.63, -2.90.85}, ["color"]={255,0,0}, ["size"]=0.11, ["phase"]=0.0}, 
[6]={["pos"]={-0.75, -2.90.85}, ["color"]={255,0,0}, ["size"]=0.11, ["phase"]=0.0}, 
[7]={["pos"]={0.75, -2.90.85}, ["color"]={0,0,255}, ["size"]=0.11, ["phase"]=10.0},
[8]={["pos"]={0.63, -2.90.85}, ["color"]={0,0,255}, ["size"]=0.11, ["phase"]=10.0},
}
-- since 0.8 there are no default lights positionbecause only emergency and pre-defined vehicles can use lights
--["default"] = {["mode"]="lamp", [1]={["pos"]={0.500.8}, ["color"]={255,0,0}, ["size"]=0.25, ["phase"]=0.0}, [2]={["pos"]={-0.500.8}, ["color"]={0,0,255}, ["size"]=0.25, ["phase"]=10.0}}
}

-- do not modify --------------------------------------------
local vehicles = {}
local timers = {}

local base_freq 50    -- freq of timer for light change

-------------------------------------------------------------
function release_vehicle(vehicle)
    if (isElement(vehicle)) then
        if (is_strobo_enabledthen
            setVehicleOverrideLights vehicle0)
            setVehicleLightState vehicle0,  )
            setVehicleLightState vehicle1,  )
            setVehicleLightState vehicle2,  )
            setVehicleLightState vehicle3,  )
        end
    end
    if (vehicles[vehicle]~=nilthen    
        -- release the markers
        for keyvalue in pairs(vehicles[vehicle]["flist"]) do
            destroyElement (value["m"])
        end
        
        vehicles[vehicle] = nil
    end
    if (timers[vehicle]~=nilthen
        -- kill the strobo timer
        killTimer(timers[vehicle])
        timers[vehicle] = nil
        
        if (isElement(vehicle)) then
            if (getElementDatavehicle"emerlights_source")==getPlayerName(getLocalPlayer())) then
                triggerEvent "onPlayerEmergencyLightStateChange"getRootElement(), )
            end
        end
    end
end

function checkForAbility(vehicle)
    local veh_model getElementModel vehicle )
    if (car_lights_table[veh_model]==nil)or(getElementDatavehicle"emerlights_enabled" )=="false"then
        return false
    end
    return true
end

function strobo_state_update (vehicle)
    -- check for valid vehicle
    if (isElement(vehicle)) then
        if (vehicles[vehicle]==nilthen
            -- check for disallowing to use lights
            -- its enabled by default
            if (checkForAbility(vehicle)==falsethen
                release_vehicle(vehicle)
                return
            end
            local veh_model getElementModel vehicle )
            
            --if (car_lights_table[veh_model]==nilthen
            --veh_model "default"
            --end
            
            local occupant getVehicleOccupantvehicle0)
            if (getElementType(occupant)=="player"then    -- peds also can use emerlights
                local src getPlayerName(occupant)
                setElementDatavehicle"emerlights_source"srcfalse)
                if (src==getPlayerName(getLocalPlayer())) then
                    triggerEvent "onPlayerEmergencyLightStateChange"getRootElement(), )
                end
            end
            -- init state variable
            
            vehicles[vehicle] = {}
            vehicles[vehicle]["lstate"] = 0     -- strobo lights state
            vehicles[vehicle]["fstate"] = 0    -- flash light state
            vehicles[vehicle]["flist"] = {}        -- flash lights list (marker ids)
            
            -- create flash lights

            
            local mode car_lights_table[veh_model]["mode"]
            if (mode==nilthen
                mode "lamp"
            end
            
            local coeff 0
            if (mode=="lamp"then
                coeff 3.141592654/10.0
            else
                coeff blink_interval/20.0
            end
            
            vehicles[vehicle]["fmode"] = mode
            
            for light_idlight_desc in pairs(car_lights_table[veh_model]) do
                if (light_id~="mode"then
                    vehicles[vehicle]["flist"][light_id] = {}
                    vehicles[vehicle]["flist"][light_id]["m"] = createMarker0.00010.00010.0001"corona"light_desc["size"], light_desc["color"][1], light_desc["color"][2], light_desc["color"][3], 100)
                    vehicles[vehicle]["flist"][light_id]["p"] = light_desc["phase"]*coeff
                    attachElements vehicles[vehicle]["flist"][light_id]["m"], vehiclelight_desc["pos"][1], light_desc["pos"][2], light_desc["pos"][3] )
                end
            end
                
        end
        
        -- strobo light
        if (is_strobo_enabledthen
            setVehicleOverrideLights vehicle2)
            if (vehicles[vehicle]["lstate"]<strobo_intervalthen
                setVehicleLightState vehicle0,  )
                setVehicleLightState vehicle1,  )
                setVehicleLightState vehicle2,  )
                setVehicleLightState vehicle3,  )    
            else
                setVehicleLightState vehicle0,  )
                setVehicleLightState vehicle1,  )
                setVehicleLightState vehicle2,  )
                setVehicleLightState vehicle3,  )     
            end
            if (vehicles[vehicle]["lstate"]>=strobo_interval*2then
                vehicles[vehicle]["lstate"] = 0
            else
                vehicles[vehicle]["lstate"] = vehicles[vehicle]["lstate"] + 1
            end
        end
        -- flash light
        if (vehicles[vehicle]["fmode"]=="lamp"then
        -- lamp mode
            local tmp_fstate vehicles[vehicle]["fstate"]
            for keyvalue in pairs(vehicles[vehicle]["flist"]) do
                local RGBgetMarkerColorvalue["m"] )
                setMarkerColor(value["m"], RGB, (math.sin(tmp_fstate+value["p"])+1.0)*128.0)
            end
            
            vehicles[vehicle]["fstate"] = vehicles[vehicle]["fstate"] + flash_interval
            
        else
        -- led mode
            local tmp_fstate vehicles[vehicle]["fstate"]

            for keyvalue in pairs(vehicles[vehicle]["flist"]) do
                local RGBgetMarkerColor(value["m"])
                -- blinking mode
                local tmp_val tmp_fstate+value["p"]
                if (tmp_val>blink_intervalthen
                    tmp_val tmp_val blink_interval
                end
                if ((tmp_val>=0)and(tmp_val<blink_duration))or((tmp_val>=blink_duration+1)and(tmp_val<blink_duration*2+1)) then
                    setMarkerColor(value["m"], RGB255)
                else
                    setMarkerColor(value["m"], RGB0)
                end
            end        
            vehicles[vehicle]["fstate"] = vehicles[vehicle]["fstate"] + 1
            if (vehicles[vehicle]["fstate"]>blink_intervalthen
                vehicles[vehicle]["fstate"] = vehicles[vehicle]["fstate"] - blink_interval
            end
        end
    else
        -- if vehicle is no more exists
        release_vehicle(vehicle)
    end
end

-- not used anymore
function stroboLightOn()
    playerVehicle getPedOccupiedVehicle getLocalPlayer()  )  -- get the player's vehicle

    --setElementData( playerVehicle, "emerlights_enabled", "true" )    -- debug
    
    if ( playerVehicle ) then
        -- if player is not a driver
        if (getLocalPlayer()~=getVehicleOccupant( playerVehicle )) then
            --outputChatBox("you're not a driver!")
            return
        end
        
        setStroboLightsOn(playerVehicle, nil)
    end
end

function isStroboLightsOn (vehicle_id)
    if (timers[vehicle_id]) then
        return 1
    else
        return 0
    end
end

function setStroboLightsOn(vehicle_id, value)
    if ( vehicle_id ) then
        if (value==nil) then
            if (isStroboLightsOn(vehicle_id)==1) then
                value = 0
            else
                value = 1
            end;
        end;
        if (value==0) then
            if (timers[vehicle_id]) then
                release_vehicle(vehicle_id)
                end
        end
        if (value==1) then
            if (timers[vehicle_id]) then
                release_vehicle(vehicle_id)
            end
            -- create strobo timer
            timers[vehicle_id] = setTimer ( strobo_state_update, base_freq, 0,  vehicle_id )
        end
    end
end

-- only local effect
function enableStroboLightsMode(source, value)
    if (value=="0")or(value=="false") then
        is_strobo_enabled = false
        outputConsole("Stroboscopic mode disabled")
    else
        if (value=="1")or(value=="true") then
            is_strobo_enabled = true
            outputChatBox("Stroboscopic mode enabled")
        else
            outputChatBox("Usagestrobo 0 or strobo 1  for disable/enable stroboscopic lights mode")
        end
    end
end
addCommandHandler("strobo", enableStroboLightsMode)

-- triggered by server
function setEmerlightsState(value, state)
    local player = getPlayerFromName ( value )
    local vehicle = getPedOccupiedVehicle(player)
    if (vehicle) then
        setStroboLightsOn(vehicle, state)
    end
end
addEvent("setEmerlights", true)
addEventHandler("setEmerlights", getRootElement(), setEmerlightsState)

function requestEmerlights()
    -- check for driver
    playerVehicle = getPedOccupiedVehicle (getLocalPlayer())  -- get the player's vehicle

    if (playerVehicle) then
        -- if player is not a driver
        if (getLocalPlayer()~=getVehicleOccupant( playerVehicle )) then
            --outputChatBox("you're not a driver!")
            return
        end
        if (checkForAbility(playerVehicle)) then
            -- sync
            triggerServerEvent("requestEmerlightChangeState", getLocalPlayer(), 1-isStroboLightsOn(getPedOccupiedVehicle(getLocalPlayer())))
        else
            -- not able to use lights for this vehicle
                --outputChatBox("unknown car!")
        end
    end

end

addCommandHandler("Strobo Light On", requestEmerlights)--stroboLightOn)
bindKey("h", "down", "Strobo Light On")

addEvent("onPlayerEmergencyLightStateChange") 


[ Dodano: 2016-04-16, 11:19 ]
CO musze zrobic? wymierzyc pozycje?!

[ Dodano: 2016-04-16, 11:36 ]
Emm upominasz mnie prawda , ale nie wiem o co ci chodzi z tymi []

Ostatnio zmieniony przez Emm 2016-04-16, 11:27, w całości zmieniany 1 raz  
Postaw piwo autorowi tego posta
 

 
Wysłany: 2016-04-16, 13:21


marcin778

Krytyk serwerów MTA






Wiek: 24
Na forum: 4149 dni
Posty: 2268
Nick w MP: Marcineg

Piwa: 4662

Respekt: 1436,8
Respekt: 1436,8

Pozycje wymierzy? i reszt? paremetr?w tak jak jest na tym kodzie.

U?yj do pozycji sirenEdit.

Podpis
Moje prace: https://www.youtube.com/c...MuaWGHPp1mhlGnw

-- obecnie
-- obecnie
-- dawniej
-- dawniej
-- dawniej
Postaw piwo autorowi tego posta
 

 
Wysłany: 2016-06-26, 07:58


OskarYT

Mapper MTA






Wiek: 26
Na forum: 4245 dni
Posty: 267
Nick w MP: Kaczorek2306

Piwa: 1230

Respekt: 85,3

olo12345, we? pobierz skrypt sireneditor b?dzie ci ?atwiej ogarn?? :)

Podpis
Postaw piwo autorowi tego posta
 

 
Tagi: koguty :: firetrucku :: ambulansie
Anonymous





Na forum: 245 dni
Posty: 1



Anonymous Koniecznie zajrzyj na:






Skocz do:  
Wyświetl posty z ostatnich:   
GTAONLINE.PL » JĘZYKI PROGRAMOWANIA » LUA » Koguty w FireTrucku i Ambulansie 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