damien111 Posted August 11, 2012 Share Posted August 11, 2012 I wont answer right away as i will be back in a few hours but. Here is my code for a taxi script. local VehMarker1 = createMarker ( 297.669372255859, 1938.08776855859, 18, "cylinder", 2, 0, 0, 255, 153) function startJob ( )( hitElement, matchingDimension ) local elementType = getElementType ( hitElement ) if ( elementType == "player" ) then setPlayerTeam ( source, theTeam) local theTeam = createTeam ( "Taxi Drivers" ) setPlayerSkin( source, 210) local x, y, z = getElementPosition ( hitElement ) local vehicle = createVehicle ( 597, x + 5, y, z ) function picfunction ( ) functions [ math.random ( #functions ) ] ( ) end addEventHandler ( "onMarkerHit", VehMarker1, spawnveh ) end function Stop1 ( ) local missionmarker = createMarker ( 1112.4752197266, 1376.9332275391, 9, "cylinder", 2, 0, 0, 255, 153 ) local missionblip = createBlip ( 1112.4752197266, 1376.9332275391, 9, 41, 0, 0, 0, 255 ) function startstop1 ( hitElement, matchingDimension ) local elementType = getElementType ( hitElement ) if ( elementType == "player" ) then local pteam = getPlayerTeam ( hitElement ) local pTeamName = ( pteam and getTeamName ( pteam ) or "" ) if ( pTeamName == "Taxi Driver" ) then destroyElement (missionblip) destroyElement (missionmarker) local missionmarker2 = createMarker ( 2099.5419921875, 2026.4774169922, 9, "cylinder", 2, 0, 0, 255, 153 ) local missionblip2 = createBlip ( 2099.5419921875, 2026.4774169922, 9, 41, 0, 0, 0, 255 ) addEventHandler ( "onMarkerHit", missionmarker, Stop1 ) addEventHandler ( "onMarkerHit", missionmarker2, getmoney ) if ( elementType == "player" ) then function getmoney ( ) local pteam = getPlayerTeam ( hitElement ) local pTeamName = ( pteam and getTeamName ( pteam ) or "" ) if ( pTeamName == "Taxi Driver" ) then givePlayerMoney (source, 1000) destroyElement (missionblip2) destroyElement (missionmarker2) end function picfunction ( ) functions [ math.random ( #functions ) ] ( ) end end end end end end end end function Stop2 ( ) local missionmarker3 = createMarker ( 1012.4227905273, 2017.2518319547, 9, "cylinder", 2, 0, 0, 255, 153 ) local missionblip3 = createBlip ( 1012.4227905273, 2017.2518319547, 9 , 41, 0, 0, 0, 255 ) function startstop1 ( hitElement, matchingDimension ) local elementType = getElementType ( hitElement ) if ( elementType == "player" ) then local pteam = getPlayerTeam ( hitElement ) local pTeamName = ( pteam and getTeamName ( pteam ) or "" ) if ( pTeamName == "Taxi Driver" ) then destroyElement (missionblip3) destroyElement (missionmarker3) local missionmarker4 = createMarker ( 2903.5383300781, 2403.18017527813, 9, "cylinder", 2, 0, 0, 255, 153 ) local missionblip4 = createBlip ( 2903.5383300781, 2403.18017527813, 9, 41, 0, 0, 0, 255 ) addEventHandler ( "onMarkerHit", missionmarker, Stop1 ) addEventHandler ( "onMarkerHit", missionmarker2, getmoney ) if ( elementType == "player" ) then function getmoney ( ) local pteam = getPlayerTeam ( hitElement ) local pTeamName = ( pteam and getTeamName ( pteam ) or "" ) if ( pTeamName == "Taxi Driver" ) then givePlayerMoney (source, 1000) destroyElement (missionblip4) destroyElement (missionmarker4) end function picfunction ( ) functions [ math.random ( #functions ) ] ( ) end end end end end end end end end functions = { Stop1, Stop2 } end It doesnt spawn the marker. and also. i want to know if that will work correctly. i will be adding several more functions and probally add a ped spawner part in there to. then it warps ped into the car. but anyways. please tell me if i did this correctly and also tell me why it wont spawn the marker. Heres the Meta To: <meta> <info author="damien" version="1.1.1" type="script" name="Test" /> <script src="Script.lua" type="server" /> </meta> Link to comment
denny199 Posted August 11, 2012 Share Posted August 11, 2012 First off all what does /debugscript 3 says? and the second this might be the error: 2 times ()?? function startJob ( )( hitElement, matchingDimension ) anyways: local theTeam = createTeam ( "Taxi Drivers" ) local VehMarker1 = createMarker ( 297.669372255859, 1938.08776855859, 18, "cylinder", 2, 0, 0, 255, 153) function spawnveh ( hitElement, matchingDimension ) local elementType = getElementType ( hitElement ) if ( elementType == "player" ) then setPlayerTeam ( hitElement, theTeam) setPlayerSkin( hitElement, 210) local x, y, z = getElementPosition ( hitElement ) local vehicle = createVehicle ( 597, x + 5, y, z ) end end addEventHandler ( "onMarkerHit", VehMarker1, spawnveh ) edit: Tip: You should make a table with random positions and then unpack a random position then create a marker on that position. and then add an handler on it. because this is a tottaly mess. Link to comment
ernst Posted August 11, 2012 Share Posted August 11, 2012 table = { [1]={x, y, z}, } function f() pos = math.random(1, #table) local x, y, z = table[pos][1], table[pos][2], table[pos][3] marker = createMarker(x, y, z, "cylinder", 2, 250, 250, 250) blip = createBlipAttachedTo(id, marker) end because your code is a fucking mess. Link to comment
damien111 Posted August 12, 2012 Author Share Posted August 12, 2012 Okay, i completely redid the script tell me if this will work pickedup = false local id = getElementModel ( vehicle ) local VehMarker = createMarker ( 1731.9326171875, 1927.2426757813, 10, "cylinder", 2, 0, 120, 255, 0 ) local theTeam = createTeam ( "Taxi Drivers" ) function startjob ( hitElement, matchingDimension ) local elementType = getElementType ( hitElement ) if ( elementType == "player" ) then setPlayerTeam(source, theTeam) setPlayerSkin(playerSource, 280) local x, y, z = getElementPosition ( hitElement ) local vehicle = createVehicle ( 597, x, y, z ) if id == 420 then function f() pickup = createMarker(x, y, z, "cylinder", 2, 250, 250, 250) pickupblip = createBlipAttachedTo(43, pickup) dropoff = createMarker(a, b, c, "cylinder", 2, 250, 250, 250) dropoffblip = createBlipAttachedTo(44, pickup) end end end end addEventHandler ( "onMarkerHit", VehMarker, startjob ) function checkifintaxi ( ) end --Tabel Of Cooridnates of Pickups local pickups = { { 1012.4227905273, 2017.2518319547, 9 }, { 987.3311767582, 2288.8173828125, 9 }, { 1614,3260498047, 2085.966796875, 9 }, { 2099.5419921875, 2026.4774169922, 9 }, { 2362.6103515625, 2005.8046875, 9 }, { 2826.5612792969, 1980.7646484375, 9 }, { 2903.5383300781, 2403.18017527813, 9 }, { 2099.5419921875, 2026.4774169922, 9 } } local dropoffs = { { 2290.7290039063, 2417.2971191406, 9 }, { 2211.8864746094, 1839.1610107422, 9 }, { 2155.9345703125, 977.22955322266, 9 }, { 1863.4801025391, 654.181640625, 9 }, { 1688.4946289063, 994.02716064453, 9 }, { 1398.4516601563, 1052.9704589844, 9 }, { 1039.3806152344, 1138.0095214844, 9 }, { 1112.4752197266, 1376.9332275391, 9 } } x, y, z = getRandomCoordinatesDropOff ( ) a, b, c = getRandomCoordinatesPickup ( ) function getRandomCoordinatesPickup ( ) return unpack ( pickups [ math.random ( #pickups ) ] ) end function getRandomCoordinatesDropOff ( ) return unpack ( dropoffs [ math.random ( #dropoffs ) ] ) end function pickingup ( hitElement, matchingDimension ) local elementType = getElementType ( hitElement ) if ( elementType == "player" ) then if id == 420 then local pickedup = true end end function dropoff ( hitElement, matchingDimension ) local elementType = getElementType ( hitElement ) if ( elementType == "player" ) then givePlayerMoney ( source, 1000 ) destroyElement (pickup) destroyElement (dropoff) destroyElement (pickupblip) destroyElement (dropoffblip) function g() pickup = createMarker(x, y, z, "cylinder", 2, 0, 250, 250, 250) pickupblip = createBlipAttachedTo(43, pickup) dropoff = createMarker(a, b, c, "cylinder", 2, 0, 250, 250, 250) dropoffblip = createBlipAttachedTo(44, pickup) end end end end addEventHandler ( "onMarkerHit", pickup, pickingup ) addEventHandler ( "onMarkerHit", dropoff, dropoff ) 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