Jump to content

Help with job script


DiGiTal

Recommended Posts

Hi, i have a criminal job which you go to a place to take a bag and go to the destination BUT the probleme al (cops,civilans...)l want the job and blip apear only on car jacker classe.

mark = {
	--Las Venturas
	{2630.802734375, 1824.3828125, 10.0234375},
	{2184.5078125, 2805.859375, 9.8203125},
	{1097.6328125, 1601.888671875, 11.546875},
	{1918.73828125, 664.7099609375, 13.2734375},
	{2849.0302734375, 1290.7861328125, 10.390625},
	{1087.7451171875, 1076.703125, 9.838157653809},
	{2182.9580078125, 1115.119140625, 11.6484375},
	{2451.8359375, 1223.9072265625, 9.8203125},
	{2329.740234375, 1436.3671875, 41.8203125},
	{1091.53515625, 2119.6787109375, 14.350400924683},
	{2005.9912109375, 2310.5322265625, 9.8203125},
	{2225.2021484375, 1964.65234375, 30.779651641846},
	{2026.419921875, 1916.4453125, 11.337824821472},
	{1383.40625, 2183.7421875, 10.0234375},
	{1418.59375, 2773.5654296875, 9.8203125},
	{2291.869140625, 2451.37109375, 9.8203125},
	{1704.822265625, 1025.646484375, 9.8203125},
	{1600.3994140625, 2220.3740234375, 10.0625},
	--San Fierro
	{-1947.6494140625, 795.720703125, 54.722202301025},
	{-1809.30859375, 1301.337890625, 58.734375},
	{-2521.078125, -623.7021484375, 131.77600097656},
	{-2552.34765625, 53.529296875, 15.421875},
	{-2026.630859375, -98.302734375, 34.1640625},
	{-2583.583984375, 887.673828125, 63.982246398926},
	{-1954.6171875, -809.1669921875, 34.890884399414},
	{-1545.107421875, -440.0419921875, 7},
	{-1571.2021484375, 82.6435546875, 2.5546875},
	{-2419.0703125, 334.4072265625, 34.178676605225},
	{ -1353.466796875, -102.4404296875, 6},
	--Los Santos
	{377.70703125, -2020.7353515625, 6.8300905227661},
	{1641.6123046875, -2240.2080078125, 12.49627494812},
	{1925.76171875, -1764.08984375, 12.539072036743},
	{1097.671875, -1604.8408203125, 19.525354385376},
	{2266.1455078125, -1667.8115234375, 14.393363952637},
	{1726.861328125, -1635.6357421875, 19.216711044312},
	{918.46875, -1252.248046875, 15.2109375},
	{1298.591796875, -799.853515625, 83.140625},
	{1980.1220703125, -1281.9013671875, 22.976850509644},
	{2747.7236328125, -1692.3193359375, 10.84375},
	{2094.9111328125, -1797.814453125, 12.3828125},
	{2746.896484375, -1352.2314453125, 43.558689117432},
	{2719.22265625, -2515.9111328125, 16.367183685303},
}

bag = {
    --Las Venturas
	{2577.3095703125, 2733.6640625, 10.8203125},
	{1498.7255859375, 721.623046875, 10.8203125},
	{1665.47265625, 1423.3603515625, 10.783618927002},
	{943.0888671875, 1733.2734375, 8.8515625},
	{1486.9326171875, 2773.982421875, 10.8203125},
	{2880.8017578125, 2523.0654296875, 10.8203125},
	{2318.6923828125, 1261.4091796875, 67.46875},
	{2617.1005859375, 717.099609375, 14.739588737488},
	{2193.6787109375, 1677.2421875, 12.3671875},
	{984.4345703125, 2562.916015625, 10.749537467957},
	{2476.1513671875, 1876.45703125, 10.315457344055},
	{1865.462890625, 2071.6962890625, 11.0625},
	--San Fierro
	{-2765.03515625, 785.369140625, 52.78125},
	{-2723.453125, -314.8759765625, 7.183753490448},
	{-2343.7060546875, -166.9033203125, 35.5546875},
	{-2026.23046875, 156.92578125, 29.0390625},
	{-1978.89453125, 432.111328125, 25.506650924683},
	{-1884.7626953125, 826.2412109375, 35.172046661377},
	{-2377.771484375, 910.033203125, 45.4453125},
	{-2158.24609375, 654.6279296875, 52.370674133301},
	{ -2180.5712890625, 706.3505859375, 53.890625},
	{ -2152.990234375, 481.7080078125, 35.171875},
	{-1669.751953125, 1015.1767578125, 7.921875},
	{-1418.03515625, -293.97265625, 14.1484375},
	--Los Santos
	{2525.474609375, -1703.5, 13.379940986633},
	{2371.5791015625, -2114.7255859375, 27.17497253418},
	{1247.306640625, -902.60546875, 42.8828125},
	{1449.1142578125, -2287.1103515625, 13.546875},
	{1972.845703125, -1235.2744140625, 20.051183700562},
	{2754.2041015625, -1400.837890625, 39.371463775635},
	{1665.642578125, -990.134765625, 29.430828094482},
	{2793.3388671875, -2456.2119140625, 13.632308006287},
	{390.9072265625, -2058.5888671875, 10.720296859741},
}


function createBag()
	local mt = math.random(#bag)
	ob = createObject(1210,bag[mt][1],bag[mt][2],bag[mt][3])
	setElementCollisionsEnabled(ob,false)
	time = setTimer(roo,100,0,ob)
	mar = createMarker(bag[mt][1],bag[mt][2],bag[mt][3],"corona",0.5,255,0,0,0)
	bl = createBlipAttachedTo(mar,19)
	setElementData(mar,"num",mt)
    exports.SADZcommands:sendMessage("* SADZ:RPG BAG* A bag has been spawned. Go to 'Red Flag' blip on the map to grab the bag and deliver it.",177,74,0,root)
end
addEventHandler("onResourceStart",resourceRoot,createBag)

addEventHandler("onMarkerHit",root,
	function (player)
		if ( source == mar ) then
			if getElementType(player) == "player" then
				local x,y,z = getElementPosition(player)
				local data = getElementData(mar,"num")
				local data = tonumber(data)
				destroyElement(mar)
				destroyElement(ob)
				destroyElement(bl)
				killTimer(time)
				setElementData(player,"bag",true)
				atBag = createObject(1210,x,y,z)
				setElementData(atBag,"num",data)
				exports.bone_attach:attachElementToBone(atBag,player,12,0,0.05,0.27,0,180,0)
				bli = createBlipAttachedTo(player,3)
				exports.SADZcommands:sendMessage("" .. getPlayerName(player) .. " has taken the bag.",0,255,0,root,true)
				marker = createMarker(mark[data][1],mark[data][2],mark[data][3],"cylinder",1.5,177,74,0,155,player)
				marBli = createBlipAttachedTo(marker,60,2,255,0,0,255,0,99999.0,player)
			end
		end
	end
)

function roo(ele)
	local x,y,z = getElementRotation(ele)
	setElementRotation(ele,x,y,z + 5)
end

addEventHandler("onPlayerWasted",root,
	function ()
		if getElementData(source,"bag") and getElementData(source,"bag") == true then
			local data = getElementData(atBag,"num")
			local data = tonumber(data)
			local x,y,z = getElementPosition(source)
			setElementData(source,"bag",false)
			destroyElement(atBag)
			destroyElement(marker)
			destroyElement(bli)
			destroyElement(marBli)
			ob = createObject(1210,x,y,z)
			setElementCollisionsEnabled(ob,false)
			time = setTimer(roo,100,0,ob)
			mar = createMarker(x,y,z,"corona",0.5,255,0,0,120)
			setElementData(mar,"num",data)
			bl = createBlipAttachedTo(mar,8)
		end
	end
)

addEventHandler("onMarkerHit",root,
	function (player)
		if ( source == marker ) then
			if getElementType(player) == "player" then
				setElementData(player,"bag",false)
				destroyElement(marker)
				destroyElement(marBli)
				destroyElement(bli)
				destroyElement(atBag)
				exports.SADZcommands:sendMessage("*BAG* " .. getPlayerName(player) .. " has delivered the bag and won 30,000$.",255,255,0,root,true)
				exports.SADZcommands:giveMoney(player,30000)
				triggerClientEvent(player,"onShowMoney",player)
				setTimer(createBag,300000,1)
			end
		end
	end
)



addEventHandler("onPlayerQuit",root,
	function ()
		if getElementData(source,"bag") and getElementData(source,"bag") == true then
			local data = getElementData(atBag,"num")
			local data = tonumber(data)
			local x,y,z = getElementPosition(source)
			setElementData(source,"bag",false)
			destroyElement(atBag)
			destroyElement(marker)
			destroyElement(bli)
			destroyElement(marBli)
			ob = createObject(1210,x,y,z)
			setElementCollisionsEnabled(ob,false)
			time = setTimer(roo,100,0,ob)
			mar = createMarker(x,y,z,"corona",0.5,255,0,0,0)
			setElementData(mar,"num",data)
			bl = createBlipAttachedTo(mar,8)
		end
	end
)

 

Link to comment

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...