Ir para conteúdo
  • Cadastre-se

(Resolvido)[Pedido] Comando !withdraw


Ir para solução Resolvido por brendoonh,

Posts Recomendados

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

Mostrar mais  

 

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

 

Link para o post
Compartilhar em outros sites
  • Respostas 9
  • Created
  • Última resposta

Top Posters In This Topic

Top Posters In This Topic

Popular Posts

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 requ

@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 função tonumber, transformando a string e numero e fazendo a comparação corretamente.   Quando você fala algo no game, vamos supor que o numero 24, ex: 21:30 KotZletY [132]: 24  como falei o numero 24, ele na distro é reconhecido assim "24", em string, e não tem como comparar, a funç

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   function onSay(cid, words, param)          if getPlayerTown(cid) == 24 then         doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You cannot withdraw money while being in Rookgaard.")         return true     end          if isPlayer(cid) == TRUE and param ~= nil then         if getTilePzInfo

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)
Link para o post
Compartilhar em outros sites
  Em 23/01/2017 em 02:06, 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
Mostrar mais  

Testei

ta acusando que o meu player nao tem money!

00:12 Your account balance is 3616 gold.

Link para o post
Compartilhar em outros sites
  • 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

Link para o post
Compartilhar em outros sites
  Em 23/01/2017 em 02:26, 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

Expand   Mostrar mais  

Obrigado @brendoonh ajudo muito!!

 

Link para o post
Compartilhar em outros sites

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

×   Você colou conteúdo com formatação.   Remover formatação

  Apenas 75 emojis são permitidos.

×   Seu link foi automaticamente incorporado.   Mostrar como link

×   Seu conteúdo anterior foi restaurado.   Limpar o editor

×   Não é possível colar imagens diretamente. Carregar ou inserir imagens do URL.

  • Quem Está Navegando   0 membros estão online

    Nenhum usuário registrado visualizando esta página.

  • Estatísticas dos Fóruns

    96844
    Tópicos
    519597
    Posts



×
×
  • Criar Novo...

Informação Importante

Confirmação de Termo