Skript do ped:
local posicaoped = 359.71392822266,173.86311340332,1008.3893432617
local thePed = createPed(120, 359.71392822266, 173.86311340332, 1008.3893432617, 280) -- Creates a ped
setElementFrozen(thePed, true)
setElementInterior ( thePed, 3 )
setElementDimension ( thePed, 0 )
function freezePed()
local pedposition = getElementPosition(thePed)
if not pedposition == posicaoped then
setElementPosition(thePed, 359.71392822266, 173.86311340332, 1008.3893432617)
end
end
addEventHandler("onResourceStart", getRootElement(), freezePed)
function cancelPedDamage()
cancelEvent() -- Cancels the onClientPedDamage event
end
addEventHandler("onClientPedDamage", thePed, cancelPedDamage) -- When thePed is damaged, cancelPedDamage is called
addEventHandler( "onClientRender", root, function()
local x, y, z = getElementPosition(thePed)
local Mx, My, Mz = getCameraMatrix( )
if ( getDistanceBetweenPoints3D( x, y, z, Mx, My, Mz ) <= 10 ) then
local WorldPositionX, WorldPositionY = getScreenFromWorldPosition( x, y, z +1, 0.07 )
if ( WorldPositionX and WorldPositionY ) then
dxDrawText("#8a2be1[NPC] #FFFFFFJubiscleido", WorldPositionX - 5, WorldPositionY + 1, WorldPositionX - 5, WorldPositionY + 1, tocolor(255,215,0,255), 1.4, "default", "center", "center", false, false, false, true, false)
-- dxDrawText("Alugue Bikes Aqui!", WorldPositionX - 1, WorldPositionY + 1, WorldPositionX - 1, WorldPositionY + 1, tocolor(255, 255, 255, 255), 2.50, "default-bold", "center", "center", false, false, false, false, false)
end
end
end)
----------------------------------------------------------
function render()
local screenx, screeny, worldx, worldy, worldz = getCursorPosition()
local px, py, pz = getCameraMatrix()
local hit, x, y, z, elementHit = processLineOfSight ( px, py, pz, worldx, worldy, worldz )
local tx, ty, tz = getElementPosition(localPlayer)
local rx, ry, rz = getElementPosition(thePed)
local screenWidth,screenHeight = guiGetScreenSize()
MunitorC, MunitorL = guiGetScreenSize()
abx, aby = (MunitorC/1366), (MunitorL/768)
local distancia = getDistanceBetweenPoints3D(tx, ty, tz, rx, ry, rz)
if not isEventHandlerAdded("onClientRender", root, AbrirAgenciaEmpregos) then
if (distancia < 1.5) then
if hit then
if elementHit == thePed then
addEventHandler("onClientRender", root, AbrirAgenciaEmpregos)
showCursor(true)
showChat(true)
AgenciaEmpregosNew = true
end
end
end
end
end
addEventHandler ("onClientClick", root, AbrirAgenciaEmpregos)
----------------------------------------------------------------------------------------------------------------------------------------
Skript do menu:
function PainelAgenciaEmpregosNew ()
local screenWidth,screenHeight = guiGetScreenSize()
MunitorC, MunitorL = guiGetScreenSize()
abx, aby = (MunitorC/1366), (MunitorL/768)
dxDrawImage(abx*230, aby*150, abx*960, aby*530, "agenciadeemprego.png", 0, 0, 0, tocolor(255, 255, 255, 255), false)
end
function ObjetosDaLoja (_,state)
if AgenciaEmpregosAirNew == true then
if state == "down" then
if isCursorOnElement ( x*1125 - 1, - y*46 - 1, x*990 - 1, y*236 - 1 ) then
removeEventHandler ( "onClientRender", root, PainelAgenciaEmpregosNew )
showCursor ( false )
AgenciaEmpregosAirNew = false
elseif isCursorOnElement ( x*248, y*260, x*109, y*195 ) then -- Carregador
triggerServerEvent ( "Encaminhar>Carregador", localPlayer )
FecharAgenciaEmpregos ()
elseif isCursorOnElement ( x*388, y*260, x*109, y*195 ) then -- Taxista
triggerServerEvent ( "Encaminhar>Taxista", localPlayer )
FecharAgenciaEmpregos ()
elseif isCursorOnElement ( x*530, y*260, x*109, y*195 ) then -- Pizzaboy
triggerServerEvent ( "Encaminhar>PizzaBoy", localPlayer )
FecharAgenciaEmpregos ()
elseif isCursorOnElement ( x*248, y*470, x*109, y*195 ) then -- Caminhoneiro
triggerServerEvent ( "Encaminhar>Caminhoneiroj", localPlayer )
FecharAgenciaEmpregos ()
elseif isCursorOnElement ( x*388, y*470, x*109, y*195 ) then -- Gerente
triggerServerEvent ( "Encaminhar>Gerente", localPlayer )
FecharAgenciaEmpregos ()
elseif isCursorOnElement ( x*530, y*470, x*109, y*195 ) then -- PilotoDeHelicoptero
triggerServerEvent ( "Encaminhar>PilotoDeHelicoptero", localPlayer )
FecharAgenciaEmpregos ()
--elseif isCursorOnElement ( x*412, y*108, x*543, y*29 ) then -- PilotoDeAviao
--triggerServerEvent ( "Encaminhar>MotoristaDeUber", localPlayer )
--FecharAgenciaEmpregos ()
end
end
end
end
addEventHandler ( "onClientClick", root, ObjetosDaLoja )
eu queria que quando eu desse um click no ped ele abrir o menu