Postado Março 25, 2014 11 anos Boa noite gente. Bem, quando vou depositar dinheiro na conta da guild, usando o comando /balance donate 1000 (exemplo) Me deparo com este erro no distro do servidor; SQLITE3_prepare_v2<>: SQLITE error: near "LIMIT": syntax error (UPDATE) guilds SET "balance" + 1000 WHERE "id" = 1 LIMIT 1> Alguém sabe como resolver? Peço que algum moderador feche o tópico. Consegui arrumar, era um erro bem idiota, mexi muito e não tinha conseguido, ai agora me veio a cabeça deletar o LIMIT 1 (que sinceramente era bem óbvio, mas não pensei nisso, eu estava mexendo era na DB ao invés de mexer no script) e consegui ahuaudsuha Estou postando a solução caso alguém se depare com o mesmo erro. No script que citei abaixo (balance.lua) Troque a linha: if(not db.executeQuery('UPDATE `guilds` SET `balance` = `balance` - ' .. money[1] .. ' WHERE `id` = ' .. guild .. ' LIMIT')) then Por: if(not db.executeQuery("UPDATE `guilds` SET `balance` = `balance` - " .. money[1] .. " WHERE `id` = " .. guild .. "")) then E mais abaixo troque a outra linha: db.executeQuery('UPDATE `guilds` SET `balance` = `balance` + ' .. money .. ' WHERE `id` = ' .. guild .. ' LIMIT') Por: db.executeQuery("UPDATE `guilds` SET `balance` = `balance` + " .. money .. " WHERE `id` = " .. guild .. "") Meu script; local function isValidMoney(value) if(value == nil) then return false end return (value > 0 and value <= 99999999999999) end function onSay(cid, words, param, channel) local guild = getPlayerGuildId(cid) if(guild == 0) then return false end local t = string.explode(param, ' ', 1) if(getPlayerGuildLevel(cid) == GUILDLEVEL_LEADER and isInArray({ 'pick' }, t[1])) then if(t[1] == 'pick') then local money = { tonumber(t[2]) } if(not isValidMoney(money[1])) then doPlayerSendChannelMessage(cid, '', 'Invalid amount of money specified.', TALKTYPE_CHANNEL_HIGHLIGHT, CHANNEL_GUILD) return true end local result = db.getResult('SELECT `balance` FROM `guilds` WHERE `id` = ' .. guild) if(result:getID() == -1) then return false end money[2] = result:getDataLong('balance') result:free() if(money[1] > money[2]) then doPlayerSendChannelMessage(cid, '', 'The balance is too low for such amount.', TALKTYPE_CHANNEL_HIGHLIGHT, CHANNEL_GUILD) return true end if(not db.executeQuery('UPDATE `guilds` SET `balance` = `balance` - ' .. money[1] .. ' WHERE `id` = ' .. guild .. ' LIMIT')) then return false end doPlayerAddMoney(cid, money[1]) doPlayerSendChannelMessage(cid, '', 'You have just picked ' .. money[1] .. ' money from your guild balance.', TALKTYPE_CHANNEL_HIGHLIGHT, CHANNEL_GUILD) else doPlayerSendChannelMessage(cid, '', 'Invalid sub-command.', TALKTYPE_CHANNEL_HIGHLIGHT, CHANNEL_GUILD) end elseif(t[1] == 'donate') then local money = tonumber(t[2]) if(not isValidMoney(money)) then doPlayerSendChannelMessage(cid, '', 'Invalid amount of money specified.', TALKTYPE_CHANNEL_HIGHLIGHT, CHANNEL_GUILD) return true end if(getPlayerMoney(cid) < money) then doPlayerSendChannelMessage(cid, '', 'You don\'t have enough money.', TALKTYPE_CHANNEL_HIGHLIGHT, CHANNEL_GUILD) return true end if(not doPlayerRemoveMoney(cid, money)) then return false end db.executeQuery('UPDATE `guilds` SET `balance` = `balance` + ' .. money .. ' WHERE `id` = ' .. guild .. ' LIMIT') doPlayerSendChannelMessage(cid, '', 'You have transfered ' .. money .. ' money to your guild balance.', TALKTYPE_CHANNEL_HIGHLIGHT, CHANNEL_GUILD) else local result = db.getResult('SELECT `name`, `balance` FROM `guilds` WHERE `id` = ' .. guild) if(result:getID() == -1) then return false end doPlayerSendChannelMessage(cid, '', 'Current balance of guild ' .. result:getDataString('name') .. ' is: ' .. result:getDataLong('balance') .. ' bronze coins.', TALKTYPE_CHANNEL_HIGHLIGHT, CHANNEL_GUILD) result:free() end return true end Editado Março 25, 2014 11 anos por Eduardo Dantas (veja o histórico de edições)
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.