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

Wysłany: 2021-01-11, 13:46


Kacper645PL







Wiek: 29
Na forum: 2866 dni
Posty: 25
Nick w MP: Kacper645PL



Respekt: 50

Witam jak co zrobi? zeby w panelu interakcji zmienia?y sie opcje u g?ry i na dole https://imgur.com/a/07NPoi3



Kod:

local font1 = dxCreateFont("f.ttf", 20)
local font2 = dxCreateFont("f.ttf", 15)
local screenW, screenH = guiGetScreenSize()
local img = dxCreateTexture("tlo1.png", "argb", true, "clamp")
local sx,sy=guiGetScreenSize()
local px,py = (sx/1600),(sy/900)
local w,h = guiGetScreenSize()
local sX, sY = guiGetScreenSize()
local startY = (sY - 155)/2
opcjaWybrana = 1

function stworzListe()
opcje = {}

local veh = getPedOccupiedVehicle(localPlayer)
if veh then
if not getVehicleEngineState(veh) then
table.insert(opcje, {"Odpal silnik", 1})
else
table.insert(opcje, {"Zga? silnik", 2})
end


if getVehicleOverrideLights(veh) ~= 2 then
table.insert(opcje, {"W??cz ?wiat?a", 3})
else
table.insert(opcje, {"Zga? ?wiat?a", 4})
end


if isElementFrozen(veh) then
table.insert(opcje, {"Spu?? r?czny", 7})
else
table.insert(opcje, {"Zaci?gnij r?czny", 8})
end


if isVehicleLocked(veh) then
table.insert(opcje, {"Otw?rz pojazd", 5})
else
table.insert(opcje, {"Zamknij pojazd", 6})
end


if getVehicleDoorOpenRatio(veh,0) == 0 then
table.insert(opcje, {"Otw?rz mask?", 9})
else
table.insert(opcje, {"Zamknij mask?", 10})
end

if getVehicleDoorOpenRatio(veh,1) == 0 then
table.insert(opcje, {"Otw?rz baga?nik", 11})
else
table.insert(opcje, {"Zamknij baga?nik", 12})
end

end
if #opcje > 0 then
if not show then
bindKey("arrow_u", "down", onSuwakZmien)
bindKey("arrow_d", "down", onSuwakZmien)
bindKey("space", "down", onSuwakWybierz)
addEventHandler("onClientRender", getRootElement(), PanelInterakcji)
show = true
end
end
end

function ostatniPojazd()
local veh = getElementData(localPlayer, "lastVeh")
if veh then
if isElement(veh) then
local driver = getElementData(veh, "lastDriver")
if driver == localPlayer then
local dx, dy, dz = getElementPosition(localPlayer)
local vx, vy, vz = getElementPosition(veh)
if 10 >= getDistanceBetweenPoints3D(dx, dy, dz, vx, vy, vz) then
saveV = veh
return veh
end
end
end
end
end

function wlaczPanelInterakcji()
local veh = getPedOccupiedVehicle(localPlayer)
if veh then
if getVehicleController(veh) == localPlayer then
showChat(false)
stworzListe()
end
else
local veh = ostatniPojazd()
if veh then
stworzListe()
end
end
end

function wylaczPanelInterakcji()
if show then
show = false
showChat(true)
unbindKey("arrow_u", "down", onSuwakZmien)
unbindKey("arrow_d", "down", onSuwakZmien)
unbindKey("space", "down", onSuwakWybierz)
opcjaWybrana = 1
removeEventHandler("onClientRender", getRootElement(), PanelInterakcji)
saveV = nil
end
end

bindKey("lshift", "down", wlaczPanelInterakcji)
bindKey("lshift", "up", wylaczPanelInterakcji)

function PanelInterakcji()
dxDrawRectangle(screenW * 0.6488, screenH * 0.3444, screenW * 0.3513, screenH * 0.0444, tocolor(8, 8, 8, 0), false)

for i,v in pairs(opcje) do
if i == opcjaWybrana then

dxDrawText(v[1], (screenW * 0.6488) + 1, (screenH * 0.3422) + 1, (screenW * 1.0000) + 1, (screenH * 0.3889) + 1, tocolor(25, 25, 25, 255), 1, font2, "center", "center", false, false, false, false, false)
dxDrawText(v[1], screenW * 0.6488, screenH * 0.3422, screenW * 1.0000, screenH * 0.3889, tocolor(125, 125, 125, 255), 1, font2, "center", "center", false, false, false, false, false)
dxDrawText(v[1], screenW * 0.6488, screenH * 0.4000, screenW * 1.0000, screenH * 0.4467, tocolor(255, 255, 255, 255), 1, font2, "center", "center", false, false, true, false, false)
dxDrawText(v[1], screenW * 0.6488, screenH * 0.4556, screenW * 1.0000, screenH * 0.5022, tocolor(25, 25, 25, 255), 1, font2, "center", "center", false, false, true, false, false)
dxDrawText(v[1], screenW * 0.6488+1, screenH * 0.4556+1, screenW * 1.0000+1, screenH * 0.5022+1, tocolor(125,125,125, 255), 1, font2, "center", "center", false, false, true, false, false)
dxDrawRectangle(screenW * 0.6488, screenH * 0.4578, screenW * 0.3513, screenH * 0.0444, tocolor(8, 8, 8, 00), false)
end
end

if #opcje == 1 then
opcjaWybrana = 1
end

stworzListe()
end

function onSuwakZmien(k,ks)
if k == "mouse_wheel_up" then --na dol
opcjaWybrana = opcjaWybrana - 1
if opcjaWybrana == 0 then
opcjaWybrana = #opcje
end
else
opcjaWybrana = opcjaWybrana + 1
if opcjaWybrana == #opcje + 1 then
opcjaWybrana = 1
end
end
end

function onSuwakZmien(k,ks)
if k == "arrow_u" then --na dol
opcjaWybrana = opcjaWybrana - 1
if opcjaWybrana == 0 then
opcjaWybrana = #opcje
end
else
opcjaWybrana = opcjaWybrana + 1
if opcjaWybrana == #opcje + 1 then
opcjaWybrana = 1
end
end
end

function onSuwakWybierz()
if #opcje == 1 then
triggerServerEvent("onInterakcjeWybierzAkcje", localPlayer, false, saveV)
return
end

if opcjaWybrana then
local id = opcje[opcjaWybrana][2]
if id then
triggerServerEvent("onInterakcjeWybierzAkcje", localPlayer, id, saveV)
end
end
end


Postaw piwo autorowi tego posta
 

 
Tagi: interakcja
Anonymous





Na forum: 245 dni
Posty: 1



Anonymous Koniecznie zajrzyj na:






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