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

Wysłany: 2017-02-22, 16:59


Krzemo1234







Wiek: 26
Na forum: 3751 dni
Posty: 387
Nick w MP: Krzemo

Piwa: 16

Respekt: 40

 local w,guiGetScreenSize()
local rowery = {[509]=true,[481]=false,[510]=true}

function gui()
    local v getPedOccupiedVehicle(localPlayer)
        local x,y,getElementPosition(v)
        getGroundPosition(x,y,z)


    if getVehicleOverrideLights(v) ~= 2 then
        w1 "Zapal swiatla"
    else
        w1 "Zgas swiatla"
    end
        
    local silnik getVehicleEngineState(v)
    if silnik == false then
        w2 "Zapal silnik"
    else
        w2 "Zgas silnik"
    end
        
    w3 "Wysad? pasa?er?w"
    
    if isElementFrozen(vthen
        w4 "Spusc reczny"
    else
        w4 "Zaciagnij reczny"
    end
    
    if getVehicleDoorOpenRatio(v,0) == 0 then
        w5 "Otworz maske"
    else
        w5 "Zamknij maske"
    end
    
    if getVehicleDoorOpenRatio(v,1) == 0 then
        w6 "Otworz bagaznik"
    else
        w6 "Zamknij bagaznik"
    end

    r1,r2,r3,r4,r5,r6 0.9,0.9,0.9,0.9,0.9,0.9
    local wybor getElementData(localPlayer,"wybor")
    if wybor == 1 then
        r1 1.5
    elseif wybor == 2 then
        r2 1.2
    elseif wybor == 3 then
        r3 1.2
    elseif wybor == 4 then
        r4 1.2
    elseif wybor == 5 then
        r5 1.2
    elseif wybor == 6 then
        r6 1.5
    end
    
    local sx,sy,sz getElementVelocity(v)
    local kmhs math.ceil(((sx^2+sy^2+sz^2)^(0.5))*155)
    if kmhs 20 then
        setElementData(localPlayer,"maxwybor",6)
        dxDrawText(w11.00000.400.22660.3278tocolor(255,255,255255), r1"pricedown""center""top"falsefalsefalsefalsefalse)
        dxDrawText(w21.00000.450.22660.3278tocolor(255,255,255255), r2"pricedown""center""top"falsefalsefalsefalsefalse)
        dxDrawText(w31.00000.500.22660.3278tocolor(255,255,255255), r3"pricedown""center""top"falsefalsefalsefalsefalse)
        dxDrawText(w41.00000.550.22660.3278tocolor(255,255,255255), r4"pricedown""center""top"falsefalsefalsefalsefalse)
        dxDrawText(w51.00000.600.22660.3278tocolor(255,255,255255), r5"pricedown""center""top"falsefalsefalsefalsefalse)
        dxDrawText(w61.00000.650.22660.3278tocolor(255,255,255255), r6"pricedown""center""top"falsefalsefalsefalsefalse)
        dxDrawRectangle(0.30000.3800.42660.3278tocolor(30,30,30100), false)
        dxDrawImage(0.293000.350000.440000.3800"images/inter.png"000whitefalse)
    else
        dxDrawText(w11.00000.400.22660.3278tocolor(255,255,255255), r1"pricedown""center""top"falsefalsefalsefalsefalse)
        dxDrawText(w21.00000.450.22660.3278tocolor(255,255,255255), r2"pricedown""center""top"falsefalsefalsefalsefalse)
        dxDrawText(w31.00000.500.22660.3278tocolor(255,255,255255), r3"pricedown""center""top"falsefalsefalsefalsefalse)
        dxDrawRectangle(0.30000.3800.42660.3278tocolor(30,30,30100), false)
        dxDrawImage(0.293000.350000.440000.3800"images/inter.png"000whitefalse)
        setElementData(localPlayer,"maxwybor",3)
    end
end

function wybor1(key,state)
    if state == "down" then
        if getElementData(localPlayer,"wybor") == 1 then return end
        setElementData(localPlayer,"wybor",getElementData(localPlayer,"wybor")-1)
    end
end

function wybor2(key,state)
    if state == "down" then
        if getElementData(localPlayer,"wybor") == getElementData(localPlayer,"maxwybor"then return end
        setElementData(localPlayer,"wybor",getElementData(localPlayer,"wybor")+1)
    end
end

function pokazinterakcje(value)
    local v getPedOccupiedVehicle(localPlayer)
    if and getVehicleController(v) == localPlayer then
        if rowery[getElementModel(v)] then return end
        if getElementData(v,"multiseat"then return end
        if value == true then
            if getElementData(v,"dokupienia"then return end
            addEventHandler("onClientRender",root,gui)
            bindKey("arrow_up","both",wybor1)
            bindKey("arrow_down","both",wybor2)
            bindKey("arrow_u","both",wybor1)
            bindKey("arrow_d","both",wybor2)
            bindKey("mouse_wheel_up","both",wybor1)
            bindKey("mouse_wheel_down","both",wybor2)
            setElementData(localPlayer,"interakcja",true)
        elseif value == false then
            if getElementData(v,"dokupienia"then return end
            removeEventHandler("onClientRender",root,gui)
            unbindKey("arrow_up","both",wybor1)
            unbindKey("arrow_down","both",wybor2)
            unbindKey("mouse_wheel_up","both",wybor1)
            unbindKey("mouse_wheel_down","both",wybor2)
            unbindKey("arrow_u","both",wybor1)
            unbindKey("arrow_d","both",wybor2)
            setElementData(localPlayer,"interakcja",false)
        end
    end
end

bindKey("lshift""both", function(key,state)
    if state == "down" then
        pokazinterakcje(true)
        setElementData(localPlayer,"wybor",1)
    elseif state == "up" then
        wybierz()
        pokazinterakcje(false)
    end
end)

function wybierz()
    local wybrano getElementData(localPlayer,"wybor")
    local v getPedOccupiedVehicle(localPlayer)
    if not v then return end
    if getElementData(v,"multiseat"then return end
    if and getVehicleController(v) == localPlayer then
        if wybrano == 1 then
            triggerServerEvent("?wiat?a"localPlayer)
        elseif wybrano == 2 then
            triggerServerEvent("silnik"localPlayer)    
        elseif wybrano == 3 then
            triggerServerEvent("wysadz"localPlayer)
        elseif wybrano == 4 then
            local x,y,getElementPosition(v)
            getGroundPosition(x,y,z)
            if getDistanceBetweenPoints3D x,y,z,x,y,) > 99 then return end
            triggerServerEvent("r?czny"localPlayer)
        elseif wybrano == 5 then
            triggerServerEvent("maska"localPlayer)
        elseif wybrano == 6 then
            triggerServerEvent("baga?nik"localPlayer)
        end 
    end
end
function interactionRender()
    if interaction.show == true then 
        dxDrawImage(w60.00000.550.22660.3278"images/interaction.png"000tocolor(255255255255), false)
    end
end

function zamknij(plr,seat)
    if plr ~= localPlayer then return end
    if seat ~= 0 then return end
    removeEventHandler("onClientRender",root,gui)
    unbindKey("arrow_u","both",wybor1)
    unbindKey("arrow_d","both",wybor2)
end
addEventHandler("onClientVehicleStartExit",root,zamknij)
addEventHandler("onClientVehicleExit",root,zamknij) 
 

To jest client



 local rowery = {[509]=true,[481]=true,[510]=true}

addEvent("silnik",true)
addEventHandler("silnik",root,function()
    local v getPedOccupiedVehicle(source)
    if v then
        local silnik getVehicleEngineState(v)
        if silnik == false then
        if type(getElementData(v,'vehicle:mileage')) == "string" then
            outputDebugString(getPlayerName(source))
        end
        if getElementData(v,'vehicle:mileage') and getElementData(v,'vehicle:mileage')>120000 then
                outputChatBox('* Nie mozna odpalic silnik, zbyt duzy przebieg...',source)
                return
        end
        if getElementData(v,"vehicle:fuel")<1 then
            outputChatBox('* Nie mozna odpalic silnika, malo paliwa w baku...',source)
            return
        end
            setVehicleEngineState(v,true)
        else
            setVehicleEngineState(v,false)
        end
    end
end)

addEvent("?wiat?a",true)
addEventHandler("?wiat?a",root,function()
    local v getPedOccupiedVehicle(source)
    if v then
        if getVehicleOverrideLights(v) ~= 2 then
            setVehicleOverrideLights(v,2)
        else
            setVehicleOverrideLights(v,1)
        end
    end
end)

addEvent("wysadz",true)
addEventHandler("wysadz",root,function()
    local v getPedOccupiedVehicle(source)
    if v then
        local wysadzil false
        for _player in pairs(getVehicleOccupants(v)) do
            if player ~= getVehicleController(vthen
                if not getControlState player"enter_exit" then                
                setControlState(player,"enter_exit",true)
                setTimer(setControlState,200,1,player,"enter_exit",false)
                if not wysadzil then wysadzil true end
                end
            end
        end
        if wysadzil then 
            local x,y,getElementPosition(v)
            local col createColSphere(x,y,z,5)
            for _,p in pairs(getElementsWithinColShape(col,"player")) do
                outputChatBox(("* %s wysadza pasa?er?w z swojego pojazdu"):format(getPlayerName(source):gsub("#%x%x%x%x%x%x","")),p)
            end
            destroyElement(col)
        end
    end
end)

addEvent("r?czny",true)
addEventHandler("r?czny",root,function()
    local v getPedOccupiedVehicle(source)
    if v then
        if getElementData(v,"vehicle.selling"then outputChatBox("*Interakcja nie dzia?a na pojazdach z salonu",source,255,0,0) return end
        if isElementFrozen(vthen
            setElementFrozen(v,false)
        else
        --    if isVehicleOnGround ) == false then return end
            setElementFrozen(v,true)
        end
    end
end)

addEvent("maska",true)
addEventHandler("maska",root,function()
    local v getPedOccupiedVehicle(source)
    if v then
        if getVehicleDoorOpenRatio(v,0) == 0 then
            setVehicleDoorOpenRatio(v,0,1,2000)
        else
            setVehicleDoorOpenRatio(v,0,0,2000)
        end
    end
end)

addEvent("baga?nik",true)
addEventHandler("baga?nik",root,function()
    local v getPedOccupiedVehicle(source)
    if v then
        if getVehicleDoorOpenRatio(v,1) == 0 then
            setVehicleDoorOpenRatio(v,1,1,2000)
        else
            setVehicleDoorOpenRatio(v,1,0,2000)
        end
    end
end)

addEventHandler("onVehicleEnter",root,function(plr,seat)
    if seat == 0 then
        if rowery[getElementModel(source)] then setVehicleEngineState(source,true) return end
        setVehicleEngineState(source,false)
    end
end)

addEventHandler("onVehicleStartExit",root,function(plr,seat)
    if seat == 0 then
        veh getPedOccupiedVehicle(plr)
        if rowery[getElementModel(veh)] then return end
        v getPedOccupiedVehicle(plr)
    end
end)

addEventHandler("onVehicleExit",root,function(plr,seat)
    if seat == 0 then
        if not v then return end
        if not source then return end
        setVehicleEngineState(v,false)
        setVehicleLocked(v,false)
        nil
    end
end)

addEvent("r?cznysalon",true)
addEventHandler("r?cznysalon",root,function()
    local v getPedOccupiedVehicle(source)
    if v then
        if not isVehicleOnGround(vthen return end
        if getElementData(v,"vehicle.selling"then outputChatBox("*Interakcja nie dzia?a na pojazd z salonu",source,255,0,0) return end
        if isElementFrozen(vthen
            setElementFrozen(v,false)
        else
            setElementFrozen(v,true)
        end
    end
end)


a to server

Dodano: 2017-02-22, 17:00
Przepraszam ale umia?em tego inaczej napisa?

Komentarz Emm dodany 2017-02-22, 22:42Dodaje znaczniki lua
Ostatnio zmieniony przez Emm 2017-02-22, 22:42, w całości zmieniany 4 razy  
Postaw piwo autorowi tego posta
 

 
Wysłany: 2017-02-23, 22:41


amited







Wiek: 26
Na forum: 3714 dni
Posty: 1233
Nick w MP: Amited

Piwa: 512

Respekt: 466
Respekt: 466

Podaj db3

Podpis
"amited" napisał/a:
Postaw piwo autorowi tego posta
 

 
Wysłany: 2017-02-24, 13:21


Krzemo1234







Wiek: 26
Na forum: 3751 dni
Posty: 387
Nick w MP: Krzemo

Piwa: 16

Respekt: 40

Temat do zamkni?cia naprawi?em

Podpis
Jeśli ci pomogłem zostaw zimne :piwo:
Postaw piwo autorowi tego posta
 

 
Tagi: mam :: interakcje :: nie :: mogę :: odpalić :: pojazdu :: !!!
Anonymous





Na forum: 245 dni
Posty: 1



Anonymous Koniecznie zajrzyj na:






Skocz do:  
Wyświetl posty z ostatnich:   
GTAONLINE.PL » JĘZYKI PROGRAMOWANIA » LUA » Mam Interakcje i nie mogę odpalić pojazdu !!! 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