Jump to content

[Problemas]Script de Fabricar Armas


Recommended Posts

Posted (edited)

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
Posted

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

Posted (edited)

 

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
Posted (edited)

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

Posted
3 minutes ago, Renazz said:

exatamente isso. funcionou

Editei o post acima, olhe lá e tente entrar no marker com veículo pra ver oque acontece.

  • Thanks 1
Posted (edited)
7 minutes ago, Jonas^ said:

Editei o post acima, olhe lá e tente entrar no marker com veículo pra ver oque acontece.

humm blz, editado aqui

Edited by Renazz
Posted

Blz, agora o próximo problema é a parte de criar os paranaue , você deve usar setElementData e no marker seguinte usar getElementData se a data existir ele prossegue se não existir retorna avisando que o jogador precisa passar pelo passo 1.

SetElementData

GetElementData

  • Thanks 1
Posted (edited)

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
Posted

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.

 

Posted
3 minutes ago, Jonas^ said:

value: The value you wish to store. See element data for a list of acceptable datatypes.

não estou entendendo o value

Posted

true or false

Não necessariamente precisa ser true or false, mas no seu caso é true como se trata de uma data temporaria apenas pra verificar se o elemento realmente fez o primeiro passo.

Posted
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?

Posted
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)

 

Posted (edited)

E se quiser fazer para um terceira funçao é so colocar para verificar os modelos do mesmo jeito?

ou terei que criar uma outra data?

Edited by Renazz
Posted

Seta a data no segundo e verifica no terceiro.

Dai no terceiro quando o cara terminar anula as datas assim:

setElementData (player, "modelos", nil)
setElementData (player, "modelos1", nil)

 

Posted (edited)

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
Posted
4 minutes ago, Jonas^ said:

Tem, pra demorar um tempo use setTimer e pra permitir somente um jogador no marker acredito que de pra usar a função:

GetPlayersInMarker

usei o setTimer , mas não dá nada 

não estou conseguindo usar o GetPlayerInMarker

Posted
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)

Posted

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

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