Jump to content

Dúvidas Marcadores


Recommended Posts

  • Moderators

Do jeito que tá no código o blip vai sumir só depois que o timer ser executado.

Se quiser que destrua assim que digitar o comando, só colocar o :

if isElement(BlipsMEC[theUser]) then destroyElement(BlipsMEC[theUser]) end

Fora do setTimer. Antes do damagedVehs[theUser] = veh por exemplo.

  • Like 1
Link to comment
  • Other Languages Moderators

Bom, eu colocaria alguns print pelo código para saber por onde ele está lendo e quais condições ele não está validando. Assim posso saber qual condição está com problema.

function solicitaPay (thePlayer, cmd, user)
    local accName = getAccountName(getPlayerAccount(thePlayer))
    if isObjectInACLGroup ("user."..accName, aclGetGroup ("Mec") ) then
        print ("01")
        if not user then
            outputChatBox ("Erro de sintaxe, use /consertar <nick>", thePlayer, 255, 255, 0)
        elseif not getPlayerFromPartialName (user) then
            outputChatBox ("Jogador não encontrado.", thePlayer, 255, 255, 0)
        else
            print ("02")
            local veh = getPedOccupiedVehicle(thePlayer)
            if not (veh) then
                return outputChatBox( "Você precisa estar dentro de um veículo", thePlayer, 255, 255, 0 )
            end
        
            local theUser = getPlayerFromPartialName (user)
            if getElementData (theUser, "mecanico.solicitation") then
                outputChatBox ("Alguém já está solicitando pagamento mecânico a este jogador.", thePlayer, 255, 255, 0)
            else
                print ("03")
                damagedVehs[theUser] = veh
                setElementData (theUser, "mecanico.solicitation", thePlayer)
                outputChatBox ("Você solicitou pagamento para consertar o veículo de "..user, thePlayer, 0, 255, 0, true)
                outputChatBox (getPlayerName (thePlayer).."#FFFF00 está pedindo $800 para consertar seu veículo. Use /aceitar ou /recusar", theUser, 255, 255, 255, true)
                if isElement(BlipsMEC[theUser]) then
                    print ("04")
                    destroyElement (BlipsMEC[theUser])
                    BlipsMEC[theUser] = nil
                end
                mechTimer[thePlayer] = setTimer (function ()
                    if getElementData (theUser, "mecanico.solicitation") then
                        setElementData (theUser, "mecanico.solicitation", false)
                        outputChatBox ("O pedido de pagamento de "..getPlayerName (thePlayer).."#FFFF00 expirou.", theUser, 255, 255, 0, true)
                    end
                end, 10000, 1)
            end
        end
    else
        outputChatBox("#FF0000Você não tem permissão para executar este comando!", thePlayer, 255, 255, 255, true )
    end
end
addCommandHandler ("reparar", solicitaPay)

 

Edited by Lord Henry
Link to comment
6 hours ago, Lord Henry said:

Bom, eu colocaria alguns print pelo código para saber por onde ele está lendo e quais condições ele não está validando. Assim posso saber qual condição está com problema.


function solicitaPay (thePlayer, cmd, user)
    local accName = getAccountName(getPlayerAccount(thePlayer))
    if isObjectInACLGroup ("user."..accName, aclGetGroup ("Mec") ) then
        print ("01")
        if not user then
            outputChatBox ("Erro de sintaxe, use /consertar <nick>", thePlayer, 255, 255, 0)
        elseif not getPlayerFromPartialName (user) then
            outputChatBox ("Jogador não encontrado.", thePlayer, 255, 255, 0)
        else
            print ("02")
            local veh = getPedOccupiedVehicle(thePlayer)
            if not (veh) then
                return outputChatBox( "Você precisa estar dentro de um veículo", thePlayer, 255, 255, 0 )
            end
        
            local theUser = getPlayerFromPartialName (user)
            if getElementData (theUser, "mecanico.solicitation") then
                outputChatBox ("Alguém já está solicitando pagamento mecânico a este jogador.", thePlayer, 255, 255, 0)
            else
                print ("03")
                damagedVehs[theUser] = veh
                setElementData (theUser, "mecanico.solicitation", thePlayer)
                outputChatBox ("Você solicitou pagamento para consertar o veículo de "..user, thePlayer, 0, 255, 0, true)
                outputChatBox (getPlayerName (thePlayer).."#FFFF00 está pedindo $800 para consertar seu veículo. Use /aceitar ou /recusar", theUser, 255, 255, 255, true)
                if isElement(BlipsMEC[theUser]) then
                    print ("04")
                    destroyElement (BlipsMEC[theUser])
                    BlipsMEC[theUser] = nil
                end
                mechTimer[thePlayer] = setTimer (function ()
                    if getElementData (theUser, "mecanico.solicitation") then
                        setElementData (theUser, "mecanico.solicitation", false)
                        outputChatBox ("O pedido de pagamento de "..getPlayerName (thePlayer).."#FFFF00 expirou.", theUser, 255, 255, 0, true)
                    end
                end, 10000, 1)
            end
        end
    else
        outputChatBox("#FF0000Você não tem permissão para executar este comando!", thePlayer, 255, 255, 255, true )
    end
end
addCommandHandler ("reparar", solicitaPay)

 

Não entendi muito bem ao certo.. como funcionaria pra ver?

17 hours ago, DNL291 said:

Do jeito que tá no código o blip vai sumir só depois que o timer ser executado.

Se quiser que destrua assim que digitar o comando, só colocar o :


if isElement(BlipsMEC[theUser]) then destroyElement(BlipsMEC[theUser]) end

Fora do setTimer. Antes do damagedVehs[theUser] = veh por exemplo.

Eu coloquei mas o comando de reparar não estava funcionanmdo.. 
ficou assim:

 

...
            else
                if isElement(BlipsMEC[theUser]) then destroyElement(BlipsMEC[theUser]) end
                damagedVehs[theUser] = veh
                setElementData (theUser, "mecanico.solicitation", thePlayer)
...

 

Edited by hawkbr
Link to comment
  • Moderators

1º Veja se o debug mostra algum erro quando você iniciar o resource/digitar o comando. Se não mostrar nada, faça o que o Lord disse acima, depure o código, veja este tópico https://forum.multitheftauto.com/topic/95654-tut-debugging/.

Pode ser difícil no começo? Sim. Mas vai ser útil pra você não precisar mais de ajuda com depuração simples.

Use este código, veja quais mensagens mostram no chat e cole aqui, por favor:

function solicitaPay (thePlayer, cmd, user)
    local accName = getAccountName(getPlayerAccount(thePlayer))
	outputChatBox("comando /reparar executado!")
    if isObjectInACLGroup ("user."..accName, aclGetGroup ("Mec") ) then
        if not user then
            outputChatBox ("Erro de sintaxe, use /consertar <nick>", thePlayer, 255, 255, 0)
        elseif not getPlayerFromPartialName (user) then
            outputChatBox ("Jogador não encontrado.", thePlayer, 255, 255, 0)
        else
            local veh = getPedOccupiedVehicle(thePlayer)
            if not (veh) then
                return outputChatBox( "Você precisa estar dentro de um veículo", thePlayer, 255, 255, 0 )
            end
        
            local theUser = getPlayerFromPartialName (user)
		outputChatBox("@theUser: "..tostring(theUser))
		outputChatBox("@mecanico.solicitation 1#: "..tostring(getElementData (theUser, "mecanico.solicitation")))
            if getElementData (theUser, "mecanico.solicitation") then
                outputChatBox ("Alguém já está solicitando pagamento mecânico a este jogador.", thePlayer, 255, 255, 0)
            else
                if isElement(BlipsMEC[theUser]) then
				outputChatBox("BlipsMEC[theUser] existe")
				destroyElement(BlipsMEC[theUser])
			end
                damagedVehs[theUser] = veh
			outputChatBox("@damagedVehs[theUser]: "..tostring(damagedVehs[theUser]))
                setElementData (theUser, "mecanico.solicitation", thePlayer)
			outputChatBox("@mecanico.solicitation 2#: "..tostring(getElementData (theUser, "mecanico.solicitation")))
                outputChatBox ("Você solicitou pagamento para consertar o veículo de "..user, thePlayer, 0, 255, 0, true)
                outputChatBox (getPlayerName (thePlayer).."#FFFF00 está pedindo $800 para consertar seu veículo. Use /aceitar ou /recusar", theUser, 255, 255, 255, true)
                mechTimer[thePlayer] = setTimer (function ()
                    if getElementData (theUser, "mecanico.solicitation") then
                        setElementData (theUser, "mecanico.solicitation", false)
                        outputChatBox ("O pedido de pagamento de "..getPlayerName (thePlayer).."#FFFF00 expirou.", theUser, 255, 255, 0, true)
                    end
                end, 10000, 1)
            end
        end
    else
        outputChatBox("#FF0000Você não tem permissão para executar este comando!", thePlayer, 255, 255, 255, true )
    end
end
addCommandHandler ("reparar", solicitaPay)

 

Link to comment
29 minutes ago, DNL291 said:

1º Veja se o debug mostra algum erro quando você iniciar o resource/digitar o comando. Se não mostrar nada, faça o que o Lord disse acima, depure o código, veja este tópico https://forum.multitheftauto.com/topic/95654-tut-debugging/.

Pode ser difícil no começo? Sim. Mas vai ser útil pra você não precisar mais de ajuda com depuração simples.

Use este código, veja quais mensagens mostram no chat e cole aqui, por favor:


function solicitaPay (thePlayer, cmd, user)
    local accName = getAccountName(getPlayerAccount(thePlayer))
	outputChatBox("comando /reparar executado!")
    if isObjectInACLGroup ("user."..accName, aclGetGroup ("Mec") ) then
        if not user then
            outputChatBox ("Erro de sintaxe, use /consertar <nick>", thePlayer, 255, 255, 0)
        elseif not getPlayerFromPartialName (user) then
            outputChatBox ("Jogador não encontrado.", thePlayer, 255, 255, 0)
        else
            local veh = getPedOccupiedVehicle(thePlayer)
            if not (veh) then
                return outputChatBox( "Você precisa estar dentro de um veículo", thePlayer, 255, 255, 0 )
            end
        
            local theUser = getPlayerFromPartialName (user)
		outputChatBox("@theUser: "..tostring(theUser))
		outputChatBox("@mecanico.solicitation 1#: "..tostring(getElementData (theUser, "mecanico.solicitation")))
            if getElementData (theUser, "mecanico.solicitation") then
                outputChatBox ("Alguém já está solicitando pagamento mecânico a este jogador.", thePlayer, 255, 255, 0)
            else
                if isElement(BlipsMEC[theUser]) then
				outputChatBox("BlipsMEC[theUser] existe")
				destroyElement(BlipsMEC[theUser])
			end
                damagedVehs[theUser] = veh
			outputChatBox("@damagedVehs[theUser]: "..tostring(damagedVehs[theUser]))
                setElementData (theUser, "mecanico.solicitation", thePlayer)
			outputChatBox("@mecanico.solicitation 2#: "..tostring(getElementData (theUser, "mecanico.solicitation")))
                outputChatBox ("Você solicitou pagamento para consertar o veículo de "..user, thePlayer, 0, 255, 0, true)
                outputChatBox (getPlayerName (thePlayer).."#FFFF00 está pedindo $800 para consertar seu veículo. Use /aceitar ou /recusar", theUser, 255, 255, 255, true)
                mechTimer[thePlayer] = setTimer (function ()
                    if getElementData (theUser, "mecanico.solicitation") then
                        setElementData (theUser, "mecanico.solicitation", false)
                        outputChatBox ("O pedido de pagamento de "..getPlayerName (thePlayer).."#FFFF00 expirou.", theUser, 255, 255, 0, true)
                    end
                end, 10000, 1)
            end
        end
    else
        outputChatBox("#FF0000Você não tem permissão para executar este comando!", thePlayer, 255, 255, 255, true )
    end
end
addCommandHandler ("reparar", solicitaPay)

 

Apareceu no chat assim:

Comando /reparar executado!
@theUser: userdata:00000097
@mecanico.solicitation 1#: false

Link to comment
  • Other Languages Moderators
19 hours ago, hawkbr said:

 


...
            else
                if isElement(BlipsMEC[theUser]) then destroyElement(BlipsMEC[theUser]) end
                damagedVehs[theUser] = veh
                setElementData (theUser, "mecanico.solicitation", thePlayer)
...

 

Isso não existe. Vc deve fazer elseif em vez do else seguido de um if.

function solicitaPay (thePlayer, cmd, user)
	local accName = getAccountName(getPlayerAccount(thePlayer))
	outputChatBox("comando /reparar executado!")
	if isObjectInACLGroup ("user."..accName, aclGetGroup ("Mec") ) then
		if not user then
			outputChatBox ("Erro de sintaxe, use /consertar <nick>", thePlayer, 255, 255, 0)
		elseif not getPlayerFromPartialName (user) then
			outputChatBox ("Jogador não encontrado.", thePlayer, 255, 255, 0)
		else
			local veh = getPedOccupiedVehicle(thePlayer)
			if not (veh) then
				return outputChatBox( "Você precisa estar dentro de um veículo", thePlayer, 255, 255, 0 )
			end
			local theUser = getPlayerFromPartialName (user)
			outputChatBox("@theUser: "..tostring(theUser))
			outputChatBox("@mecanico.solicitation 1#: "..tostring(getElementData (theUser, "mecanico.solicitation")))
			if getElementData (theUser, "mecanico.solicitation") then
				outputChatBox ("Alguém já está solicitando pagamento mecânico a este jogador.", thePlayer, 255, 255, 0)
			elseif isElement(BlipsMEC[theUser]) then
				outputChatBox("BlipsMEC[theUser] existe")
				destroyElement(BlipsMEC[theUser])
			end
			damagedVehs[theUser] = veh
			outputChatBox("@damagedVehs[theUser]: "..tostring(damagedVehs[theUser]))
			setElementData (theUser, "mecanico.solicitation", thePlayer)
			outputChatBox("@mecanico.solicitation 2#: "..tostring(getElementData (theUser, "mecanico.solicitation")))
			outputChatBox ("Você solicitou pagamento para consertar o veículo de "..user, thePlayer, 0, 255, 0, true)
			outputChatBox (getPlayerName (thePlayer).."#FFFF00 está pedindo $800 para consertar seu veículo. Use /aceitar ou /recusar", theUser, 255, 255, 255, true)
			mechTimer[thePlayer] = setTimer (function ()
				if getElementData (theUser, "mecanico.solicitation") then
					setElementData (theUser, "mecanico.solicitation", false)
					outputChatBox ("O pedido de pagamento de "..getPlayerName (thePlayer).."#FFFF00 expirou.", theUser, 255, 255, 0, true)
				end
			end, 10000, 1)
		end
	else
		outputChatBox("#FF0000Você não tem permissão para executar este comando!", thePlayer, 255, 255, 255, true )
	end
end
addCommandHandler ("reparar", solicitaPay)

Quais mensagens aparecem no chat?

Edited by Lord Henry
Link to comment
4 hours ago, Lord Henry said:

Isso não existe. Vc deve fazer elseif em vez do else seguido de um if.


function solicitaPay (thePlayer, cmd, user)
	local accName = getAccountName(getPlayerAccount(thePlayer))
	outputChatBox("comando /reparar executado!")
	if isObjectInACLGroup ("user."..accName, aclGetGroup ("Mec") ) then
		if not user then
			outputChatBox ("Erro de sintaxe, use /consertar <nick>", thePlayer, 255, 255, 0)
		elseif not getPlayerFromPartialName (user) then
			outputChatBox ("Jogador não encontrado.", thePlayer, 255, 255, 0)
		else
			local veh = getPedOccupiedVehicle(thePlayer)
			if not (veh) then
				return outputChatBox( "Você precisa estar dentro de um veículo", thePlayer, 255, 255, 0 )
			end
			local theUser = getPlayerFromPartialName (user)
			outputChatBox("@theUser: "..tostring(theUser))
			outputChatBox("@mecanico.solicitation 1#: "..tostring(getElementData (theUser, "mecanico.solicitation")))
			if getElementData (theUser, "mecanico.solicitation") then
				outputChatBox ("Alguém já está solicitando pagamento mecânico a este jogador.", thePlayer, 255, 255, 0)
			elseif isElement(BlipsMEC[theUser]) then
				outputChatBox("BlipsMEC[theUser] existe")
				destroyElement(BlipsMEC[theUser])
			end
			damagedVehs[theUser] = veh
			outputChatBox("@damagedVehs[theUser]: "..tostring(damagedVehs[theUser]))
			setElementData (theUser, "mecanico.solicitation", thePlayer)
			outputChatBox("@mecanico.solicitation 2#: "..tostring(getElementData (theUser, "mecanico.solicitation")))
			outputChatBox ("Você solicitou pagamento para consertar o veículo de "..user, thePlayer, 0, 255, 0, true)
			outputChatBox (getPlayerName (thePlayer).."#FFFF00 está pedindo $800 para consertar seu veículo. Use /aceitar ou /recusar", theUser, 255, 255, 255, true)
			mechTimer[thePlayer] = setTimer (function ()
				if getElementData (theUser, "mecanico.solicitation") then
					setElementData (theUser, "mecanico.solicitation", false)
					outputChatBox ("O pedido de pagamento de "..getPlayerName (thePlayer).."#FFFF00 expirou.", theUser, 255, 255, 0, true)
				end
			end, 10000, 1)
		end
	else
		outputChatBox("#FF0000Você não tem permissão para executar este comando!", thePlayer, 255, 255, 255, true )
	end
end
addCommandHandler ("reparar", solicitaPay)

Quais mensagens aparecem no chat?

Apareceu isto:

comando /reparar executado!
@theUser: userdata: 000000A0
@mecanico.solicitation 1#: false

 

Link to comment
  • Other Languages Moderators

Impossível. Deve ter algum erro no /debugscript 3
Não faz sentido ele parar a execução, mesmo que as condições ali sejam falsas.

Pelo menos não no código que mandei.

Link to comment
Just now, Lord Henry said:

Impossível. Deve ter algum erro no /debugscript 3
Não faz sentido ele parar a execução, mesmo que as condições ali sejam falsas.

Com esses problemas, tivemos outra ideia. Não tem como adicionar uma função separada desta, com o mesmo comando do mecanico, com o destroy? dai lá no final ficaria a função sei la "desmarcar" com o command /reparar ?? eu tentei fazer mas não consegui 

Link to comment
2 hours ago, hawkbr said:

Com esses problemas, tivemos outra ideia. Não tem como adicionar uma função separada desta, com o mesmo comando do mecanico, com o destroy? dai lá no final ficaria a função sei la "desmarcar" com o command /reparar ?? eu tentei fazer mas não consegui 

Estranho não estar aparecendo nada no debug sobre o script.

Edited by OverKILL
Link to comment
  • Moderators

@hawkbr

Realmente não era pra ter mostrado só essas mensagens no chat sem ter algum erro no script. Pode ter um erro no trecho da tabela BlipsMEC, essa tabela tá definida no script?

Seria mais fácil postar o código inteiro, poderíamos ter resolvido faz tempo sem ter que ficar olhando pra pequenas partes do código.

Fica a seu critério mandar o código pra alguém em privado ou não.

2 hours ago, hawkbr said:

Com esses problemas, tivemos outra ideia. Não tem como adicionar uma função separada desta, com o mesmo comando do mecanico, com o destroy? dai lá no final ficaria a função sei la "desmarcar" com o command /reparar ?? eu tentei fazer mas não consegui 

Acho que faltou uma explicação do que vocês de fato querem fazer com essa marcação, mecânico, etc. O destroyElement(BlipsMEC[theUser]) vai remover o blip do jogador sem erros, o problema como eu já disse pode estar em outra coisa.

  • Like 1
Link to comment
On 15/06/2018 at 21:44, DNL291 said:

@hawkbr

Realmente não era pra ter mostrado só essas mensagens no chat sem ter algum erro no script. Pode ter um erro no trecho da tabela BlipsMEC, essa tabela tá definida no script?

Seria mais fácil postar o código inteiro, poderíamos ter resolvido faz tempo sem ter que ficar olhando pra pequenas partes do código.

Fica a seu critério mandar o código pra alguém em privado ou não.

Acho que faltou uma explicação do que vocês de fato querem fazer com essa marcação, mecânico, etc. O destroyElement(BlipsMEC[theUser]) vai remover o blip do jogador sem erros, o problema como eu já disse pode estar em outra coisa.

O que de fato queremos fazer... Então a odeia é, quando a pessoa pedir o mecanico ele vai por um marcador pra localizar o cliente e vai até ele e quando ele solicitar o reparo e a pessoa aceitar o blip some pois ele já concluiu aquele trabalho. É possivel ter um /desmarcar ? Pq desse jeito aí não está funcionando.

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