Ne haragudj, elhúzódott a film. :D
Client:
local x,y = guiGetScreenSize()
function panelRender()
dxDrawRectangle((x-230)/2,(y-120)/2,230,120,tocolor(0,0,0,160))
dxCreateButton((x-230)/2,(y-30)/1.93,230,30,tocolor(73, 150, 122,160),\"Átkelés\")
dxCreateButton((x-230)/2,(y-30)/1.78,230,30,tocolor(150, 73, 73,160),\"Bezárás\")
end
function buttons(b,s)
local theVehicle = getPedOccupiedVehicle ( localPlayer )
if theVehicle then
if b == \"left\" and s == \"down\" then
if isCursorInPosition((x-230)/2,(y-30)/1.93,230,30) then
core(\"ok\")
elseif isCursorInPosition((x-230)/2,(y-30)/1.78,230,30) then
core(\"close\")
end
end
end
end
addEventHandler(\"onClientClick\", getRootElement(), buttons)
function core(type)
if type == \"Hit\"then
showCursor(true)
addEventHandler(\"onClientRender\", getRootElement(), panelRender)
elseif type == \"Leave\" or type == \"close\" then
showCursor(false)
removeEventHandler(\"onClientRender\", getRootElement(), panelRender)
elseif type == \"ok\" then
outputChatBox(\"Sikeres\")
showCursor(false)
removeEventHandler(\"onClientRender\", getRootElement(), panelRender)
triggerServerEvent(\"openGate\",localPlayer)
end
end
addEvent(\"inTheMarker\",true)
addEventHandler(\"inTheMarker\",getRootElement(),core)
function dxCreateButton(sx,sy,w,h,color,text)
dxDrawRectangle(sx,sy,w,h,color)
dxDrawText(text,sx+w,sy+h,sx,sy,tocolor(255,255,255),1,\"arial\",\"center\",\"center\")
end
function isCursorInPosition(boxX, boxY, boxW, boxH)
if isCursorShowing() then
local absoluteX, absoluteY = getCursorPosition()
absoluteX, absoluteY = absoluteX*x, absoluteY*y
return (absoluteX >= boxX and absoluteX <= boxX+boxW) and (absoluteY >= boxY and absoluteY <= boxY+boxH)
else
return false
end
end
Server:
local Marker = createMarker(2476.72925, -1670.19153, 12.3,\"cylinder\",1.4,73, 150, 122,160)
local defaultGate = createObject( 968, 2473.53613, -1669.20337, 13.32032, 90, 0, 0 )
addEvent( \"openGate\", true )
addEventHandler( \"openGate\", root, function(thePlayer)
moveObject(defaultGate, 2000, 2473.53613, -1669.20337, 13.32032, -90, 0, 0)
setTimer(function()
moveObject(defaultGate, 2000, 2473.53613, -1669.20337, 13.32032, 90, 0, 0)
end, 3000, 1)
end)
addEventHandler(\'onMarkerHit\', root, function(hitElement, hitDimension)
if getElementType(hitElement) ~= \'player\' then return end
local vehicle = getPedOccupiedVehicle(hitElement)
if vehicle then
if source == Marker then
triggerClientEvent(hitElement, \"inTheMarker\", hitElement, \"Hit\")
end
end
end)
addEventHandler(\'onMarkerLeave\', root, function(hitElement, hitDimension)
if getElementType(hitElement) ~= \'player\' then return end
local vehicle = getPedOccupiedVehicle(hitElement)
if vehicle then
if source == Marker then
triggerClientEvent(hitElement, \"inTheMarker\", hitElement, \"Leave\")
end
end
end)
Közel sem tökéletes, de kiindulási alapnak talán jó. :D
Ne haragudj, elhúzódott a film. :D
Client:
local x,y = guiGetScreenSize()
function panelRender()
dxDrawRectangle((x-230)/2,(y-120)/2,230,120,tocolor(0,0,0,160))
dxCreateButton((x-230)/2,(y-30)/1.93,230,30,tocolor(73, 150, 122,160),\"Átkelés\")
dxCreateButton((x-230)/2,(y-30)/1.78,230,30,tocolor(150, 73, 73,160),\"Bezárás\")
end
function buttons(b,s)
local theVehicle = getPedOccupiedVehicle ( localPlayer )
if theVehicle then
if b == \"left\" and s == \"down\" then
if isCursorInPosition((x-230)/2,(y-30)/1.93,230,30) then
core(\"ok\")
elseif isCursorInPosition((x-230)/2,(y-30)/1.78,230,30) then
core(\"close\")
end
end
end
end
addEventHandler(\"onClientClick\", getRootElement(), buttons)
function core(type)
if type == \"Hit\"then
showCursor(true)
addEventHandler(\"onClientRender\", getRootElement(), panelRender)
elseif type == \"Leave\" or type == \"close\" then
showCursor(false)
removeEventHandler(\"onClientRender\", getRootElement(), panelRender)
elseif type == \"ok\" then
outputChatBox(\"Sikeres\")
showCursor(false)
removeEventHandler(\"onClientRender\", getRootElement(), panelRender)
triggerServerEvent(\"openGate\",localPlayer)
end
end
addEvent(\"inTheMarker\",true)
addEventHandler(\"inTheMarker\",getRootElement(),core)
function dxCreateButton(sx,sy,w,h,color,text)
dxDrawRectangle(sx,sy,w,h,color)
dxDrawText(text,sx+w,sy+h,sx,sy,tocolor(255,255,255),1,\"arial\",\"center\",\"center\")
end
function isCursorInPosition(boxX, boxY, boxW, boxH)
if isCursorShowing() then
local absoluteX, absoluteY = getCursorPosition()
absoluteX, absoluteY = absoluteX*x, absoluteY*y
return (absoluteX >= boxX and absoluteX <= boxX+boxW) and (absoluteY >= boxY and absoluteY <= boxY+boxH)
else
return false
end
end
Server:
local Marker = createMarker(2476.72925, -1670.19153, 12.3,\"cylinder\",1.4,73, 150, 122,160)
local defaultGate = createObject( 968, 2473.53613, -1669.20337, 13.32032, 90, 0, 0 )
addEvent( \"openGate\", true )
addEventHandler( \"openGate\", root, function(thePlayer)
moveObject(defaultGate, 2000, 2473.53613, -1669.20337, 13.32032, -90, 0, 0)
setTimer(function()
moveObject(defaultGate, 2000, 2473.53613, -1669.20337, 13.32032, 90, 0, 0)
end, 3000, 1)
end)
addEventHandler(\'onMarkerHit\', root, function(hitElement, hitDimension)
if getElementType(hitElement) ~= \'player\' then return end
local vehicle = getPedOccupiedVehicle(hitElement)
if vehicle then
if source == Marker then
triggerClientEvent(hitElement, \"inTheMarker\", hitElement, \"Hit\")
end
end
end)
addEventHandler(\'onMarkerLeave\', root, function(hitElement, hitDimension)
if getElementType(hitElement) ~= \'player\' then return end
local vehicle = getPedOccupiedVehicle(hitElement)
if vehicle then
if source == Marker then
triggerClientEvent(hitElement, \"inTheMarker\", hitElement, \"Leave\")
end
end
end)
Közel sem tökéletes, de kiindulási alapnak talán jó. :D
Köszi, és ez már például ha berakom megy is? :)