Ir para conteúdo

Featured Replies

Postado

Fala galera, peguei um comando aqui no TK, de !withdraw tirar dinheiro do banco,

mais não esta funcionando está dando erro em linha 9!

Citar

[Error - TalkAction Interface] data/talkactions/scripts/withdraw.lua:onSay Description: data/talkactions/scripts/withdraw.lua:9: attempt to compare string with number stack traceback: data/talkactions/scripts/withdraw.lua:9: in function

 

Scripts

function onSay(cid, words, param) 
    if getPlayerTown(cid) == 24 then 
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You cannot withdraw money being in Rookgaard.") 
        return 
    end 
     
    if isPlayer(cid) == TRUE and param ~= "" then 
        if getTilePzInfo(getPlayerPosition(cid)) == TRUE then 
                if getPlayerBalance(cid) >= param then           -----------> ERRO NESSA LINHA
                    doPlayerSetBalance(cid, getPlayerBalance(cid) - param) 
                    doPlayerAddMoney(cid, param) 
                    doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Here you are, ".. param .." gold.") 
                else 
                    doPlayerSendCancel(cid, "You do not have enough money.") 
                    doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF) 
                end 
        else 
            doPlayerSendCancel(cid, "You can only use this command in PZ.") 
            doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF) 
        end 
    end 
end

 

Resolvido por brendoonh

Ir para solução
  • Respostas 9
  • Visualizações 1k
  • Created
  • Última resposta

Top Posters In This Topic

Most Popular Posts

  • function onSay(cid, words, param) local config = { bankSystemEnabled = getBooleanFromString(getConfigInfo('bankSystem')), playerIsFighting = hasCondition(cid, CONDITION_INFIGHT) } if config.bankSystem

  • @Tópico movido para área correta, mais atenção da próxima vez!   Tal erro era causado pelo fato do script está tentando comparar string com number, como o membro acima postou, bastava usar a

  • Fiquei sem internet por 1 dia e não deu tempo ajudar, mas vi que o membro acima já lhe passou um script. Mas se quiser usar o seu próprio script olha ai, testei e tá funcionando normal  

Postado

Tenta

 

function onSay(cid, words, param) 
    if getPlayerTown(cid) == 24 then 
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You cannot withdraw money being in Rookgaard.") 
        return 
    end 
     
    if isPlayer(cid) == TRUE and param ~= "" then 
        if getTilePzInfo(getPlayerPosition(cid)) == TRUE then 
                if getPlayerBalance(cid) == param then
                    doPlayerSetBalance(cid, getPlayerBalance(cid) - param) 
                    doPlayerAddMoney(cid, param) 
                    doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Here you are, ".. param .." gold.") 
                else 
                    doPlayerSendCancel(cid, "You do not have enough money.") 
                    doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF) 
                end 
        else 
            doPlayerSendCancel(cid, "You can only use this command in PZ.") 
            doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF) 
        end 
    end 
end

Editado por Noob II (veja o histórico de edições)

Postado
  • Autor
7 minutos atrás, Noob II disse:

Tenta

 


function onSay(cid, words, param) 
    if getPlayerTown(cid) == 24 then 
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You cannot withdraw money being in Rookgaard.") 
        return 
    end 
     
    if isPlayer(cid) == TRUE and param ~= "" then 
        if getTilePzInfo(getPlayerPosition(cid)) == TRUE then 
                if getPlayerBalance(cid) == param then
                    doPlayerSetBalance(cid, getPlayerBalance(cid) - param) 
                    doPlayerAddMoney(cid, param) 
                    doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Here you are, ".. param .." gold.") 
                else 
                    doPlayerSendCancel(cid, "You do not have enough money.") 
                    doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF) 
                end 
        else 
            doPlayerSendCancel(cid, "You can only use this command in PZ.") 
            doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF) 
        end 
    end 
end

Testei

ta acusando que o meu player nao tem money!

00:12 Your account balance is 3616 gold.

Postado
  • Solução
function onSay(cid, words, param)
local config = {
bankSystemEnabled = getBooleanFromString(getConfigInfo('bankSystem')),
playerIsFighting = hasCondition(cid, CONDITION_INFIGHT)
}
if config.bankSystemEnabled == TRUE then
if config.playerIsFighting == FALSE then
local m = tonumber(param)
if(param == "") then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Command requires param.")
return TRUE
end
if(not m) then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Command requires numeric param.")
return TRUE
end
m = math.abs(m)
if m <= getPlayerBalance(cid) then
doPlayerWithdrawMoney(cid, m)
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Here you are, " .. m .. " gold. Your account balance is " .. getPlayerBalance(cid) .. ".")
else
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "There is not enough gold on your account.")
end
return TRUE
else
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Bank can not be used in fight.")
return TRUE
end
else
return FALSE
end
end

testa ai

Postado
  • Autor
28 minutos atrás, brendoonh disse:

function onSay(cid, words, param)
local config = {
bankSystemEnabled = getBooleanFromString(getConfigInfo('bankSystem')),
playerIsFighting = hasCondition(cid, CONDITION_INFIGHT)
}
if config.bankSystemEnabled == TRUE then
if config.playerIsFighting == FALSE then
local m = tonumber(param)
if(param == "") then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Command requires param.")
return TRUE
end
if(not m) then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Command requires numeric param.")
return TRUE
end
m = math.abs(m)
if m <= getPlayerBalance(cid) then
doPlayerWithdrawMoney(cid, m)
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Here you are, " .. m .. " gold. Your account balance is " .. getPlayerBalance(cid) .. ".")
else
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "There is not enough gold on your account.")
end
return TRUE
else
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Bank can not be used in fight.")
return TRUE
end
else
return FALSE
end
end

testa ai

Obrigado @brendoonh ajudo muito!!

 

Participe da conversa

Você pode postar agora e se cadastrar mais tarde. Se você tem uma conta, faça o login para postar com sua conta.

Visitante
Responder

Quem Está Navegando 0

  • Nenhum usuário registrado visualizando esta página.

Estatísticas dos Fóruns

  • Tópicos 96.9k
  • Posts 519.6k

Informação Importante

Confirmação de Termo