Jump to content

Dúvidas Marcadores


Recommended Posts

Pessoal, me tirem uma dúvida...

 

Tenho um emprego e queria incluir dentro desse emprego uma função...

Por exemplo: /marcar PlayerName (e aí essa função colocaria um blip nele no mapa, e /desmarcar PlayerName para remover.

 

Como posso fazer isso?

Edited by KingBC
Link to comment
  • Other Languages Moderators

Uma pergunta: Pq vc está citando ninguém em sua assinatura? É proposital isso?

--------------------------

Referente ao post, use getPlayerFromName ou getPlayerFromPartialName (este é melhor, já que o nome não precisa ser inteiro e exato) para obter o jogador pelo nick. Depois use createBlipAttachedTo para criar um blip anexado ao jogador. A função deve ser chamada por um comando ativador (addCommandHandler) e os parâmetros de nick são informados na função, assim como mostra na Wiki do AddCommandHandler.

  • Thanks 2
Link to comment
32 minutes ago, Lord Henry said:

Uma pergunta: Pq vc está citando ninguém em sua assinatura? É proposital isso?

--------------------------

Referente ao post, use getPlayerFromName ou getPlayerFromPartialName (este é melhor, já que o nome não precisa ser inteiro e exato) para obter o jogador pelo nick. Depois use createBlipAttachedTo para criar um blip anexado ao jogador. A função deve ser chamada por um comando ativador (addCommandHandler) e os parâmetros de nick são informados na função, assim como mostra na Wiki do AddCommandHandler.

desculpe não entendi da assinatura

Link to comment
  • Other Languages Moderators
37 minutes ago, Lord Henry said:

Referente ao post, use getPlayerFromName ou getPlayerFromPartialName (este é melhor, já que o nome não precisa ser inteiro e exato) para obter o jogador pelo nick. Depois use createBlipAttachedTo para criar um blip anexado ao jogador. A função deve ser chamada por um comando ativador (addCommandHandler) e os parâmetros de nick são informados na função, assim como mostra na Wiki do AddCommandHandler.

 

  • Thanks 1
Link to comment
57 minutes ago, Lord Henry said:

Uma pergunta: Pq vc está citando ninguém em sua assinatura? É proposital isso?

--------------------------

Referente ao post, use getPlayerFromName ou getPlayerFromPartialName (este é melhor, já que o nome não precisa ser inteiro e exato) para obter o jogador pelo nick. Depois use createBlipAttachedTo para criar um blip anexado ao jogador. A função deve ser chamada por um comando ativador (addCommandHandler) e os parâmetros de nick são informados na função, assim como mostra na Wiki do AddCommandHandler.

Ok.. vou tentar aqui com aquela dica que você deu. No caso, para a função de desmarcar como eu faria para desativar o blip ??

 

Link to comment
1 hour ago, Lord Henry said:

Destrua o elemento do blip.

E depois anule a variável dele.

Opa, beleza ? Fiz aqui a função usando aquela ajuda que nos deu, mas tivemos dois problemas:

Nessa função, o player que está sendo marcado é o mecanico :(
 

function marcarplayer(thePlayer, cmd, user)
    local accName = getAccountName(getPlayerAccount(thePlayer))
    if isObjectInACLGroup ("user."..accName, aclGetGroup ("Mec") ) then
        if not user then
            outputChatBox ("Erro: use /marcar <nick>", thePlayer, 255, 255, 0)
        elseif not getPlayerFromPartialName (user) then
            outputChatBox ("Jogador não encontrado.", thePlayer, 255, 255, 0)
        else
        BlipsMEC[thePlayer] = createBlipAttachedTo(thePlayer,0,2,0,0,250,210)
        outputChatBox ("O cliente "..getPlayerName (thePlayer).."#FFFF00 foi marcado no mapa!", theUser, 255, 255, 0, true)
        end
    else
        outputChatBox ("Você não tem permissão para executar este comando!", thePlayer, 255, 0, 0)
    end
end
addCommandHandler ("marcar", marcarplayer)    
    

 

E eu tentei adicionar uma função na solicitaplay de tirar o blip, mas dai nem o script funcionou :(

 

function solicitaPay (thePlayer, cmd, user)
    local accName = getAccountName(getPlayerAccount(thePlayer))
    if isObjectInACLGroup ("user."..accName, aclGetGroup ("Mec") ) then
        if not user then
            outputChatBox ("Erro de sintaxe, use /repararr <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)
            if getElementData (theUser, "mecanico.solicitation") then
                outputChatBox ("Alguém já está solicitando pagamento mecânico a este jogador.", thePlayer, 255, 255, 0)
            else
                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)
                mechTimer[thePlayer] = setTimer (function ()
                destroyElement(BlipsMEC[source])
                    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)

Se puder me dizer o que fiz de errado e me mostrar uma possivel correção ou algo do tipo, eu ficaria muito grato !

Link to comment
  • Other Languages Moderators

Você anexou ao jogador que está executando o comando /marcar (thePlayer), use no usuário alvo (user), mas user é o nick dele, vc deve converter para o elemento jogador antes de usá-lo.

local user = getPlayerFromPartialName (user)
BlipsMEC[thePlayer] = createBlipAttachedTo (user, 0, 2, 0, 0, 250, 210)

 

  • Thanks 1
Link to comment
11 minutes ago, Lord Henry said:

Você anexou ao jogador que está executando o comando /marcar (thePlayer), use no usuário alvo (user), mas user é o nick dele, vc deve converter para o elemento jogador antes de usá-lo.


local user = getPlayerFromPartialName (user)
BlipsMEC[thePlayer] = createBlipAttachedTo (user, 0, 2, 0, 0, 250, 210)

 

E sobre tirar o blip ?Que eu adicionei, porem o script parou de funcionar

14 minutes ago, Lord Henry said:

Você anexou ao jogador que está executando o comando /marcar (thePlayer), use no usuário alvo (user), mas user é o nick dele, vc deve converter para o elemento jogador antes de usá-lo.


local user = getPlayerFromPartialName (user)
BlipsMEC[thePlayer] = createBlipAttachedTo (user, 0, 2, 0, 0, 250, 210)

 

fizemos os testes.. não marcou :( 

 

function marcarplayer(thePlayer, cmd, user)
    local user = getPlayerFromPartialName (user)
    if isObjectInACLGroup ("user."..accName, aclGetGroup ("Mec") ) then
        if not user then
            outputChatBox ("Erro: use /marcar <nick>", thePlayer, 255, 255, 0)
        elseif not getPlayerFromPartialName (user) then
            outputChatBox ("Jogador não encontrado.", thePlayer, 255, 255, 0)
        else
        BlipsMEC[thePlayer] = createBlipAttachedTo (user, 0, 2, 0, 0, 250, 210)
        outputChatBox ("O cliente "..getPlayerFromPartialName (user).."#FFFF00 foi marcado no mapa!", thePlayer, 255, 255, 0, true)
        end
    else
        outputChatBox ("Você não tem permissão para executar este comando!", thePlayer, 255, 0, 0)
    end
end
addCommandHandler ("marcar", marcarplayer)    

 

Edited by hawkbr
Link to comment
  • Moderators

Deixou o debug ativado? Digite /debugscript 3 quando for testar script.

Você está usando a função getPlayerFromPartialName? (https://wiki.multitheftauto.com/wiki/GetPlayerFromPartialName)

Fora isso, o que percebi é que o valor 'user' do comando passa a ser uma variável do elemento-jogador, mas continua sendo passado na função getPlayerFromPartialName.

Link to comment
3 minutes ago, DNL291 said:

Deixou o debug ativado? Digite /debugscript 3 quando for testar script.

Você está usando a função getPlayerFromPartialName? (https://wiki.multitheftauto.com/wiki/GetPlayerFromPartialName)

Fora isso, o que percebi é que o valor 'user' do comando passa a ser uma variável do elemento-jogador, mas continua sendo passado na função getPlayerFromPartialName.

Usei o debug, aparecel algo sobre nill value na linha 100

Precisamente: Attempt to concatenate global 'accName' (a nill value)
eu não consegui entender muito bem .. e não entendi isso do valor do user continuar sendo passado  

if isObjectInACLGroup ("user."..accName, aclGetGroup ("Mec") ) then 

 

Link to comment
  • Moderators

Tenta isto:

function marcarplayer(thePlayer, cmd, user)
	if isObjectInACLGroup ("user."..getAccountName(getPlayerAccount(thePlayer)), aclGetGroup ("Mec") ) ~= true then
		return outputChatBox ("Você não tem permissão para executar este comando!", thePlayer, 255, 0, 0)
	end
	if not user then
		outputChatBox ("Erro: use /marcar <nick>", thePlayer, 255, 255, 0)
	elseif user and not isElement(getPlayerFromPartialName (user)) then
		outputChatBox ("Jogador não encontrado.", thePlayer, 255, 255, 0)
	elseif isElement(getPlayerFromPartialName (user)) then
		local player = getPlayerFromPartialName (user)
		BlipsMEC[thePlayer] = createBlipAttachedTo (player, 0, 2, 0, 0, 250, 210)
		outputChatBox ("O cliente "..getPlayerName(player).."#FFFF00 foi marcado no mapa!", thePlayer, 255, 255, 0, true)
	end
end
addCommandHandler ("marcar", marcarplayer)

function getPlayerFromPartialName(name)
    local name = name and name:gsub("#%x%x%x%x%x%x", ""):lower() or nil
    if name then
        for _, player in ipairs(getElementsByType("player")) do
            local name_ = getPlayerName(player):gsub("#%x%x%x%x%x%x", ""):lower()
            if name_:find(name, 1, true) then
                return player
            end
        end
    end
end

 

Link to comment
12 minutes ago, DNL291 said:

Tenta isto:


function marcarplayer(thePlayer, cmd, user)
	if isObjectInACLGroup ("user."..getAccountName(getPlayerAccount(thePlayer)), aclGetGroup ("Mec") ) ~= true then
		return outputChatBox ("Você não tem permissão para executar este comando!", thePlayer, 255, 0, 0)
	end
	if not user then
		outputChatBox ("Erro: use /marcar <nick>", thePlayer, 255, 255, 0)
	elseif user and not isElement(getPlayerFromPartialName (user)) then
		outputChatBox ("Jogador não encontrado.", thePlayer, 255, 255, 0)
	elseif isElement(getPlayerFromPartialName (user)) then
		local player = getPlayerFromPartialName (user)
		BlipsMEC[thePlayer] = createBlipAttachedTo (player, 0, 2, 0, 0, 250, 210)
		outputChatBox ("O cliente "..getPlayerName(player).."#FFFF00 foi marcado no mapa!", thePlayer, 255, 255, 0, true)
	end
end
addCommandHandler ("marcar", marcarplayer)

function getPlayerFromPartialName(name)
    local name = name and name:gsub("#%x%x%x%x%x%x", ""):lower() or nil
    if name then
        for _, player in ipairs(getElementsByType("player")) do
            local name_ = getPlayerName(player):gsub("#%x%x%x%x%x%x", ""):lower()
            if name_:find(name, 1, true) then
                return player
            end
        end
    end
end

 

FUNCIONOU ! Muito obrigado. Agora pra tirar o blip, eu usei o 

 

destroyElement(BlipsMEC[source])

na hora do mecanico solicitar, porem o blip não ta sendo removido. Teria como me ajudar ??


 

function solicitaPay (thePlayer, cmd, user)
    local accName = getAccountName(getPlayerAccount(thePlayer))
    if isObjectInACLGroup ("user."..accName, aclGetGroup ("Mec") ) then
        if not user then
            outputChatBox ("Erro de sintaxe, use /reparar <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)
            if getElementData (theUser, "mecanico.solicitation") then
                outputChatBox ("Alguém já está solicitando pagamento mecânico a este jogador.", thePlayer, 255, 255, 0)
            else
                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)
                mechTimer[thePlayer] = setTimer (function ()
                destroyElement(BlipsMEC[source])
                    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
  • Moderators
if isElement(BlipsMEC[theUser]) then destroyElement(BlipsMEC[theUser]) end

Acho que meu comentário acima por algum motivo ficou oculto ;), então tente isso.

EDIT: Então o comando /marcar ficaria assim:

function marcarplayer(thePlayer, cmd, user)
	if isObjectInACLGroup ("user."..getAccountName(getPlayerAccount(thePlayer)), aclGetGroup ("Mec") ) ~= true then
		return outputChatBox ("Você não tem permissão para executar este comando!", thePlayer, 255, 0, 0)
	end
	if not user then
		outputChatBox ("Erro: use /marcar <nick>", thePlayer, 255, 255, 0)
	elseif user and not isElement(getPlayerFromPartialName (user)) then
		outputChatBox ("Jogador não encontrado.", thePlayer, 255, 255, 0)
	elseif isElement(getPlayerFromPartialName (user)) then
		local player = getPlayerFromPartialName (user)
		BlipsMEC[player] = createBlipAttachedTo (player, 0, 2, 0, 0, 250, 210)
		outputChatBox ("O cliente "..getPlayerName(player).."#FFFF00 foi marcado no mapa!", thePlayer, 255, 255, 0, true)
	end
end
addCommandHandler ("marcar", marcarplayer)

Limpando a tabela quando saírem do server:

addEventHandler ( "onPlayerQuit", root, function ( )
	if BlipsMEC[source] then
		if isElement(BlipsMEC[source]) then destroyElement(BlipsMEC[source]) end
		BlipsMEC[source] = nil
	end
end )

 

Edited by DNL291
Link to comment
49 minutes ago, DNL291 said:

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

Acho que meu comentário acima por algum motivo ficou oculto ;), então tente isso.

EDIT: Então o comando /marcar ficaria assim:


function marcarplayer(thePlayer, cmd, user)
	if isObjectInACLGroup ("user."..getAccountName(getPlayerAccount(thePlayer)), aclGetGroup ("Mec") ) ~= true then
		return outputChatBox ("Você não tem permissão para executar este comando!", thePlayer, 255, 0, 0)
	end
	if not user then
		outputChatBox ("Erro: use /marcar <nick>", thePlayer, 255, 255, 0)
	elseif user and not isElement(getPlayerFromPartialName (user)) then
		outputChatBox ("Jogador não encontrado.", thePlayer, 255, 255, 0)
	elseif isElement(getPlayerFromPartialName (user)) then
		local player = getPlayerFromPartialName (user)
		BlipsMEC[player] = createBlipAttachedTo (player, 0, 2, 0, 0, 250, 210)
		outputChatBox ("O cliente "..getPlayerName(player).."#FFFF00 foi marcado no mapa!", thePlayer, 255, 255, 0, true)
	end
end
addCommandHandler ("marcar", marcarplayer)

Limpando a tabela quando saírem do server:


addEventHandler ( "onPlayerQuit", root, function ( )
	if BlipsMEC[source] then
		if isElement(BlipsMEC[source]) then destroyElement(BlipsMEC[source]) end
		BlipsMEC[source] = nil
	end
end )

 

Não está saindo o blip quando o mecanico manda a solicitação.


 

function getPlayerFromPartialName (name)
    local name = name and name:gsub("#%x%x%x%x%x%x", ""):lower() or nil
    if name then
        for _, player in ipairs(getElementsByType("player")) do
            local name_ = getPlayerName(player):gsub("#%x%x%x%x%x%x", ""):lower()
            if name_:find(name, 1, true) then
                return player
            end
        end
    end
end

local damagedVehs = {}

function solicitaPay (thePlayer, cmd, user)
    local accName = getAccountName(getPlayerAccount(thePlayer))
    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)
            if getElementData (theUser, "mecanico.solicitation") then
                outputChatBox ("Alguém já está solicitando pagamento mecânico a este jogador.", thePlayer, 255, 255, 0)
            else
                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)
                mechTimer[thePlayer] = setTimer (function ()
                    if isElement(BlipsMEC[theUser]) then 
                        destroyElement(BlipsMEC[theUser])
                        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
                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)

function aceitaPay (thePlayer, cmd)
    local mech = getElementData (thePlayer, "mecanico.solicitation")
    if mech and damagedVehs[thePlayer] and isElement(damagedVehs[thePlayer]) then
        if getPlayerMoney (thePlayer) >= 2500 and getPedOccupiedVehicle(mech) == damagedVehs[thePlayer] then
            takePlayerMoney (thePlayer, 2500)
            givePlayerMoney (mech, 2500)
            outputChatBox ("Seu pedido foi aceito. Voce recebeu R$2.500 pelo conserto.", mech, 0, 255, 0)
            
            fixVehicle (damagedVehs[thePlayer])
            damagedVehs[thePlayer] = nil
            
            setElementData (thePlayer, "mecanico.solicitation", false)
            outputChatBox ("Seu veículo foi consertado.", thePlayer, 0, 255, 0)
        else
            outputChatBox ("Você não tem dinheiro suficiente.", thePlayer, 255, 0, 0)
        end
    end
end
addCommandHandler ("aceitar", aceitaPay)

addEventHandler( "onPlayerQuit", root,
    function()
        if damagedVehs[source] then
            damagedVehs[source] = nil
        end
    end
)

--- Mensagem /mec
function globalMessage(thePlayer, cmd, ...) 
    local message = table.concat ( { ... }, " " ); 
    local name = getPlayerName(thePlayer); 
for _,v in ipairs(getElementsByType("player")) do 
    outputChatBox("#FF0000[AJUDA]#00FF00"..name.." #FFFFFFPrecisa de um MECÂNICO"..message,v, 255, 255, 255, true) 
    end 
end 
addCommandHandler("mec",  globalMessage);

function recusaPay (thePlayer, cmd)
    if getElementData (thePlayer, "mecanico.solicitation") then
        outputChatBox ("Seu pedido foi recusado.", getElementData (thePlayer, "mecanico.solicitation"), 255, 0, 0)
        setElementData (thePlayer, "mecanico.solicitation", false)
        outputChatBox ("Você recusou o pagamento. Seu veículo não foi consertado.", thePlayer, 255, 0, 0)
    end
end
addCommandHandler ("recusar", recusaPay)

function marcarplayer(thePlayer, cmd, user)
    if isObjectInACLGroup ("user."..getAccountName(getPlayerAccount(thePlayer)), aclGetGroup ("Mec") ) ~= true then
        return outputChatBox ("Você não tem permissão para executar este comando!", thePlayer, 255, 0, 0)
    end
    if not user then
        outputChatBox ("Erro: use /marcar <nick>", thePlayer, 255, 255, 0)
    elseif user and not isElement(getPlayerFromPartialName (user)) then
        outputChatBox ("Jogador não encontrado.", thePlayer, 255, 255, 0)
    elseif isElement(getPlayerFromPartialName (user)) then
        local player = getPlayerFromPartialName (user)
        BlipsMEC[player] = createBlipAttachedTo (player, 0, 2, 0, 0, 250, 210)
        outputChatBox ("O cliente "..getPlayerName(player).."#FFFF00 foi marcado no mapa!", thePlayer, 255, 255, 0, true)
    end
end
addCommandHandler ("marcar", marcarplayer)

function getPlayerFromPartialName(name)
    local name = name and name:gsub("#%x%x%x%x%x%x", ""):lower() or nil
    if name then
        for _, player in ipairs(getElementsByType("player")) do
            local name_ = getPlayerName(player):gsub("#%x%x%x%x%x%x", ""):lower()
            if name_:find(name, 1, true) then
                return player
            end
        end
    end
end

addEventHandler ( "onPlayerQuit", root, function ( )
    if BlipsMEC[source] then
        if isElement(BlipsMEC[source]) then destroyElement(BlipsMEC[source]) end
        BlipsMEC[source] = nil
    end
end )
    
        
        

 

Edited by hawkbr
Link to comment
  • Moderators

Tem um 'end' a mais na linha 42. Tem duas funções getPlayerFromPartialName no código, tire uma delas.

Por favor, da próxima vez use o comando /debugscript 3 e mostre aqui o erro. Desse jeito você faz a gente vasculhar o código inteiro pra achar um erro simples.

Link to comment
5 minutes ago, DNL291 said:

Tem um 'end' a mais na linha 42. Tem duas funções getPlayerFromPartialName no código, tire uma delas.

Por favor, da próxima vez use o comando /debugscript 3 e mostre aqui o erro. Desse jeito você faz a gente vasculhar o código inteiro pra achar um erro simples.

function getPlayerFromPartialName (name)
    local name = name and name:gsub("#%x%x%x%x%x%x", ""):lower() or nil
    if name then
        for _, player in ipairs(getElementsByType("player")) do
            local name_ = getPlayerName(player):gsub("#%x%x%x%x%x%x", ""):lower()
            if name_:find(name, 1, true) then
                return player
            end
        end
    end
end

local damagedVehs = {}

function solicitaPay (thePlayer, cmd, user)
    local accName = getAccountName(getPlayerAccount(thePlayer))
    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)
            if getElementData (theUser, "mecanico.solicitation") then
                outputChatBox ("Alguém já está solicitando pagamento mecânico a este jogador.", thePlayer, 255, 255, 0)
            else
                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)
                mechTimer[thePlayer] = setTimer (function ()
                    if isElement(BlipsMEC[theUser]) then 
                        destroyElement(BlipsMEC[theUser])
                        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)

function aceitaPay (thePlayer, cmd)
    local mech = getElementData (thePlayer, "mecanico.solicitation")
    if mech and damagedVehs[thePlayer] and isElement(damagedVehs[thePlayer]) then
        if getPlayerMoney (thePlayer) >= 2500 and getPedOccupiedVehicle(mech) == damagedVehs[thePlayer] then
            takePlayerMoney (thePlayer, 2500)
            givePlayerMoney (mech, 2500)
            outputChatBox ("Seu pedido foi aceito. Voce recebeu R$2.500 pelo conserto.", mech, 0, 255, 0)
            
            fixVehicle (damagedVehs[thePlayer])
            damagedVehs[thePlayer] = nil
            
            setElementData (thePlayer, "mecanico.solicitation", false)
            outputChatBox ("Seu veículo foi consertado.", thePlayer, 0, 255, 0)
        else
            outputChatBox ("Você não tem dinheiro suficiente.", thePlayer, 255, 0, 0)
        end
    end
end
addCommandHandler ("aceitar", aceitaPay)

addEventHandler( "onPlayerQuit", root,
    function()
        if damagedVehs[source] then
            damagedVehs[source] = nil
        end
    end
)

--- Mensagem /mec
function globalMessage(thePlayer, cmd, ...) 
    local message = table.concat ( { ... }, " " ); 
    local name = getPlayerName(thePlayer); 
for _,v in ipairs(getElementsByType("player")) do 
    outputChatBox("#FF0000[AJUDA]#00FF00"..name.." #FFFFFFPrecisa de um MECÂNICO"..message,v, 255, 255, 255, true) 
    end 
end 
addCommandHandler("mec",  globalMessage);

function recusaPay (thePlayer, cmd)
    if getElementData (thePlayer, "mecanico.solicitation") then
        outputChatBox ("Seu pedido foi recusado.", getElementData (thePlayer, "mecanico.solicitation"), 255, 0, 0)
        setElementData (thePlayer, "mecanico.solicitation", false)
        outputChatBox ("Você recusou o pagamento. Seu veículo não foi consertado.", thePlayer, 255, 0, 0)
    end
end
addCommandHandler ("recusar", recusaPay)

function marcarplayer(thePlayer, cmd, user)
    if isObjectInACLGroup ("user."..getAccountName(getPlayerAccount(thePlayer)), aclGetGroup ("Mec") ) ~= true then
        return outputChatBox ("Você não tem permissão para executar este comando!", thePlayer, 255, 0, 0)
    end
    if not user then
        outputChatBox ("Erro: use /marcar <nick>", thePlayer, 255, 255, 0)
    elseif user and not isElement(getPlayerFromPartialName (user)) then
        outputChatBox ("Jogador não encontrado.", thePlayer, 255, 255, 0)
    elseif isElement(getPlayerFromPartialName (user)) then
        local player = getPlayerFromPartialName (user)
        BlipsMEC[player] = createBlipAttachedTo (player, 0, 2, 0, 0, 250, 210)
        outputChatBox ("O cliente "..getPlayerName(player).."#FFFF00 foi marcado no mapa!", thePlayer, 255, 255, 0, true)
    end
end
addCommandHandler ("marcar", marcarplayer)


addEventHandler ( "onPlayerQuit", root, function ( )
    if BlipsMEC[source] then
        if isElement(BlipsMEC[source]) then destroyElement(BlipsMEC[source]) end
        BlipsMEC[source] = nil
    end
end )


    Linha 43: unexpected symbol near "," 
        
        

Link to comment
  • Moderators

Não, deve ser apenas a linha como eu postei. Como você pode ver, já tem o 'end' fechando.

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

Assim:

function solicitaPay (thePlayer, cmd, user)
    local accName = getAccountName(getPlayerAccount(thePlayer))
    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)
            if getElementData (theUser, "mecanico.solicitation") then
                outputChatBox ("Alguém já está solicitando pagamento mecânico a este jogador.", thePlayer, 255, 255, 0)
            else
                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)
                mechTimer[thePlayer] = setTimer (function ()
                    if isElement(BlipsMEC[theUser]) then destroyElement(BlipsMEC[theUser]) end
                    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
2 minutes ago, DNL291 said:

Não, deve ser apenas a linha como eu postei. Como você pode ver, já tem o 'end' fechando.


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

Assim:


function solicitaPay (thePlayer, cmd, user)
    local accName = getAccountName(getPlayerAccount(thePlayer))
    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)
            if getElementData (theUser, "mecanico.solicitation") then
                outputChatBox ("Alguém já está solicitando pagamento mecânico a este jogador.", thePlayer, 255, 255, 0)
            else
                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)
                mechTimer[thePlayer] = setTimer (function ()
                    if isElement(BlipsMEC[theUser]) then destroyElement(BlipsMEC[theUser]) end
                    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)

 

Quando o mecanico solicita, ainda ta continuando o blip.. teria outra forma de fazer o blip desaparecer quando ele digitar o comando /reparar ???

 

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