Ir para conteúdo
  • Cadastre-se

(Resolvido)attempt to perform arithmetic on a boolean value SQL


Ir para solução Resolvido por matsantos,

Posts Recomendados

Usando tfs 0.4

Estou recebendo o erro 

[23:22:26.742] [Error - Action Interface]
[23:22:26.747] data/actions/scripts/points.lua:onUse
[23:22:26.750] Description:
[23:22:26.752] data/lib/048-ppoints.lua:13: attempt to perform arithmetic on a boolean value
[23:22:26.756] stack traceback:
[23:22:26.758]  data/lib/048-ppoints.lua:13: in function 'doAccountAddPoints'
[23:22:26.762]  data/actions/scripts/points.lua:8: in function <data/actions/scripts/points.lua:5>

 

meu script é 

function getAccountPoints(cid)
    local res = db.getResult("SELECT `points` FROM `znote_accounts` WHERE id = " .. getAccountNumberByPlayerName(getCreatureName(cid))..";")
    if(res:getID() == -1) then
        return false
    end

    local ret = res:getDataInt("points")
    res:free()
    return tonumber(ret)
end

function doAccountAddPoints(cid, count)
    return db.query("UPDATE `znote_accounts` SET `points` = '".. getAccountPoints(cid) + count .."' WHERE id = " .. getAccountNumberByPlayerName(getCreatureName(cid))..";")
end

function doAccountRemovePoints(cid, count)
    return db.query("UPDATE `znote_accounts` SET `points` = '".. getAccountPoints(cid) - count .."' WHERE id = " .. getAccountNumberByPlayerName(getCreatureName(cid))..";")
end

a ideia é quando o player usar o item ele receber os pts na conta

Link para o post
Compartilhar em outros sites
local cfg = {
amount = 1
}

function onUse(cid, item, fromPosition, itemEx, toPosition)

if getPlayerLevel(cid) > 8 then
doAccountAddPoints(cid, cfg.amount)
doCreatureSay(cid, "Parabéns! Você recebeu 1 Premium Points! ", TALKTYPE_ORANGE_1)
doSendMagicEffect(getCreaturePosition(cid), 28)
doRemoveItem(item.uid,1)
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "RELOGUE PARA SALVAR. SEUS PONTOS ESTÃO DISPONIVEIS NO SITE")
else
doPlayerSendCancel(cid,"Você precisa de level 8 para usar este item.")
end
return TRUE
end

action ai

Link para o post
Compartilhar em outros sites
function getAccountPoints(cid)
    local res = db.getResult("SELECT `points` FROM `znote_accounts` WHERE id = " .. getAccountNumberByPlayerName(getCreatureName(cid))..";")
    if(res:getID() ~= -1) then
    	repeat
      		return res:getDataInt("points")
      	until not(res:next())
    	res:free()
    end
end

Aew mano!

só substituir a sua getAccountPoints por essa

Editado por Suckie
esqueci informações (veja o histórico de edições)
Link para o post
Compartilhar em outros sites

@Suckie  deu esse erro

[3:32:36.726] [Error - Action Interface]
[3:32:36.729] data/actions/scripts/points.lua:onUse
[3:32:36.732] Description:
[3:32:36.734] data/lib/048-ppoints.lua:12: attempt to perform arithmetic on a nil value
[3:32:36.739] stack traceback:
[3:32:36.741]   data/lib/048-ppoints.lua:12: in function 'doAccountAddPoints'
[3:32:36.745]   data/actions/scripts/points.lua:8: in function <data/actions/scripts/points.lua:5>

 

Link para o post
Compartilhar em outros sites

ué, aqui ta pegando, verifica se os nomes das tabelas estão corretas.
você colocou essa função abaixo da função doAccountAddPoints?? pq tem que ser EM CIMA
você substitiu a função corretamente? manda outro print

Editado por Suckie (veja o histórico de edições)
Link para o post
Compartilhar em outros sites

 meu código ta assim @Suckie 

function getAccountPoints(cid)
    local res = db.getResult("SELECT `points` FROM `znote_accounts` WHERE id = " .. getAccountNumberByPlayerName(getCreatureName(cid))..";")
    if(res:getID() ~= -1) then
    	repeat
      		return res:getDataInt("points")
      	until not(res:next())
    	res:free()
    end
end

function doAccountAddPoints(cid, count)
return db.query("UPDATE `znote_accounts` SET `points` = '".. getAccountPoints(cid) + count .."' WHERE id = " ..getPlayerAccountId(cid)..";")
end

function doAccountRemovePoints(cid, count)
return db.query("UPDATE `znote_accounts` SET `points` = '".. getAccountPoints(cid) - count .."' WHERE id = " ..getPlayerAccountId(cid)..";")
end

 

e aqui o schema da tabela, os nomes tão certinho

CREATE TABLE IF NOT EXISTS `znote_accounts` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `account_id` int(11) NOT NULL,
  `ip` bigint(20) UNSIGNED NOT NULL,
  `created` int(10) NOT NULL,
  `points` int(10) DEFAULT 0,
  `cooldown` int(10) DEFAULT 0,
  `active` tinyint(4) NOT NULL DEFAULT '0',
  `active_email` tinyint(4) NOT NULL DEFAULT '0',
  `activekey` int(11) NOT NULL DEFAULT '0',
  `flag` varchar(20) NOT NULL,
  `secret` char(16) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB;

 

Editado por Gabrieldsadaxas (veja o histórico de edições)
Link para o post
Compartilhar em outros sites

Você editou a função doAccountAddPoints e doAccountRemovePoints

 

Volte para:

function doAccountAddPoints(cid, count)
    return db.query("UPDATE `znote_accounts` SET `points` = '".. getAccountPoints(cid) + count .."' WHERE id = " .. getAccountNumberByPlayerName(getCreatureName(cid))..";")
end

function doAccountRemovePoints(cid, count)
    return db.query("UPDATE `znote_accounts` SET `points` = '".. getAccountPoints(cid) - count .."' WHERE id = " .. getAccountNumberByPlayerName(getCreatureName(cid))..";")
end
Editado por Suckie
erro de português (veja o histórico de edições)
Link para o post
Compartilhar em outros sites

@Suckie 

[3:53:28.614] [Error - Action Interface]
[3:53:28.619] data/actions/scripts/points.lua:onUse
[3:53:28.622] Description:
[3:53:28.623] data/lib/048-ppoints.lua:12: attempt to perform arithmetic on a nil value
[3:53:28.627] stack traceback:
[3:53:28.629]   data/lib/048-ppoints.lua:12: in function 'doAccountAddPoints'
[3:53:28.634]   data/actions/scripts/points.lua:8: in function <data/actions/scripts/points.lua:5>

usando esse

function getAccountPoints(cid)
    local res = db.getResult("SELECT `points` FROM `znote_accounts` WHERE id = " .. getAccountNumberByPlayerName(getCreatureName(cid))..";")
    if(res:getID() ~= -1) then
    	repeat
      		return res:getDataInt("points")
      	until not(res:next())
    	res:free()
    end
end

function doAccountAddPoints(cid, count)
    return db.query("UPDATE `znote_accounts` SET `points` = '".. getAccountPoints(cid) + count .."' WHERE id = " .. getAccountNumberByPlayerName(getCreatureName(cid))..";")
end

function doAccountRemovePoints(cid, count)
    return db.query("UPDATE `znote_accounts` SET `points` = '".. getAccountPoints(cid) - count .."' WHERE id = " .. getAccountNumberByPlayerName(getCreatureName(cid))..";")
end

 

Editado por Gabrieldsadaxas (veja o histórico de edições)
Link para o post
Compartilhar em outros sites
Link para o post
Compartilhar em outros sites
  • Solução

cê não mexeu no script em actions não?

sinceramente, deveria estar pegando, ou você fez algo errado ou tem alguma maldição mesmo

tenta dar uma revisada em tudo, vou dormir

Link para o post
Compartilhar em outros sites

n mexi em nada alem do arquivo das query... vlw man boa noite

 

 

edit: consegui arrumar, na primeira query ali em vez de "id" era "account_id"

Editado por Gabrieldsadaxas (veja o histórico de edições)
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.

×
×
  • Criar Novo...

Informação Importante

Confirmação de Termo