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

Wysłany: 2018-04-11, 21:26


PenkY

Mapper






Wiek: 23
Na forum: 3464 dni
Posty: 223
Nick w MP: penky

Piwa: 2210

Respekt: 472
Respekt: 472

Witam!
Ot?? wsiadaj?c do pojazdu na miejsce pasa?era mog? obs?ugiwa? Interakcj?.
M?g?by mi to kto? powiedzie? jak to zablokowa?? Stawiam R* oraz :piwo: za pomoc!

Kod:


local sx,sy guiGetScreenSize ()
local zoom if sx 1920 then 
    zoom math.min(21920/sx)
end 

local shader dxCreateShader("f/shader.fx")
local screenSource dxCreateScreenSource(sxsy)
local bind false

function isCursorOnElementposXposYwidthheight )
    if isCursorShowing( ) then
        local mouseXmouseY getCursorPosition( )
        local clientWclientH guiGetScreenSize( )
        local mouseXmouseY mouseX clientWmouseY clientH
        if ( mouseX posX and mouseX < ( posX width ) and mouseY posY and mouseY < ( posY height ) ) then
            return true
        end
    end
    return false
end

local interakcja = {
    swiatla false,
    zamek false,
    silnik false,
    hamulec false,
}

function gui ()
    if getPedOccupiedVehicle(localPlayer) and bind == true then 
        dxUpdateScreenSource(screenSource)     
        dxSetShaderValue(shader"screenColor"screenSource)
        dxDrawImage(0,0,sx,sy,shader)
        
        local theVehicle getPedOccupiedVehicle(localPlayer)
        
        if isVehicleLocked (theVehiclethen 
            interakcja.zamek true 
        else
            interakcja.zamek false
        end
        if isElementFrozen(theVehiclethen 
            interakcja.hamulec true 
        else
            interakcja.hamulec false
        end
        if getVehicleOverrideLights(theVehicle) == 2 then 
            interakcja.swiatla true 
        else
            interakcja.swiatla false
        end
        if getVehicleEngineState(theVehicle) == true then 
            interakcja.silnik true
        else
            interakcja.silnik false
        end
        
        --gui
        if interakcja.zamek == true then 
            dxDrawImage(sx/2-50/zoom,sy/2+30/zoom,125/zoom,125/zoom,"i/zamekotw.png",0,0,0,tocolor(255,255,255,255))
        else
            dxDrawImage(sx/2-50/zoom,sy/2+30/zoom,125/zoom,125/zoom,"i/zamek.png",0,0,0,tocolor(255,255,255,255))
        end
        if interakcja.swiatla == true then 
            dxDrawImage(sx/2+100/zoom,sy/2-100/zoom,125/zoom,125/zoom,"i/swiatlootw.png",0,0,0,tocolor(255,255,255,255))
        else
            dxDrawImage(sx/2+100/zoom,sy/2-100/zoom,125/zoom,125/zoom,"i/swiatlo.png",0,0,0,tocolor(255,255,255,255))
        end
        
        if interakcja.silnik == true then 
            dxDrawImage(sx/2-200/zoom,sy/2-100/zoom,125/zoom,125/zoom,"i/silnikotw.png",0,0,0,tocolor(255,255,255,255))
        else
            dxDrawImage(sx/2-200/zoom,sy/2-100/zoom,125/zoom,125/zoom,"i/silnik.png",0,0,0,tocolor(255,255,255,255))
        end
        
        if interakcja.hamulec == true then 
            dxDrawImage(sx/2-50/zoom,sy/2-230/zoom,125/zoom,125/zoom,"i/hamulecotw.png",0,0,0,tocolor(255,255,255,255))
        else
            dxDrawImage(sx/2-50/zoom,sy/2-230/zoom,125/zoom,125/zoom,"i/hamulec.png",0,0,0,tocolor(255,255,255,255))
        end
    elseif bind == true and not getPedOccupiedVehicle(localPlayerthen 
        showCursor(false)
    end
end
--addEventHandler("onClientRender",root,gui)

addEventHandler("onClientClick",root,function(btn,state)
    if btn and getKeyState("mouse1") and state then 
        if bind == true and getPedOccupiedVehicle(localPlayerthen 
            if isCursorOnElement(sx/2-50/zoom,sy/2+30/zoom,125/zoom,125/zoomthen 
                triggerServerEvent("zamek",localPlayer)
            elseif isCursorOnElement(sx/2-200/zoom,sy/2-100/zoom,125/zoom,125/zoomthen 
                triggerServerEvent("silnik",localPlayer)
            elseif isCursorOnElement(sx/2-50/zoom,sy/2-230/zoom,125/zoom,125/zoomthen 
                triggerServerEvent("hamulec",localPlayer) 
            elseif isCursorOnElement(sx/2+100/zoom,sy/2-100/zoom,125/zoom,125/zoomthen
                triggerServerEvent("swiatlo",localPlayer)
            end
        end
    end
end)

bindKey("lshift","down",function()
    local theVehicle getPedOccupiedVehicle(localPlayer)
    if theVehicle then 
        if bind == false then 
            addEventHandler("onClientRender",root,gui)
            bind true
            showCursor(true)
        else    
            removeEventHandler("onClientRender",root,gui)
            bind false
            showCursor(false)
        end
    end
end)


Podpis
Discord: p3nky.
Postaw piwo autorowi tego posta
 

 
Wysłany: 2018-04-11, 22:25


amited







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

Piwa: 512

Respekt: 466
Respekt: 466

dodaj ifa z funkcja:

Więcej informacji znajdziesz w Wikipedii MTA:

GetPedOccupiedVehicleSeat


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

 
Wysłany: 2018-04-12, 14:56


Yasuo







Wiek: 22
Na forum: 2978 dni
Posty: 6
Nick w MP: Pyke

Piwa: 1

Respekt: 60

Ostrzeżeń: 100%
bindKey("lshift","down",function()
    local theVehicle getPedOccupiedVehicle(localPlayer)
    if theVehicle and getVehicleController(pedzik) == localPlayer then 
        if bind == false then 
            addEventHandler("onClientRender",root,gui)
            bind true
            showCursor(true)
        else    
            removeEventHandler("onClientRender",root,gui)
            bind false
            showCursor(false)
        end
    end
end)

albo tak jak kolega wy?ej

bindKey("lshift","down",function()
    local theVehicle getPedOccupiedVehicle(localPlayer)
    if theVehicle and getPedOccupiedVehicleSeat thePed ) == 1 then 
        if bind == false then 
            addEventHandler("onClientRender",root,gui)
            bind true
            showCursor(true)
        else    
            removeEventHandler("onClientRender",root,gui)
            bind false
            showCursor(false)
        end
    end
end)


Postaw piwo autorowi tego posta
 

 
Więcej szczegółów
Wystawiono 1 piw(a):
PenkY
Wysłany: 2018-04-12, 20:38


Eitho







Wiek: 24
Na forum: 3489 dni
Posty: 330
Nick w MP: Eitho

Piwa: 746

Respekt: 256,5
Respekt: 256,5Respekt: 256,5Respekt: 256,5

"Yasuo" napisał/a:

bindKey("lshift","down",function()
    local theVehicle getPedOccupiedVehicle(localPlayer)
    if theVehicle and getVehicleController(pedzik) == localPlayer then 
        if bind == false then 
            addEventHandler("onClientRender",root,gui)
            bind true
            showCursor(true)
        else    
            removeEventHandler("onClientRender",root,gui)
            bind false
            showCursor(false)
        end
    end
end)

albo tak jak kolega wy?ej

bindKey("lshift","down",function()
    local theVehicle getPedOccupiedVehicle(localPlayer)
    if theVehicle and getPedOccupiedVehicleSeat thePed ) == 1 then 
        if bind == false then 
            addEventHandler("onClientRender",root,gui)
            bind true
            showCursor(true)
        else    
            removeEventHandler("onClientRender",root,gui)
            bind false
            showCursor(false)
        end
    end
end)

no nie do ko?ca tak jak napisa?e?:
W pierwszym powinno by?:
getVehicleController(theVehicle) == localPlayer



W drugim:
getPedOccupiedVehicleSeat(localPlayer) == 0


Podpis
good old days :]
Postaw piwo autorowi tego posta
 

 
Więcej szczegółów
Wystawiono 1 piw(a):
PenkY
Wysłany: 2018-04-12, 20:56


PenkY

Mapper






Wiek: 23
Na forum: 3464 dni
Posty: 223
Nick w MP: penky

Piwa: 2210

Respekt: 472
Respekt: 472

Yasuo, Niestety ?aden z kod?w nie dzia?a, interakcja si? nie otwiera ani po stronie pasa?era ani po stronie kierowcy.

[ Dodano: 2018-04-12, 21:00 ]
Eitho, Teraz tak wygl?da kod:


bindKey("lshift","down",function()
    local theVehicle getVehicleController(theVehicle) == localPlayer
    if theVehicle and getPedOccupiedVehicleSeat(localPlayer) == 0 then 
        if bind == false then 
            addEventHandler("onClientRender",root,gui)
            bind true
            showCursor(true)
        else    
            removeEventHandler("onClientRender",root,gui)
            bind false
            showCursor(false)
        end
    end
end)


I nadal nie dzia?a.

Podpis
Discord: p3nky.
Postaw piwo autorowi tego posta
 

 
Wysłany: 2018-04-12, 21:07


amited







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

Piwa: 512

Respekt: 466
Respekt: 466

local theVehicle = getVehicleController(theVehicle) == localPlayer
deklarujesz w zly sposob

i wystarczy ze dasz tylko ta funkcje gdzie
if getPedOccupiedVehicleSeat(localPlayer) == 0
wtedy wiadomo ze gracz siedzi na miejscu kierowcy i jest w jakims pojezdzie wiec dasz mu dostep do gui

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

 
Więcej szczegółów
Wystawiono 1 piw(a):
PenkY
Wysłany: 2018-04-12, 21:12


PenkY

Mapper






Wiek: 23
Na forum: 3464 dni
Posty: 223
Nick w MP: penky

Piwa: 2210

Respekt: 472
Respekt: 472

amited, Nie za bardzo ci? zrozumia?em.. m?g?by? mi to dopisa? do tego kodu?

Podpis
Discord: p3nky.
Postaw piwo autorowi tego posta
 

 
Wysłany: 2018-04-12, 21:35


Pevo

Jabłko






Wiek: 23
Na forum: 3589 dni
Posty: 356
Nick w MP: Pevo

Piwa: 1571

Respekt: 355,8
Respekt: 355,8Respekt: 355,8Respekt: 355,8Respekt: 355,8


bindKey("lshift","down",function()
    if getPedOccupiedVehicleSeat(localPlayer) == 0 then 
        if bind == false then 
            addEventHandler("onClientRender",root,gui)
            bind true
            showCursor(true)
        else    
            removeEventHandler("onClientRender",root,gui)
            bind false
            showCursor(false)
        end
    end
end)


Podpis
Jabłko
Postaw piwo autorowi tego posta
 

 
Więcej szczegółów
Wystawiono 1 piw(a):
PenkY
Wysłany: 2018-04-12, 21:37


PenkY

Mapper






Wiek: 23
Na forum: 3464 dni
Posty: 223
Nick w MP: penky

Piwa: 2210

Respekt: 472
Respekt: 472

Dzi?kuje wszystkim za pomoc! Ka?dy otrzymuje obiecan? "Reputajcie" oraz "Piwko".

Podpis
Discord: p3nky.
Postaw piwo autorowi tego posta
 

 
Tagi: interakcja :: 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 » Interakcja 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