Jump to content

[help] resource name


Recommended Posts

Try this code:

Client side:

-- Client side

function clicked(btn, state, x, y, wx, wy, wz, obj)
	if btn ~= "left" or state ~= "down" or not obj then return end
	triggerServerEvent("checkobj", resourceRoot, getLocalPlayer(), obj)
end
addEventHandler("onClientClick", getRootElement(), clicked)
 

Server side:

-- Server side

addEvent("checkobj", true)
function checkobj(p, o)
	resources = getResources()
	for k,v in ipairs(resources) do
		if getResourceState(v) == "running" then
			local reselements = getResourceDynamicElementRoot(v)
			local objs = getElementsByType("object", reselements)
			for i, obj in ipairs(objs) do
				if obj == o then
					outputChatBox("Resource name: "..getResourceName(v), p)
					return true
				end
			end
		end
	end
	return false
end
addEventHandler("checkobj", resourceRoot, checkobj)

 

Edited by NONAME_1224
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...