damien111 Posted January 3, 2013 Share Posted January 3, 2013 I cant seem to figure out why this isnt working. Im not sure if i used the HitElement variable right, but i am not getting any debug errors, heres my code Trucking C job = createMarker ( -701.61175537109, 958.58966064453, 12.401006697608, "cylinder", 5.0, 255, 0, 0, 175 ) locations = { {-748.70367431641, 741.42608642578, 18.222219467163}, {-745.70367431641, 741.42608642578, 18.222219467163} } function getRandomLocation ( ) return unpack ( locations [ math.random ( #locations ) ] ) end function destroyAll() destroyElement(blip) destroyElement(marker) destroyElement(trailer) outputChatBox("Mission Failed") end addEventHandler("onTrailerDetach", getRootElement(), destroyAll) function hitMarker() destroyElement(blip) destroyElement(marker) destroyElement(trailer) setupAssigment() end function setupAssigment(hitElement, matchingDimension) local elementType = getElementType ( hitElement ) if ( elementType == "vehicle" ) then if getElementModel(hitElement) == 515 or getElementModel(hitElement) == 514 or getElementModel(hitElement) == 403 then marker = createMarker ( x, y, z, "cylinder", 5.0, 255, 0, 0, 175 ) x, y, z = getRandomLocation( ) blip = createBlip ( x, y, z, 51, 10, 0, 0, 0, 255 ) vx, vy, vz = getElementPosition(hitElement) trailer = createVehicle ( 435, vx, vy, vz ) -- create a trailer attachTrailerToVehicle ( hitElement, trailer ) -- attach them end end end addEvent( "onMission", true ) addEventHandler( "onMission", getRootElement(), setupAssigment ) Trucker - S addEventHandler("onResourceStart", getResourceRootElement(getThisResource()), function() truckSkins = { [206]=true, [133]=true } trucks = { [515]=true, [514]=true, [403]=true } end ) function enterVehicle ( thePlayer, seat, jacked ) if ( trucks[getElementModel ( source )] ) and ( not truckSkins[getElementModel ( thePlayer )] ) and (seat == 0) then cancelEvent() outputChatBox ( "Only truckers drivers can drive this", thePlayer ) end end addEventHandler ( "onVehicleStartEnter", getRootElement(), enterVehicle ) Link to comment
Tete omar Posted January 3, 2013 Share Posted January 3, 2013 (edited) Truckers - C local job = createMarker ( -701.61175537109, 958.58966064453, 12.401006697608, "cylinder", 5.0, 255, 0, 0, 175 ) local locations = { {-748.70367431641, 741.42608642578, 18.222219467163}, {-745.70367431641, 741.42608642578, 18.222219467163} } function destroyAll() destroyElement(blip) destroyElement(marker) destroyElement(trailer) outputChatBox("Mission Failed") end addEventHandler("onTrailerDetach", getRootElement(), destroyAll) function hitMarker() destroyElement(blip) destroyElement(marker) destroyElement(trailer) setupAssigment() end local models = { [514] = true, [514] = true, [403] = true} function setupAssigment(hitElement, matchingDimension) if ( getElementType(hitElement) == "vehicle" ) then if( models[getElementModel(hitElement)] )then local x, y, z = unpack ( locations [ math.random ( #locations ) ] ) marker = createMarker ( x, y, z, "cylinder", 5.0, 255, 0, 0, 175 ) blip = createBlip ( x, y, z, 51, 10, 0, 0, 0, 255 ) vx, vy, vz = getElementPosition(hitElement) trailer = createVehicle ( 435, vx, vy, vz ) -- create a trailer attachTrailerToVehicle ( hitElement, trailer ) -- attach them end end end addEvent( "onMission", true ) addEventHandler( "onMission", root, setupAssigment ) Truckers S addEventHandler("onResourceStart", resourceRoot, function() truckSkins = { [206]=true, [133]=true } trucks = { [515]=true, [514]=true, [403]=true } end ) function enterVehicle ( thePlayer, seat, jacked ) if ( trucks[getElementModel ( source )] ) and ( not truckSkins[getElementModel ( thePlayer )] ) and (seat == 0) then cancelEvent() outputChatBox ( "Only truckers drivers can drive this", thePlayer ) end end addEventHandler ( "onVehicleStartEnter", root, enterVehicle ) Edited January 3, 2013 by Guest Link to comment
TAPL Posted January 3, 2013 Share Posted January 3, 2013 (edited) This make no sense. Event onTrailerDetach is server side only. In fact your whole script should be server side. From where do you trigger onMission? and where is the event onMarkerHit or event onClientMarkerHit? And here, you use x, y, z before you define it. marker = createMarker ( x, y, z, "cylinder", 5.0, 255, 0, 0, 175 ) x, y, z = getRandomLocation( ) Edited January 3, 2013 by Guest Link to comment
Alen141 Posted January 3, 2013 Share Posted January 3, 2013 where did you define "locations"? Link to comment
damien111 Posted January 3, 2013 Author Share Posted January 3, 2013 the table ^ Sorry, ill re read it, i always forget to check if events are server or client 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