Jump to content

[Problemas]Script de Fabricar Armas


Recommended Posts

Posted

Desculpe a demora para responder,  no caso ele não teria tempo limitado para ficar dentro da fabrica, no caso existem 3 markers, para fabricação no máximo 1 player por cada marker. E no caso do tempo era o tempo de fabricação da arma(respondido pelo celular) 

Discord: Rena#5383

 

Posted (edited)

Ué, você já tem o código quase todo pronto, agora basta você adaptar do seu gosto, não espere que o @DNL291 faça isso por você, se tiver alguma dúvida pergunte aqui, mas tente antes.

Edited by Jonas^
Posted

Correto , porém eu peguei a parte do setTimer e do toggleAllControls (partes que me faltavam) e ficou dando erro de unexpected symbol near ' '  e eu não tou conseguindo arrumar

 

Discord: Rena#5383

 

Posted

Desculpa a demora tava arrumando a verificação se o player estava na marker. 

function fab1 (player , cmd)
if isElementWithinMarker(player, fabricar1) then		
	if getPlayerMoney (player) >= 5000 then 
		takePlayerMoney (player , 5000)
		setElementData (player, "pecas", true)
		toggleAllControls( thePlayer, false, true, false ) 
		setPedAnimation (player, "ped", "WOMAN_walknorm")
			
			setTimer( function(player,60000,1)
		outputChatBox ("[FabricarArmas] Você pegou as peças do AK-47!" , player, 112, 128, 144)
	else	
		outputChatBox ("[FabricarArmas] Você não tem dinheiro para pegar as peças do AK-47!", player, 112,128,144)
	end
else
	outputChatBox("[FabricarArmas]Você não está na Fábrica de Armas!")
end	
end
addEventHandler ("onMarkerHit", fabricar1 , player)
addCommandHandler ("fabricar1", fab1)

function fab2 (player , cmd)
if isElementWithinMarker(player, fabricar2) then	
	if getElementData (player, "pecas") then
		if getPlayerMoney (player) >= 3000 then
			takePlayerMoney (player , 3000)
			setElementData (player , "ak47" , true)
			toggleAllControls( thePlayer, false, true, false ) 
			setPedAnimation (player, "ped", "WOMAN_walknorm")
			
			setTimer( function(player,60000,1)
			outputChatBox ("[FabricarArmas] Você fabricou 30 AK-47!" , player, 112,128,144)
	    else	
			outputChatBox ("[FabricarArmas] Você não tem dinheiro para fabricar os AK-47!", player, 112,128,144)
		end	
	else
		outputChatBox("[FabricarArmas] Você ainda não pegou as peças do AK-47!")
	end
else
	outputChatBox("[FabricarArmas]Você não está na Fábrica de Armas!")
end
end
addEventHandler ("onMarkerHit", fabricar2 , player)
addCommandHandler ("fabricar2", fab2)


function fab3 (player , commandHandler)
if isElementWithinMarker(player, fabricar3) then	
	if getElementData (player, "ak47") then
		if getPlayerMoney (player) >= 2000 then
			takePlayerMoney (player , 2000)
			toggleAllControls( thePlayer, false, true, false ) 
			setPedAnimation (player, "ped", "WOMAN_walknorm")
			
			setTimer( function(player,60000,1)
			
			giveWeapon (player, 30 , 30)
			removeElementData(player , "ak47")
			removeElementData(player , "pecas")
			outputChatBox ("[FabricarArmas] Você acabou de dar os últimos toques nas suas AKs!" , player, 112,128,144)
	else	
		outputChatBox ("[FabricarArmas] Você não tem dinheiro para dar os últimos toques nas suas AKs!", player, 112,128,144)
		end
	else
		outputChatBox("[FabricarArmas] Você ainda não fabricou os AK-47!")
	end
else
	outputChatBox("[FabricarArmas]Você não está na Fábrica de Armas!")
end
end
addEventHandler ("onMarkerHit", fabricar3 , player)
addCommandHandler ("fabricar3" , fab3)

 

Discord: Rena#5383

 

Posted (edited)

continua dando o mesmo erro, eu alterei um pouco o código.

 

acho que não é caractér invisivel e sim algum erro no código.

Edited by Renazz

Discord: Rena#5383

 

Posted

Seu código nunca vai funcionar desta forma, não sei porque você prefere fazer da pior forma as coisas, DNL te deu o código praticamente pronto...

Posted
9 minutes ago, Jonas^ said:

Seu código nunca vai funcionar desta forma, não sei porque você prefere fazer da pior forma as coisas, DNL te deu o código praticamente pronto...

porque o código que estou agora está praticamente feito, só tem alguns erros que não estão deixando o script iniciar. e se eu pegasse o que o DNL mandou teria que editar uma pá de coisas e daria o triplo do trabalho.

Discord: Rena#5383

 

Posted
function fab1 (player , cmd)
	if isElementWithinMarker(player, fabricar1) then		
		if getPlayerMoney (player) >= 5000 then 
			takePlayerMoney (player , 5000)
			setPedAnimation (player, "ped", "WOMAN_walknorm")
			
			setTimer (function()
				toggleAllControls (player, true) 
				setPedAnimation (player)
				setElementData (player, "pecas", true, false)
				outputChatBox ("[FabricarArmas] Você pegou as peças do AK-47!" , player, 112, 128, 144)
			end, 10000, 1)
		
		else	
			outputChatBox ("[FabricarArmas] Você não tem dinheiro para pegar as peças do AK-47!", player, 112,128,144)
		end
	else
		outputChatBox("[FabricarArmas]Você não está na Fábrica de Armas!")
	end	
end
addEventHandler ("onMarkerHit", fabricar1 , fab1)

function fab2 (player , cmd)
	if isElementWithinMarker(player, fabricar2) then	
		if getElementData (player, "pecas") then
			if getPlayerMoney (player) >= 3000 then
				takePlayerMoney (player , 3000)
				setPedAnimation (player, "ped", "WOMAN_walknorm")
			
				setTimer (function()
					toggleAllControls (player, true) 
					setPedAnimation (player)
					setElementData (player, "ak47", true, false)
					removeElementData (player, "pecas")
					outputChatBox ("[FabricarArmas] Você fabricou 30 AK-47!" , player, 112,128,144)
				end, 10000, 1)
			
			else	
				outputChatBox ("[FabricarArmas] Você não tem dinheiro para fabricar os AK-47!", player, 112,128,144)
			end	
		else
			outputChatBox("[FabricarArmas] Você ainda não pegou as peças do AK-47!")
		end
	else
		outputChatBox("[FabricarArmas]Você não está na Fábrica de Armas!")
	end
end
addEventHandler ("onMarkerHit", fabricar2 , fab2)

function fab3 (player , cmd)
	if isElementWithinMarker(player, fabricar3) then	
		if getElementData (player, "ak47") then
			if getPlayerMoney (player) >= 2000 then
				takePlayerMoney (player , 2000)
				setPedAnimation (player, "ped", "WOMAN_walknorm")
				
				setTimer (function()
					toggleAllControls (player, true) 
					setPedAnimation (player)
					giveWeapon (player, 30 , 30)
					removeElementData (player, "ak47")
					outputChatBox ("[FabricarArmas] Você acabou de dar os últimos toques nas suas AKs!" , player, 112,128,144)
				end, 10000, 1)
			
			else	
				outputChatBox ("[FabricarArmas] Você não tem dinheiro para dar os últimos toques nas suas AKs!", player, 112,128,144)
			end
		else
			outputChatBox("[FabricarArmas] Você ainda não fabricou os AK-47!")
		end
	else
		outputChatBox("[FabricarArmas]Você não está na Fábrica de Armas!")
	end
end
addEventHandler ("onMarkerHit", fabricar3 , fab3)

 

  • Moderators
Posted

Esse Ctrl+C e Ctrl+V todo aí daria pra fazer com 1 função só.

Eu te ajudei ou achou meu comentário útil? Não esqueça de deixar um Thanksspacer.png

Minhas contribuições para a comunidade: LordHenry - MTA Wiki Profile
Inscreva-se no meu canal do YouTube: Lord Henry - Entertainment
Discord Oficial do MTA: https://mtasa.com/discord
Blacklist e Whitelist de Scripters: Planilha

Por favor, não me envie mensagens privadas solicitando suporte. Crie um tópico no fórum em vez disso.

Posted
2 minutes ago, Lord Henry said:

Esse Ctrl+C e Ctrl+V todo aí daria pra fazer com 1 função só.

Logico que da, ele prefere fazer da maneira mais zoada possível.

Pra fazer da forma que o Lord disse faça assim:

function fabricarArmas (player, cmd)
	if (not isGuestAccount (getPlayerAccount (player))) then
		if cmd == "fabricar1" then 
			if isElementWithinMarker(player, fabricar1) then		
				if getPlayerMoney (player) >= 5000 then 
					takePlayerMoney (player , 5000)
					setPedAnimation (player, "ped", "WOMAN_walknorm")
			
					setTimer (function()
						toggleAllControls (player, true) 
						setPedAnimation (player)
						setElementData (player, "pecas", true, false)
						outputChatBox ("[FabricarArmas] Você pegou as peças do AK-47!" , player, 112, 128, 144)
					end, 10000, 1)
		
				else	
					outputChatBox ("[FabricarArmas] Você não tem dinheiro para pegar as peças do AK-47!", player, 112,128,144)
				end
			else
				outputChatBox("[FabricarArmas]Você não está na Fábrica de Armas!")
			end	
		elseif cmd == "fabricar2" then
			if isElementWithinMarker(player, fabricar2) then	
				if getElementData (player, "pecas") then
					if getPlayerMoney (player) >= 3000 then
						takePlayerMoney (player , 3000)
						setPedAnimation (player, "ped", "WOMAN_walknorm")
			
						setTimer (function()
							toggleAllControls (player, true) 
							setPedAnimation (player)
							setElementData (player, "ak47", true, false)
							removeElementData (player, "pecas")
							outputChatBox ("[FabricarArmas] Você fabricou 30 AK-47!" , player, 112,128,144)
						end, 10000, 1)
			
					else	
						outputChatBox ("[FabricarArmas] Você não tem dinheiro para fabricar os AK-47!", player, 112,128,144)
					end	
				else
					outputChatBox("[FabricarArmas] Você ainda não pegou as peças do AK-47!")
				end
			else
				outputChatBox("[FabricarArmas]Você não está na Fábrica de Armas!")
			end
		elseif cmd == "fabricar3" then
			if isElementWithinMarker(player, fabricar3) then	
				if getElementData (player, "ak47") then
					if getPlayerMoney (player) >= 2000 then
						takePlayerMoney (player , 2000)
						setPedAnimation (player, "ped", "WOMAN_walknorm")
				
						setTimer (function()
							toggleAllControls (player, true) 
							setPedAnimation (player)
							giveWeapon (player, 30 , 30)
							removeElementData (player, "ak47")
							outputChatBox ("[FabricarArmas] Você acabou de dar os últimos toques nas suas AKs!" , player, 112,128,144)
						end, 10000, 1)
			
					else	
						outputChatBox ("[FabricarArmas] Você não tem dinheiro para dar os últimos toques nas suas AKs!", player, 112,128,144)
					end
				else
					outputChatBox("[FabricarArmas] Você ainda não fabricou os AK-47!")
				end
			else
				outputChatBox("[FabricarArmas]Você não está na Fábrica de Armas!")
			end
		end
	end	
end
addCommandHandler ("fabricar1", fabricarArmas)
addCommandHandler ("fabricar2", fabricarArmas)
addCommandHandler ("fabricar3", fabricarArmas)

 

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