• 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.X Bounty Hunter System

yes much players don't check the bounty page so the broadcast should work as a reminder
 
yes much players don't check the bounty page so the broadcast should work as a reminder

data/globalevents/bounty.lua
Code:
function onThink(interval)

    local player = db.storeQuery("SELECT `sp_id`, `prize` FROM `bounty_hunters` WHERE `killed` = '0' ORDER BY `prize` DESC LIMIT 3;")
    local output = "MOST WANTED:\n"
    if(player ~= false) then
        local number = 1
                while (true) do
                    local name = result.getDataString(player, "sp_id")
                    local prize = result.getDataInt(player, "prize")
                    local playerName = db.storeQuery("SELECT `name` FROM `players` WHERE `players`.`id` = "..name..";")
                    local playerName1 = result.getDataString(playerName, "name")
                    output = output.. "\n"..number..". "..playerName1.." - "..prize.."k"
                    number = number + 1
                    if not(result.next(player)) then
                        break
                    end
                end
                result.free(player)
    end
    Game.broadcastMessage(output)

return true
end

globalevents.xml
Code:
<globalevent name="bounty" interval="3600000" script="bounty.lua"/>
 
When i kill the "hunt" player, i dont any gold. And on website he are still "still alive"
 
When i kill the "hunt" player, i dont any gold. And on website he are still "still alive"

Code:
function onKill(cid, target)
local player2 = Creature(target)
if not player2:isPlayer() then
return true
end
---- BOUNTY HUNTERS START -----
pid = cid
pid2 = player2:getGuid()
    local result_plr = db.storeQuery("SELECT * FROM `bounty_hunters` WHERE `sp_id` = "..pid2.." AND `killed` = 0;")
    if(result_plr ~= false) then
    prize = tonumber(result.getDataInt(result_plr, "prize"))
    bid = tonumber(result.getDataInt(result_plr, "id"))
    result.free(result_plr)
    else
    prize = 0
    bid = 0
    end

if (bid ~= 0 and prize ~= 0 and not(getTileInfo(getCreaturePosition(cid)).pvp)) then
    local player = Player(cid)
    db.query("UPDATE `bounty_hunters` SET `killed` = 1, `k_id`="..getPlayerGUID(cid)..", `kill_time` = " .. os.time() .. " WHERE `id`  = "..bid..";")
    player:setBankBalance(player:getBankBalance() + prize)
    player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE,'[BOUNTY HUNTERS] You killed hunted player, so you gained the reward!')
    Game.broadcastMessage("Bounty Hunter Update:\n " .. player:getName() .. " has killed " .. player2:getName() .. " and earned the prize of " .. prize .. " gps!", MESSAGE_EVENT_ADVANCE)
end
---- BOUNTY HUNTERS END -----
return true
end

Let me know if you get any errors. The gold is added to the players bank account, not his backpack.
 
Last edited:
i haven't tested it but should be great if only broadcast the hunted players that are online
 
I think I could use one change.
For example, if someone actually marks someone to kill another person has not already can do.
You can do this:
if 5 players mark to kill the player "Test Player"
And a player kill "Test Player" will get a reward from the "oldest marks"
And so, until the fall as many times as is provided prizes for him.
 
How do i make it not use the decimal point? for example my minimum bounty is 1000. i want it to be 1k, 10k, 100k etc

nevermind i did it. Anyone else want to change it like mine change

Code:
$b = round($bounty[prize] / 1000000,2);
to
Code:
$b = round($bounty[prize] / 1000,2);
 
Let me know if you get any errors. The gold is added to the players bank account, not his backpack.

I got this one onDeath
IT40u4i.png
 
TFS 1.1 http://nightlies.otland.net/ x64-Debug.exe as it's the only one I get to work without crashes. My own-compiled one crashes after about 5 minutes.
change
Code:
if (bid ~= 0 and prize ~= 0 and not(getTileInfo(getCreaturePosition(cid)).pvp)) then
db.query("UPDATE `bounty_hunters` SET `killed` = 1, `k_id`="..getPlayerGUID(cid)..", `kill_time` = " .. os.time() .. " WHERE `id` = "..bid..";")
to
Code:
if (bid ~= 0 and prize ~= 0 and (not creature:getTile():hasFlag(TILESTATE_PVPZONE))) then
db.query("UPDATE `bounty_hunters` SET `killed` = 1, `k_id`="..creature:getGuid()..", `kill_time` = " .. os.time() .. " WHERE `id` = "..bid..";")
 
Are you sure your using the script from the first post? I don't see a getCreaturePosition on line 19 in the bh-kill script. o_O
Nope I'm using the one you posted on this page ^ up there. Because I had the same problem as giddy92.

EDIT: Used the correct code and now it worked. Wierd, I tested with that one b4.
 
Last edited:
A simple talkaction in-game to see the hunted players and their price would be great as well. :)

Kind Regards,
Eldin
 
A simple talkaction in-game to see the hunted players and their price would be great as well. :)

Kind Regards,
Eldin

ZISr5Nk.png

Code:
<talkaction words="!hunted" separator=" " script="test/bounthunter_check.lua" />

Code:
local config = {
    dialogBoxImageId = 24560, -- change this ID to the image you want to see on the Dialog Box
    delay = true, -- Would you like to add a delay on this talkaction?
    delayTime = 30, -- time in seconds you would like to add a delay on the talkaction
    delayStorage = 60799 -- empty storage value
}


function onSay(cid, words, param)
    local player = Player(cid)
    if config.delay and player:getStorageValue(config.delayStorage) > os.time() then
        player:sendCancelMessage('Please wait another ' .. (player:getStorageValue(config.delayStorage) - os.time()) .. ' seconds before you try the command again.')
        return false
    end
  
    local huntedPlayers = db.storeQuery("SELECT `sp_id`, `prize` FROM `bounty_hunters` WHERE `killed` = '0' ORDER BY `prize` DESC;")
    local output = "MOST WANTED:\n"
    if(huntedPlayers ~= false) then
        local number = 1
                while (true) do
                    local id = result.getDataInt(huntedPlayers, "sp_id")
                    local prize = result.getDataInt(huntedPlayers, "prize")
                    local playerName = db.storeQuery("SELECT `name`,`level` FROM `players` WHERE `id` = "..id..";")
                    if playerName then
                        local playerName1 = result.getDataString(playerName, "name")
                        local level = result.getDataInt(playerName, "level")
                        output = output .. "\n" .. number .. ". " .. playerName1 .. " [" .. level .. "] --- " .. prize .. "gps"
                        number = number + 1
                    end
                    if not(result.next(huntedPlayers)) then
                        break
                    end
                end
                result.free(huntedPlayers)
    end
  
    player:showTextDialog(config.dialogBoxImageId, output)
    if config.delay then
        player:setStorageValue(config.delayStorage, os.time() + config.delayTime)
    end      
    return false
end
 
Back
Top