Jump to content

Panel opening on Ped Click


Recommended Posts

If the player clicks the ped with the id 1 it open the panel

 

SERVER-SIDE:

-- IDSkin, "id number", x, y, z, r
peds = { 
	{0, "1", 0, 0, 13, 0} 
} 
  
for i = 1, #peds do 
	ped = createPed(peds[i][1], peds[i][3], peds[i][4], peds[i][5]) 
	setElementRotation(ped, 0, 0, peds[i][6]) 
	setElementData(ped, "id", peds[i][2], true) 
end 

 

CLIENT-SIDE

function clickPed(button, state, absoluteX, absoluteY, worldX, worldY, worldZ, clickedElement) 
	if (clickedElement) and (getElementType(clickedElement) == "ped" ) then 
		local x, y, z = getElementPosition(getLocalPlayer()) 
		local wx, wy, wz = getElementPosition(clickedElement) 
		local jij = getLocalPlayer() 
	             
		if (getDistanceBetweenPoints3D(x, y, z, wx, wy, wz)<=3) and (button == "left") and (state == "down" ) then          
			local ped = getElementData(clickedElement, "id") 
			if (ped == "1") then 
				--FUNCTION PANEL
			end 
		end 
	else 
		return 
	end 
end 
addEventHandler("onClientClick", getRootElement(), clickPed, true) 

 

Link to comment
local peds = {}

function ped(id, model, x,y,z, rotz)
	local pedTable = {}

	pedTable.newPed = createPed(model, x,y,z, rotz)

	setElementFrozen(pedTable.newPed, true)

	setElementCollisionsEnabled(pedTable.newPed, false)
	setElementDimension(pedTable.newPed, getElementDimension(localPlayer))
	
	table.insert(peds, pedTable)
end

function execute()
	for i, v in pairs(peds) do
		if (v.id == "1") then
			-- do whatever you want
		end
	end
end
bindKey("f", "down", execute)

ped("1", 65, 2488.64160, -1664.28223, 13.34375, 90) -- grove street

 

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...