tosfera Posted August 12, 2013 Share Posted August 12, 2013 Hey guys, There is something going wrong but I'm not sure what or where. When the player hits the last marker it resets all the data and restarts the function. But it doesn't restart the function. O_O client; -- accepts the job function bus_accept() guiSetVisible ( bus_start_window, false ); showCursor( false ); triggerServerEvent ( "bus_start_accept", getLocalPlayer(), getLocalPlayer() ); end addEvent("bus_start_job", true); addEventHandler("bus_start_job", root, function() local jobs = { { "2447.0329", "2055.8024", "10" }, { "2339.8483", "1990.3818", "10" }, { "2546.0214", "1966.8399", "10" }, { "2850.3469", "2092.4084", "10" }, { "2581.9252", "2115.7055", "10" }, { "2617.3837", "1716.0717", "10" }, { "2447.0329", "2055.8024", "10" }}; for i, item in ipairs ( jobs ) do if ( i == getElementData(getLocalPlayer(), "marker") ) then finish_marker_bus = createMarker( item[1], item[2], item[3], "checkpoint", 5, 0, 0, 255, getLocalPlayer() ); finish_blip_bus = createBlip( item[1], item[2], item[3], 19 ); outputChatBox(tostring(i)); end if ( getElementData(getLocalPlayer(), "marker") == #jobs ) then setElementData(getLocalPlayer(), "marker", 0 ); triggerEvent("bus_start_job", localPlayer ); call ( getResourceFromName ( "hud_messages" ), "showBox","[Company] Great work, now pick up the new people!", 0, 255, 0, 5000 ); givePlayerMoney( 250 ); setElementData( getLocalPlayer(), "Money", getPlayerMoney() ); end end end ); addEventHandler("onClientMarkerHit", root, function ( hitElement ) if ( source == finish_marker_bus and hitElement == localPlayer ) then if ( getPedOccupiedVehicle ( hitElement ) and getElementModel ( getPedOccupiedVehicle ( hitElement ) ) == 431 ) then setElementData(getLocalPlayer(), "marker", getElementData(getLocalPlayer(), "marker") + 1 ); destroyElement(finish_marker_bus); destroyElement(finish_blip_bus); triggerEvent("bus_start_job", localPlayer ); call ( getResourceFromName ( "hud_messages" ), "showBox","[People] Right in time, lets go!", 0, 255, 0, 5000 ); else call ( getResourceFromName ( "hud_messages" ), "showBox","[People] Where is the bus? I'm coming late for work!!", 255, 0, 0, 5000 ); end end end ); server; addEvent("bus_start_accept", true); addEventHandler("bus_start_accept", root, function( source ) setPlayerTeam( source, getTeamFromName("Busdriver") ); setElementData( source, "marker", 1 ); setElementModel( source, 171 ); triggerClientEvent( "bus_start_job", source ); end ); Thaanks Link to comment
InVision Posted August 12, 2013 Share Posted August 12, 2013 I suggest adding an event that will stop the function after hitting the last marker? Link to comment
tosfera Posted August 12, 2013 Author Share Posted August 12, 2013 Ahh a serversided event that gets activated with a triggerEvent? Will try it tomorrow. edit; works like a charm! 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