local dx = exports.ad_dx;
local font = dx:getFont("rbt-b", 10);
local font2 = dx:getFont("rbt-r", 4);
local font3 = dx:getFont("rbt-r", 5);
local sw,sh = guiGetScreenSize();
local baseX = 1920;
local zoom = 1;
local minzoom = 2;
if sw < baseX then
zoom = math.min(minzoom, baseX/sw);
end;
local selected = 1;
local tick = getTickCount();
local interaction = {};
local type_i = "join"
local a1,a2,a3 = 0,0,0;
local textures = { -- Teksturki
"img/I_brutto.png",
"img/I_engine.png",
"img/I_handbrake.png",
"img/I_getout.png",
"img/I_carlock.png",
"img/bagaznik.png",
"img/maska.png",
"img/I_leftbutton.png",
"img/I_rightbutton.png",
"img/I_spacebutton.png",
};
local tbl = {
[1] = "light",
[2] = "engine",
[3] = "handbrake",
[4] = "cancel",
[5] = "leave",
[6] = "lock",
[7] = "bagaznik",
[8] = "maska",
};
local img = {} -- Wszystkie tekstury
for i,v in pairs(textures) do
img[i] = dxCreateTexture(v, "argb", false, "clamp")
end
function isEventHandlerAdded( sEventName, pElementAttachedTo, func )
local aAttachedFunctions = getEventHandlers( sEventName, pElementAttachedTo )
if #aAttachedFunctions > 0 then
for i, v in ipairs( aAttachedFunctions ) do
if v == func then
return true
end
end
end
return false
end
local selected_option = {
function(veh, option, trigger)
if trigger then
if option == 1 then
return "switchLIGHT"
elseif option == 2 then
return "switchENGINE"
elseif option == 3 then
return "switchHANDBRAKE"
elseif option == 4 then
return "kickOCCUPANTS"
elseif(option == 5)then
return "changeLOCKED"
elseif(option == 6)then
return "bagaznik"
elseif option == 7 then
return "maska"
elseif option == 12 then
return "bagaznik"
end
else
if option == 1 then
return getVehicleOverrideLights(veh) == 1 and "Odpal lampy" or "Zga? lampy"
elseif option == 2 then
return getVehicleEngineState(veh) == true and "Zga? silnik" or "Odpal silnik"
elseif option == 3 then
return getElementData(veh, "vehicle:handbrake") and "Spu?? r?czny" or "Zaci?gnij r?czny"
elseif option == 4 then
return "Wysadz pasa?er?w"
elseif option == 5 then
return isVehicleLocked(veh) == true and "Otw?rz zamek" or "Zamknij zamek"
elseif option == 6 then
return "Otw?rz/Zamknij bagaznik"
elseif option == 7 then
return "Otw?rz/Zamknij maske"
end
end
end
}
bindKey("lshift", "both", function(_, state)
local veh = getPedOccupiedVehicle(localPlayer)
if not veh then return end
if state == "up" then
type_i = "quit";
tick = getTickCount();
unbindKey("arrow_r", "down", down)
unbindKey("mouse_wheel_down", "down", down)
unbindKey("arrow_l", "down", up)
unbindKey("mouse_wheel_up", "down", up)
unbindKey("space", "down", accept);
elseif(state == "down" and not isCursorShowing())then
if(not isEventHandlerAdded("onClientRender", root, guiInter))then
addEventHandler("onClientRender", root, guiInter)
end;
selected = 4;
tick = getTickCount();
type_i = "join";
a1,a2,a3 = 0,0,0;
bindKey("arrow_r", "down", down)
bindKey("mouse_wheel_down", "down", down)
bindKey("arrow_l", "down", up)
bindKey("mouse_wheel_up", "down", up)
bindKey("space", "down", accept);
end
end)
function guiInter()
local v = getPedOccupiedVehicle(localPlayer)
if not v then
removeEventHandler("onClientRender", root, guiInter)
unbindKey("arrow_r", "down", down)
unbindKey("mouse_wheel_down", "down", down)
unbindKey("arrow_l", "down", up)
unbindKey("mouse_wheel_up", "down", up)
unbindKey("space", "down", accept);
return
end
if type_i == "join" then
a1,a2,a3 = interpolateBetween(a1, a2, a3, 255, 100, 200, (getTickCount()-tick)/500, "Linear");
elseif type_i == "quit" then
a1,a2,a3 = interpolateBetween(a1, a2, a3, 0, 0, 0, (getTickCount()-tick)/500, "Linear");
if(a1 == 0)then
removeEventHandler("onClientRender", root, guiInter);
end;
end;
dxDrawRectangle(0, 0, sw, sh, tocolor(28, 28, 34, a3), false);
dxDrawText("Klawiszologia", 0, 0, sw, sh-130/zoom, tocolor(227, 226, 223, a1), 1, font, "center", "bottom", false, false, true, true);
dxDrawImage(sw/2-110/zoom, sh-100/zoom, 104/zoom, 30/zoom, textures[10], 0, 0, 0, tocolor(255, 255, 255, a1), false);
dxDrawText("Zatwierd?", sw/2+5/zoom, sh-97/zoom, 104/zoom, 30/zoom, tocolor(250, 249, 249, a1), 1, font3, "left", "top", false, false, true, true);
dxDrawImage(sw/2-250/zoom, sh-100/zoom, 30/zoom, 30/zoom, textures[8], 0, 0, 0, tocolor(255, 255, 255, a1), false);
dxDrawText("W lewo", sw/2-210/zoom, sh-97/zoom, 104/zoom, 30/zoom, tocolor(250, 249, 249, a1), 1, font3, "left", "top", false, false, true, true);
dxDrawImage(sw/2+130/zoom, sh-100/zoom, 30/zoom, 30/zoom, textures[9], 0, 0, 0, tocolor(255, 255, 255, a1), false);
dxDrawText("W prawo", sw/2+170/zoom, sh-97/zoom, 104/zoom, 30/zoom, tocolor(250, 249, 249, a1), 1, font3, "left", "top", false, false, true, true);
local max = getElementData(v, "vehicle:type") == "LPG" and 8 or 7;
for i = 1,max do
local x = i-selected;
local sX = (120/zoom)*x;
if(selected == i)then
dxDrawImage(sw/2-40/zoom+sX, sh/2-64/zoom, 80/zoom, 80/zoom, textures[i], 0, 0, 0, tocolor(255, 255, 255, a1), false);
dxDrawText(selected_option[1](v, selected), sw/2-40/zoom+sX+1, sh/2+15/zoom+1, 80/zoom+sw/2-40/zoom+sX+1, 80/zoom+1, tocolor(0, 0, 0, a1), 1, font2, "center", "top", false, false, true, true);
dxDrawText(selected_option[1](v, selected), sw/2-40/zoom+sX, sh/2+15/zoom, 80/zoom+sw/2-40/zoom+sX, 80/zoom, tocolor(250, 249, 249, a1), 1, font2, "center", "top", false, false, true, true);
else
dxDrawImage(sw/2-40/zoom+sX, sh/2-64/zoom, 80/zoom, 80/zoom, textures[i], 0, 0, 0, tocolor(108, 107, 108, a1), false);
end;
end;
end;
function accept()
local veh = getPedOccupiedVehicle(localPlayer);
if(veh and selected_option[1](veh, selected, true))then
triggerServerEvent(selected_option[1](veh, selected, true), resourceRoot, veh);
end;
end;
function up()
tick = getTickCount()
selected = math.max(selected - 1, 1)
end
function down()
local v = getPedOccupiedVehicle(localPlayer)
local max = getElementData(v, "vehicle:type") == "LPG" and 8 or 7;
tick = getTickCount()
selected = math.min(selected + 1, max)
end