• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

TFS 1.0 Bounty Hunter System DB errors

trustjah

Newbie
Joined
Jan 22, 2009
Messages
124
Solutions
6
Reaction score
14
Location
Belgium
Anyone that can help me with this? i've been stuck for days with this problem
i'm using TFS 1.X Bounty Hunter System
i'm getting these errors in the server console:

121pbw7.jpg


20j0lua.png


any help would be much appreciated, thanks in advance!

Column count doens't match value count at row 1.
Using;
Code:
function onSay(cid, words, param)
    if(param == "") then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "[BOUNTY HUNTERS] Use: \"!hunt [prize],[nick]\" where prize is for example 1(k).")
        return TRUE
    end
    local t = string.split(param, ",")
    if(not t[2]) then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "[BOUNTY HUNTERS] Use: \"!hunt [prize],[nick]\" where prize is for example 1(k).")
        return TRUE
    end
    local sp_id = getPlayerGUIDByName(t[2])
    if sp_id == nil then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "[BOUNTY HUNTERS] This player doesn't exists.") 
        return TRUE
    end
    local result_plr = db.storeQuery("SELECT * FROM `bounty_hunters` WHERE `sp_id` = "..sp_id.."  AND `killed` = 0;")
    if(result_plr ~= false) then
        is = tonumber(result.getDataInt(result_plr, "sp_id"))
        result.free(result_plr)
    else
        is = 0
    end
    prize = tonumber(t[1])
    if(prize == nil or prize < 1) then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "[BOUNTY HUNTERS] Use: \"!hunt [prize],[nick]\" where prize is for example 1(k).")
        return TRUE
    end
    if(prize >= 100000000000000000000) then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "[BOUNTY HUNTERS] Sorry, you typed too big number!")
        return TRUE
    end
    if is ~= 0 then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "[BOUNTY HUNTERS] This player has already hunted.")
        return TRUE
    end
    if doPlayerRemoveMoney(cid, prize*1000) == TRUE then
        db.query("INSERT INTO `bounty_hunters` VALUES (NULL,"..getPlayerGUID(cid)..","..sp_id..",0," .. os.time() .. ","..prize..",0,0);")
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "[BOUNTY HUNTERS] Hunt has been added!")     
    else
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "[BOUNTY HUNTERS] You haven't got enough money!")     
    end
    return 1
end

Anyone?
 
Last edited:
The problem is your database schema / SQL query.
You don't have sp_id in your database, try to replace it with id in your Lua file.
At this query;
Lua:
local result_plr = db.storeQuery("SELECT * FROM `bounty_hunters` WHERE `sp_id` = "..sp_id.."  AND `killed` = 0;")
 
The way his script is set up is:

Code:
sp_id = getPlayerGUIDByName()

He probably needs to change that to:

Code:
target = Player(t[2])
sp_id = target:getGUID()


or for it to work with the player being offline:


Code:
function getOfflinePlayerGUIDByName(name)
       local resultr, ret = db.storeQuery("SELECT `id` FROM `players` WHERE `name` = '" .. name .. "';")
        ret = result.getDataInt(resultr,'id')
        result.free(resultr)
        return ret
end

sp_id = getOfflinePlayerGUIDByName(t[2])
 
Or here is a code I made just incase nothing else works...

Code:
local function getOfflinePlayerGUIDByName(name)
       local resultr, ret = db.storeQuery("SELECT `id` FROM `players` WHERE `name` = '" .. name .. "';")
        ret = result.getDataInt(resultr,'id')
        result.free(resultr)
        return ret
end

local function checkBountyName(name)
       local resultr, ret = db.storeQuery("SELECT `id` FROM `bounty_hunters` WHERE `name` = '" .. name .. "';")
        ret = result.getDataInt(resultr,'id')
        result.free(resultr)
        if ret >= 0 then
            return true
        else
            return false
        end
end

local min_bounty = 1000
local max_bounty = 100000000000000000000


function onSay(cid, words, param)
    t = string.split(param, ",")

    if(param == "") or not t[1] or not t[2] then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "[BOUNTY HUNTERS] Use: \"!hunt [nick],[prize]\" where prize is for example 1(k).")
        return TRUE
    end
  
    name = t[1]
    prize = tonumber(t[2])
  
    target = getOfflinePlayerGUIDByName(name)
  
    if not target then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Player doesn't exist.")
        return TRUE
    end
  
    if checkBountyName(name) == true then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Player is already being hunted.")
        return TRUE
    end
  
    prize = prize * 1000
  
    if prize < min_bounty or prize > max_bounty then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Bounty must be between "..min_bounty.." and "..max_bounty..".")
        return TRUE
    end

    if doPlayerRemoveMoney(cid, prize) == TRUE then
        db.query("INSERT INTO `bounty_hunters` VALUES (NULL,"..getPlayerGUID(cid)..","..target..",0," .. os.time() .. ","..prize..",0,0);")
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "[BOUNTY HUNTERS] Hunt has been added!")   
    else
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "[BOUNTY HUNTERS] You haven't got enough money!")   
    end
  
    return true
end

It works with offline players too.
 
Back
Top