TFS 1.X Bounty Hunter System

Discussion in 'GlobalEvents, Spells & CreatureEvents' started by imkingran, Apr 14, 2014.

  1. Cotizado

    Cotizado Member

    Joined:
    May 12, 2008
    Messages:
    321
    Likes Received:
    6
    Best Answers:
    0
    yes much players don't check the bounty page so the broadcast should work as a reminder
     
  2. imkingran

    imkingran Learning everyday. Premium User

    Joined:
    Jan 15, 2014
    Messages:
    1,199
    Likes Received:
    365
    Best Answers:
    6
    data/globalevents/bounty.lua
    Code (Text):
    1. function onThink(interval)
    2.  
    3.     local player = db.storeQuery("SELECT `sp_id`, `prize` FROM `bounty_hunters` WHERE `killed` = '0' ORDER BY `prize` DESC LIMIT 3;")
    4.     local output = "MOST WANTED:\n"
    5.     if(player ~= false) then
    6.         local number = 1
    7.                 while (true) do
    8.                     local name = result.getDataString(player, "sp_id")
    9.                     local prize = result.getDataInt(player, "prize")
    10.                     local playerName = db.storeQuery("SELECT `name` FROM `players` WHERE `players`.`id` = "..name..";")
    11.                     local playerName1 = result.getDataString(playerName, "name")
    12.                     output = output.. "\n"..number..". "..playerName1.." - "..prize.."k"
    13.                     number = number + 1
    14.                     if not(result.next(player)) then
    15.                         break
    16.                     end
    17.                 end
    18.                 result.free(player)
    19.     end
    20.     Game.broadcastMessage(output)
    21.  
    22. return true
    23. end  
    globalevents.xml
    Code (Text):
    1. <globalevent name="bounty" interval="3600000" script="bounty.lua"/>
     
    Cotizado likes this.
  3. giddy92

    giddy92 Member

    Joined:
    Aug 8, 2014
    Messages:
    69
    Likes Received:
    0
    Best Answers:
    0
    When i kill the "hunt" player, i dont any gold. And on website he are still "still alive"
     
  4. imkingran

    imkingran Learning everyday. Premium User

    Joined:
    Jan 15, 2014
    Messages:
    1,199
    Likes Received:
    365
    Best Answers:
    6
    Code (Text):
    1. function onKill(cid, target)
    2. local player2 = Creature(target)
    3. if not player2:isPlayer() then
    4. return true
    5. end
    6. ---- BOUNTY HUNTERS START -----
    7. pid = cid
    8. pid2 = player2:getGuid()
    9.     local result_plr = db.storeQuery("SELECT * FROM `bounty_hunters` WHERE `sp_id` = "..pid2.." AND `killed` = 0;")
    10.     if(result_plr ~= false) then
    11.     prize = tonumber(result.getDataInt(result_plr, "prize"))
    12.     bid = tonumber(result.getDataInt(result_plr, "id"))
    13.     result.free(result_plr)
    14.     else
    15.     prize = 0
    16.     bid = 0
    17.     end
    18.  
    19. if (bid ~= 0 and prize ~= 0 and not(getTileInfo(getCreaturePosition(cid)).pvp)) then
    20.     local player = Player(cid)
    21.     db.query("UPDATE `bounty_hunters` SET `killed` = 1, `k_id`="..getPlayerGUID(cid)..", `kill_time` = " .. os.time() .. " WHERE `id`  = "..bid..";")
    22.     player:setBankBalance(player:getBankBalance() + prize)
    23.     player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE,'[BOUNTY HUNTERS] You killed hunted player, so you gained the reward!')
    24.     Game.broadcastMessage("Bounty Hunter Update:\n " .. player:getName() .. " has killed " .. player2:getName() .. " and earned the prize of " .. prize .. " gps!", MESSAGE_EVENT_ADVANCE)
    25. end
    26. ---- BOUNTY HUNTERS END -----
    27. return true
    28. end
    Let me know if you get any errors. The gold is added to the players bank account, not his backpack.
     
    Last edited: Nov 15, 2014
  5. giddy92

    giddy92 Member

    Joined:
    Aug 8, 2014
    Messages:
    69
    Likes Received:
    0
    Best Answers:
    0
    Now all work! Thanks! :)
     
  6. Cotizado

    Cotizado Member

    Joined:
    May 12, 2008
    Messages:
    321
    Likes Received:
    6
    Best Answers:
    0
    i haven't tested it but should be great if only broadcast the hunted players that are online
     
  7. giddy92

    giddy92 Member

    Joined:
    Aug 8, 2014
    Messages:
    69
    Likes Received:
    0
    Best Answers:
    0
    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.
     
  8. strutZ

    strutZ Australian OT Member {AKA Beastn}

    Joined:
    Nov 16, 2014
    Messages:
    1,269
    Likes Received:
    446
    Best Answers:
    3
    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 (Text):
    1. $b = round($bounty[prize] / 1000000,2);
    to
    Code (Text):
    1. $b = round($bounty[prize] / 1000,2);
     
  9. Tickit

    Tickit Member

    Joined:
    Feb 20, 2009
    Messages:
    364
    Likes Received:
    5
    Best Answers:
    0
    I got this one onDeath [​IMG]
     
  10. StreamSide

    StreamSide Joseluis Gonzalez

    Joined:
    Aug 31, 2007
    Messages:
    2,773
    Likes Received:
    580
    Best Answers:
    10
    what tfs r u using?
     
  11. Tickit

    Tickit Member

    Joined:
    Feb 20, 2009
    Messages:
    364
    Likes Received:
    5
    Best Answers:
    0
  12. StreamSide

    StreamSide Joseluis Gonzalez

    Joined:
    Aug 31, 2007
    Messages:
    2,773
    Likes Received:
    580
    Best Answers:
    10
    change
    Code (Text):
    1.  
    2. if (bid ~= 0 and prize ~= 0 and not(getTileInfo(getCreaturePosition(cid)).pvp)) then
    3. db.query("UPDATE `bounty_hunters` SET `killed` = 1, `k_id`="..getPlayerGUID(cid)..", `kill_time` = " .. os.time() .. " WHERE `id` = "..bid..";")
    4.  
    to
    Code (Text):
    1.  
    2. if (bid ~= 0 and prize ~= 0 and (not creature:getTile():hasFlag(TILESTATE_PVPZONE))) then
    3. db.query("UPDATE `bounty_hunters` SET `killed` = 1, `k_id`="..creature:getGuid()..", `kill_time` = " .. os.time() .. " WHERE `id` = "..bid..";")
    4.  
     
  13. imkingran

    imkingran Learning everyday. Premium User

    Joined:
    Jan 15, 2014
    Messages:
    1,199
    Likes Received:
    365
    Best Answers:
    6
    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
     
  14. Tickit

    Tickit Member

    Joined:
    Feb 20, 2009
    Messages:
    364
    Likes Received:
    5
    Best Answers:
    0
    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: Mar 17, 2015
  15. danalex07

    danalex07 New Member

    Joined:
    Aug 29, 2010
    Messages:
    14
    Likes Received:
    2
    Best Answers:
    0
    nice men, it works perfect
     
    imkingran likes this.
  16. Sir Knighter

    Sir Knighter ArchLight Developer Premium User

    Joined:
    Jun 29, 2009
    Messages:
    3,592
    Likes Received:
    925
    Best Answers:
    0
    Anyone end up making a Znote Version of the Php for this?
     
  17. Eldin

    Eldin Eldin Projects

    Joined:
    Jun 12, 2008
    Messages:
    1,256
    Likes Received:
    504
    Best Answers:
    0
    A simple talkaction in-game to see the hunted players and their price would be great as well. :)

    Kind Regards,
    Eldin
     
  18. Codex NG

    Codex NG Recurrent Flamer

    Joined:
    Jul 24, 2015
    Messages:
    3,002
    Likes Received:
    1,586
    Best Answers:
    11
    This is why there needs to be a standardized aac which utilizes an api similar to Joomla..
    https://api.joomla.org/cms-3/index.html

    Then there will be less questions like "is it compatible with x"
     
  19. Sir Knighter

    Sir Knighter ArchLight Developer Premium User

    Joined:
    Jun 29, 2009
    Messages:
    3,592
    Likes Received:
    925
    Best Answers:
    0
    Agreed.
     
  20. imkingran

    imkingran Learning everyday. Premium User

    Joined:
    Jan 15, 2014
    Messages:
    1,199
    Likes Received:
    365
    Best Answers:
    6
    [​IMG]

    Code (Text):
    1. <talkaction words="!hunted" separator=" " script="test/bounthunter_check.lua" />
    Code (Text):
    1. local config = {
    2.     dialogBoxImageId = 24560, -- change this ID to the image you want to see on the Dialog Box
    3.     delay = true, -- Would you like to add a delay on this talkaction?
    4.     delayTime = 30, -- time in seconds you would like to add a delay on the talkaction
    5.     delayStorage = 60799 -- empty storage value
    6. }
    7.  
    8.  
    9. function onSay(cid, words, param)
    10.     local player = Player(cid)
    11.     if config.delay and player:getStorageValue(config.delayStorage) > os.time() then
    12.         player:sendCancelMessage('Please wait another ' .. (player:getStorageValue(config.delayStorage) - os.time()) .. ' seconds before you try the command again.')
    13.         return false
    14.     end
    15.  
    16.     local huntedPlayers = db.storeQuery("SELECT `sp_id`, `prize` FROM `bounty_hunters` WHERE `killed` = '0' ORDER BY `prize` DESC;")
    17.     local output = "MOST WANTED:\n"
    18.     if(huntedPlayers ~= false) then
    19.         local number = 1
    20.                 while (true) do
    21.                     local id = result.getDataInt(huntedPlayers, "sp_id")
    22.                     local prize = result.getDataInt(huntedPlayers, "prize")
    23.                     local playerName = db.storeQuery("SELECT `name`,`level` FROM `players` WHERE `id` = "..id..";")
    24.                     if playerName then
    25.                         local playerName1 = result.getDataString(playerName, "name")
    26.                         local level = result.getDataInt(playerName, "level")
    27.                         output = output .. "\n" .. number .. ". " .. playerName1 .. " [" .. level .. "] --- " .. prize .. "gps"
    28.                         number = number + 1
    29.                     end
    30.                     if not(result.next(huntedPlayers)) then
    31.                         break
    32.                     end
    33.                 end
    34.                 result.free(huntedPlayers)
    35.     end
    36.  
    37.     player:showTextDialog(config.dialogBoxImageId, output)
    38.     if config.delay then
    39.         player:setStorageValue(config.delayStorage, os.time() + config.delayTime)
    40.     end      
    41.     return false
    42. end
     
    Eldin likes this.

Share This Page

Loading...