Jump to content

addEventHandler()


Nonameman

Recommended Posts

Posted

Hey All!

I'm a newbie, so sorry if I ask stupid things.

In the addEventHandler() command, I don't know what should be the second parameter.

I use the wiki to get help, but there's a lot of variations to this params, GetRootElement()/GetLocalPlayer(),

What to use in different situations? What is it for?

Thanks

Nonameman

Posted
Hey All!

I'm a newbie, so sorry if I ask stupid things.

In the addEventHandler() command, I don't know what should be the second parameter.

I use the wiki to get help, but there's a lot of variations to this params, GetRootElement()/GetLocalPlayer(),

What to use in different situations? What is it for?

Thanks

Nonameman

seriusly, i don't know i ever use getRootElement()

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

client-side scripts are running INDEPENDLY on each client (player) - outputChatBox will output chat to that player who is running that scripts.

like (in words) - you are checking for current vehicle speed every second, and if its > 50, you are outputting text - its doing (independly) the same thing on every client, but only client driving faster than 50 will see message.

addEventHandler - 2nd parameter is attached element.

every event is triggered by something (this is called "source" in handler function).

if you are making onMarkerHit - attached element could be one marker, or all markers, example:

  
myMarker = createMarker(arguments, we, dont, care, in_, this, example) 
otherMarker = createMarker(arguments, we, dont, care, in_, this, example) 
  
function myMarkerHandler(element, matchingDimensions) 
  outputChatBox("something hit my marker") 
end 
function anyMarkerHandler(element, matchingDimensions) 
  outputChatBox("something hit some marker, it can be ANY marker") 
  if (source==myMarker) then 
    outputChatBox("oh, and it was MY marker") 
  end 
end 
  
addEventHandler("onMarkerHit", myMarker, myMarkerHandler) 
addEventHandler("onMarkerHit", getRootElement(), anyMarkerHandler) 
  

see the difference? try it out :)

Multi theft auto tools - replace cars and peds, move your map or compile your Lua files online!

programista php rzeszów

Need free webhosting for your small site? PM me. Need help with portforwarding? PM me. Do not PM me asking for help with scripting.

Having problems with port forwarding? Send me pm, I can do whole thing for you using TeamViewer (already helped about 20 people, no worries)!

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...