Jump to content

[Problemas]Script de Fabricar Armas


Recommended Posts

Olá pessoal do forúm hoje venho com uma dúvida que não consigo resolver. vou explicar o script : O script é o seguinte , um cara que esteja nas acls "...." ele poderá entrar dentro de um interior para fabricar as armas , depois ele teria 3 markers para 3 etapas , fabricar , desenvolver , acabar . a primeira teria o custo de 5k , a segunda 3k e a terceira , 2k (para ele fazer a segunda ele precisaria já ter feito a primeira  , e para fazer a terçeira ele precisaria já ter feito a segunda) , enquanto ele estivesse fazendo as armas apareceria uma animação de ele mexendo na mesa, quando ele completasse todas a terceira etapa ele receberia um AK-47 com 30 balas. (edit: quando ele iniciasse uma fabricação esse processo demoraria 5 minutos só depois disso cancelaria a animação e daria por concluido)

Problemas:

Não estou conseguindo colocar a entrada do interior só para acl ,

Não achei a animação (sem problema)

Não estou conseguindo fazer esse esquema de , ele só poder fazer a segunda fase se já tiver feito a primeira e assim por diante

Edited by Renazz
Link to comment

1. Você esta criando o marker no client ou server?

2. O terceiro problema: Você deve setar uma data no jogador quando ele acabar a primeira e na segunda parte verificar essa data se ela existir prossegue senão existir retorna avisando o jogador que ele precisa fazer a primeira parte.

  • Thanks 1
Link to comment
Just now, Jonas^ said:

1. Você esta criando o marker no client ou server?

só sei usar server-side acho o client-side muito complicado

 

1 minute ago, Jonas^ said:

2. O terceiro problema: Você deve setar uma data no jogador quando ele acabar a primeira e na segunda parte verificar essa data se ela existir prossegue senão existir retorna avisando o jogador que ele precisa fazer a primeira parte.

como assim setar a data

Link to comment

 

4 minutes ago, Jonas^ said:

Vamos lá, mostre a parte do marker que acessa o interior primeiro.

traficoaentrar = createMarker(125.20397186279,-285.93417358398,0.578125, "cylinder", 1.3, 255,0,0, 50) ----- Marker de Entrar
traficoasair = createMarker (2807.6264648438,-1174.2368164063,1024.5703125 , "cylinder" , 1.3 , 255,0,0 , 50) ----- Marker de Sair
setElementDimension(traficoasair ,0) ---- Dimensão do Marker de Sair
setElementInterior(traficoasair ,8) ---- Interior da Marker de Sair

function teletraficoe (thePlayer)
	setElementPosition (thePlayer, 2807.8166503906,-1170.1173095703,1025.5703125)
	setElementInterior (thePlayer,8)
	setElementDimension (thePlayer,0)
end
addEventHandler ("onMarkerHit", traficoaentrar, teletraficoe)

function teletraficos (thePlayer)
	setElementPosition (thePlayer, 125.05652618408,-279.69366455078,1.578125)
	setElementInterior (thePlayer, 0)
	setElementDimension (thePlayer, 0)
end
addEventHandler ("onMarkerHit", traficoasair, teletraficos)

 

Edited by Renazz
functions
Link to comment

Isso não me adianta de nada, cade a parte do onMarkerHit?

Neste caso somente no marker de entrada é necessário colocar a verificação pois se o jogador entrou, logicamente ele deveria ter permissão.

function teletraficoe (hitElement , matchingDimension)
	if not isGuestAccount (getPlayerAccount (hitElement)) then -- Se o jogador não estiver deslogado, então:
		if isObjectInACLGroup ("user."..getAccountName(getPlayerAccount (hitElement)), aclGetGroup ("Traficante")) then -- Se o jogador que colidir no marker for traficante, então:
			if not isPlayerInVehicle (hitElement) then -- Se o jogador que colidir no marker não estiver em um veículo, então:
				setElementPosition (hitElement, 2807.8166503906, -1170.1173095703, 1025.5703125)
				setElementInterior (hitElement, 8)
				setElementDimension (hitElement, 1)
			end
		else
			outputChatBox ("Você não é um traficante!", hitElement, 255, 30, 30)
		end	
	end
end	
addEventHandler ("onMarkerHit", traficoaentrar, teletraficoe)

 

Edited by Jonas^
Correção
  • Thanks 1
Link to comment
11 minutes ago, Jonas^ said:

Neste caso somente no marker de entrada é necessário colocar a verificação pois se o jogador entrou, logicamente ele deveria ter permissão.

exatamente isso. funcionou

Link to comment

beleza fiz aqui, 

ai no caso ficaria assim :

function fab1 (player , commandHandler)
	if getPlayerMoney (player) >= 5000 then 
			takePlayerMoney (player , 5000)
			setElementData( modelos , player)
			setPedAnimation(thePed, "ped", "WOMAN_walknorm")
			outputChatBox ("[FabricarArmas] Você fabricou 30 modelos de AK-47." , player, 112,128,144)
	else	
		outputChatBox ("[FabricarArmas] Você não tem dinheiro para fabricar os modelos da AK-47.", player, 112,128,144)
	end
end
addEventHandler ("onMarkerHit", fabricar1 , player)
addCommandHandler ("fabricar1" , player , fab1)

function fab2 (player , commandHandler)
	if getElementData(player , modelos) then
		getPlayerMoney (player) >= 3000 then
			takePlayerMoney (player , 3000)
			setPedAnimation(thePed, "ped", "WOMAN_walknorm")
			outputChatBox ("[FabricarArmas] Você fabricou 30 gatilhos de AK-47." , player, 112,128,144)
	    else	
			outputChatBox ("[FabricarArmas] Você não tem dinheiro para fabricar os Gatilhos da AK-47.", player, 112,128,144)
	else
		outputChatBox("[FabricarArmas] Você ainda não fabricou os modelos")
	end
end
addEventHandler ("onMarkerHit", fabricar2 , player)
addCommandHandler ("fabricar2" , player , fab2)

 

Edited by Renazz
Link to comment

Falta parametro no seu element-data

theElement: The element you wish to attach the data to.
key: The key you wish to store the data under. (Maximum 31 characters.)
value: The value you wish to store. See element data for a list of acceptable datatypes.

 

Link to comment
function fab1 (player , commandHandler)
	if getPlayerMoney (player) >= 5000 then 
			takePlayerMoney (player , 5000)
			setElementData(element modelos , player , modelosak, true)
			setPedAnimation(thePed, "ped", "WOMAN_walknorm")
			outputChatBox ("[FabricarArmas] Você fabricou 30 modelos de AK-47." , player, 112,128,144)
	else	
		outputChatBox ("[FabricarArmas] Você não tem dinheiro para fabricar os modelos da AK-47.", player, 112,128,144)
	end
end
addEventHandler ("onMarkerHit", fabricar1 , player)
addCommandHandler ("fabricar1" , player , fab1)

assim?

Link to comment
function fab1 (player , cmd)
	if getPlayerMoney (player) >= 5000 then 
		takePlayerMoney (player , 5000)
		setElementData (player, "modelos", true)
		setPedAnimation (player, "ped", "WOMAN_walknorm")
		outputChatBox ("[FabricarArmas] Você fabricou 30 modelos de AK-47." , player, 112, 128, 144)
	else	
		outputChatBox ("[FabricarArmas] Você não tem dinheiro para fabricar os modelos da AK-47.", player, 112,128,144)
	end
end
addEventHandler ("onMarkerHit", fabricar1 , player)
addCommandHandler ("fabricar1", fab1)

function fab2 (player , cmd)
	if getElementData (player, "modelos") then
		if getPlayerMoney (player) >= 3000 then
			takePlayerMoney (player , 3000)
			setPedAnimation (player, "ped", "WOMAN_walknorm")
			outputChatBox ("[FabricarArmas] Você fabricou 30 gatilhos de AK-47." , player, 112,128,144)
	    else	
			outputChatBox ("[FabricarArmas] Você não tem dinheiro para fabricar os Gatilhos da AK-47.", player, 112,128,144)
		end	
	else
		outputChatBox("[FabricarArmas] Você ainda não fabricou os modelos")
	end
end
addEventHandler ("onMarkerHit", fabricar2 , player)
addCommandHandler ("fabricar2", fab2)

 

Link to comment

já está tudo funcionando certinho aqui, porém eu não quero que assim que ele digite o comando de fabricar ele fabrique instantâneamente e sim demorando um certo tempo tem como eu fazer isso?

e tem como eu fazer também por exemplo se uma pessoa está usando aquela função mais ninguem poderá usar até ela acabar de fabricar

Edited by Renazz
Link to comment
function fab1 (player , cmd)
	if getPlayerMoney (player) >= 5000 then 
		takePlayerMoney (player , 5000)
		setElementData (player, "modelos", true)
		setTimer(fab1 , 300000 , 1)
		setPedAnimation (player, "ped", "WOMAN_walknorm")
		outputChatBox ("[FabricarArmas] Você fabricou 30 modelos de AK-47." , player, 112, 128, 144)
	else	
		outputChatBox ("[FabricarArmas] Você não tem dinheiro para fabricar os modelos da AK-47.", player, 112,128,144)
	end
end
addEventHandler ("onMarkerHit", fabricar1 , player)
addCommandHandler ("fabricar1", fab1)

ele ficaria bloqueado dos movimentos e ficaria fazendo uma certa animação por 5 minutos (tempo de fabricação)

Link to comment
  • Moderators

Deixe false no último argumento de setElementData para desativar a sinc com cliente.

Tirei um tempo pra fazer o código aqui, apenas siga a lógica e tente fazer o restante. E, não testei o código em nenhum momento, pode ser que tenha erros.


local jogadores_no_interior
local traficoaentrar = createMarker(125.20397186279,-285.93417358398,0.578125, "cylinder", 1.3, 255,0,0, 50) ----- Marker de Entrar
local traficoasair = createMarker (2807.6264648438,-1174.2368164063,1024.5703125 , "cylinder" , 1.3 , 255,0,0 , 50) ----- Marker de Sair
setElementInterior(traficoasair ,8) ---- Interior da Marker de Sair

local marker_etapa1 = createMarker(...)
local marker_etapa2 = createMarker(...)
local marker_etapa3 = createMarker(...)

do
	for _,m in ipairs({ marker_etapa1, marker_etapa2, marker_etapa3 }) do
		setElementInterior(m, 8)
		setElementDimension(m, 1)
	end
end

addEventHandler( "onMarkerHit", resourceRoot, 
	function ( hitElement, dim )
		if getElementType(hitElement) == "player" not isPedInVehicle(hitElement) and dim then
			if source == traficoaentrar then
			
				if isObjectInACLGroup ("user."..getAccountName(getPlayerAccount (hitElement)), aclGetGroup ("Traficante")) then -- Se o jogador que colidir no marker for traficante, então:
					if jogadores_no_interior then return outputChatBox( "Já tem um jogador fabricando arma, aguarde um momento!", hitElement, 225, 50, 50 ) end
					--
					setElementPosition (hitElement, 2807.8166503906, -1170.1173095703, 1025.5703125)
					setElementInterior (hitElement, 8)
					setElementDimension (hitElement, 1)
					setElementData( hitElement, "criarArma_etapa1", true, false )
					jogadores_no_interior = true
			
					setTimer( -- definir um limite de tempo ao jogador que entrar no interior
						function( )
							jogadores_no_interior = true
							-- teleportar o jogador pra fora
							onPlayerExitInterior( hitElement )
							outputChatBox( "Fábrica de armas: seu tempo acabou!", hitElement, 225, 50, 50 )
						end, 60000, 1
					)
				else
					outputChatBox ("Você não é um traficante!", hitElement, 255, 30, 30)
				end
			elseif source == traficoasair then
			
				setElementPosition (thePlayer, 125.05652618408,-279.69366455078,1.578125)
				setElementInterior (thePlayer, 0)
				setElementDimension (thePlayer, 0)
				jogadores_no_interior = false
				
			end
		end
	end
)

function fabricarArma( thePlayer, cmd )
	if cmd == "fabricar1" and isElementWithinMarker( thePlayer, marker_etapa1 ) and getElementData( thePlayer, "criarArma_etapa1" ) then
		if getPlayerMoney (thePlayer) >= 5000 then
			takePlayerMoney (thePlayer , 5000)
			toggleAllControls( thePlayer, false, true, false ) 
			setPedAnimation (thePlayer, "ped", "WOMAN_walknorm")
			
			setTimer( function()
			
				toggleAllControls( thePlayer, true ) 
				setPedAnimation( thePlayer )
				setElementData( hitElement, "criarArma_etapa2", true, false )
				removeElementData( hitElement, "criarArma_etapa1" )
				outputChatBox ("[FabricarArmas] Você fabricou 30 modelos de AK-47." , thePlayer, 112, 128, 144)
			end, 30000, 1 )
		else
			outputChatBox ("[FabricarArmas] Você não tem dinheiro para fabricar os modelos da AK-47.", thePlayer, 112,128,144)
		end
	elseif cmd == "fabricar2" and isElementWithinMarker( thePlayer, marker_etapa2 ) and getElementData( thePlayer, "criarArma_etapa2" ) then
		
	elseif cmd == "fabricar3" and isElementWithinMarker( thePlayer, marker_etapa3 ) and getElementData( thePlayer, "criarArma_etapa3" ) then
	
	end
end
addCommandHandler( "fabricar1", fabricarArma )
addCommandHandler( "fabricar2", fabricarArma )
addCommandHandler( "fabricar3", fabricarArma )

function onPlayerExitInterior( player )
	setElementPosition (player, 125.05652618408,-279.69366455078,1.578125)
	setElementInterior (player, 0)
	setElementDimension (player, 0)
	removeElementData( player, "criarArma_etapa1" )
	removeElementData( player, "criarArma_etapa2" )
	removeElementData( player, "criarArma_etapa3" )
end

addEventHandler( "onPlayerWasted", root,
	function()
		if getElementInterior(source) == 8 and getElementDimension(source) == 1 then jogadores_no_interior = false end
	end
)

addEventHandler( "onPlayerQuit", root,
	function()
		if getElementInterior(source) == 8 and getElementDimension(source) == 1 then jogadores_no_interior = false end
	end
)

local _removeElementData = removeElementData
function removeElementData( ... )
	local a = {...}
	if getElementData(a[1], a[2]) then
		return _removeElementData( ... )
	end
end

Fiz uma variável que verifica quando existe alguém já dentro do interior, como você já disse no post acima, e também defini um tempo-limite de 1 minuto ao jogador para criar a arma.

  • Like 1
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...