Jump to content

ajuda nas plantações


Recommended Posts

obs: eu sei que eu postei este post em ingles e acho que ninguem pode me ajudar então decidi tentar aki, desculpem por em comodar.

como funciona script:

  • Primeiro um contador é criado, para calcular as plantas que foram adicionadas com o comando / d
  • Só é possível plantar se você estiver na Zona
  • Para cada planta que é adicionada, uma verificação é feita para ver se ela ainda não forneceu o total = 2
  • se igual a 2 então ativará a função para completar a missão
  • onde ele irá ativar um gatilho que irá destruir os elementos, Onde estou com problemas?
  • Você poderia me ajudar aqui?

Estou desenvolvendo uma missão de plantio, tenho um problema em destruir elemento

  • Está apenas destruindo o último a ser plantado
  • se outro jogador fizer ao mesmo tempo destruir o do outro jogador
  • Eu queria que a destruição das plantas funcionasse individualmente, tipo se 2 jogadores estão fazendo e 1 jogador completo remove apenas o seu

Obrigado antecipadamente, ?

Lado do server

local plants = {}

function iniciarFarm8 ( x, y, z )

    animation = setPedAnimation(source, "medic", "CPR", -1, false, false, false, false)
    setTimer(function()
      plants[client] = createObject ( 862, x , y , z - 1 , 0, 0, 0 )
    end, 6500, 1)
    
end
addEvent ("iniciaJob8", true) 
addEventHandler ("iniciaJob8", getRootElement(), iniciarFarm8)

function plantDestroy (source)
    destroyElement ( plants[client] )
end
addEvent ("onDestroyElement", true) 
addEventHandler ("onDestroyElement", getRootElement(), plantDestroy)

Lado do client

plantsPoints = 0

function inicio8 ( )
	
	local retanguloParaPlantio = createColRectangle ( 209.52605, 1906.70947, 155, 155 )
	hillRadar = createRadarArea ( 209.52605, 1906.70947, 155, 155, 0, 255, 0, 175 )
	
	addEventHandler("onClientColShapeHit", retanguloParaPlantio, function ( theElement, matchingDimension )
		if ( theElement == localPlayer ) then 
			function plant ()	
				local block, anim = getPedAnimation( localPlayer ) 
				if ( not( block == "medic" and  anim == "CPR" ) ) then 
					local x, y, z = getElementPosition ( localPlayer ) 
					triggerServerEvent ("iniciaJob8", localPlayer, x, y, z )			
					setTimer(function() 
						plantsPoints = plantsPoints+1 
						outputChatBox( "Foi plantado  "..(plantsPoints).."/2" )
						
						if plantsPoints >= 2 then 
							completMission() 
						end
					end, 6500, 1)

				else
					outputChatBox (" voçê deve esperar 6 sec para plantar novamente " )
				end	
			end
			addCommandHandler ( "d", plant )
		end
	end )
	
	addEventHandler("onClientColShapeLeave", retanguloParaPlantio, function ( theElement, matchingDimension )
		if ( theElement == localPlayer ) then 
			outputChatBox( "nop Function." )
			removeCommandHandler ( "d", plant )
		end
	end )

end

function completMission ()
	outputChatBox ("voçê plantou todos")
	plantsPoints = 0
	destroyElement ( hillRadar )
	triggerServerEvent ( "onDestroyElement", localPlayer )
end

 

Link to comment
plantsPoints = 0

function inicio8 ( )
	
	local retanguloParaPlantio = createColRectangle ( 209.52605, 1906.70947, 155, 155 )
	hillRadar = createRadarArea ( 209.52605, 1906.70947, 155, 155, 0, 255, 0, 175 )
	
	addEventHandler("onClientColShapeHit", retanguloParaPlantio, function ( theElement, matchingDimension )
		if ( theElement == localPlayer ) then 
			function plant ()	
				local block, anim = getPedAnimation( localPlayer ) 
				if ( not( block == "medic" and  anim == "CPR" ) ) then 
					local x, y, z = getElementPosition ( localPlayer ) 
					triggerServerEvent ("iniciaJob8", localPlayer, localPlayer, x, y, z )			
					setTimer(function() 
						plantsPoints = plantsPoints+1 
						outputChatBox( "Foi plantado  "..(plantsPoints).."/2" )
						
						if plantsPoints >= 2 then 
							completMission() 
						end
					end, 6500, 1)

				else
					outputChatBox (" voçê deve esperar 6 sec para plantar novamente " )
				end	
			end
			addCommandHandler ( "d", plant )
		end
	end )
	
	addEventHandler("onClientColShapeLeave", retanguloParaPlantio, function ( theElement, matchingDimension )
		if ( theElement == localPlayer ) then 
			outputChatBox( "nop Function." )
			removeCommandHandler ( "d", plant )
		end
	end )

end
addEventHandler("onClientResourceStart", resourceRoot, inicio8)

function completMission ()
	outputChatBox ("voçê plantou todos")
	plantsPoints = 0
	destroyElement ( hillRadar )
	triggerServerEvent ( "onDestroyElement", localPlayer, localPlayer )
end

 

local plants = {}

function iniciarFarm8 ( client, x, y, z )

    animation = setPedAnimation(source, "medic", "CPR", -1, false, false, false, false)
    setTimer(function()
      plants[client] = createObject ( 862, x , y , z - 1 , 0, 0, 0 )
    end, 6500, 1)
    
end
addEvent ("iniciaJob8", true) 
addEventHandler ("iniciaJob8", getRootElement(), iniciarFarm8)

function plantDestroy (source)
    destroyElement ( plants[source] )
end
addEvent ("onDestroyElement", true) 
addEventHandler ("onDestroyElement", getRootElement(), plantDestroy)

Tente desse jeito.

Coloquei onClientResourceStart apenas para a função ser startada, pois, ela não estava sendo chamada, em nenhuma outra :)

Edited by zMpyster
Link to comment
3 hours ago, kevincouto6 said:

 A função e iniada por guiwindonclient.lua, que esta em outra notePaf

inicia8 ()

Testei o jeito que voçê falou mais ainda sim não e possivel destruir todos os objetos que foram criados 

ah, não percebi que vc queria destruir todos os objetos :/. Você não está conseguindo pois plants tem o valor de createObject, ai dps o valor que tinha da outra planta é substituido por o outro createObject, entende?

tente usar dessa forma

local plants = {}
local plants1 = {}

function iniciarFarm8 ( client, x, y, z )

    animation = setPedAnimation(source, "medic", "CPR", -1, false, false, false, false)
    setTimer(function()
      	if plants[client] then
        plants1[client] = createObject ( 862, x , y , z - 1 , 0, 0, 0 )
        else
      	plants[client] = createObject ( 862, x , y , z - 1 , 0, 0, 0 )
        end
    end, 6500, 1)
    
end
addEvent ("iniciaJob8", true) 
addEventHandler ("iniciaJob8", getRootElement(), iniciarFarm8)

function plantDestroy (source)
    destroyElement ( plants[source] )
    destroyElement ( plant1[source] )
end
addEvent ("onDestroyElement", true) 
addEventHandler ("onDestroyElement", getRootElement(), plantDestroy)

Se no caso sempre que for destruir, destruir as duas, então não precisa da verificação pra ver se n é nulo

Link to comment
19 hours ago, zMpyster said:

 

Lado Server

function plantDestroy ( thePlayer )
	for id, plant in ipairs(getElementsByType("object")) do 
		if getElementModel( plant ) == 862 then
			destroyElement ( plant )
		end
	end 

end
addEvent ("onDestroyElement", true) 
addEventHandler ("onDestroyElement", getRootElement(), plantDestroy)

Este formato destroy todos, porem ate o dos outros players que estão na missão, saberia como posso fazer para especificar que é pra destruir apenas as que eu plantei não a dos outros

Edited by kevincouto6
Link to comment
11 minutes ago, kevincouto6 said:

Este formato destroy todos, porem ate o dos outros players que estão na missão, saberia como posso fazer para especificar que é pra destruir apenas as que eu plantei não a dos outros

Teste dessa forma

function plantDestroy ( thePlayer )
	if plant[thePlayer] and isElement(plant[thePlayer]) and getElementModel( plant[thePlayer ) == 862 then
		destroyElement ( plant[thePlayer )
	end 
end
addEvent ("onDestroyElement", true) 
addEventHandler ("onDestroyElement", getRootElement(), plantDestroy)
Edited by zMpyster
Link to comment
17 minutes ago, zMpyster said:

Teste dessa forma


function plantDestroy ( thePlayer )
	if plant[thePlayer] and isElement(plant[thePlayer]) and getElementModel( plant[thePlayer ) == 862 then
		destroyElement ( plant[thePlayer )
	end 
end
addEvent ("onDestroyElement", true) 
addEventHandler ("onDestroyElement", getRootElement(), plantDestroy)

 for id, plant in ipairs(getElementsByType("object")) do 

end

porem sem esta parte ele remove apenas a ultima planta,  tem um modo de juntar as duas será ?

Link to comment
1 minute ago, kevincouto6 said:

 for id, plant in ipairs(getElementsByType("object")) do 

end

porem sem esta parte ele remove apenas a ultima planta,  tem um modo de juntar as duas será ?

Você esta usando meu exemplo da parte de cima? se estiver faça dessa forma


function plantDestroy ( thePlayer )
	if plants[thePlayer] and isElement(plants[thePlayer]) and getElementModel( plants[thePlayer ) == 862 then
		destroyElement ( plants[thePlayer )
	end 
 	if plants1[thePlayer] and isElement(plants1[thePlayer]) and getElementModel( plants1[thePlayer ) == 862 then
		destroyElement ( plants1[thePlayer )
    end
end
addEvent ("onDestroyElement", true) 
addEventHandler ("onDestroyElement", getRootElement(), plantDestroy)

 

Link to comment
local plant = {}

function iniciarFarm8 ( x, y, z )
	
	setElementData( client, "Trabalho8", true, false )
	
	plant[client] = createObject ( 862, x , y , z - 1 , 0, 0, 0 )


end
addEvent ("iniciaJob8", true) 
addEventHandler ("iniciaJob8", getRootElement(), iniciarFarm8)

function plantDestroy ( thePlayer )
	local thePlayer = client
	if plant[thePlayer] and isElement(plant[thePlayer]) and getElementModel( plant[thePlayer] ) == 862 then
		for thePlayer, plant in ipairs(getElementsByType("object")) do 
			destroyElement ( plant )
		end
	end 
	
end
addEvent ("onDestroyElement", true) 
addEventHandler ("onDestroyElement", getRootElement(), plantDestroy)

Estou usando desta forma, assim posso criar varias, e remover todos porem remove a dos outros jogadores tambem, preciso que seja removido apenas a minha

Link to comment
5 minutes ago, kevincouto6 said:

local plant = {}

function iniciarFarm8 ( x, y, z )
	
	setElementData( client, "Trabalho8", true, false )
	
	plant[client] = createObject ( 862, x , y , z - 1 , 0, 0, 0 )


end
addEvent ("iniciaJob8", true) 
addEventHandler ("iniciaJob8", getRootElement(), iniciarFarm8)

function plantDestroy ( thePlayer )
	local thePlayer = client
	if plant[thePlayer] and isElement(plant[thePlayer]) and getElementModel( plant[thePlayer] ) == 862 then
		for thePlayer, plant in ipairs(getElementsByType("object")) do 
			destroyElement ( plant )
		end
	end 
	
end
addEvent ("onDestroyElement", true) 
addEventHandler ("onDestroyElement", getRootElement(), plantDestroy)

Estou usando desta forma, assim posso criar varias, e remover todos porem remove a dos outros jogadores tambem, preciso que seja removido apenas a minha

Use desta forma

local plants = {}
local plants1 = {}

function iniciarFarm8 ( client, x, y, z )  
      	if plants[client] then
        plants1[client] = createObject ( 862, x , y , z - 1 , 0, 0, 0 )
    	setElementData( client, "Trabalho8", true, false )
        animation = setPedAnimation(source, "medic", "CPR", -1, false, false, false, false)
        else
      	plants[client] = createObject ( 862, x , y , z - 1 , 0, 0, 0 )
    	setElementData( client, "Trabalho8", true, false )
        animation = setPedAnimation(source, "medic", "CPR", -1, false, false, false, false)
        end    
end
addEvent ("iniciaJob8", true) 
addEventHandler ("iniciaJob8", getRootElement(), iniciarFarm8)

edit: Não se esqueça de quando usar o triggeClientEvent ou triggerEvent, de colocar todas as variáveis que se pede (client, x, y, z)

Edited by zMpyster
Link to comment
12 minutes ago, kevincouto6 said:

será que esta é a unica fora, tipo a missão vai ser plantar +-- 50 plantas, vou ter que criar para as 50, ou será que tem outra forma, estou usando 2 apenas para test 

local plants = {}
local plants1 = {}
local indexPl = {}

function iniciarFarm8 ( client, x, y, z )  
  	if not indexPl[client] then
    	indexPl[client] = 1    
  		indexPl[client] = indexPl[client] + 1
		plants[client][indexPl[client]] = createObject ( 862, x , y , z - 1 , 0, 0, 0 )
    	setElementData( client, "Trabalho8", true, false )
   	    animation = setPedAnimation(source, "medic", "CPR", -1, false, false, false, false)   
    end
end
addEvent ("iniciaJob8", true) 
addEventHandler ("iniciaJob8", getRootElement(), iniciarFarm8)

function plantDestroy ( thePlayer )
	if plant[thePlayer][indexPl[thePlayer]] and isElement(plant[thePlayer][indexPl[thePlayer]]) and getElementModel( plant[thePlayer][indexPl[thePlayer]] ) == 862 then
			destroyElement ( plant[thePlayer][indexPl[thePlayer]] )
		end	
end
addEvent ("onDestroyElement", true) 
addEventHandler ("onDestroyElement", getRootElement(), plantDestroy)

Tenta assim, não testei o mod, por isso não sei se tem algum erro.

Edited by zMpyster
Link to comment
3 hours ago, zMpyster said:

Tenta assim, não testei o mod, por isso não sei se tem algum erro.

Não funcionou, omg eu estou ficando louco XD

* primeiro ele não encontra o valor X

*então removi o Cliente de (client, x, y,z )

* ai fica dizendo ( attemple to index field '?' (a nil value )

mas não vou desistir tem alguma ideia do que fazer ?

Link to comment
1 hour ago, kevincouto6 said:

Não funcionou, omg eu estou ficando louco XD

* primeiro ele não encontra o valor X

*então removi o Cliente de (client, x, y,z )

* ai fica dizendo ( attemple to index field '?' (a nil value )

mas não vou desistir tem alguma ideia do que fazer ?

O erro ta sendo no trigger, recomendo que mande essa parte

Link to comment
1 hour ago, zMpyster said:

O erro ta sendo no trigger, recomendo que mande essa parte

 

Aki esta os dois lados

guiWindonClient.lua ( client - side )

a parte que inicia8 é esta, botei apenas um pedaço

		elseif (guiGridListGetSelectedItem(ListMissions) == 2) then
        outputDebugString("2 was selected")
		inicio8 ()
		guiSetVisible (WinMission, me)
		showCursor (me)
			for wnd, id in pairs(elementos.window) do
				guiSetVisible (wnd, false)
			end

Client-side

plantsPoints = 0

function inicio8 ( )
	
	local retanguloParaPlantio = createColRectangle ( 209.52605, 1906.70947, 155, 155 )
	hillRadar = createRadarArea ( 209.52605, 1906.70947, 155, 155, 0, 255, 0, 175 )
	
	addEventHandler("onClientColShapeHit", retanguloParaPlantio, function ( theElement, matchingDimension )
		if ( theElement == localPlayer ) then 
			function plant ( thePlayer )	
				local block, anim = getPedAnimation( localPlayer ) 
				if ( not( block == "medic" and  anim == "CPR" ) ) then 
					if ( thePlayer ) then
						local x, y, z = getElementPosition ( localPlayer ) 
						triggerServerEvent ("iniciaJob8", localPlayer, x, y, z )
						
							--setTimer(function() 
								plantsPoints = plantsPoints+1 
								outputChatBox( "Foi plantado  "..(plantsPoints).."/2" )
								
								if plantsPoints >= 2 then
									if ( thePlayer ) then
										if plantsPoints >= 2 then
											outputChatBox ("voçê plantou todos")
											plantsPoints = 0
											destroyElement ( hillRadar )
											triggerServerEvent ( "onDestroyElement", localPlayer )
										end
									end
								end
							--end, 6500, 1)
					end
				else
					outputChatBox (" voçê deve esperar 6 sec para plantar novamente " )
				end	
			end
			addCommandHandler ( "d", plant )
		end
	end )
	
	addEventHandler("onClientColShapeLeave", retanguloParaPlantio, function ( theElement, matchingDimension )
		if ( theElement == localPlayer ) then 
			outputChatBox( "nop Function." )
			removeCommandHandler ( "d", plant )
		end
	end )

end

Server-side 

local plants = {}
local plants1 = {}
local indexPl = {}

function iniciarFarm8 ( client, x, y, z )  
  	if not indexPl[client] then
    	indexPl[client] = 1    
  		indexPl[client] = indexPl[client] + 1
		plants[client][indexPl[client]] = createObject ( 862, x , y , z - 1 , 0, 0, 0 )
    	setElementData( client, "Trabalho8", true, false )
   	    animation = setPedAnimation(source, "medic", "CPR", -1, false, false, false, false)   
    end
end
addEvent ("iniciaJob8", true) 
addEventHandler ("iniciaJob8", getRootElement(), iniciarFarm8)

function plantDestroy ( thePlayer )
	if plant[thePlayer][indexPl[thePlayer]] and isElement(plant[thePlayer][indexPl[thePlayer]]) and getElementModel( plant[thePlayer][indexPl[thePlayer]] ) == 862 then
			destroyElement ( plant[thePlayer][indexPl[thePlayer]] )
		end	
end
addEvent ("onDestroyElement", true) 
addEventHandler ("onDestroyElement", getRootElement(), plantDestroy)

 

Edited by kevincouto6
Link to comment
26 minutes ago, kevincouto6 said:

 

Aki esta os dois lados

guiWindonClient.lua ( client - side )

a parte que inicia8 é esta, botei apenas um pedaço


		elseif (guiGridListGetSelectedItem(ListMissions) == 2) then
        outputDebugString("2 was selected")
		inicio8 ()
		guiSetVisible (WinMission, me)
		showCursor (me)
			for wnd, id in pairs(elementos.window) do
				guiSetVisible (wnd, false)
			end

Client-side


plantsPoints = 0

function inicio8 ( )
	
	local retanguloParaPlantio = createColRectangle ( 209.52605, 1906.70947, 155, 155 )
	hillRadar = createRadarArea ( 209.52605, 1906.70947, 155, 155, 0, 255, 0, 175 )
	
	addEventHandler("onClientColShapeHit", retanguloParaPlantio, function ( theElement, matchingDimension )
		if ( theElement == localPlayer ) then 
			function plant ( thePlayer )	
				local block, anim = getPedAnimation( localPlayer ) 
				if ( not( block == "medic" and  anim == "CPR" ) ) then 
					if ( thePlayer ) then
						local x, y, z = getElementPosition ( localPlayer ) 
						triggerServerEvent ("iniciaJob8", localPlayer, x, y, z )
						
							--setTimer(function() 
								plantsPoints = plantsPoints+1 
								outputChatBox( "Foi plantado  "..(plantsPoints).."/2" )
								
								if plantsPoints >= 2 then
									if ( thePlayer ) then
										if plantsPoints >= 2 then
											outputChatBox ("voçê plantou todos")
											plantsPoints = 0
											destroyElement ( hillRadar )
											triggerServerEvent ( "onDestroyElement", localPlayer )
										end
									end
								end
							--end, 6500, 1)
					end
				else
					outputChatBox (" voçê deve esperar 6 sec para plantar novamente " )
				end	
			end
			addCommandHandler ( "d", plant )
		end
	end )
	
	addEventHandler("onClientColShapeLeave", retanguloParaPlantio, function ( theElement, matchingDimension )
		if ( theElement == localPlayer ) then 
			outputChatBox( "nop Function." )
			removeCommandHandler ( "d", plant )
		end
	end )

end

Server-side 


local plants = {}
local plants1 = {}
local indexPl = {}

function iniciarFarm8 ( client, x, y, z )  
  	if not indexPl[client] then
    	indexPl[client] = 1    
  		indexPl[client] = indexPl[client] + 1
		plants[client][indexPl[client]] = createObject ( 862, x , y , z - 1 , 0, 0, 0 )
    	setElementData( client, "Trabalho8", true, false )
   	    animation = setPedAnimation(source, "medic", "CPR", -1, false, false, false, false)   
    end
end
addEvent ("iniciaJob8", true) 
addEventHandler ("iniciaJob8", getRootElement(), iniciarFarm8)

function plantDestroy ( thePlayer )
	if plant[thePlayer][indexPl[thePlayer]] and isElement(plant[thePlayer][indexPl[thePlayer]]) and getElementModel( plant[thePlayer][indexPl[thePlayer]] ) == 862 then
			destroyElement ( plant[thePlayer][indexPl[thePlayer]] )
		end	
end
addEvent ("onDestroyElement", true) 
addEventHandler ("onDestroyElement", getRootElement(), plantDestroy)

 

triggerServerEvent ("iniciaJob8", localPlayer, localPlayer, x, y, z )
triggerServerEvent ( "onDestroyElement", localPlayer, localPlayer )

Coloca esses trigger no lugar para ver

 

Edited by zMpyster
Link to comment
20 minutes ago, zMpyster said:

Eu não sei nem como está removendo a ultima, o código de destruir o elemento esta com "plant", sendo que o que foi criado foi "plants", tenta mudar isso.

Acabei de faze-lo criei o objeto como plant não funcionou 

então tentei destruir if plants[thePlayer][indexPl[thePlayer]]  e ainda não funcionou, mds estou ficando louco, hheheh, 

Link to comment
12 minutes ago, kevincouto6 said:

Acabei de faze-lo criei o objeto como plant não funcionou 

então tentei destruir if plants[thePlayer][indexPl[thePlayer]]  e ainda não funcionou, mds estou ficando louco, hheheh, 

Use o debugscript, e fale o erro, fica ruim de resolve-lo sem saber aonde é

Link to comment

gui_Windon_Mission.lua ( client-side )

-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
-------------------------------------------------------------------------------------Panel Gui Missions--------------------------------------------------------------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

GUIEditor = {
    gridlist = {},
    window = {},
    button = {}
}
addEventHandler("onClientResourceStart", resourceRoot,
	function ()
        WinMission = guiCreateWindow(374, 156, 594, 329, "Mission ZHP", false)
		guiSetVisible (WinMission, false )
        guiWindowSetSizable(WinMission, false)

        accepted = guiCreateButton(12, 236, 180, 34, "ACCEPTED", false, WinMission)
        info = guiCreateButton(207, 236, 180, 34, "INFO", false, WinMission)
        abandon = guiCreateButton(397, 236, 180, 34, "ABANDON", false, WinMission)
        ListMissions = guiCreateGridList(12, 36, 565, 190, false, WinMission)
		guiGridListSetSortingEnabled ( ListMissions, false )
        guiGridListAddColumn(ListMissions, "MISSION", 0.9)
        for i = 1, 11 do
            guinumeber = guiGridListAddRow(ListMissions)
        end
        guiGridListSetItemText(ListMissions, 0, 1, "Mission Plants", false, false)
        guiGridListSetItemText(ListMissions, 1, 1, "-", false, false)
        guiGridListSetItemText(ListMissions, 2, 1, "-", false, false)
        guiGridListSetItemText(ListMissions, 3, 1, "-", false, false)
        guiGridListSetItemText(ListMissions, 4, 1, "-", false, false)
        guiGridListSetItemText(ListMissions, 5, 1, "-", false, false)
        guiGridListSetItemText(ListMissions, 6, 1, "-", false, false)
        guiGridListSetItemText(ListMissions, 7, 1, "-", false, false)
		guiGridListSetItemText(ListMissions, 8, 1, "-", false, false)
        guiGridListSetItemText(ListMissions, 9, 1, "-", false, false)
        guiGridListSetItemText(ListMissions, 10, 1, "-", false, false)
		
        Buttonexit = guiCreateButton(10, 276, 567, 43, "EXIT", false, WinMission)    
	end
)

-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------Memo info Mission--------------------------------------------------------------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

local janelas = {
	{
		titulo = "Mission Description",
		memo = "You must kill 50 zombies in area 51\n\n \n             Reward\nMoney: R$ 5,000.00 \nEXP : 3555 "
	}
}

-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
-------------------------------------------------------------------------------------Info Missios--------------------------------------------------------------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------


local elementos = {
	window = {},
	btns = {},
}

addEventHandler("onClientResourceStart", resourceRoot,
    function()
		for i,janela in ipairs(janelas) do
			wnd = guiCreateWindow(939, 156, 196, 329, janela.titulo, false)
			elementos.window[wnd] = i-1
			guiSetVisible (wnd, false)
			guiWindowSetSizable(wnd, false)
		
			guiCreateMemo(9, 32, 175, 196, janela.memo, false, wnd)
			
			btnExit = guiCreateButton(10, 280, 174, 40, "EXIT", false, wnd)
			btnCopy = guiCreateButton(9, 233, 175, 37, "COPY", false, wnd)
			elementos.btns[btnExit] = {wnd,"exit"}
			elementos.btns[btnCopy] = {wnd,"copy"}
		end
 
    end
)

addEventHandler ("onClientGUIClick", resourceRoot, function (button, state, absoluteX, absoluteY)
	if (elementos.btns[source]) then
		if (elementos.btns[source][2] == "exit") then
			guiSetVisible (elementos.btns[source][1], false)
		end
	end
end)

addEventHandler ("onClientGUIClick", resourceRoot, function (button, state, absoluteX, absoluteY)
	if (source == info) then
		for wnd, id in pairs(elementos.window) do
			if (id == guiGridListGetSelectedItem(ListMissions)) then
				guiSetVisible (wnd, true)
			else
				guiSetVisible (wnd, false)
			end
		end
	end
end)

-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------Local Marker points--------------------------------------------------------------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

--if you want add Marker# {},
Mark = {
{225.38281, 1905.20300, 17.64063},
}
--Marker
local Marker1 = createMarker(225.38281, 1905.20300, 17.64063, "cylinder", 1.5, 250,250,0)

for k,v in ipairs (Mark) do
z = v[3] -1
Marker = createMarker ( v[1], v[2], z, "cylinder", 1.5,  255, 255, 0, 255 )
addEventHandler('onClientMarkerHit', Marker,
    function ( hitPlayer )
        if ( hitPlayer == localPlayer ) then
            guiSetVisible (WinMission, true )
            showCursor( true )
        end
    end
)
end

-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------Accepted Mission--------------------------------------------------------------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------


addEventHandler ("onClientGUIClick", getRootElement(), 
  function (button, state, absoluteX, absoluteY)
    outputDebugString("onClientGUIClick called.") 

    local me = not guiGetVisible (WinMission)
    if (source == accepted) then
      outputDebugString("guiGridListGetSelectedItem(ListMissions): "..guiGridListGetSelectedItem(ListMissions))

      if (guiGridListGetSelectedItem(ListMissions) == 0) then 
        outputDebugString("1 was selected")
		inicio8 ()
		guiSetVisible (WinMission, me)
		showCursor (me)
      end
    end
  end
)
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
-------------------------------------------------------------------------------------Button EXIT --------------------------------------------------------------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

addEventHandler ("onClientGUIClick", getRootElement(), function (button, state, absoluteX, absoluteY)
	if (source == Buttonexit) then
		guiSetVisible (WinMission, false)
			for wnd, id in pairs(elementos.window) do
				guiSetVisible (wnd, false)
			end
		showCursor (false)
	end
end)

client_mission.lua ( client-side )


plantsPoints = 0

function inicio8 ( )
	
	local retanguloParaPlantio = createColRectangle ( 209.52605, 1906.70947, 155, 155 )
	hillRadar = createRadarArea ( 209.52605, 1906.70947, 155, 155, 0, 255, 0, 175 )
	
	addEventHandler("onClientColShapeHit", retanguloParaPlantio, function ( theElement, matchingDimension )
		if ( theElement == localPlayer ) then 
			function plant ()	
				local block, anim = getPedAnimation( localPlayer ) 
				if ( not( block == "medic" and  anim == "CPR" ) ) then 
					local x, y, z = getElementPosition ( localPlayer ) 
					triggerServerEvent ("iniciaJob8", localPlayer, localPlayer, x, y, z )			
					setTimer(function() 
						plantsPoints = plantsPoints+1 
						outputChatBox( "Foi plantado  "..(plantsPoints).."/2" )
						
						if plantsPoints >= 2 then 
							triggerServerEvent ( "onDestroyElement", localPlayer, localPlayer )
							outputChatBox ("voçê plantou todos")
							plantsPoints = 0
							destroyElement ( hillRadar )
						end
					end, 6500, 1)

				else
					outputChatBox (" voçê deve esperar 6 sec para plantar novamente " )
				end	
			end
			addCommandHandler ( "d", plant )
		end
	end )
	
	addEventHandler("onClientColShapeLeave", retanguloParaPlantio, function ( theElement, matchingDimension )
		if ( theElement == localPlayer ) then 
			outputChatBox( "nop Function." )
			removeCommandHandler ( "d", plant )
		end
	end )

end

server_mission.lua ( server-side )

 
local plant = {}
local plants1 = {}
local indexPl = {}

function iniciarFarm8 ( client, x, y, z )  
  	if not indexPl[client] then
    	indexPl[client] = 1    
  		indexPl[client] = indexPl[client] + 1
		plant[client][indexPl[client]] = createObject ( 862, x , y , z - 1 , 0, 0, 0 )
    	setElementData( client, "Trabalho8", true, false )
   	    animation = setPedAnimation(source, "medic", "CPR", -1, false, false, false, false)   
    end
end
addEvent ("iniciaJob8", true) 
addEventHandler ("iniciaJob8", getRootElement(), iniciarFarm8)

function plantDestroy ( thePlayer )
	if plant[thePlayer][indexPl[thePlayer]] and isElement(plant[thePlayer][indexPl[thePlayer]]) and getElementModel( plant[thePlayer][indexPl[thePlayer]] ) == 862 then
			destroyElement ( plant[thePlayer][indexPl[thePlayer]] )
		end	
end
addEvent ("onDestroyElement", true) 
addEventHandler ("onDestroyElement", getRootElement(), plantDestroy)

meta.xml

<meta>
	<script src="gui_Windon_Mission.lua" type="client"/>
	<script src="client_mission.lua" type="client" />
	<script src="server_mission.lua" type="server" />
</meta>

 

aki esta todo o script @DNL291 e @zMpyster

Edited by kevincouto6
Link to comment
28 minutes ago, kevincouto6 said:

gui_Windon_Mission.lua ( client-side )


------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------Panel Gui Missions-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------GUIEditor = {    gridlist = {},    window = {},    button = {}}addEventHandler("onClientResourceStart", resourceRoot,	function ()        WinMission = guiCreateWindow(374, 156, 594, 329, "Mission ZHP", false)		guiSetVisible (WinMission, false )        guiWindowSetSizable(WinMission, false)        accepted = guiCreateButton(12, 236, 180, 34, "ACCEPTED", false, WinMission)        info = guiCreateButton(207, 236, 180, 34, "INFO", false, WinMission)        abandon = guiCreateButton(397, 236, 180, 34, "ABANDON", false, WinMission)        ListMissions = guiCreateGridList(12, 36, 565, 190, false, WinMission)		guiGridListSetSortingEnabled ( ListMissions, false )        guiGridListAddColumn(ListMissions, "MISSION", 0.9)        for i = 1, 11 do            guinumeber = guiGridListAddRow(ListMissions)        end        guiGridListSetItemText(ListMissions, 0, 1, "Mission Plants", false, false)        guiGridListSetItemText(ListMissions, 1, 1, "-", false, false)        guiGridListSetItemText(ListMissions, 2, 1, "-", false, false)        guiGridListSetItemText(ListMissions, 3, 1, "-", false, false)        guiGridListSetItemText(ListMissions, 4, 1, "-", false, false)        guiGridListSetItemText(ListMissions, 5, 1, "-", false, false)        guiGridListSetItemText(ListMissions, 6, 1, "-", false, false)        guiGridListSetItemText(ListMissions, 7, 1, "-", false, false)		guiGridListSetItemText(ListMissions, 8, 1, "-", false, false)        guiGridListSetItemText(ListMissions, 9, 1, "-", false, false)        guiGridListSetItemText(ListMissions, 10, 1, "-", false, false)		        Buttonexit = guiCreateButton(10, 276, 567, 43, "EXIT", false, WinMission)    	end)--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------Memo info Mission-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------local janelas = {	{		titulo = "Mission Description",		memo = "You must kill 50 zombies in area 51              RewardMoney: R$ 5,000.00 EXP : 3555 "	}}------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------Info Missios-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------local elementos = {	window = {},	btns = {},}addEventHandler("onClientResourceStart", resourceRoot,    function()		for i,janela in ipairs(janelas) do			wnd = guiCreateWindow(939, 156, 196, 329, janela.titulo, false)			elementos.window[wnd] = i-1			guiSetVisible (wnd, false)			guiWindowSetSizable(wnd, false)					guiCreateMemo(9, 32, 175, 196, janela.memo, false, wnd)						btnExit = guiCreateButton(10, 280, 174, 40, "EXIT", false, wnd)			btnCopy = guiCreateButton(9, 233, 175, 37, "COPY", false, wnd)			elementos.btns[btnExit] = {wnd,"exit"}			elementos.btns[btnCopy] = {wnd,"copy"}		end     end)addEventHandler ("onClientGUIClick", resourceRoot, function (button, state, absoluteX, absoluteY)	if (elementos.btns[source]) then		if (elementos.btns[source][2] == "exit") then			guiSetVisible (elementos.btns[source][1], false)		end	endend)addEventHandler ("onClientGUIClick", resourceRoot, function (button, state, absoluteX, absoluteY)	if (source == info) then		for wnd, id in pairs(elementos.window) do			if (id == guiGridListGetSelectedItem(ListMissions)) then				guiSetVisible (wnd, true)			else				guiSetVisible (wnd, false)			end		end	endend)-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------Local Marker points---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------if you want add Marker# {},Mark = {{225.38281, 1905.20300, 17.64063},}--Markerlocal Marker1 = createMarker(225.38281, 1905.20300, 17.64063, "cylinder", 1.5, 250,250,0)for k,v in ipairs (Mark) doz = v[3] -1Marker = createMarker ( v[1], v[2], z, "cylinder", 1.5,  255, 255, 0, 255 )addEventHandler('onClientMarkerHit', Marker,    function ( hitPlayer )        if ( hitPlayer == localPlayer ) then            guiSetVisible (WinMission, true )            showCursor( true )        end    end)end----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------Accepted Mission-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------addEventHandler ("onClientGUIClick", getRootElement(),   function (button, state, absoluteX, absoluteY)    outputDebugString("onClientGUIClick called.")     local me = not guiGetVisible (WinMission)    if (source == accepted) then      outputDebugString("guiGridListGetSelectedItem(ListMissions): "..guiGridListGetSelectedItem(ListMissions))      if (guiGridListGetSelectedItem(ListMissions) == 0) then         outputDebugString("1 was selected")		inicio8 ()		guiSetVisible (WinMission, me)		showCursor (me)      end    end  end)------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------Button EXIT -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------addEventHandler ("onClientGUIClick", getRootElement(), function (button, state, absoluteX, absoluteY)	if (source == Buttonexit) then		guiSetVisible (WinMission, false)			for wnd, id in pairs(elementos.window) do				guiSetVisible (wnd, false)			end		showCursor (false)	endend)

client_mission.lua ( client-side )


plantsPoints = 0function inicio8 ( )		local retanguloParaPlantio = createColRectangle ( 209.52605, 1906.70947, 155, 155 )	hillRadar = createRadarArea ( 209.52605, 1906.70947, 155, 155, 0, 255, 0, 175 )		addEventHandler("onClientColShapeHit", retanguloParaPlantio, function ( theElement, matchingDimension )		if ( theElement == localPlayer ) then 			function plant ()					local block, anim = getPedAnimation( localPlayer ) 				if ( not( block == "medic" and  anim == "CPR" ) ) then 					local x, y, z = getElementPosition ( localPlayer ) 					triggerServerEvent ("iniciaJob8", localPlayer, localPlayer, x, y, z )								setTimer(function() 						plantsPoints = plantsPoints+1 						outputChatBox( "Foi plantado  "..(plantsPoints).."/2" )												if plantsPoints >= 2 then 							triggerServerEvent ( "onDestroyElement", localPlayer, localPlayer )							outputChatBox ("voçê plantou todos")							plantsPoints = 0							destroyElement ( hillRadar )						end					end, 6500, 1)				else					outputChatBox (" voçê deve esperar 6 sec para plantar novamente " )				end				end			addCommandHandler ( "d", plant )		end	end )		addEventHandler("onClientColShapeLeave", retanguloParaPlantio, function ( theElement, matchingDimension )		if ( theElement == localPlayer ) then 			outputChatBox( "nop Function." )			removeCommandHandler ( "d", plant )		end	end )end

server_mission.lua ( server-side )


 local plant = {}local plants1 = {}local indexPl = {}function iniciarFarm8 ( client, x, y, z )    	if not indexPl[client] then    	indexPl[client] = 1      		indexPl[client] = indexPl[client] + 1		plant[client][indexPl[client]] = createObject ( 862, x , y , z - 1 , 0, 0, 0 )    	setElementData( client, "Trabalho8", true, false )   	    animation = setPedAnimation(source, "medic", "CPR", -1, false, false, false, false)       endendaddEvent ("iniciaJob8", true) addEventHandler ("iniciaJob8", getRootElement(), iniciarFarm8)function plantDestroy ( thePlayer )	if plant[thePlayer][indexPl[thePlayer]] and isElement(plant[thePlayer][indexPl[thePlayer]]) and getElementModel( plant[thePlayer][indexPl[thePlayer]] ) == 862 then			destroyElement ( plant[thePlayer][indexPl[thePlayer]] )		end	endaddEvent ("onDestroyElement", true) addEventHandler ("onDestroyElement", getRootElement(), plantDestroy)

meta.xml


<meta>	<script src="gui_Windon_Mission.lua" type="client"/>	<script src="client_mission.lua" type="client" />	<script src="server_mission.lua" type="server" /></meta>

 

aki esta todo o script @DNL291 e @zMpyster

plantsPoints = 0

	local retanguloParaPlantio = createColRectangle ( 209.52605, 1906.70947, 155, 155 )
	hillRadar = createRadarArea ( 209.52605, 1906.70947, 155, 155, 0, 255, 0, 175 )
		
			function plant ()	
				local block, anim = getPedAnimation( localPlayer ) 
				if block and anim then
				if block == "medic" and anim == "CPR"  then 
					outputChatBox (" voçê deve esperar 6 sec para plantar novamente " )
				end	
				return end
						local x, y, z = getElementPosition ( localPlayer ) 
						triggerServerEvent ("iniciaJob8", localPlayer, localPlayer, x, y, z )
							setTimer(function() 
								plantsPoints = plantsPoints+1 
								outputChatBox( "Foi plantado  "..(plantsPoints).."/2" )
								
								if plantsPoints >= 2 then
										if plantsPoints >= 2 then
											outputChatBox ("voçê plantou todos")
											plantsPoints = 0
											destroyElement ( hillRadar )
											triggerServerEvent ( "onDestroyElement", localPlayer, localPlayer)
								end
								end
							end, 6500, 1)
			end
			addCommandHandler ( "d", plant )
			
			
	addEventHandler("onClientColShapeLeave", retanguloParaPlantio, function ( theElement, matchingDimension )
		if ( theElement == localPlayer ) then 
			outputChatBox( "nop Function." )
			removeCommandHandler ( "d", plant )
		end
	end )
local plants = {}
local plants1 = {}
local indexPl = {}
function iniciarFarm8 ( client, x, y, z ) 
  	if not indexPl[client] then
    	indexPl[client] = 1    
	end
  		indexPl[client] = indexPl[client] + 1
		plants[indexPl[client]] = createObject ( 862, x , y , z - 1 , 0, 0, 0 )
    	setElementData( client, "Trabalho8", true, false )
   	    animation = setPedAnimation(source, "medic", "CPR", -1, false, false, false, false) 
end
addEvent ("iniciaJob8", true) 
addEventHandler ("iniciaJob8", getRootElement(), iniciarFarm8)

function plantDestroy ( thePlayer )
	if plants[indexPl[client]]  and isElement(plants[indexPl[client]] ) and getElementModel(plants[indexPl[client]]  ) == 862 then
			destroyElement ( plants[indexPl[client]] )
		end	
end
addEvent ("onDestroyElement", true) 
addEventHandler ("onDestroyElement", getRootElement(), plantDestroy)

Ainda ta com alguns bugs, más, ai vc conserta


function plantDestroy ( thePlayer )
	if plants[indexPl[thePlayer]]  and isElement(plants[indexPl[thePlayer]] ) and getElementModel(plants[indexPl[thePlayer]]  ) == 862 then
	local numero = tonumber(indexPl[thePlayer])
	for i=1,numero do
			destroyElement ( plants[indexPl[thePlayer]] )
			indexPl[thePlayer] = indexPl[thePlayer] -1
	end
	end	
end
addEvent ("onDestroyElement", true) 
addEventHandler ("onDestroyElement", getRootElement(), plantDestroy)

Aqui está pra destruir todas as plantas

Edited by zMpyster
Link to comment
1 hour ago, zMpyster said:

 

OKay funcionou obrigado, porem 

 

o outro poblema e assim 

player 1 plantou 1 planta 

player 2 plantou 2 plantas e completou, as plantas dele foram destruidos tudo coretamente,

player1 apos o player 2 completar , player1 plantou e quando chegou na contidade total de 2, foi completar nãa destruiu todos.

espera que consiga me entender.

No debug aparece esse erro 

GUImission/server.lua:176: Bad argument @ 'destroyElement' [Expected element at argument 1, got nill]

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...