Daniels69 Posted July 29, 2019 Share Posted July 29, 2019 Hi, how can i get the objects parent resource name ? I need to know which object is parented with which resource. To output it on the screen when i click an object Link to comment
NONAME_1224 Posted July 30, 2019 Share Posted July 30, 2019 (edited) 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 July 30, 2019 by NONAME_1224 Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now