Scripting Moderators ds1-e Posted April 15, 2019 Scripting Moderators Share Posted April 15, 2019 Hey, as title says. Is there any good equivalent to the thing above? I would need to get colshape userdata - colshape attached to vehicle. elementData would be easiest way, but i am not happy to use it. I'm looking for good alternative. I prefer to use tables + manual sync instead. It's not a problem to get this when player hit colshape, the real problem begins when i need to get this when player is inside of car. This is temporary solution, which imo isn't good. -- server side example addCommandHandler("data", function(plr, command) local vehicle = getPedOccupiedVehicle(plr) if not vehicle then outputChatBox("You need to be in vehicle to get data.", plr) return end local parent = getElementAttachedTo(vehicle) outputChatBox(tostring(parent), plr) end) I was thinking about setElementParent/getElementParent. And i found this topic. Just want to know if this function can do the work. Link to comment
Moderators IIYAMA Posted April 15, 2019 Moderators Share Posted April 15, 2019 6 hours ago, majqq said: Hey, as title says. Is there any good equivalent to the thing above? I would need to get colshape userdata - colshape attached to vehicle. elementData would be easiest way, but i am not happy to use it. I'm looking for good alternative. I prefer to use tables + manual sync instead. It's not a problem to get this when player hit colshape, the real problem begins when i need to get this when player is inside of car. This is temporary solution, which imo isn't good. -- server side example addCommandHandler("data", function(plr, command) local vehicle = getPedOccupiedVehicle(plr) if not vehicle then outputChatBox("You need to be in vehicle to get data.", plr) return end local parent = getElementAttachedTo(vehicle) outputChatBox(tostring(parent), plr) end) I was thinking about setElementParent/getElementParent. And i found this topic. Just want to know if this function can do the work. Quote setElementParent/getElementParent Yes those will work just fine. But keep in mind that other resources might also add other children. So it's better to be a little bit more specific. local colshapes = getElementChildren ( vehicle, "colshape" ) local colshape = colshapes[1] -- is the colshape not a direct child? Use: local colshapes = getElementsByType ( "colshape", vehicle ) local colshape = colshapes[1] 1 Link to comment
Scripting Moderators ds1-e Posted April 15, 2019 Author Scripting Moderators Share Posted April 15, 2019 1 hour ago, IIYAMA said: Yes those will work just fine. But keep in mind that other resources might also add other children. So it's better to be a little bit more specific. local colshapes = getElementChildren ( vehicle, "colshape" ) local colshape = colshapes[1] -- is the colshape not a direct child? Use: local colshapes = getElementsByType ( "colshape", vehicle ) local colshape = colshapes[1] Thank you. In case i would need to get vehicle which is related with this colshape it should be like this? local parent = getElementParent(vehicle) -- returns colshape userdata local child = getElementChild(parent, 0) -- returns vehicle userdata? 1 Link to comment
Moderators IIYAMA Posted April 15, 2019 Moderators Share Posted April 15, 2019 13 minutes ago, majqq said: Thank you. In case i would need to get vehicle which is related with this colshape it should be like this? local parent = getElementParent(vehicle) -- returns colshape userdata local child = getElementChild(parent, 0) -- returns vehicle userdata? yup! 1 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