#Ivan7 Posted June 18, 2014 Share Posted June 18, 2014 Ok So Everything seems to work now, just 1 problem when your the taximan it wont show the peds, or the blips .. once u click accept on the gui all thats happens is the taximan skin shows and u spawn in the taxi car here is the clientside GUIEditor = { memo = {}, button = {}, window = {}, } GUIEditor.window[1] = guiCreateWindow(0.4, 0.16, 0.35, 0.45, "Gta-Ar Taxi Job", true) guiWindowSetSizable(GUIEditor.window[1], false) guiSetVisible(GUIEditor.window[1], false) bAccept = guiCreateButton(0.10, 0.90, 0.41, 0.80, "Accept", true, GUIEditor.window[1]) guiSetProperty(bAccept, "NormalTextColour", "FFAAAAAA") bClose = guiCreateButton(0.52, 0.90, 0.41, 0.80, "Decline", true, GUIEditor.window[1]) guiSetProperty(bClose, "NormalTextColour", "FFAAAAAA") GUIEditor.memo[1] = guiCreateMemo(0.10, 0.1, 0.80, 0.75, " Gta-Ar Taxi Job Rules: 1) Go To Player (Blue Blip). 2) Pick up Player by pressing car horn. 3) Drop off Player to Red Blip. Be sure not to die, if you do you will lose your customer. Every dropoff you will earn up to $1000! Made By: [Gta-Ar]#Ivan ", true, GUIEditor.window[1]) local taximarker = createMarker(-2479.9282226563, -198.06895446777, 24.623662948608, "cylinder", 1.5, 255, 0, 0) createBlipAttachedTo( taximarker, 42) addEventHandler( "onClientRender", root, function ( ) local x, y, z = getElementPosition( taximarker ) local Mx, My, Mz = getCameraMatrix( ) if ( getDistanceBetweenPoints3D( x, y, z, Mx, My, Mz ) <= 15 ) then local WorldPositionX, WorldPositionY = getScreenFromWorldPosition( x, y, z +1.2, 3 ) if ( WorldPositionX and WorldPositionY ) then dxDrawText ( "Taxi Job", WorldPositionX, WorldPositionY, WorldPositionX, WorldPositionY, tocolor(255,255,255,255), 2.4, "arial" ) end end end ) function showGUIbt(hitElement) if (hitElement == localPlayer ) and not isPedInVehicle(localPlayer) then if getTeamName(getPlayerTeam(localPlayer)) ~= "Police" then guiSetVisible(GUIEditor.window[1], true) showCursor( true ) end end end addEventHandler("onClientMarkerHit", taximarker, showGUIbt) function showGUIbf() if source == bAccept then guiSetVisible (GUIEditor.window[1], false ) showCursor ( false ) triggerServerEvent("sTeame",localPlayer) elseif source == bClose then guiSetVisible (GUIEditor.window[1], false ) showCursor ( false ) end end addEventHandler("onClientGUIClick", GUIEditor.window[1], showGUIbf) This is server side local pickups = { { -2514.2985839844, -19.26721572876, 25.6171875 }, { -2413.8093261719, 314.66299438477, 35.171875 }, { -1980.0808105469, 884.00354003906, 45.203125 }, { -1584.2047119141, 812.43743896484, 6.8203125 }, { -1817.1701660516, 1286.7491455078, 15.492509841919 }, { -2343.4348144531, 983.23840322031, 50.6953125 }, { -2554.942629531, 193.716659548, 6.2031769752502 } } local dropoffss = { { -2275.2744140625, 612.84197998047, 43.402828216553 }, { -2566.2153320313, 578.38897705078, 14.453125 }, { -2128.4689941406, 310.44934082031, 35.254566192627 }, { -1702.652941016, 717.54370117188, 24.890625 }, { -1912.1589355469, 883.3916015625, 35.215755462646 }, { -1977.3975830078, 1118.9444580078, 53.23331451416 }, { -1703.1501464844, 1340.6345214844, 7.1796875 } } local pedCus = { { 7 }, { 21 }, { 29 }, { 137 }, { 27 }, { 240 }, { 264 } } function SetVisiteFor (mark,player) setElementVisibleTo ( mark, root, false ) setElementVisibleTo ( mark, player, true ) end taxiVehs = { [420] = true } Cars = {} function teamSet ( ) if (isElement(Cars[source])) then destroyElement(Cars[source]) end setElementData(source,"markertax",4) setElementModel(source, 255) Cars[source] = createVehicle(420, -2485.3188476563, -169.93522644043, 25.6171875) addEventHandler ( "onVehicleExit", Cars[source], deleteOnExit ) addEventHandler ( "onVehicleEnter", Cars[source], inVEH ) addEventHandler ( "onVehicleStartEnter", Cars[source], enterVehicle ) warpPedIntoVehicle ( source, Cars[source] ) outputChatBox("You are now employed as a Taxi Driver!", source) end addEvent ( "sTeame", true) addEventHandler ( "sTeame", root, teamSet ) addEventHandler('onPlayerQuit', root, function() if isElement( Cars[source] ) then destroyElement(Cars[source] ) end end ) function enterVehicle ( thePlayer, seat, jacked ) if getElementType ( thePlayer ) == "player" and getElementData(thePlayer,"JobNew") ~= 4 then removePedFromVehicle( thePlayer ) outputChatBox("Only Taxi Drivers can drive this vehicle!", thePlayer) end end markers = { } blips = { } peds = { } mposi = { } mposii = {} function startJob ( thePlayer ) local x, y, z = unpack ( pickups [ math.random ( #pickups ) ] ) markers [ thePlayer ] = createMarker ( x, y, z, "cylinder", 5.0, 255, 0, 0, 0 ) SetVisiteFor (markers [ thePlayer ],thePlayer) mposi = { getElementPosition( markers [ thePlayer ] ) } local skins = unpack ( pedCus [ math.random ( #pedCus ) ] ) peds [ thePlayer ] = createPed( skins, x, y, z ) SetVisiteFor (peds [ thePlayer ],thePlayer) blips [ thePlayer ] = createBlipAttachedTo ( markers [ thePlayer ], 58 ) SetVisiteFor (blips [ thePlayer ],thePlayer) addEventHandler ( "onMarkerHit", markers [ thePlayer ], warpit ) end function inVEH ( thePlayer ) if ( getElementType ( thePlayer ) == "player" and isPedInVehicle ( thePlayer ) ) and getElementData(thePlayer,"JobNew") == 4 then startJob ( thePlayer ) end end function warpit ( thePlayer ) if ( getElementType ( thePlayer ) == "player" and isPedInVehicle ( thePlayer ) ) then local vehiclee = getPedOccupiedVehicle ( thePlayer ) if ( getElementModel ( vehiclee ) == 420 ) and getElementData(thePlayer,"JobNew") == 4 then setTimer ( warpPedIntoVehicle, 2000, 1, peds [ thePlayer ], vehiclee, 2 ) destroyJob ( thePlayer ) local x, y, z = unpack ( dropoffss [ math.random ( #dropoffss ) ] ) markers [ thePlayer ] = createMarker ( x, y, z - 1, "cylinder", 5.0, 195, 197, 9, 255 ) SetVisiteFor (markers [ thePlayer ],thePlayer) mposii = { getElementPosition( markers [ thePlayer ] ) } blips [ thePlayer ] = createBlipAttachedTo ( markers [ thePlayer ], 41 ) SetVisiteFor (blips [ thePlayer ],thePlayer) addEventHandler ( "onMarkerHit", markers [ thePlayer ], pickmeup ) end end end function pickmeup ( thePlayer ) if ( getElementType ( thePlayer ) == "player" and isPedInVehicle ( thePlayer ) ) then destroyJob ( thePlayer ) local mx, my, mz = unpack ( mposi ) local mmx, mmy, mmz = unpack ( mposii ) local money = getDistanceBetweenPoints2D ( mx, my, mmx, mmy ) finalmoney = math.floor ( money ) if finalmoney then setTimer( function () finalmoney = finalmoney + 1000 setElementData(thePlayer,"Money", (getElementData(thePlayer,"Money" or 0 ) ) ) outputChatBox( "You have earned "..finalmoney.."!", thePlayer,0, 144, 0) setElementData(thePlayer,"Money", getElementData(thePlayer,"Money" or 0 ) ) end, 3000, 1 ) setTimer ( function ( ) if ( isElement ( peds [ thePlayer ] ) ) then destroyElement ( peds [ thePlayer ] ) end startJob ( thePlayer ) end ,3000, 1 ) end end end function deleteOnExit ( thePlayer ) if ( isElement ( markers [ thePlayer ] ) ) then destroyElement ( markers [ thePlayer ] ) end if ( isElement ( blips [ thePlayer ] ) ) then destroyElement ( blips [ thePlayer ] ) end if ( isElement ( peds [ thePlayer ] ) ) then destroyElement ( peds [ thePlayer ] ) end end function destroyJob ( thePlayer ) if ( isElement ( markers [ thePlayer ] ) ) then destroyElement ( markers [ thePlayer ] ) end if ( isElement ( blips [ thePlayer ] ) ) then destroyElement( blips [ thePlayer ] ) end end Link to comment
diesel974 Posted June 19, 2014 Share Posted June 19, 2014 Hey Well, you triggered the server and skin is set, and you are warped into the vehicle, good. But what should happen next!!??? O_o i guess the job should start now, isnt it?? And the function which actually start the job is startJob(thePlayer)... so just write this : startJob(source) -- yes, here you write source instead of thePlayer, because thePlayer is undefined here below line 55 or 56 Link to comment
#Ivan7 Posted June 19, 2014 Author Share Posted June 19, 2014 Lol wow i was working for like 9 hours yesterday honostly I didnt get sleep, probley was tired and forgot it , anyways thanks but 1 more issue and i think im good ok i have warppedInVechile just issue is when I hit caps lock it wont warp him in.. but I have it set up, btw thanks alot diesel i owe u big time Link to comment
#DRAGON!FIRE Posted June 19, 2014 Share Posted June 19, 2014 u must remove value from table .. : Cars[ source ] = nil Link to comment
#Ivan7 Posted June 19, 2014 Author Share Posted June 19, 2014 No Im talking about the peds i created around the map when I go to 1 of the peds im suppose to hit caps and it will warp the ped in.. it worked in my other verison but not this 1 for some reason Link to comment
#Ivan7 Posted June 19, 2014 Author Share Posted June 19, 2014 Ok guys.. so i changed it to bindkey and it still doesnt work.. please any suggestions? local pickups = { { -2514.2985839844, -19.26721572876, 25.6171875 }, { -2413.8093261719, 314.66299438477, 35.171875 }, { -1980.0808105469, 884.00354003906, 45.203125 }, { -1584.2047119141, 812.43743896484, 6.8203125 }, { -1817.1701660516, 1286.7491455078, 15.492509841919 }, { -2343.4348144531, 983.23840322031, 50.6953125 }, { -2554.942629531, 193.716659548, 6.2031769752502 } } local dropoffss = { { -2275.2744140625, 612.84197998047, 43.402828216553 }, { -2566.2153320313, 578.38897705078, 14.453125 }, { -2128.4689941406, 310.44934082031, 35.254566192627 }, { -1702.652941016, 717.54370117188, 24.890625 }, { -1912.1589355469, 883.3916015625, 35.215755462646 }, { -1977.3975830078, 1118.9444580078, 53.23331451416 }, { -1703.1501464844, 1340.6345214844, 7.1796875 } } local pedCus = { { 7 }, { 21 }, { 29 }, { 137 }, { 27 }, { 240 }, { 264 } } function SetVisiteFor (mark,player) setElementVisibleTo ( mark, root, false ) setElementVisibleTo ( mark, player, true ) end taxiVehs = { [420] = true } Cars = {} function teamSet ( ) if (isElement(Cars[source])) then destroyElement(Cars[source]) end setElementData(source,"markertax",4) setElementModel(source, 255) Cars[source] = createVehicle(420, -2485.3188476563, -169.93522644043, 25.6171875) addEventHandler ( "onVehicleExit", Cars[source], deleteOnExit ) addEventHandler ( "onVehicleEnter", Cars[source], inVEH ) addEventHandler ( "onVehicleStartEnter", Cars[source], enterVehicle ) warpPedIntoVehicle ( source, Cars[source] ) startJob() outputChatBox("You are now employed as a Taxi Driver!", source) end addEvent ( "sTeame", true) addEventHandler ( "sTeame", root, teamSet ) addEventHandler('onPlayerQuit', root, function() if isElement( Cars[source] ) then destroyElement(Cars[source] ) end end ) function enterVehicle ( seat, jacked ) if getElementData(source,"JobNew") ~= 4 then removePedFromVehicle( source ) outputChatBox("Only Taxi Drivers can drive this vehicle!", source) end end markers = { } blips = { } peds = { } mposi = { } mposii = {} function startJob ( ) local x, y, z = unpack ( pickups [ math.random ( #pickups ) ] ) markers [ source ] = createMarker ( x, y, z, "cylinder", 5.0, 255, 0, 0, 0 ) SetVisiteFor (markers [ source ],source) mposi = { getElementPosition( markers [ source ] ) } local skins = unpack ( pedCus [ math.random ( #pedCus ) ] ) peds [ source ] = createPed( skins, x, y, z ) SetVisiteFor (peds [ source ],source) blips [ source ] = createBlipAttachedTo ( markers [ source ], 58 ) SetVisiteFor (blips [ source ],source) addEventHandler ( "onMarkerHit", markers [ source ], warpit ) end function inVEH () if isPedInVehicle ( source ) and getElementData(source,"JobNew") == 4 then startJob () end end function warpit ( ) if isPedInVehicle ( source ) then local vehiclee = getPedOccupiedVehicle ( source ) if ( getElementModel ( vehiclee ) == 420 ) then bindKey(source,"H","down",warpit) end end end function warpit2 () warpPedIntoVehicle(peds [ source ], getPedOccupiedVehicle ( source ), 2 ) local x, y, z = unpack ( dropoffss [ math.random ( #dropoffss ) ] ) markers [ source ] = createMarker ( x, y, z - 1, "cylinder", 5.0, 195, 197, 9, 255 ) SetVisiteFor (markers [ source ],source) mposii = { getElementPosition( markers [ source ] ) } blips [ source ] = createBlipAttachedTo ( markers [ source ], 41 ) SetVisiteFor (blips [ source ],source) addEventHandler ( "onMarkerHit", markers [ source ], pickmeup ) unbindKey(source,"H","down",warpit2) end function pickmeup () if isPedInVehicle ( source ) then destroyJob () local mx, my, mz = unpack ( mposi ) local mmx, mmy, mmz = unpack ( mposii ) local money = getDistanceBetweenPoints2D ( mx, my, mmx, mmy ) finalmoney = math.floor ( money ) if finalmoney then setTimer( function () finalmoney = finalmoney + 1000 setElementData(source,"Money", (getElementData(source,"Money" or 0 ) ) ) outputChatBox( "You have earned "..finalmoney.."!",source,0, 144, 0) setElementData(source,"Money", getElementData(source,"Money" or 0 ) ) end, 3000, 1 ) setTimer ( function () if ( isElement ( peds [ source ] ) ) then destroyElement ( peds [ source ] ) end startJob () end ,3000, 1 ) end end end function deleteOnExit ( ) if ( isElement ( markers [ source ] ) ) then destroyElement ( markers [ source ] ) end if ( isElement ( blips [ source ] ) ) then destroyElement ( blips [ source ] ) end if ( isElement ( peds [ source ] ) ) then destroyElement ( peds [ source ] ) end end function destroyJob () if ( isElement ( markers [ source ] ) ) then destroyElement ( markers [ source ] ) end if ( isElement ( blips [ source ] ) ) then destroyElement( blips [ source ] ) end end Link to comment
diesel974 Posted June 20, 2014 Share Posted June 20, 2014 Man I clearly showed you what to do. All you had to do was copy - paste, but you have not done that. i told you : so just write this : startJob(source) -- yes, here you write source instead of thePlayer, because thePlayer is undefined here below line 55 or 56 But you wrote startJob() only Correct this plz!. Hmm, nvm, here is the script, i wrote some comments to explain you some things, read it : local pickups = { { -2514.2985839844, -19.26721572876, 25.6171875 }, { -2413.8093261719, 314.66299438477, 35.171875 }, { -1980.0808105469, 884.00354003906, 45.203125 }, { -1584.2047119141, 812.43743896484, 6.8203125 }, { -1817.1701660516, 1286.7491455078, 15.492509841919 }, { -2343.4348144531, 983.23840322031, 50.6953125 }, { -2554.942629531, 193.716659548, 6.2031769752502 } } local dropoffss = { { -2275.2744140625, 612.84197998047, 43.402828216553 }, { -2566.2153320313, 578.38897705078, 14.453125 }, { -2128.4689941406, 310.44934082031, 35.254566192627 }, { -1702.652941016, 717.54370117188, 24.890625 }, { -1912.1589355469, 883.3916015625, 35.215755462646 }, { -1977.3975830078, 1118.9444580078, 53.23331451416 }, { -1703.1501464844, 1340.6345214844, 7.1796875 } } local pedCus = { { 7 }, { 21 }, { 29 }, { 137 }, { 27 }, { 240 }, { 264 } } function SetVisiteFor (mark,player) setElementVisibleTo ( mark, root, false ) setElementVisibleTo ( mark, player, true ) end taxiVehs = { [420] = true } Cars = {} function teamSet ( ) if (isElement(Cars[source])) then destroyElement(Cars[source]) end setElementData(source,"markertax",4) setElementModel(source, 255) Cars[source] = createVehicle(420, -2485.3188476563, -169.93522644043, 25.6171875) addEventHandler ( "onVehicleExit", Cars[source], deleteOnExit ) addEventHandler ( "onVehicleEnter", Cars[source], inVEH ) addEventHandler ( "onVehicleStartEnter", Cars[source], enterVehicle ) warpPedIntoVehicle ( source, Cars[source] ) -- source is the current player who is actually running the script(or the job) startJob(source) -- here, we add source as argument so as to give the function startJob the current player as argument outputChatBox("You are now employed as a Taxi Driver!", source) end addEvent ( "sTeame", true) addEventHandler ( "sTeame", root, teamSet ) addEventHandler('onPlayerQuit', root, function() if isElement( Cars[source] ) then destroyElement(Cars[source] ) end end ) function enterVehicle ( seat, jacked ) if getElementData(source,"JobNew") ~= 4 then removePedFromVehicle( source ) outputChatBox("Only Taxi Drivers can drive this vehicle!", source) end end markers = { } blips = { } peds = { } mposi = { } mposii = {} function startJob (source ) -- the argument we had given to startJob above ( source) is going to be used here local x, y, z = unpack ( pickups [ math.random ( #pickups ) ] ) markers [ source ] = createMarker ( x, y, z, "cylinder", 5.0, 255, 0, 0, 0 ) SetVisiteFor (markers [ source ],source) -- wat is this function, SetVisiteFor, never heard that mposi = { getElementPosition( markers [ source ] ) } local skins = unpack ( pedCus [ math.random ( #pedCus ) ] ) peds [ source ] = createPed( skins, x, y, z ) SetVisiteFor (peds [ source ],source) blips [ source ] = createBlipAttachedTo ( markers [ source ], 58 ) SetVisiteFor (blips [ source ],source) addEventHandler ( "onMarkerHit", markers [ source ], warpit ) end function inVEH () if isPedInVehicle ( source ) and getElementData(source,"JobNew") == 4 then startJob () end end function warpit (hitElement,matchingDimension ) --[[ please, take some times, go to mta wiki, and read about function and events. like you wrote above, "onMarkerHit" is an event which means when something hits a marker. So, when this event is triggered, it passes 2 parameters(or arguments) to the function that it calls ( warpit, in your case). The 2 parameters are hitElement, which means the element that has hit the marker, and matchingDimension, which is not that much important for now.]] if isPedInVehicle ( hitElement ) then -- use hitElement instead of source. Source is the marker that you just hit. local vehiclee = getPedOccupiedVehicle ( hitElement ) if ( getElementModel ( vehiclee ) == 420 ) then bindKey(hitElement,"H","down",warpit2) -- pass the argument hitElement to the function warpit2 end end end function warpit2 (hitElement) warpPedIntoVehicle(peds [ hitElement ], getPedOccupiedVehicle ( hitElement ), 2 ) local x, y, z = unpack ( dropoffss [ math.random ( #dropoffss ) ] ) markers [ hitElement ] = createMarker ( x, y, z - 1, "cylinder", 5.0, 195, 197, 9, 255 ) SetVisiteFor (markers [ hitElement ],hitElement) -- i still dont know wat is this function.... correct this plz mposii = { getElementPosition( markers [ hitElement ] ) } blips [ hitElement ] = createBlipAttachedTo ( markers [ hitElement ], 41 ) SetVisiteFor (blips [ hitElement ],hitElement) addEventHandler ( "onMarkerHit", markers [ hitElement ], pickmeup ) unbindKey(hitElement,"H","down",warpit2) end function pickmeup (hitElement,matchingDimension) -- again, write the parameters, i will give you some links below, check them to learn more info if isPedInVehicle ( hitElement ) then destroyJob () local mx, my, mz = unpack ( mposi ) local mmx, mmy, mmz = unpack ( mposii ) local money = getDistanceBetweenPoints2D ( mx, my, mmx, mmy ) finalmoney = math.floor ( money ) if finalmoney then setTimer( function (hitElement) finalmoney = finalmoney + 1000 setElementData(hitElement,"Money", (getElementData(hitElement,"Money" or 0 ) ) ) outputChatBox( "You have earned "..finalmoney.."!",hitElement,0, 144, 0) setElementData(hitElement,"Money", getElementData(hitElement,"Money" or 0 ) ) end, 3000, 1, hitElement ) setTimer ( function (hitElement) if ( isElement ( peds [ hitElement ] ) ) then destroyElement ( peds [ hitElement ] ) end startJob (hitElement) end ,3000, 1, hitElement ) end end end function deleteOnExit ( ) if ( isElement ( markers [ source ] ) ) then destroyElement ( markers [ source ] ) end if ( isElement ( blips [ source ] ) ) then destroyElement ( blips [ source ] ) end if ( isElement ( peds [ source ] ) ) then destroyElement ( peds [ source ] ) end end function destroyJob () if ( isElement ( markers [ source ] ) ) then destroyElement ( markers [ source ] ) end if ( isElement ( blips [ source ] ) ) then destroyElement( blips [ source ] ) end end It still contains some mistakes like the unknown function that you wrote SetVisiteFor.. correct this and maybe i miss a mistake too. Also, you need to know what and how events are used. Go to this page : https://wiki.multitheftauto.com/wiki/Event If you want to learn to script better, spend more time at wiki rather than opening resources and editing them. Learn the basics first ( functions, events...) Regards Link to comment
#Ivan7 Posted June 20, 2014 Author Share Posted June 20, 2014 Thanks, it worked but imma go back to wiki after i finish this, and their are 3 bugs left but i will fix them my self again thanks 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