MrJuhis Posted November 24, 2014 Share Posted November 24, 2014 marker = createMarker ( 1808.4814453125, -1909.2841796875, 13.571605682373, "cylinder", 1.1, 0, 255, 0) addEventHandler ("onMarkerHit", marker, startMission) function startMission(hitElement) if getElementType (hitElement) == "player" then local team = getPlayerTeam (hitElement) if getTeamName (team) ~= "Civilians" then local teamName = getTeamName (team) exports["FFS-TopBar"]:outputTopBar( "You have to be Civilian before using Bus Driver Job (/civilian)", hitElement, 255, 246, 7 ) else setElementData( source, "Occupation", "Bus Driver", true ) exports["FFS-TopBar"]:outputTopBar( "You are now a Bus Driver", source, 0, 255, 43 ) setPlayerNametagColor(source, 255, 246, 7) end end end Can't get it working, when i enter to marker nothing happens. Link to comment
ViRuZGamiing Posted November 24, 2014 Share Posted November 24, 2014 Function is created after the handler, the handler does not know of the creation of the function. Solution, place the handler below the function Link to comment
LaCosTa Posted November 26, 2014 Share Posted November 26, 2014 (edited) try it now EDITED : yea he can't use the function after the eventhandler . marker = createMarker ( 1808.4814453125, -1909.2841796875, 13.571605682373, "cylinder", 1.1, 0, 255, 0) addEventHandler ("onMarkerHit", marker, function() if (getElementType (hitElement) == "player") then local team = getPlayerTeam (hitElement) if getTeamName (team) ~= "Civilians" then local teamName = getTeamName (team) exports["FFS-TopBar"]:outputTopBar( "You have to be Civilian before using Bus Driver Job (/civilian)", hitElement, 255, 246, 7 ) else setElementData( source, "Occupation", "Bus Driver", true ) exports["FFS-TopBar"]:outputTopBar( "You are now a Bus Driver", source, 0, 255, 43 ) setPlayerNametagColor(source, 255, 246, 7) end end end) Edited November 27, 2014 by Guest Link to comment
Mr_Moose Posted November 26, 2014 Share Posted November 26, 2014 @Cmtv no you can't add the function handler before the function, you can add the function inside the event handler however like this: addEventHandler ("onMarkerHit", marker, function(args) -- Code here end) And on topic, 'source' in the 'onMarkerHit' event is the marker, 'hitElement' is the player in this case. Occupation is set to the marker, a topbar message is displayed... to the marker, and on the line after, you try to set the nametag color on the marker. 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