Jump to content

2 TRABS EM UMA MARCAÇÃO SÓ, AJUDA PFV


Recommended Posts

Bom eu fiz 2 trabalhos, um de entregar pizza e outro de entregar jornal, no caso toda vez que eu vou ao mark vermelho aparece ambos os trabalhos sendo que os marks estão em localizações diferentes, segue o print a baixo.

e7bi8k.png

2rzyyap.png

ESSE AQUI É O CODIGO QUE USO NOS 2 TRABS SÓ MUDO NOMES E LOCALIZAÇÕES SE PUDEREM ME DIZER ONDE ESTÁ ERRADO, EU USO IMAGENS PARA GERAR OS PAINEIS DE ACEITAR TRAB, TEM OUTROS ARQUIVOS.LUA MAS PROVAVELMENTE NÃO SÃO ELES QUE ESTÃO CAUSANDO ISSO, MAS CASO SEJA ME AVISEM QUE EU COLOCO ELES TAMBÉM, PARA ME AJUDAREM .-.

TRABALHO DE JORNAL:

addEvent("openinf_kop", true)
screenWidth, screenHeight = guiGetScreenSize()
function windm ()
	if not getElementData ( localPlayer, "kop_working") then
		  infowind = guiCreateStaticImage(screenWidth - 700, screenHeight - 500, 300, 359, "background.png", false)
		  
		  guiMemoSetReadOnly( infotext, true )
		  --guiSetFont(text2, "default-bold-small") 
		  showCursor(true)
		  guiSetVisible ( infowind , true) 
		  guiWindowSetSizable(infowind, false) 
		  Button_Glose = guiCreateStaticImage(25, 300, 250, 45, "teste.png", false, infowind)
		  Button_Start = guiCreateStaticImage(25, 250, 250, 45, "bu.png", false, infowind)
		 
		  addEventHandler("onClientGUIClick", Button_Start, kit )
			addEventHandler("onClientGUIClick", Button_Glose, noshow )
	else
		for i, v in ipairs ( createdPickups ) do
			if isElement ( v ) then
				local pick2 = getElementData ( v, "pick2")
				if isElement ( pick2 ) then
					destroyElement ( pick2 )
				end
				local icon = getElementData ( v, "icon" )
				if isElement ( icon ) then
					destroyElement ( icon )
				end
				destroyElement ( v )
			end
		end
		triggerServerEvent ( "finitoWork_kop", localPlayer )
		setElementData ( localPlayer, "kop_working", false )
		outputChatBox ( "Você terminou o trabalho de entregar jornal.", 255, 255, 255, true )
	end
end
addEventHandler("openinf_kop", root, windm )
function noshow ()
 if ( source == Button_Glose ) then
   destroyElement ( infowind )
   showCursor ( false ) 
 end
end
function kit ()
 if ( source == Button_Start ) then
	startWorking()
    destroyElement ( infowind )
    showCursor ( false )
  end 
end

addEvent ( "pay", true )
function giving ()
 outputChatBox ( "Você coletou e pegou - 50$ ", getRootElement(), 255, 100, 100, true )
end
addEventHandler("pay", resourceRoot, giving )
addEvent ( "get", true )
function peremen (plr)
 plr = getLocalPlayer ()
end
addEventHandler("get", resourceRoot, peremen )

pickupSpawns = {
	{ 824 ,-1421,14 },
    { 1365,-1432,13 },
    { 1413,-1701,13 },
    { 1929,-1777,13 },
	{ 2326,-1717,13 },
	{ 2495,-1689,14 },
	{ 2067,-1628,14 },
	{ 1909,-1598,14 },

}

max_pickups_set = 8 -- Número de entregas maximo

createdPickups = {}

max_pickups = max_pickups_set
if max_pickups_set > #pickupSpawns then
	max_pickups = #pickupSpawns
end

function startWorking ()
	if not getElementData ( localPlayer, "kop_working" ) then
		createdPickups = {}
		triggerServerEvent ( "picku_kop", localPlayer )
		setElementData ( localPlayer, "kop_working", true )
		setElementData ( localPlayer, "kop_working_hit", 0 )
			outputChatBox ( "Você começou o trabalho.\nPegue a bicicleta e vá entregar jornal!!", 255, 255, 255, true )		
				
		for i, v in ipairs ( pickupSpawns ) do
			local pick = createMarker ( v[1],v[2],v[3], "checkpoint", 4.0, 0, 0, 255 )
			local pick2 = createPickup ( v[1],v[2],v[3], 3, 1582, 10000 )
			setElementData ( pick, "taken", false )
			setElementData ( pick, "pick2", pick2 )
			setElementData ( pick, "kop_pickup", true )
			setElementData ( pick, "id", i )
			if i == 1 then
				local icon = createBlipAttachedTo ( pick, 41, 2 )
				setElementData ( pick, "icon", icon )
			end
			table.insert (createdPickups, pick)
		end
	end
end	

addEventHandler("onClientVehicleExit", getRootElement(),
    function(thePlayer, seat)
        if thePlayer == getLocalPlayer() then
			if getElementData ( localPlayer, "kop_working" ) then
				for i, v in ipairs ( createdPickups ) do
					if isElement ( v ) then
						local pick2 = getElementData ( v, "pick2")
						if isElement ( pick2 ) then
							destroyElement ( pick2 )
						end
						local icon = getElementData ( v, "icon" )
						if isElement ( icon ) then
							destroyElement ( icon )
						end
						destroyElement ( v )
					end
				end
				triggerServerEvent ( "finitoWork_kop", localPlayer )
				setElementData ( localPlayer, "kop_working", false )
				outputChatBox ( "Você terminou o trabalho", 255, 255, 255, true )
			end
        end
    end
)

function clientPickupHit(thePlayer, matchingDimension)
	if thePlayer == localPlayer and getElementData ( source, "kop_pickup" ) and not getElementData ( source, "taken" ) then
		setElementData ( source, "taken", true )
					setElementVelocity ( getPedOccupiedVehicle(localPlayer), 0, 0, 0 )
					toggleAllControls ( false, true, false )
					setTimer ( finishBoarding, 5000, 1 )
					outputChatBox("Entrega está em andamento", 0,153,51)
					setElementData ( localPlayer, "kop_pickup", 2 )
		local hitted = getElementData ( localPlayer, "kop_working_hit" ) or 0
		hitted = hitted+1
		local pick2 = getElementData ( source, "pick2" )
		if isElement ( pick2 ) then
			destroyElement ( pick2 )
		end
		local icon = getElementData ( source, "icon" )
		if isElement ( icon ) then
			destroyElement ( icon )
		end
		destroyElement(source)
		setElementData ( localPlayer, "kop_working_hit", hitted)
		if hitted >= max_pickups then
			for i, v in ipairs ( createdPickups ) do
				if isElement ( v ) then
					local pick2 = getElementData ( v, "pick2")
					if isElement ( pick2 ) then
						destroyElement ( pick2 )
					end
					local icon = getElementData ( v, "icon" )
					if isElement ( icon ) then
						destroyElement ( icon )
					end
					destroyElement ( v )
				end
			end
			setElementData ( localPlayer, "kop_working", false )
			triggerServerEvent ( "finitoWork_kop", localPlayer )
			outputChatBox ( "Você terminou o trabalho, espere", 255, 255, 255, true )
			return true
		end
		if createdPickups[hitted+1] then
			local icon = createBlipAttachedTo ( createdPickups[hitted+1], 41, 2 )
			setElementData ( createdPickups[hitted+1], "icon", icon )
		end
	end
end

function finishBoarding ()
	toggleAllControls ( true, true, true )
			outputChatBox ( "você entregou os jornais, sua recompensa é de R$ 100 ", 255, 100, 100, true )
			triggerServerEvent ( "giveMoneyFromClient_kop", localPlayer, 100 ) --VALOR MONEY PRA DAR
				setElementPosition ( trailer, bases[getElementData ( localPlayer, "nearestBase" )][1], bases[getElementData ( localPlayer, "nearestBase" )][2], bases[getElementData ( localPlayer, "nearestBase" )][3] )
end
addEventHandler ( "onClientMarkerHit", getRootElement(), clientPickupHit )

 

TRABALHO DE PIZZA:

addEvent("openinf_kop", true)
screenWidth, screenHeight = guiGetScreenSize()
function windm ()
	if not getElementData ( localPlayer, "kop_working") then
		  infowind = guiCreateStaticImage(screenWidth - 700, screenHeight - 500, 300, 359, "background.png", false)
		  
		  guiMemoSetReadOnly( infotext, true )
		  --guiSetFont(text2, "default-bold-small") 
		  showCursor(true)
		  guiSetVisible ( infowind , true) 
		  guiWindowSetSizable(infowind, false) 
		  Button_Glose = guiCreateStaticImage(25, 300, 250, 45, "teste.png", false, infowind)
		  Button_Start = guiCreateStaticImage(25, 250, 250, 45, "bu.png", false, infowind)
		 
		  addEventHandler("onClientGUIClick", Button_Start, kit )
			addEventHandler("onClientGUIClick", Button_Glose, noshow )
	else
		for i, v in ipairs ( createdPickups ) do
			if isElement ( v ) then
				local pick2 = getElementData ( v, "pick2")
				if isElement ( pick2 ) then
					destroyElement ( pick2 )
				end
				local icon = getElementData ( v, "icon" )
				if isElement ( icon ) then
					destroyElement ( icon )
				end
				destroyElement ( v )
			end
		end
		triggerServerEvent ( "finitoWork_kop", localPlayer )
		setElementData ( localPlayer, "kop_working", false )
		outputChatBox ( "Você terminou o trabalho de entregar pizza.", 255, 255, 255, true )
	end
end
addEventHandler("openinf_kop", root, windm )
function noshow ()
 if ( source == Button_Glose ) then
   destroyElement ( infowind )
   showCursor ( false ) 
 end
end
function kit ()
 if ( source == Button_Start ) then
	startWorking()
    destroyElement ( infowind )
    showCursor ( false )
  end 
end

addEvent ( "pay", true )
function giving ()
 outputChatBox ( "Você coletou e pegou - 50$ ", getRootElement(), 255, 100, 100, true )
end
addEventHandler("pay", resourceRoot, giving )
addEvent ( "get", true )
function peremen (plr)
 plr = getLocalPlayer ()
end
addEventHandler("get", resourceRoot, peremen )

pickupSpawns = {
	{ 2225,2520,10 },
    { 2102,2484,11 },
    { 1889,2408,11 },
    { 1934,2306,10 },
	{ 2065,2290,10 },
	{ 2279,2341,10 },
	{ 2258,2289,10 },
	{ 2497,2239,10 },
	{ 2519,2335,10 },	
    { 2301,2507,10 },	
    { 2318,2516,10 },
	{ 2347,2506,10 },
}

max_pickups_set = 15 -- Número de entregas maximo

createdPickups = {}

max_pickups = max_pickups_set
if max_pickups_set > #pickupSpawns then
	max_pickups = #pickupSpawns
end

function startWorking ()
	if not getElementData ( localPlayer, "kop_working" ) then
		createdPickups = {}
		triggerServerEvent ( "picku_kop", localPlayer )
		setElementData ( localPlayer, "kop_working", true )
		setElementData ( localPlayer, "kop_working_hit", 0 )
			outputChatBox ( "Você começou o trabalho.\nPegue a moto e vá entregar pizzas!!", 255, 255, 255, true )		
				
		for i, v in ipairs ( pickupSpawns ) do
			local pick = createMarker ( v[1],v[2],v[3], "checkpoint", 4.0, 0, 0, 255 )
			local pick2 = createPickup ( v[1],v[2],v[3], 3, 1582, 10000 )
			setElementData ( pick, "taken", false )
			setElementData ( pick, "pick2", pick2 )
			setElementData ( pick, "kop_pickup", true )
			setElementData ( pick, "id", i )
			if i == 1 then
				local icon = createBlipAttachedTo ( pick, 41, 2 )
				setElementData ( pick, "icon", icon )
			end
			table.insert (createdPickups, pick)
		end
	end
end	

addEventHandler("onClientVehicleExit", getRootElement(),
    function(thePlayer, seat)
        if thePlayer == getLocalPlayer() then
			if getElementData ( localPlayer, "kop_working" ) then
				for i, v in ipairs ( createdPickups ) do
					if isElement ( v ) then
						local pick2 = getElementData ( v, "pick2")
						if isElement ( pick2 ) then
							destroyElement ( pick2 )
						end
						local icon = getElementData ( v, "icon" )
						if isElement ( icon ) then
							destroyElement ( icon )
						end
						destroyElement ( v )
					end
				end
				triggerServerEvent ( "finitoWork_kop", localPlayer )
				setElementData ( localPlayer, "kop_working", false )
				outputChatBox ( "Você terminou o trabalho", 255, 255, 255, true )
			end
        end
    end
)

function clientPickupHit(thePlayer, matchingDimension)
	if thePlayer == localPlayer and getElementData ( source, "kop_pickup" ) and not getElementData ( source, "taken" ) then
		setElementData ( source, "taken", true )
					setElementVelocity ( getPedOccupiedVehicle(localPlayer), 0, 0, 0 )
					toggleAllControls ( false, true, false )
					setTimer ( finishBoarding, 5000, 1 )
					outputChatBox("Entrega está em andamento", 0,153,51)
					setElementData ( localPlayer, "kop_pickup", 2 )
		local hitted = getElementData ( localPlayer, "kop_working_hit" ) or 0
		hitted = hitted+1
		local pick2 = getElementData ( source, "pick2" )
		if isElement ( pick2 ) then
			destroyElement ( pick2 )
		end
		local icon = getElementData ( source, "icon" )
		if isElement ( icon ) then
			destroyElement ( icon )
		end
		destroyElement(source)
		setElementData ( localPlayer, "kop_working_hit", hitted)
		if hitted >= max_pickups then
			for i, v in ipairs ( createdPickups ) do
				if isElement ( v ) then
					local pick2 = getElementData ( v, "pick2")
					if isElement ( pick2 ) then
						destroyElement ( pick2 )
					end
					local icon = getElementData ( v, "icon" )
					if isElement ( icon ) then
						destroyElement ( icon )
					end
					destroyElement ( v )
				end
			end
			setElementData ( localPlayer, "kop_working", false )
			triggerServerEvent ( "finitoWork_kop", localPlayer )
			outputChatBox ( "Você terminou o trabalho, espere", 255, 255, 255, true )
			return true
		end
		if createdPickups[hitted+1] then
			local icon = createBlipAttachedTo ( createdPickups[hitted+1], 41, 2 )
			setElementData ( createdPickups[hitted+1], "icon", icon )
		end
	end
end

function finishBoarding ()
	toggleAllControls ( true, true, true )
			outputChatBox ( "você entregou pizza, sua recompensa é de R$ 250 ", 255, 100, 100, true )
			triggerServerEvent ( "giveMoneyFromClient_kop", localPlayer, 250 ) --VALOR MONEY PRA DAR
				setElementPosition ( trailer, bases[getElementData ( localPlayer, "nearestBase" )][1], bases[getElementData ( localPlayer, "nearestBase" )][2], bases[getElementData ( localPlayer, "nearestBase" )][3] )
end
addEventHandler ( "onClientMarkerHit", getRootElement(), clientPickupHit )






 

Edited by AsianBR
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...