Jump to content

[AJUDA]Visibilidade de Blips


Recommended Posts

53 minutes ago, DNL291 said:

danblemes1 Quando houver um problema no script use /debugscript 3 e mostre o erro. Claro que nesse caso o erro está claro como já foi mostrado.

Só estranhei o fato de você não ter mostrado primeiro erro (da função getPlayerFromPartialName) e mais outra vez não falar do erro no debug. Você tá usando mesmo o /debugscript 3 pra ver os erros?

Sobre o take/givePlayerMoney é bem óbvio o problema ali, eu te pergunto: aonde ali que está o valor de 30? Se você ler a sintaxe verá que deve ser assim:


			takePlayerMoney (theClient, 30)			givePlayerMoney (thePlayer, 30)

Note que troquei playerName por theClient. playerName é uma string - o texto recebido do comando; theClient é o elemento, o qual deve ser passado nas funções takePlayerMoneygivePlayerMoney.

Além disso também deve ser verificado se o jogador possui o valor de "30 reais" assim como você fez ali em cima, no comando /uber. E também faça a verificação se o 'theClient' é mesmo um jogador existente.

Tente isto:


function aceitar (thePlayer, commandName, playerName)	local account = getAccountName (getPlayerAccount(thePlayer))	if isObjectInACLGroup ("user."..account, aclGetGroup ("UBER")) then		if not playerName then			return outputChatBox( "Erro: digite o nome do passageiro!", thePlayer, 230, 0, 0 )		end		local theClient = getPlayerFromPartialName (playerName)		if theClient then			local money = getPlayerMoney (theClient)			if (money < 30) then				return outputChatBox( "Erro: esse passageiro não tem a quantia necessária!", thePlayer, 230, 0, 0 )			end			if blip[theClient] and isElement (blip[theClient]) then				destroyElement (blip[theClient])				blip[theClient] = nil			end			takePlayerMoney (theClient, 30)			givePlayerMoney (thePlayer, 30)		else			outputChatBox( "Erro: jogador não encontrado!", thePlayer, 230, 0, 0 )		end	endendaddCommandHandler ("aceitar", aceitar)

 

Mano, tipo, eu digitei o nome completo do jogador (ele estava do meu lado), acusou que o player não foi encontrado!

Edited by danblemes1
Link to comment
9 hours ago, DNL291 said:

Então getPlayerFromPartialName não encontrou o jogador com esse nome ou não está executando.

Tipo, antes de adicionar essa parte do dinheiro, ele tava funcionando tranquilo pra destruir o blip, quando ao nick, eu até usei o TAB para auto-completar 

Link to comment

Só uma que me resta, tipo, um player pediu um Uber, ai ninguem foi atender atender, como eu faria pra esse blip ser destruido após 5 minutos? Tipo, eu dei uma olhada no setTimer, mas não entendi muito bem...

function timer ()
	if blip[theClient] and isElement (blip[theClient]) then
		destroyElement (blip[theClient])
		blip[theClient] = nil
	end
end

Eu queria que essa função acima fosse executada, 5 minutos após a de pedir o Uber

Link to comment
  • Moderators

Quando o player pedir o Uber, adiciona o timer para o solicitante com os 5 minutos; caso o Uber chegue antes desses 5 minutos, você dá killTimer.

Dentro da função, você faz como no seu código acima passando o elemento do jogador para a função.

8 hours ago, danblemes1 said:

Tipo, antes de adicionar essa parte do dinheiro, ele tava funcionando tranquilo pra destruir o blip, quando ao nick, eu até usei o TAB para auto-completar 

Sinceramente eu continuo achando que você não tá olhando os erros no debug.

Edited by DNL291
Link to comment
2 hours ago, DNL291 said:

Quando ele pedir adiciona ele numa tabela, uma tabela global com todos os solicitantes. E no começo do comando /uber você faz a verificação pra saber se o jogador já está na tabela. Você também pode usar setElementData no lugar de tabela.

Mas como eu faria uma tabela desse tipo? (Eu não entendo muito sobre tabela)

Link to comment
1 minute ago, DNL291 said:

Funciona do mesmo jeito que a tabela blip do seu script. Armazena no player e no valor coloca true, quando o jogador não tiver mais como solicitante, remove da tabela.

Mn, não é querendo pedir demais, mas pode me dar um exemplo dessa tabela, pois contínuo sem entender

Link to comment
  • Moderators

Aqui, no comando /uber:


local solicitantes = {}

function pedir (splayer)
	local money = getPlayerMoney (splayer)
	if (money >= 30) and solicitantes[splayer] ~= true then
		local players = getElementsByType ("player")
		blip[splayer] = createBlipAttachedTo (splayer, 62)
		solicitantes[splayer] = true
		setElementVisibleTo (blip[splayer], root, false)
		for _, driver in ipairs (players) do
			local account = getAccountName (getPlayerAccount(driver))
			if isObjectInACLGroup ("user."..account, aclGetGroup ("UBER")) then
				local passageiro = getPlayerName (splayer)
				local lugar = getElementZoneName (splayer)
				setElementVisibleTo (blip[splayer], driver, true)
				outputChatBox (" ", driver, 255, 255, 255, true)
				outputChatBox ("#838B83===============================================", driver, 255, 255, 255, true)
				outputChatBox (" ", driver, 255, 255, 255, true)
				outputChatBox ("✘ #838B83Uber Brasil #FFFFFF✘ - O cidadão "..passageiro.." #FFFFFFestá solicitando um Uber em "..lugar.."", driver, 255, 255, 255, true)
				outputChatBox (" ", driver, 255, 255, 255, true)
				outputChatBox ("#838B83===============================================", driver, 255, 255, 255, true)
				outputChatBox (" ", driver, 255, 255, 255, true)
			end
		end
		outputChatBox (" ", splayer, 255, 255, 255, true)
		outputChatBox ("✘ #838B83Uber Brasil #FFFFFF✘ - Você solicitou um Uber, aguarde até alguém chegar", splayer, 255, 255, 255, true)
		outputChatBox (" ", splayer, 255, 255, 255, true)
	elseif solicitantes[splayer] then
		outputChatBox( "Erro: Você já solicitou o Uber", splayer )
	else
		outputChatBox ("✘ #838B83Uber Brasil #FFFFFF✘ - #ff0000Você não tem dinheiro suficiente para pedir um Uber #000000(#00FF00 R$30 #000000)", splayer, 255, 255, 255, true)
	end
end
addCommandHandler ("uber", pedir)

No /aceitar:

function aceitar (thePlayer, commandName, playerName)
	local account = getAccountName (getPlayerAccount(thePlayer))
	if isObjectInACLGroup ("user."..account, aclGetGroup ("UBER")) then
		if not playerName then
			return outputChatBox( "Erro: digite o nome do passageiro!", thePlayer, 230, 0, 0 )
		end
		local theClient = getPlayerFromPartialName (playerName)
		if theClient then
			local money = getPlayerMoney (theClient)
			if (money < 30) then
				return outputChatBox( "Erro: esse passageiro não tem a quantia necessária!", thePlayer, 230, 0, 0 )
			end
			if blip[theClient] and isElement (blip[theClient]) then
				destroyElement (blip[theClient])
				blip[theClient] = nil
			end
			if solicitantes[theClient] then
				solicitantes[theClient] = nil
			end
			takePlayerMoney (theClient, 30)
			givePlayerMoney (thePlayer, 30)
		else
			outputChatBox( "Erro: jogador não encontrado!", thePlayer, 230, 0, 0 )
		end
	end
end
addCommandHandler ("aceitar", aceitar)

Para remover é fácil:

if solicitantes[player] then
	solicitantes[player] = nil
end

Faça isso no onPlayerQuit também, só substituir 'player' com 'source'.

Edited by DNL291
correção
  • Thanks 1
Link to comment

DNL, Seria correto eu fazer isso?:

local blip = {}
local solicitantes = {}

function pedir (splayer)
	local money = getPlayerMoney (splayer)
	if (money >= 30) and solicitantes[splayer] ~= true then
		local players = getElementsByType ("player")
		blip[splayer] = createBlipAttachedTo (splayer, 62)
		solicitantes[splayer] = true
		setElementVisibleTo (blip[splayer], root, false)
		for _, driver in ipairs (players) do
			local account = getAccountName (getPlayerAccount(driver))
			if isObjectInACLGroup ("user."..account, aclGetGroup ("UBER")) then
				local passageiro = getPlayerName (splayer)
				local lugar = getElementZoneName (splayer)
				setElementVisibleTo (blip[splayer], driver, true)
				outputChatBox (" ", driver, 255, 255, 255, true)
				outputChatBox ("#838B83===============================================", driver, 255, 255, 255, true)
				outputChatBox (" ", driver, 255, 255, 255, true)
				outputChatBox ("✘ #838B83Uber Brasil #FFFFFF✘ - O cidadão "..passageiro.." #FFFFFFestá solicitando um Uber em "..lugar.."", driver, 255, 255, 255, true)
				outputChatBox (" ", driver, 255, 255, 255, true)
				outputChatBox ("#838B83===============================================", driver, 255, 255, 255, true)
				outputChatBox (" ", driver, 255, 255, 255, true)
			end
		end
		outputChatBox (" ", splayer, 255, 255, 255, true)
		outputChatBox ("✘ #838B83Uber Brasil #FFFFFF✘ - Você solicitou um Uber, aguarde até alguém chegar", splayer, 255, 255, 255, true)
		outputChatBox (" ", splayer, 255, 255, 255, true)
	elseif
		outputChatBox ("✘ #838B83Uber Brasil #FFFFFF✘ - #ffff00Você já solicitou um Uber, aguarde!", splayer, 255, 255, 255, true)
	else
		outputChatBox ("✘ #838B83Uber Brasil #FFFFFF✘ - #ff0000Você não tem dinheiro suficiente para pedir um Uber #000000(#00FF00 R$30 #000000)", splayer, 255, 255, 255, true)
	end
end
addCommandHandler ("uber", pedir)
setTimer (function destruir (), 300000, 1)

function destruir ()
	if blip[theClient] and isElement (blip[theClient]) then
		destroyElement (blip[theClient])
		blip[theClient] = nil
	end
end

 

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