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: 27
Na forum: 3892 dni
Posty: 387
Nick w MP: Krzemo

Piwa: 16

Respekt: 40

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

function gui()
    local v = getPedOccupiedVehicle(localPlayer)
        local x,y,z = getElementPosition(v)
        r = 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(v) then
        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(w1, w * 1.0000, h * 0.40, w * 0.2266, h * 0.3278, tocolor(255,255,255, 255), r1, "pricedown", "center", "top", false, false, false, false, false)
        dxDrawText(w2, w * 1.0000, h * 0.45, w * 0.2266, h * 0.3278, tocolor(255,255,255, 255), r2, "pricedown", "center", "top", false, false, false, false, false)
        dxDrawText(w3, w * 1.0000, h * 0.50, w * 0.2266, h * 0.3278, tocolor(255,255,255, 255), r3, "pricedown", "center", "top", false, false, false, false, false)
        dxDrawText(w4, w * 1.0000, h * 0.55, w * 0.2266, h * 0.3278, tocolor(255,255,255, 255), r4, "pricedown", "center", "top", false, false, false, false, false)
        dxDrawText(w5, w * 1.0000, h * 0.60, w * 0.2266, h * 0.3278, tocolor(255,255,255, 255), r5, "pricedown", "center", "top", false, false, false, false, false)
        dxDrawText(w6, w * 1.0000, h * 0.65, w * 0.2266, h * 0.3278, tocolor(255,255,255, 255), r6, "pricedown", "center", "top", false, false, false, false, false)
        dxDrawRectangle(w * 0.3000, h * 0.380, w * 0.4266, h * 0.3278, tocolor(30,30,30, 100), false)
        dxDrawImage(w * 0.29300, h * 0.35000, w * 0.44000, h * 0.3800, "images/inter.png", 0, 0, 0, white, false)
    else
        dxDrawText(w1, w * 1.0000, h * 0.40, w * 0.2266, h * 0.3278, tocolor(255,255,255, 255), r1, "pricedown", "center", "top", false, false, false, false, false)
        dxDrawText(w2, w * 1.0000, h * 0.45, w * 0.2266, h * 0.3278, tocolor(255,255,255, 255), r2, "pricedown", "center", "top", false, false, false, false, false)
        dxDrawText(w3, w * 1.0000, h * 0.50, w * 0.2266, h * 0.3278, tocolor(255,255,255, 255), r3, "pricedown", "center", "top", false, false, false, false, false)
        dxDrawRectangle(w * 0.3000, h * 0.380, w * 0.4266, h * 0.3278, tocolor(30,30,30, 100), false)
        dxDrawImage(w * 0.29300, h * 0.35000, w * 0.44000, h * 0.3800, "images/inter.png", 0, 0, 0, white, false)
        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 v 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 v 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,z = getElementPosition(v)
            r = getGroundPosition(x,y,z)
            if getDistanceBetweenPoints3D ( x,y,z,x,y,r ) > 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(w6, w * 0.0000, h * 0.55, w * 0.2266, h * 0.3278, "images/interaction.png", 0, 0, 0, tocolor(255, 255, 255, 255), 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(v) then
                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,z = 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(v) then
            setElementFrozen(v,false)
        else
        --    if isVehicleOnGround ( v ) == 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)
        v = nil
    end
end)

addEvent("r?cznysalon",true)
addEventHandler("r?cznysalon",root,function()
    local v = getPedOccupiedVehicle(source)
    if v then
        if not isVehicleOnGround(v) then 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(v) then
            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: 3855 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: 27
Na forum: 3892 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