Prat Posted August 27, 2013 Share Posted August 27, 2013 Hello after wasting a lot of my time , i made a script but itsn't working. so basically the script is about Pilot job , when you do /startshift , a blip and marker displays on ur map , so its working perfectly so far , but the problem is , when i add markerhit event in other function it doesn't work , so i need ur help here. the script should work in these ways :- only "Pilot" team can do /startshift you will only get money when you hit the marker by the vehicle "Dodo". local deliverP = { --Los Santos {1787.7626953125, -2555.7822265625, 13}, {-1662.8570556641, -291.42846679688, 14}, {1448.5712890625, 1508.5714111328, 10}, } thisRes = getResourceRootElement(getThisResource()) local PilotPlane = createVehicle (593, 1890.3594970703, -2493.8330078125, 13.53911781311) function PilotDeliver() random = math.random(#deliverP) x, y, z = deliverP[random][1], deliverP[random][2], deliverP[random][3] delBlip = createBlip ( x,y,z, 51) delmarker = createMarker ( x,y,z, "cylinder", 5, 255, 160, 0, 100) outputChatBox ( "You have a new flight , go to location bliped on your map!", root, 255, 100, 0, true ) end addCommandHandler ("startshift", PilotDeliver) function DelPayment(hitElement) if getElementType(hitElement) == "player" and (hitElement == localPlayer) then randomPay = math.random ( 2000, 5000 ) givePlayerMoney (randomPay) outputChatBox ( "You Arrived to your distenation , This is your payment"..tostring(randomPay).."$", root, 255, 100, 0, true ) end end addEventHandler ("onMarkerHit", delmarker, DelPayment) thanks for reading. cheers Link to comment
Castillo Posted August 27, 2013 Share Posted August 27, 2013 Use getPlayerTeam + getTeamName. Link to comment
Prat Posted August 27, 2013 Author Share Posted August 27, 2013 thanks but that doesn't really matter , just for the function 2 is not working Link to comment
manawydan Posted August 27, 2013 Share Posted August 27, 2013 localPlayer ? localPlayer is client Link to comment
Castillo Posted August 27, 2013 Share Posted August 27, 2013 Remove this part: (hitElement == localPlayer) and, to check if the vehicle is a Dodo, use getElementModel. Link to comment
manawydan Posted August 27, 2013 Share Posted August 27, 2013 try no tested local deliverP = { --Los Santos {1787.7626953125, -2555.7822265625, 13}, {-1662.8570556641, -291.42846679688, 14}, {1448.5712890625, 1508.5714111328, 10} } thisRes = getResourceRootElement(getThisResource()) local PilotPlane = createVehicle (593, 1890.3594970703, -2493.8330078125, 13.53911781311) function PilotDeliver() local random1 = math.random(#deliverP) x, y, z = deliverP[random1][1], deliverP[random1][2], deliverP[random1][3] delBlip = createBlip ( x,y,z, 51) delmarker = createMarker ( x,y,z, "cylinder", 5, 255, 160, 0, 100) outputChatBox ( "You have a new flight , go to location bliped on your map!", root, 255, 100, 0, true ) end addCommandHandler ("startshift", PilotDeliver) function DelPayment(hitElement) if getElementType(hitElement) == "player" and getElementModel(getVehicleController(hitElement)) == 593 then randomPay = math.random ( 2000, 5000 ) givePlayerMoney (randomPay) outputChatBox ( "You Arrived to your distenation , This is your payment"..tostring(randomPay).."$", root, 255, 100, 0, true ) end end addEventHandler ("onMarkerHit", delmarker, DelPayment) Link to comment
Prat Posted August 27, 2013 Author Share Posted August 27, 2013 tried everything , not working. no debug message. Link to comment
Castillo Posted August 27, 2013 Share Posted August 27, 2013 local deliverP = { --Los Santos {1787.7626953125, -2555.7822265625, 13}, {-1662.8570556641, -291.42846679688, 14}, {1448.5712890625, 1508.5714111328, 10}, } local PilotPlane = createVehicle ( 593, 1890.3594970703, -2493.8330078125, 13.53911781311 ) local data = { } function PilotDeliver ( thePlayer ) local team = getPlayerTeam ( thePlayer ) if ( team and getTeamName ( team ) == "Pilot" ) then local x, y, z = unpack ( deliverP [ math.random ( #deliverP ) ] ) data [ thePlayer ] = { delBlip = createBlip ( x, y, z, 51 ), delmarker = createMarker ( x, y, z, "cylinder", 5, 255, 160, 0, 100 ) } addEventHandler ( "onMarkerHit", data [ thePlayer ].delmarker, DelPayment ) outputChatBox ( "You have a new flight , go to location bliped on your map!", thePlayer, 255, 100, 0, true ) end end addCommandHandler ( "startshift", PilotDeliver ) function DelPayment ( hitElement ) if ( getElementType ( hitElement ) == "player" ) then local vehicle = getPedOccupiedVehicle ( hitElement ) if ( vehicle and getElementModel ( vehicle ) == 593 ) then local randomPay = math.random ( 2000, 5000 ) givePlayerMoney ( randomPay ) outputChatBox ( "You Arrived to your distenation , This is your payment".. tostring ( randomPay ) .."$", hitElement, 255, 100, 0, true ) if ( data [ hitElement ] ) then if isElement ( data [ hitElement ].delBlip ) then destroyElement ( data [ hitElement ].delBlip ) end if isElement ( data [ hitElement ].delmarker ) then destroyElement ( data [ hitElement ].delmarker ) end end end end end Link to comment
Prat Posted August 28, 2013 Author Share Posted August 28, 2013 Appreciate castillo , but anyone can make /staftshift multiple times and it spawns infinite markers and blips on the map , thus this is abusable, can you fix it please? Link to comment
Castillo Posted August 28, 2013 Share Posted August 28, 2013 local deliverP = { --Los Santos {1787.7626953125, -2555.7822265625, 13}, {-1662.8570556641, -291.42846679688, 14}, {1448.5712890625, 1508.5714111328, 10}, } local PilotPlane = createVehicle ( 593, 1890.3594970703, -2493.8330078125, 13.53911781311 ) local data = { } function PilotDeliver ( thePlayer ) local team = getPlayerTeam ( thePlayer ) if ( team and getTeamName ( team ) == "Pilot" ) then if ( data [ thePlayer ] and isElement ( data [ thePlayer ].delBlip ) and isElement ( data [ thePlayer ].delmarker ) ) then return outputChatBox ( "You already got a destination.", thePlayer, 255, 0, 0 ) end local x, y, z = unpack ( deliverP [ math.random ( #deliverP ) ] ) data [ thePlayer ] = { delBlip = createBlip ( x, y, z, 51 ), delmarker = createMarker ( x, y, z, "cylinder", 5, 255, 160, 0, 100 ) } addEventHandler ( "onMarkerHit", data [ thePlayer ].delmarker, DelPayment ) outputChatBox ( "You have a new flight , go to location bliped on your map!", thePlayer, 255, 100, 0, true ) end end addCommandHandler ( "startshift", PilotDeliver ) function DelPayment ( hitElement ) if ( getElementType ( hitElement ) == "player" ) then local vehicle = getPedOccupiedVehicle ( hitElement ) if ( vehicle and getElementModel ( vehicle ) == 593 ) then local randomPay = math.random ( 2000, 5000 ) givePlayerMoney ( randomPay ) outputChatBox ( "You Arrived to your distenation , This is your payment".. tostring ( randomPay ) .."$", hitElement, 255, 100, 0, true ) if ( data [ hitElement ] ) then if isElement ( data [ hitElement ].delBlip ) then destroyElement ( data [ hitElement ].delBlip ) end if isElement ( data [ hitElement ].delmarker ) then destroyElement ( data [ hitElement ].delmarker ) end end end end end Link to comment
Prat Posted August 28, 2013 Author Share Posted August 28, 2013 MAN I FREKING LOVE YOU Link to comment
Prat Posted August 28, 2013 Author Share Posted August 28, 2013 aaand one more thing please , after hiting the deliver marker , i want to set a timer so you don't have to do /startshift again. so once you deliver it , another destination displays automaticaly Link to comment
Castillo Posted August 28, 2013 Share Posted August 28, 2013 local deliverP = { --Los Santos {1787.7626953125, -2555.7822265625, 13}, {-1662.8570556641, -291.42846679688, 14}, {1448.5712890625, 1508.5714111328, 10}, } local PilotPlane = createVehicle ( 593, 1890.3594970703, -2493.8330078125, 13.53911781311 ) local data = { } function PilotDeliver ( thePlayer ) local team = getPlayerTeam ( thePlayer ) if ( team and getTeamName ( team ) == "Pilot" ) then if ( data [ thePlayer ] and isElement ( data [ thePlayer ].delBlip ) and isElement ( data [ thePlayer ].delmarker ) ) then return outputChatBox ( "You already got a destination.", thePlayer, 255, 0, 0 ) end giveDestination ( thePlayer ) end end addCommandHandler ( "startshift", PilotDeliver ) function DelPayment ( hitElement ) if ( getElementType ( hitElement ) == "player" ) then local vehicle = getPedOccupiedVehicle ( hitElement ) if ( vehicle and getElementModel ( vehicle ) == 593 ) then local randomPay = math.random ( 2000, 5000 ) givePlayerMoney ( randomPay ) outputChatBox ( "You Arrived to your distenation , This is your payment".. tostring ( randomPay ) .."$", hitElement, 255, 100, 0, true ) if ( data [ hitElement ] ) then if isElement ( data [ hitElement ].delBlip ) then destroyElement ( data [ hitElement ].delBlip ) end if isElement ( data [ hitElement ].delmarker ) then destroyElement ( data [ hitElement ].delmarker ) end end setTimer ( giveDestination, 5000, 1, hitElement ) end end end function giveDestination ( thePlayer ) if ( not isElement ( thePlayer ) ) then return end local x, y, z = unpack ( deliverP [ math.random ( #deliverP ) ] ) data [ thePlayer ] = { delBlip = createBlip ( x, y, z, 51 ), delmarker = createMarker ( x, y, z, "cylinder", 5, 255, 160, 0, 100 ) } addEventHandler ( "onMarkerHit", data [ thePlayer ].delmarker, DelPayment ) outputChatBox ( "You have a new flight , go to location bliped on your map!", thePlayer, 255, 100, 0, true ) end Link to comment
Prat Posted August 28, 2013 Author Share Posted August 28, 2013 YOU ARE A ONE PIECE HELL OF COOL GUY , CHEEEEEEERS Link to comment
Prat Posted August 28, 2013 Author Share Posted August 28, 2013 oh shit , timer is not working Edit: oh shit nvm i pasted the wrong code , Lol 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