Moderators IIYAMA Posted March 6, 2014 Moderators Posted March 6, 2014 onClientMarkerHit doesn't get trigged with vehicles. See wiki: https://wiki.multitheftauto.com/wiki/OnClientMarkerHit hitPlayer: The player that hit the marker So: addEventHandler ( "onClientMarkerHit", root, function ( hitElement ) if source == truckerMarker and localPlayer == hitElement then local vehicle = getPedOccupiedVehicle ( localPlayer ) if vehicle and getElementModel(vehicle) == 514 then triggerServerEvent ( "givePlayerPay", localPlayer ) destroyElement ( truckerMarker ) if isElement(truckerBlip) then -- very important destroyElement ( truckerBlip ) end guiSetVisible(destinationwindow,true) showCursor(true) triggerEvent ( "createTruckerEvent", localPlayer ) end end end)
iPrestege Posted March 6, 2014 Posted March 6, 2014 For the vehicles because using it server side every vehicled created will destroy the last one you must use table's .
iPrestege Posted March 6, 2014 Posted March 6, 2014 vehicle = { } addCommandHandler ( 'ccv', function ( player ) if vehicle [ player ] and isElement ( vehicle [ player ] ) then destroyElement ( vehicle [ player ] ) end local x,y,z = getElementPosition ( player ) vehicle [ player ] = createVehicle ( x,y,z,411 ) end ) This is an simple example.
Moderators IIYAMA Posted March 6, 2014 Moderators Posted March 6, 2014 CVC +1 local vehicleTable = {} addEvent( "sum", true) addEventHandler("sum", getRootElement(), function(car) local truck = vehicleTable[source] -- load if truck then -- check if isElement( truck ) then destroyElement( truck ) end vehicleTable[source]= nil -- clean end if isElement(source) then local truck = createVehicle ( 514, 70.21049, -233.00739, 2.33665 ) warpPedIntoVehicle ( source, truck ) vehicleTable[source]= truck --save end end ) -- extra, because I am in a good mood. addEventHandler("onPlayerQuit",root, function () local truck = vehicleTable[source] if truck then if isElement( truck ) then destroyElement( truck ) end vehicleTable[source]= nil end end) -- @CVC Lol you posted first,
justn Posted March 6, 2014 Author Posted March 6, 2014 Script working just the way i want it, Thanks @IIYAMA and @CVC
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