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


Wysłany: 2020-03-27, 17:42


smigi







Wiek: 17
Na forum: 1445 dni
Posty: 60
Nick w MP: smigi

Piwa: 2

Respekt: 50


Witam potrzebuje do tego kodu dodać żeby interakcja po wyjsciu z pojazdu sie automatycznie wylaczala gdyż się buguje


kod:
Cytat:

--[[
@author: nanKy ([email protected])
@resource: interaction
@copyright: używaj ile chcesz, jeżeli szanujesz moją pracę to nie usuwaj notki o autorze.
]]

local dxfont0_cz = dxCreateFont("cz.ttf", 19)
local screenW, screenH = guiGetScreenSize()
ww,hh = 1920, 1080
www,hhh = guiGetScreenSize()
w, h = (www/ww), (hhh/hh)

function isMouseIn(psx,psy,pssx,pssy,abx,aby)
local sx, sy = guiGetScreenSize()
if not isCursorShowing() then return end
cx,cy=getCursorPosition()
cx,cy=cx*sx,cy*sy
if cx >= psx and cx <= psx+pssx and cy >= psy and cy <= psy+pssy then
return true,cx,cy
else
return false
end
end

shift = false

function interakcja()
local veh = getPedOccupiedVehicle(localPlayer)
if getVehicleEngineState(veh) == false then silnik = "Odpal silnik" else silnik = "Zgaś silnik" end
if isElementFrozen(veh) then reczny = "Spuść ręczny" else reczny = "Zaciągnij ręczny" end
if getVehicleOverrideLights(veh) == 2 then swiatla = "Zgaś światła" else swiatla = "Zapal światła" end
if isVehicleLocked(veh) then zamek = "Otwórz zamek" else zamek = "Zamknij zamek" end
dxDrawImage(screenW * 0.3635, screenH * 0.1519, screenW * 0.2734, screenH * 0.6963, ":sr-interakcja/interakcja.png", 0*w, 0*w, 0*w, tocolor(255, 255, 255, 255), false)
if isMouseIn(screenW * 0.4510, screenH * 0.2185, screenW * 0.1505, screenH * 0.0824) then dxDrawImage(screenW * 0.4385, screenH * 0.2065, screenW * 0.1719, screenH * 0.1037, ":sr-interakcja/buttonon.png", 0*w, 0*w, 0*w, tocolor(255, 255, 255, 255), false) else dxDrawImage(screenW * 0.4385, screenH * 0.2065, screenW * 0.1719, screenH * 0.1037, ":sr-interakcja/buttonoff.png", 0*w, 0*w, 0*w, tocolor(255, 255, 255, 255), false) end
if isMouseIn(screenW * 0.4510, screenH * 0.3389, screenW * 0.1505, screenH * 0.0824) then dxDrawImage(screenW * 0.4385, screenH * 0.3296, screenW * 0.1719, screenH * 0.1037, ":sr-interakcja/buttonon.png", 0*w, 0*w, 0*w, tocolor(255, 255, 255, 255), false) else dxDrawImage(screenW * 0.4385, screenH * 0.3296, screenW * 0.1719, screenH * 0.1037, ":sr-interakcja/buttonoff.png", 0*w, 0*w, 0*w, tocolor(255, 255, 255, 255), false) end
if isMouseIn(screenW * 0.4510, screenH * 0.4639, screenW * 0.1505, screenH * 0.0824) then dxDrawImage(screenW * 0.4385, screenH * 0.4546, screenW * 0.1719, screenH * 0.1037, ":sr-interakcja/buttonon.png", 0*w, 0*w, 0*w, tocolor(255, 255, 255, 255), false) else dxDrawImage(screenW * 0.4385, screenH * 0.4546, screenW * 0.1719, screenH * 0.1037, ":sr-interakcja/buttonoff.png", 0*w, 0*w, 0*w, tocolor(255, 255, 255, 255), false) end
if isMouseIn(screenW * 0.4510, screenH * 0.5843, screenW * 0.1505, screenH * 0.0824) then dxDrawImage(screenW * 0.4385, screenH * 0.5750, screenW * 0.1719, screenH * 0.1037, ":sr-interakcja/buttonon.png", 0*w, 0*w, 0*w, tocolor(255, 255, 255, 255), false) else dxDrawImage(screenW * 0.4385, screenH * 0.5750, screenW * 0.1719, screenH * 0.1037, ":sr-interakcja/buttonoff.png", 0*w, 0*w, 0*w, tocolor(255, 255, 255, 255), false) end
if isMouseIn(screenW * 0.4510, screenH * 0.7074, screenW * 0.1505, screenH * 0.0824) then dxDrawImage(screenW * 0.4385, screenH * 0.6963, screenW * 0.1719, screenH * 0.1037, ":sr-interakcja/buttonon.png", 0*w, 0*w, 0*w, tocolor(255, 255, 255, 255), false) else dxDrawImage(screenW * 0.4385, screenH * 0.6963, screenW * 0.1719, screenH * 0.1037, ":sr-interakcja/buttonoff.png", 0*w, 0*w, 0*w, tocolor(255, 255, 255, 255), false) end
dxDrawText(silnik, (screenW * 0.4391) + 1, (screenH * 0.2074) + 1, (screenW * 0.6104) + 1, (screenH * 0.3102) + 1, tocolor(0, 0, 0, 255), 1*w, dxfont0_cz, "center", "center", false, false, false, false, false)
dxDrawText(silnik, screenW * 0.4391, screenH * 0.2074, screenW * 0.6104, screenH * 0.3102, tocolor(255, 255, 255, 255), 1*w, dxfont0_cz, "center", "center", false, false, false, false, false)
dxDrawText(reczny, (screenW * 0.4391) + 1, (screenH * 0.3296) + 1, (screenW * 0.6104) + 1, (screenH * 0.4324) + 1, tocolor(0, 0, 0, 255), 1*w, dxfont0_cz, "center", "center", false, false, false, false, false)
dxDrawText(reczny, screenW * 0.4391, screenH * 0.3296, screenW * 0.6104, screenH * 0.4324, tocolor(255, 255, 255, 255), 1*w, dxfont0_cz, "center", "center", false, false, false, false, false)
dxDrawText(swiatla, (screenW * 0.4385) + 1, (screenH * 0.4546) + 1, (screenW * 0.6099) + 1, (screenH * 0.5574) + 1, tocolor(0, 0, 0, 255), 1*w, dxfont0_cz, "center", "center", false, false, false, false, false)
dxDrawText(swiatla, screenW * 0.4385, screenH * 0.4546, screenW * 0.6099, screenH * 0.5574, tocolor(255, 255, 255, 255), 1*w, dxfont0_cz, "center", "center", false, false, false, false, false)
dxDrawText("Wysadź pasażerów", (screenW * 0.4385) + 1, (screenH * 0.5750) + 1, (screenW * 0.6099) + 1, (screenH * 0.6778) + 1, tocolor(0, 0, 0, 255), 1*w, dxfont0_cz, "center", "center", false, false, false, false, false)
dxDrawText("Wysadź pasażerów", screenW * 0.4385, screenH * 0.5750, screenW * 0.6099, screenH * 0.6778, tocolor(255, 255, 255, 255), 1*w, dxfont0_cz, "center", "center", false, false, false, false, false)
dxDrawText(zamek, (screenW * 0.4385) + 1, (screenH * 0.6963) + 1, (screenW * 0.6099) + 1, (screenH * 0.7991) + 1, tocolor(0, 0, 0, 255), 1*w, dxfont0_cz, "center", "center", false, false, false, false, false)
dxDrawText(zamek, screenW * 0.4385, screenH * 0.6963, screenW * 0.6099, screenH * 0.7991, tocolor(255, 255, 255, 255), 1*w, dxfont0_cz, "center", "center", false, false, false, false, false)
end

addEventHandler("onClientClick", root, function(btn, state)
if btn == "left" and state == "down" then
local veh = getPedOccupiedVehicle(localPlayer)
if shift == true and getVehicleController(veh) == localPlayer and veh then
if isMouseIn(screenW * 0.4510, screenH * 0.2185, screenW * 0.1505, screenH * 0.0824) then
triggerServerEvent("engine", localPlayer)
elseif isMouseIn(screenW * 0.4510, screenH * 0.3389, screenW * 0.1505, screenH * 0.0824) then
triggerServerEvent("brake", localPlayer)
elseif isMouseIn(screenW * 0.4510, screenH * 0.4639, screenW * 0.1505, screenH * 0.0824) then
triggerServerEvent("lights", localPlayer)
elseif isMouseIn(screenW * 0.4510, screenH * 0.5843, screenW * 0.1505, screenH * 0.0824) then
triggerServerEvent("exit", localPlayer)
elseif isMouseIn(screenW * 0.4510, screenH * 0.7074, screenW * 0.1505, screenH * 0.0824) then
triggerServerEvent("doors", localPlayer)
end
end
end
end)

bindKey("lshift","down",function()
local veh = getPedOccupiedVehicle(localPlayer)
if veh then
if getVehicleController(veh) == localPlayer then
if shift == false then
addEventHandler ("onClientRender", root, interakcja)
showCursor(true)
shift = true
else
removeEventHandler ("onClientRender", root, interakcja)
shift = false
showCursor (false)
end
end
end
end)


Postaw piwo autorowi tego posta
 

 
Wysłany: 2020-03-27, 18:07


NotPaladyn







Wiek: 18
Na forum: 868 dni
Posty: 338
Nick w MP: NotPaladyn

Piwa: 1632

Respekt: 430
Respekt: 430



   Mod-Team: Cześć, stosując się do regulaminów eliminujesz ryzyko otrzymania kary forumowej.
Spróbuj tak:


--[[
@author: nanKy (eryk1337.official@gmail.com)
@resource: interaction
@copyright: używaj ile chcesz, jeżeli szanujesz moją pracę to nie usuwaj notki o autorze.
]]

local dxfont0_cz = dxCreateFont("cz.ttf", 19)
local screenW, screenH = guiGetScreenSize()
ww,hh = 1920, 1080
www,hhh = guiGetScreenSize()
w, h = (www/ww), (hhh/hh)

function isMouseIn(psx,psy,pssx,pssy,abx,aby)
local sx, sy = guiGetScreenSize()
if not isCursorShowing() then return end
cx,cy=getCursorPosition()
cx,cy=cx*sx,cy*sy
if cx >= psx and cx <= psx+pssx and cy >= psy and cy <= psy+pssy then
return true,cx,cy
else
return false
end
end

function isEventHandlerAdded( sEventName, pElementAttachedTo, func )
if type( sEventName ) == 'string' and isElement( pElementAttachedTo ) and type( func ) == 'function' then
local aAttachedFunctions = getEventHandlers( sEventName, pElementAttachedTo )
if type( aAttachedFunctions ) == 'table' and #aAttachedFunctions > 0 then
for i, v in ipairs( aAttachedFunctions ) do
if v == func then
return true
end
end
end
end
return false
end

shift = false

function interakcja()
local veh = getPedOccupiedVehicle(localPlayer)
if getVehicleEngineState(veh) == false then silnik = "Odpal silnik" else silnik = "Zgaś silnik" end
if isElementFrozen(veh) then reczny = "Spuść ręczny" else reczny = "Zaciągnij ręczny" end
if getVehicleOverrideLights(veh) == 2 then swiatla = "Zgaś światła" else swiatla = "Zapal światła" end
if isVehicleLocked(veh) then zamek = "Otwórz zamek" else zamek = "Zamknij zamek" end
dxDrawImage(screenW * 0.3635, screenH * 0.1519, screenW * 0.2734, screenH * 0.6963, ":sr-interakcja/interakcja.png", 0*w, 0*w, 0*w, tocolor(255, 255, 255, 255), false)
if isMouseIn(screenW * 0.4510, screenH * 0.2185, screenW * 0.1505, screenH * 0.0824) then dxDrawImage(screenW * 0.4385, screenH * 0.2065, screenW * 0.1719, screenH * 0.1037, ":sr-interakcja/buttonon.png", 0*w, 0*w, 0*w, tocolor(255, 255, 255, 255), false) else dxDrawImage(screenW * 0.4385, screenH * 0.2065, screenW * 0.1719, screenH * 0.1037, ":sr-interakcja/buttonoff.png", 0*w, 0*w, 0*w, tocolor(255, 255, 255, 255), false) end
if isMouseIn(screenW * 0.4510, screenH * 0.3389, screenW * 0.1505, screenH * 0.0824) then dxDrawImage(screenW * 0.4385, screenH * 0.3296, screenW * 0.1719, screenH * 0.1037, ":sr-interakcja/buttonon.png", 0*w, 0*w, 0*w, tocolor(255, 255, 255, 255), false) else dxDrawImage(screenW * 0.4385, screenH * 0.3296, screenW * 0.1719, screenH * 0.1037, ":sr-interakcja/buttonoff.png", 0*w, 0*w, 0*w, tocolor(255, 255, 255, 255), false) end
if isMouseIn(screenW * 0.4510, screenH * 0.4639, screenW * 0.1505, screenH * 0.0824) then dxDrawImage(screenW * 0.4385, screenH * 0.4546, screenW * 0.1719, screenH * 0.1037, ":sr-interakcja/buttonon.png", 0*w, 0*w, 0*w, tocolor(255, 255, 255, 255), false) else dxDrawImage(screenW * 0.4385, screenH * 0.4546, screenW * 0.1719, screenH * 0.1037, ":sr-interakcja/buttonoff.png", 0*w, 0*w, 0*w, tocolor(255, 255, 255, 255), false) end
if isMouseIn(screenW * 0.4510, screenH * 0.5843, screenW * 0.1505, screenH * 0.0824) then dxDrawImage(screenW * 0.4385, screenH * 0.5750, screenW * 0.1719, screenH * 0.1037, ":sr-interakcja/buttonon.png", 0*w, 0*w, 0*w, tocolor(255, 255, 255, 255), false) else dxDrawImage(screenW * 0.4385, screenH * 0.5750, screenW * 0.1719, screenH * 0.1037, ":sr-interakcja/buttonoff.png", 0*w, 0*w, 0*w, tocolor(255, 255, 255, 255), false) end
if isMouseIn(screenW * 0.4510, screenH * 0.7074, screenW * 0.1505, screenH * 0.0824) then dxDrawImage(screenW * 0.4385, screenH * 0.6963, screenW * 0.1719, screenH * 0.1037, ":sr-interakcja/buttonon.png", 0*w, 0*w, 0*w, tocolor(255, 255, 255, 255), false) else dxDrawImage(screenW * 0.4385, screenH * 0.6963, screenW * 0.1719, screenH * 0.1037, ":sr-interakcja/buttonoff.png", 0*w, 0*w, 0*w, tocolor(255, 255, 255, 255), false) end
dxDrawText(silnik, (screenW * 0.4391) + 1, (screenH * 0.2074) + 1, (screenW * 0.6104) + 1, (screenH * 0.3102) + 1, tocolor(0, 0, 0, 255), 1*w, dxfont0_cz, "center", "center", false, false, false, false, false)
dxDrawText(silnik, screenW * 0.4391, screenH * 0.2074, screenW * 0.6104, screenH * 0.3102, tocolor(255, 255, 255, 255), 1*w, dxfont0_cz, "center", "center", false, false, false, false, false)
dxDrawText(reczny, (screenW * 0.4391) + 1, (screenH * 0.3296) + 1, (screenW * 0.6104) + 1, (screenH * 0.4324) + 1, tocolor(0, 0, 0, 255), 1*w, dxfont0_cz, "center", "center", false, false, false, false, false)
dxDrawText(reczny, screenW * 0.4391, screenH * 0.3296, screenW * 0.6104, screenH * 0.4324, tocolor(255, 255, 255, 255), 1*w, dxfont0_cz, "center", "center", false, false, false, false, false)
dxDrawText(swiatla, (screenW * 0.4385) + 1, (screenH * 0.4546) + 1, (screenW * 0.6099) + 1, (screenH * 0.5574) + 1, tocolor(0, 0, 0, 255), 1*w, dxfont0_cz, "center", "center", false, false, false, false, false)
dxDrawText(swiatla, screenW * 0.4385, screenH * 0.4546, screenW * 0.6099, screenH * 0.5574, tocolor(255, 255, 255, 255), 1*w, dxfont0_cz, "center", "center", false, false, false, false, false)
dxDrawText("Wysadź pasażerów", (screenW * 0.4385) + 1, (screenH * 0.5750) + 1, (screenW * 0.6099) + 1, (screenH * 0.6778) + 1, tocolor(0, 0, 0, 255), 1*w, dxfont0_cz, "center", "center", false, false, false, false, false)
dxDrawText("Wysadź pasażerów", screenW * 0.4385, screenH * 0.5750, screenW * 0.6099, screenH * 0.6778, tocolor(255, 255, 255, 255), 1*w, dxfont0_cz, "center", "center", false, false, false, false, false)
dxDrawText(zamek, (screenW * 0.4385) + 1, (screenH * 0.6963) + 1, (screenW * 0.6099) + 1, (screenH * 0.7991) + 1, tocolor(0, 0, 0, 255), 1*w, dxfont0_cz, "center", "center", false, false, false, false, false)
dxDrawText(zamek, screenW * 0.4385, screenH * 0.6963, screenW * 0.6099, screenH * 0.7991, tocolor(255, 255, 255, 255), 1*w, dxfont0_cz, "center", "center", false, false, false, false, false)
end

addEventHandler("onClientClick", root, function(btn, state)
if btn == "left" and state == "down" then
local veh = getPedOccupiedVehicle(localPlayer)
if shift == true and getVehicleController(veh) == localPlayer and veh then
if isMouseIn(screenW * 0.4510, screenH * 0.2185, screenW * 0.1505, screenH * 0.0824) then
triggerServerEvent("engine", localPlayer)
elseif isMouseIn(screenW * 0.4510, screenH * 0.3389, screenW * 0.1505, screenH * 0.0824) then
triggerServerEvent("brake", localPlayer)
elseif isMouseIn(screenW * 0.4510, screenH * 0.4639, screenW * 0.1505, screenH * 0.0824) then
triggerServerEvent("lights", localPlayer)
elseif isMouseIn(screenW * 0.4510, screenH * 0.5843, screenW * 0.1505, screenH * 0.0824) then
triggerServerEvent("exit", localPlayer)
elseif isMouseIn(screenW * 0.4510, screenH * 0.7074, screenW * 0.1505, screenH * 0.0824) then
triggerServerEvent("doors", localPlayer)
end
end
end
end)

bindKey("lshift","down",function()
local veh = getPedOccupiedVehicle(localPlayer)
if veh then
if getVehicleController(veh) == localPlayer then
if shift == false then
addEventHandler ("onClientRender", root, interakcja)
showCursor(true)
shift = true
else
removeEventHandler ("onClientRender", root, interakcja)
shift = false
showCursor (false)
end
end
end
end)




function closeinteraction()
local veh = getPedOccupiedVehicle(localPlayer)
if veh then
if getVehicleController(veh) == localPlayer then
if isEventHandlerAdded("onClientRender", root, interakcja) then
removeEventHandler ("onClientRender", root, interakcja)
end
end
end
end
addEventHandler("onClientVehicleExit", getRootElement(), closeinteraction)


Postaw piwo autorowi tego posta
 

 
Wysłany: 2020-03-27, 18:46


smigi







Wiek: 17
Na forum: 1445 dni
Posty: 60
Nick w MP: smigi

Piwa: 2

Respekt: 50


"NotPaladyn" napisał/a:

Spróbuj tak:


--[[
@author: nanKy (eryk1337.official@gmail.com)
@resource: interaction
@copyright: używaj ile chcesz, jeżeli szanujesz moją pracę to nie usuwaj notki o autorze.
]]

local dxfont0_cz = dxCreateFont("cz.ttf", 19)
local screenW, screenH = guiGetScreenSize()
ww,hh = 1920, 1080
www,hhh = guiGetScreenSize()
w, h = (www/ww), (hhh/hh)

function isMouseIn(psx,psy,pssx,pssy,abx,aby)
local sx, sy = guiGetScreenSize()
if not isCursorShowing() then return end
cx,cy=getCursorPosition()
cx,cy=cx*sx,cy*sy
if cx >= psx and cx <= psx+pssx and cy >= psy and cy <= psy+pssy then
return true,cx,cy
else
return false
end
end

function isEventHandlerAdded( sEventName, pElementAttachedTo, func )
if type( sEventName ) == 'string' and isElement( pElementAttachedTo ) and type( func ) == 'function' then
local aAttachedFunctions = getEventHandlers( sEventName, pElementAttachedTo )
if type( aAttachedFunctions ) == 'table' and #aAttachedFunctions > 0 then
for i, v in ipairs( aAttachedFunctions ) do
if v == func then
return true
end
end
end
end
return false
end

shift = false

function interakcja()
local veh = getPedOccupiedVehicle(localPlayer)
if getVehicleEngineState(veh) == false then silnik = "Odpal silnik" else silnik = "Zgaś silnik" end
if isElementFrozen(veh) then reczny = "Spuść ręczny" else reczny = "Zaciągnij ręczny" end
if getVehicleOverrideLights(veh) == 2 then swiatla = "Zgaś światła" else swiatla = "Zapal światła" end
if isVehicleLocked(veh) then zamek = "Otwórz zamek" else zamek = "Zamknij zamek" end
dxDrawImage(screenW * 0.3635, screenH * 0.1519, screenW * 0.2734, screenH * 0.6963, ":sr-interakcja/interakcja.png", 0*w, 0*w, 0*w, tocolor(255, 255, 255, 255), false)
if isMouseIn(screenW * 0.4510, screenH * 0.2185, screenW * 0.1505, screenH * 0.0824) then dxDrawImage(screenW * 0.4385, screenH * 0.2065, screenW * 0.1719, screenH * 0.1037, ":sr-interakcja/buttonon.png", 0*w, 0*w, 0*w, tocolor(255, 255, 255, 255), false) else dxDrawImage(screenW * 0.4385, screenH * 0.2065, screenW * 0.1719, screenH * 0.1037, ":sr-interakcja/buttonoff.png", 0*w, 0*w, 0*w, tocolor(255, 255, 255, 255), false) end
if isMouseIn(screenW * 0.4510, screenH * 0.3389, screenW * 0.1505, screenH * 0.0824) then dxDrawImage(screenW * 0.4385, screenH * 0.3296, screenW * 0.1719, screenH * 0.1037, ":sr-interakcja/buttonon.png", 0*w, 0*w, 0*w, tocolor(255, 255, 255, 255), false) else dxDrawImage(screenW * 0.4385, screenH * 0.3296, screenW * 0.1719, screenH * 0.1037, ":sr-interakcja/buttonoff.png", 0*w, 0*w, 0*w, tocolor(255, 255, 255, 255), false) end
if isMouseIn(screenW * 0.4510, screenH * 0.4639, screenW * 0.1505, screenH * 0.0824) then dxDrawImage(screenW * 0.4385, screenH * 0.4546, screenW * 0.1719, screenH * 0.1037, ":sr-interakcja/buttonon.png", 0*w, 0*w, 0*w, tocolor(255, 255, 255, 255), false) else dxDrawImage(screenW * 0.4385, screenH * 0.4546, screenW * 0.1719, screenH * 0.1037, ":sr-interakcja/buttonoff.png", 0*w, 0*w, 0*w, tocolor(255, 255, 255, 255), false) end
if isMouseIn(screenW * 0.4510, screenH * 0.5843, screenW * 0.1505, screenH * 0.0824) then dxDrawImage(screenW * 0.4385, screenH * 0.5750, screenW * 0.1719, screenH * 0.1037, ":sr-interakcja/buttonon.png", 0*w, 0*w, 0*w, tocolor(255, 255, 255, 255), false) else dxDrawImage(screenW * 0.4385, screenH * 0.5750, screenW * 0.1719, screenH * 0.1037, ":sr-interakcja/buttonoff.png", 0*w, 0*w, 0*w, tocolor(255, 255, 255, 255), false) end
if isMouseIn(screenW * 0.4510, screenH * 0.7074, screenW * 0.1505, screenH * 0.0824) then dxDrawImage(screenW * 0.4385, screenH * 0.6963, screenW * 0.1719, screenH * 0.1037, ":sr-interakcja/buttonon.png", 0*w, 0*w, 0*w, tocolor(255, 255, 255, 255), false) else dxDrawImage(screenW * 0.4385, screenH * 0.6963, screenW * 0.1719, screenH * 0.1037, ":sr-interakcja/buttonoff.png", 0*w, 0*w, 0*w, tocolor(255, 255, 255, 255), false) end
dxDrawText(silnik, (screenW * 0.4391) + 1, (screenH * 0.2074) + 1, (screenW * 0.6104) + 1, (screenH * 0.3102) + 1, tocolor(0, 0, 0, 255), 1*w, dxfont0_cz, "center", "center", false, false, false, false, false)
dxDrawText(silnik, screenW * 0.4391, screenH * 0.2074, screenW * 0.6104, screenH * 0.3102, tocolor(255, 255, 255, 255), 1*w, dxfont0_cz, "center", "center", false, false, false, false, false)
dxDrawText(reczny, (screenW * 0.4391) + 1, (screenH * 0.3296) + 1, (screenW * 0.6104) + 1, (screenH * 0.4324) + 1, tocolor(0, 0, 0, 255), 1*w, dxfont0_cz, "center", "center", false, false, false, false, false)
dxDrawText(reczny, screenW * 0.4391, screenH * 0.3296, screenW * 0.6104, screenH * 0.4324, tocolor(255, 255, 255, 255), 1*w, dxfont0_cz, "center", "center", false, false, false, false, false)
dxDrawText(swiatla, (screenW * 0.4385) + 1, (screenH * 0.4546) + 1, (screenW * 0.6099) + 1, (screenH * 0.5574) + 1, tocolor(0, 0, 0, 255), 1*w, dxfont0_cz, "center", "center", false, false, false, false, false)
dxDrawText(swiatla, screenW * 0.4385, screenH * 0.4546, screenW * 0.6099, screenH * 0.5574, tocolor(255, 255, 255, 255), 1*w, dxfont0_cz, "center", "center", false, false, false, false, false)
dxDrawText("Wysadź pasażerów", (screenW * 0.4385) + 1, (screenH * 0.5750) + 1, (screenW * 0.6099) + 1, (screenH * 0.6778) + 1, tocolor(0, 0, 0, 255), 1*w, dxfont0_cz, "center", "center", false, false, false, false, false)
dxDrawText("Wysadź pasażerów", screenW * 0.4385, screenH * 0.5750, screenW * 0.6099, screenH * 0.6778, tocolor(255, 255, 255, 255), 1*w, dxfont0_cz, "center", "center", false, false, false, false, false)
dxDrawText(zamek, (screenW * 0.4385) + 1, (screenH * 0.6963) + 1, (screenW * 0.6099) + 1, (screenH * 0.7991) + 1, tocolor(0, 0, 0, 255), 1*w, dxfont0_cz, "center", "center", false, false, false, false, false)
dxDrawText(zamek, screenW * 0.4385, screenH * 0.6963, screenW * 0.6099, screenH * 0.7991, tocolor(255, 255, 255, 255), 1*w, dxfont0_cz, "center", "center", false, false, false, false, false)
end

addEventHandler("onClientClick", root, function(btn, state)
if btn == "left" and state == "down" then
local veh = getPedOccupiedVehicle(localPlayer)
if shift == true and getVehicleController(veh) == localPlayer and veh then
if isMouseIn(screenW * 0.4510, screenH * 0.2185, screenW * 0.1505, screenH * 0.0824) then
triggerServerEvent("engine", localPlayer)
elseif isMouseIn(screenW * 0.4510, screenH * 0.3389, screenW * 0.1505, screenH * 0.0824) then
triggerServerEvent("brake", localPlayer)
elseif isMouseIn(screenW * 0.4510, screenH * 0.4639, screenW * 0.1505, screenH * 0.0824) then
triggerServerEvent("lights", localPlayer)
elseif isMouseIn(screenW * 0.4510, screenH * 0.5843, screenW * 0.1505, screenH * 0.0824) then
triggerServerEvent("exit", localPlayer)
elseif isMouseIn(screenW * 0.4510, screenH * 0.7074, screenW * 0.1505, screenH * 0.0824) then
triggerServerEvent("doors", localPlayer)
end
end
end
end)

bindKey("lshift","down",function()
local veh = getPedOccupiedVehicle(localPlayer)
if veh then
if getVehicleController(veh) == localPlayer then
if shift == false then
addEventHandler ("onClientRender", root, interakcja)
showCursor(true)
shift = true
else
removeEventHandler ("onClientRender", root, interakcja)
shift = false
showCursor (false)
end
end
end
end)




function closeinteraction()
local veh = getPedOccupiedVehicle(localPlayer)
if veh then
if getVehicleController(veh) == localPlayer then
if isEventHandlerAdded("onClientRender", root, interakcja) then
removeEventHandler ("onClientRender", root, interakcja)
end
end
end
end
addEventHandler("onClientVehicleExit", getRootElement(), closeinteraction)



nadal nie dziala

[ Dodano: 2020-03-27, 18:48 ]
teraz jest tak ze jesli chcesz wlaczyc musisz kliknac a jesli chcesz wylaczyc tez musisz kliknac shift dalbys rade to tak zedytowac zeby sie automatycznie wylaczalo?

Postaw piwo autorowi tego posta
 

 
Wysłany: 2020-03-28, 03:49


Hades.

Podążaj za marzeniami.






Wiek: 17
Na forum: 2777 dni
Posty: 371
Nick w MP: R35

Piwa: 2528

Respekt: 327,8
Respekt: 327,8Respekt: 327,8Respekt: 327,8


R*



--[[
@author: nanKy (eryk1337.official@gmail.com)
@resource: interaction
@copyright: używaj ile chcesz, jeżeli szanujesz moją pracę to nie usuwaj notki o autorze.
]]

local dxfont0_cz = dxCreateFont("cz.ttf", 19)
local screenW, screenH = guiGetScreenSize()
ww,hh = 1920, 1080
www,hhh = guiGetScreenSize()
w, h = (www/ww), (hhh/hh)

function isMouseIn(psx,psy,pssx,pssy,abx,aby)
local sx, sy = guiGetScreenSize()
if not isCursorShowing() then return end
cx,cy=getCursorPosition()
cx,cy=cx*sx,cy*sy
if cx >= psx and cx <= psx+pssx and cy >= psy and cy <= psy+pssy then
return true,cx,cy
else
return false
end
end

shift = false

function interakcja()
local veh = getPedOccupiedVehicle(localPlayer)
if getVehicleEngineState(veh) == false then silnik = "Odpal silnik" else silnik = "Zgaś silnik" end
if isElementFrozen(veh) then reczny = "Spuść ręczny" else reczny = "Zaciągnij ręczny" end
if getVehicleOverrideLights(veh) == 2 then swiatla = "Zgaś światła" else swiatla = "Zapal światła" end
if isVehicleLocked(veh) then zamek = "Otwórz zamek" else zamek = "Zamknij zamek" end
dxDrawImage(screenW * 0.3635, screenH * 0.1519, screenW * 0.2734, screenH * 0.6963, ":sr-interakcja/interakcja.png", 0*w, 0*w, 0*w, tocolor(255, 255, 255, 255), false)
if isMouseIn(screenW * 0.4510, screenH * 0.2185, screenW * 0.1505, screenH * 0.0824) then dxDrawImage(screenW * 0.4385, screenH * 0.2065, screenW * 0.1719, screenH * 0.1037, ":sr-interakcja/buttonon.png", 0*w, 0*w, 0*w, tocolor(255, 255, 255, 255), false) else dxDrawImage(screenW * 0.4385, screenH * 0.2065, screenW * 0.1719, screenH * 0.1037, ":sr-interakcja/buttonoff.png", 0*w, 0*w, 0*w, tocolor(255, 255, 255, 255), false) end
if isMouseIn(screenW * 0.4510, screenH * 0.3389, screenW * 0.1505, screenH * 0.0824) then dxDrawImage(screenW * 0.4385, screenH * 0.3296, screenW * 0.1719, screenH * 0.1037, ":sr-interakcja/buttonon.png", 0*w, 0*w, 0*w, tocolor(255, 255, 255, 255), false) else dxDrawImage(screenW * 0.4385, screenH * 0.3296, screenW * 0.1719, screenH * 0.1037, ":sr-interakcja/buttonoff.png", 0*w, 0*w, 0*w, tocolor(255, 255, 255, 255), false) end
if isMouseIn(screenW * 0.4510, screenH * 0.4639, screenW * 0.1505, screenH * 0.0824) then dxDrawImage(screenW * 0.4385, screenH * 0.4546, screenW * 0.1719, screenH * 0.1037, ":sr-interakcja/buttonon.png", 0*w, 0*w, 0*w, tocolor(255, 255, 255, 255), false) else dxDrawImage(screenW * 0.4385, screenH * 0.4546, screenW * 0.1719, screenH * 0.1037, ":sr-interakcja/buttonoff.png", 0*w, 0*w, 0*w, tocolor(255, 255, 255, 255), false) end
if isMouseIn(screenW * 0.4510, screenH * 0.5843, screenW * 0.1505, screenH * 0.0824) then dxDrawImage(screenW * 0.4385, screenH * 0.5750, screenW * 0.1719, screenH * 0.1037, ":sr-interakcja/buttonon.png", 0*w, 0*w, 0*w, tocolor(255, 255, 255, 255), false) else dxDrawImage(screenW * 0.4385, screenH * 0.5750, screenW * 0.1719, screenH * 0.1037, ":sr-interakcja/buttonoff.png", 0*w, 0*w, 0*w, tocolor(255, 255, 255, 255), false) end
if isMouseIn(screenW * 0.4510, screenH * 0.7074, screenW * 0.1505, screenH * 0.0824) then dxDrawImage(screenW * 0.4385, screenH * 0.6963, screenW * 0.1719, screenH * 0.1037, ":sr-interakcja/buttonon.png", 0*w, 0*w, 0*w, tocolor(255, 255, 255, 255), false) else dxDrawImage(screenW * 0.4385, screenH * 0.6963, screenW * 0.1719, screenH * 0.1037, ":sr-interakcja/buttonoff.png", 0*w, 0*w, 0*w, tocolor(255, 255, 255, 255), false) end
dxDrawText(silnik, (screenW * 0.4391) + 1, (screenH * 0.2074) + 1, (screenW * 0.6104) + 1, (screenH * 0.3102) + 1, tocolor(0, 0, 0, 255), 1*w, dxfont0_cz, "center", "center", false, false, false, false, false)
dxDrawText(silnik, screenW * 0.4391, screenH * 0.2074, screenW * 0.6104, screenH * 0.3102, tocolor(255, 255, 255, 255), 1*w, dxfont0_cz, "center", "center", false, false, false, false, false)
dxDrawText(reczny, (screenW * 0.4391) + 1, (screenH * 0.3296) + 1, (screenW * 0.6104) + 1, (screenH * 0.4324) + 1, tocolor(0, 0, 0, 255), 1*w, dxfont0_cz, "center", "center", false, false, false, false, false)
dxDrawText(reczny, screenW * 0.4391, screenH * 0.3296, screenW * 0.6104, screenH * 0.4324, tocolor(255, 255, 255, 255), 1*w, dxfont0_cz, "center", "center", false, false, false, false, false)
dxDrawText(swiatla, (screenW * 0.4385) + 1, (screenH * 0.4546) + 1, (screenW * 0.6099) + 1, (screenH * 0.5574) + 1, tocolor(0, 0, 0, 255), 1*w, dxfont0_cz, "center", "center", false, false, false, false, false)
dxDrawText(swiatla, screenW * 0.4385, screenH * 0.4546, screenW * 0.6099, screenH * 0.5574, tocolor(255, 255, 255, 255), 1*w, dxfont0_cz, "center", "center", false, false, false, false, false)
dxDrawText("Wysadź pasażerów", (screenW * 0.4385) + 1, (screenH * 0.5750) + 1, (screenW * 0.6099) + 1, (screenH * 0.6778) + 1, tocolor(0, 0, 0, 255), 1*w, dxfont0_cz, "center", "center", false, false, false, false, false)
dxDrawText("Wysadź pasażerów", screenW * 0.4385, screenH * 0.5750, screenW * 0.6099, screenH * 0.6778, tocolor(255, 255, 255, 255), 1*w, dxfont0_cz, "center", "center", false, false, false, false, false)
dxDrawText(zamek, (screenW * 0.4385) + 1, (screenH * 0.6963) + 1, (screenW * 0.6099) + 1, (screenH * 0.7991) + 1, tocolor(0, 0, 0, 255), 1*w, dxfont0_cz, "center", "center", false, false, false, false, false)
dxDrawText(zamek, screenW * 0.4385, screenH * 0.6963, screenW * 0.6099, screenH * 0.7991, tocolor(255, 255, 255, 255), 1*w, dxfont0_cz, "center", "center", false, false, false, false, false)
end

addEventHandler("onClientClick", root, function(btn, state)
if btn == "left" and state == "down" then
local veh = getPedOccupiedVehicle(localPlayer)
if shift == true and getVehicleController(veh) == localPlayer and veh then
if isMouseIn(screenW * 0.4510, screenH * 0.2185, screenW * 0.1505, screenH * 0.0824) then
triggerServerEvent("engine", localPlayer)
elseif isMouseIn(screenW * 0.4510, screenH * 0.3389, screenW * 0.1505, screenH * 0.0824) then
triggerServerEvent("brake", localPlayer)
elseif isMouseIn(screenW * 0.4510, screenH * 0.4639, screenW * 0.1505, screenH * 0.0824) then
triggerServerEvent("lights", localPlayer)
elseif isMouseIn(screenW * 0.4510, screenH * 0.5843, screenW * 0.1505, screenH * 0.0824) then
triggerServerEvent("exit", localPlayer)
elseif isMouseIn(screenW * 0.4510, screenH * 0.7074, screenW * 0.1505, screenH * 0.0824) then
triggerServerEvent("doors", localPlayer)
end
end
end
end)

showInteract = function( bool )
if bool and not shift then
addEventHandler('onClientRender', root, interakcja);
showCursor( true );
shift = true;
else
removeEventHandler('onClientRender', root, interakcja);
showCursor( false );
shift = false;
end
end

addEventHandler('onClientVehicleEnter', root, function( player, seat )
if player == localPlayer and seat == 0 then
bindKey('lshift', 'both', function(key, state)
if getPedOccupiedVehicle( localPlayer ) then
if state == 'down' then
showInteract( true );
elseif state == 'up' then
showInteract( false );
end
end
end);
end
end);

addEventHandler('onClientVehicleStartExit', root, function( player, seat )
if player == localPlayer and sea == 0 then
if shift then
showIntearct( false );
end
end
end);



Liczę na :piwo: lub R*

Postaw piwo autorowi tego posta
 

 
Tagi: interakcja :: wyjsciu :: auta :: zeby :: sie :: automatycznie :: wylaczal
Anonymous





Na forum: 245 dni
Posty: 1



Anonymous Koniecznie zajrzyj na:








Wyświetl posty z ostatnich:   

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

Skocz do: