• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

Solved [TFS 1.0] Bounty Hunter System

Sentinel3

New Member
Joined
Oct 16, 2014
Messages
180
Reaction score
0
Hello everyone,

I just need to correct this script, but I don't know how beocuse I didn't get any error in console.
I used this Thread to add Bounty Hunter in my OT.

The issue appear when I'm in-game and I use the command !hunt (for example: !hunt 100,Edy), in default channel only appears this text:
Captura_zps1dea8c3f.png


Using: Lastest version of TFS 1.0

/data/talkactions/scripts/bh-add.lua
HTML:
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

/data/talkactions.xml
HTML:
<talkaction words="!hunt" script="bh-add.lua" />

If someone have any idea to make it works, please don't doubt to answer ;).
 
Code:
if doPlayerRemoveMoney(cid, prize*1000) == true then
The money you have to pay is prize x 1000, if you don't want that, remove the *1000.
 
I didn't get any error in console.

And I just changed what you said:

@Limos: The money you have to pay is prize x 1000, if you don't want that, remove the *1000

Script that I just right now.
HTML:
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) == 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
 
Back
Top