Mathias Lui Posted July 8, 2016 Share Posted July 8, 2016 Hey, I wanted to replicate a job from a server. You go in a marker, spawn in an andromada, and fly to 1 of 3 airports with math.random (that looks fine yet). And now what I can't do: I want the person, which flies, to get teleported back to the marker if the person leaves the vehicle. And I want everything to get removed, when the destination marker is hit. I can only fly through the end marker, and nothing happens. Also I can easily leave the vehicle without getting respawned. When the destinationmarker is hit, The marker, blip and plane shall be removed, player gets respawned, and the player should get 450$. The variable FF stands for the airport in the top middle (with all the broken airplanes). Also I have scriptet about a week yet, so I'm a beginner. The Event Handlers should call the functions in the main function when one of the markers is hit. At least I get no console errors... Or is it wrong that I put functions into other functions? I don't know how to do it otherwise. btw has somebody got a good tutorial for "for"-loops? I don't know what pairs and ipairs are, and so on... here's my full code: jobmarker = createMarker( -1414.59399, -299.01044, 6.20313, "corona", 1, 255, 255, 0 ) inPlane = false function inMarker( playerSource ) dim = math.random( 1, 65535 ) money = getPlayerMoney( playerSource ) skin = getElementID( playerSource ) setElementDimension( playerSource, dim ) plane = createVehicle( 592, -1633, -470.7998046875, 23.200000762939, 0, 0, 45.499877929688 ) setElementDimension( plane, dim ) warpPedIntoVehicle( playerSource, plane, 0 ) inPlane = true ort = math.random( 1, 3 ) if ( ort == 1 ) then outputChatBox( "Fliege dein Flugzeug unbeschaedigt zum Flugzeugfriedhof.", playerSource, 255, 255, 0 ) FFMarker = createMarker( 397.70001220703, 2503.6999511719, 16.5, "ring", 10, 255, 0, 0 ) setElementDimension( FFMarker, dim ) FFBlip = createBlip( 397.70001220703, 2503.6999511719, 16.5, 0, 2, 255, 0, 0, 255, 0, 99999 ) setElementDimension( FFBlip, dim ) function FFExit( playerSource ) inPlane = false spawnPlayer( playerSource, -1417.73401, -301.96399, 6.20313, 0, skin, 0, 0 ) setElementDimension( playerSource, 0 ) destroyElement( FFMarker ) destroyElement( FFBlip ) destroyElement( plane ) outputChatBox( "Auftrag gescheitert: Fahrzeug verlassen!", playerSource, 255, 0, 0 ) setPlayerMoney( playerSource, money ) end function FFHit( playerSource ) inPlane = false spawnPlayer( playerSource, -1417.73401, -301.96399, 6.20313, 0, skin, 0, 0 ) setElementDimension( playerSource, 0 ) destroyElement( FFMarker ) destroyElement( FFBlip ) destroyElement( plane ) outputChatBox( "Du bekommst 450$!", playerSource, 0, 255, 0 ) return setPlayerMoney( playerSource, money + 450 ) end elseif ( ort == 2 ) then outputChatBox( "Fliege dein Flugzeug unbeschaedigt zum Las Venturas Airport.", playerSource, 255, 255, 0 ) LVMarker = createMarker( 1429.3000488281, 1463.3000488281, 10.800000190735, "ring", 10, 255, 0, 0 ) setElementDimension( LVMarker, dim ) LVBlip = createBlip( 1429.3000488281, 1463.3000488281, 10.800000190735, 0, 2, 255, 0, 0, 255, 0, 99999 ) setElementDimension( LVBlip, dim ) function LVExit( playerSource ) inPlane = false spawnPlayer( playerSource, -1417.73401, -301.96399, 6.20313, 0, skin, 0, 0 ) setElementDimension( playerSource, 0 ) destroyElement( LVMarker ) destroyElement( LVBlip ) destroyElement( plane ) outputChatBox( "Auftrag gescheitert: Fahrzeug verlassen!", playerSource, 255, 0, 0 ) return setPlayerMoney( playerSource, money ) end function LVHit( playerSource ) inPlane = false spawnPlayer( playerSource, -1417.73401, -301.96399, 6.20313, 0, skin, 0, 0 ) setElementDimension( playerSource, 0 ) destroyElement( LVMarker ) destroyElement( LVBlip ) destroyElement( plane ) outputChatBox( "Du bekommst 450$!", playerSource, 0, 255, 0 ) return setPlayerMoney( playerSource, money + 450 ) end else outputChatBox( "Fliege dein Flugzeug unbeschaedigt zum Los Santos International Airport.", playerSource, 255, 255, 0 ) LSMarker = createMarker( 1837.3000488281, -2493.8999023438, 13.60000038147, "ring", 10, 255, 0, 0 ) setElementDimension( LSMarker, dim ) LSBlip = createBlip( 1837.3000488281, -2493.8999023438, 13.60000038147, 0, 2, 255, 0, 0, 255, 0, 99999 ) setElementDimension( LSBlip, dim ) function LSExit( playerSource ) inPlane = false spawnPlayer( playerSource, -1417.73401, -301.96399, 6.20313, 0, skin, 0, 0 ) setElementDimension( playerSource, 0 ) destroyElement( LSMarker ) destroyElement( LSBlip ) destroyElement( plane ) outputChatBox( "Auftrag gescheitert: Fahrzeug verlassen!", playerSource, 255, 0, 0 ) --means "left vehicle" return setPlayerMoney( playerSource, money ) end function LSHit( playerSource ) inPlane = false spawnPlayer( playerSource, -1417.73401, -301.96399, 6.20313, 0, skin, 0, 0 ) setElementDimension( playerSource, 0 ) destroyElement( LSMarker ) destroyElement( LSBlip ) destroyElement( plane ) outputChatBox( "Du bekommst 450$!", playerSource, 0, 255, 0 ) --means "you earned 450$!" return setPlayerMoney( playerSource, money + 450 ) end end end addEventHandler( "onMarkerHit", jobmarker, inMarker ) addEventHandler( "onPlayerVehicleExit", playerSource, FFExit) addEventHandler( "onPlayerVehicleExit", playerSource, LVExit) addEventHandler( "onPlayerVehicleExit", playerSource, LSExit) addEventHandler( "onMarkerHit", FFMarker, FFHit ) addEventHandler( "onMarkerHit", FFMarker, LVHit ) addEventHandler( "onMarkerHit", FFMarker, LSHit ) --on my screen it says "LS Hit"(without space) and when I submit it, it says ":~" 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