Hero192 Posted February 21, 2016 Share Posted February 21, 2016 Can I just know what's the difference between the first example and the second one? I mean if we attached root to the event and if we attached localplayer. --1st Example: function targeting ( target ) if ( target ) then --code end end addEventHandler ( "onClientPlayerTarget", getRootElement(), targeting ) --2nd Example: function targeting ( target ) if ( target ) then --code end end addEventHandler ( "onClientPlayerTarget", getLocalPlayer(), targeting ) Link to comment
Noki Posted February 21, 2016 Share Posted February 21, 2016 This event is triggered whenever the local player targets an element. Either one will produce the same result. Whenever the local player (meaning client-side, for only that one player) targets, the function tied to that event will be triggered. onClientPlayer* --> These only work for the local player onClient* --> These work for any element that is synced client-side (can also be local player, vehicles created server-side etc) Link to comment
Hero192 Posted February 21, 2016 Author Share Posted February 21, 2016 Can I just know why I have to use getLocalPlayer() and getRootElement() in client side, I mean in which case Link to comment
Noki Posted February 21, 2016 Share Posted February 21, 2016 It's what element the event is attached to. So when something happens to that element, the event triggers a function. root would mean whenever something happens to any element (that fits within the scope of the event obviously). localPlayer would attach the event to the local player. So when anything happens to the local player, as long as it's in the scope of the event, it will trigger a function. When something happens to any element --> Do this (root) When something happens to the local player --> Do this (local player) 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