GhostXoP Posted June 28, 2012 Share Posted June 28, 2012 Is there any links that explain very well the idea and how to use getRootElement() and the event system. How it restricts to one type to trigger an event. Can someone give me an example as to why getRootElement() was used for example for an addEventHandler() situation Link to comment
Jaysds1 Posted June 28, 2012 Share Posted June 28, 2012 ok, Root(getRootElement()) is all the elements in the server (basically) but if you put it in a addEventHandler() client-sided then it would only apply for the localPlayer or the player viewing what ever they're viewing, but if it's added server-sided then it means all the elements, but if the elements are created by the server then those would receive what's happening in the addEventHandler. Link to comment
GhostXoP Posted June 28, 2012 Author Share Posted June 28, 2012 Would there be senario's when id have to use something other then getRootElement()? (other then GUI Events) Link to comment
Jaysds1 Posted June 28, 2012 Share Posted June 28, 2012 well, for resources, you could use: resourceRoot resourceSourceRoot or for gui's, you could use: guiRoot root for every player, you could use: getElementsByType("player") Link to comment
GhostXoP Posted June 28, 2012 Author Share Posted June 28, 2012 Are those predefined variables or should i define them myself? Where can i get more detailed information over this? Link to comment
Jaysds1 Posted June 28, 2012 Share Posted June 28, 2012 Ya, those are predefined variables, and here: viewtopic.php?f=91&t=39678 Link to comment
GhostXoP Posted June 28, 2012 Author Share Posted June 28, 2012 So if i can sum this up correctly. addEventHandler(Run function if "this event" fires, and only run it if the element is a child of, or is thisElement, then run this function() ) Link to comment
Jaysds1 Posted June 28, 2012 Share Posted June 28, 2012 nah, you have to put an event first then attach it to a player(if it's client-sided then it's automatically localplayer, but you should still put root) after you attach it to the player then the function comes in, this is where you're going to start the script. Link to comment
GhostXoP Posted June 28, 2012 Author Share Posted June 28, 2012 Please view link to see full image. http://i46.tinypic.com/zssl12.png Link to comment
qaisjp Posted June 28, 2012 Share Posted June 28, 2012 addEventHandler Root Element tree Anything you put as the second argument in triggerEvent is the source that you find in addEventHandler. The second argument of addEventHandler LIMITS the source and gives you specifics. For example: For all markers, including "supermarker" local supermarker = createMarker(0,0,0) addEventHandler("onColShapeHit", root, function() outputChatBox("hit a marker") end ) Different message for supermarker local supermarker = createMarker(0,0,0) addEventHandler("onColShapeHit", root, function() if source == supermarker then outputChatBox("hit supermarker") end outputChatBox("hit a marker") end ) Only for supermarker: local supermarker = createMarker(0,0,0) addEventHandler("onColShapeHit", supermarker, function() outputChatBox("supermarker hit") end ) Only tells the player that he hit the supermarker, in the dimension he is in: local supermarker = createMarker(0,0,0) addEventHandler("onColShapeHit", supermarker, function(p,d) if (getElementType(p)~="player") or (not d) then return end outputChatBox("you hit the supermarker", p) end ) Link to comment
GhostXoP Posted June 28, 2012 Author Share Posted June 28, 2012 So its basically, run this function if This event triggered, and only if it was triggered by this element or any children of this element, then run this function (). In your case, if we chose root, it would trigger if any marker was hit, if we specify the specific marker, it will only run if the event was triggered by that marker. Starting to make alot of sense now. If im right, thank you very much Link to comment
GhostXoP Posted June 28, 2012 Author Share Posted June 28, 2012 Your Avi, supernatural? Link to comment
GhostXoP Posted June 28, 2012 Author Share Posted June 28, 2012 Cannot wait till the last series is available to buy, i have all of them except that one. 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