The original thread can be found here:
http://otland.net/f81/perfect-bounty-hunters-system-php-m-aac-forgotten-server-0-4-a-127706/
Talkactions:
!hunt [gold],[playername]
/hunt [gold],[playername]
!bounty [gold],[playername]
/bounty [gold],[playername]
Example:
!hunt 10000,Testcharacter
SQL Query (run in tfs database):
Create a new file in /tfs folder/mods/ named bountyhunters.xml and paste this:
http://otland.net/f81/perfect-bounty-hunters-system-php-m-aac-forgotten-server-0-4-a-127706/
Talkactions:
!hunt [gold],[playername]
/hunt [gold],[playername]
!bounty [gold],[playername]
/bounty [gold],[playername]
Example:
!hunt 10000,Testcharacter
SQL Query (run in tfs database):
PHP:
CREATE TABLE IF NOT EXISTS `bounty_hunters` (
`id` int(11) NOT NULL auto_increment,
`fp_id` int(11) NOT NULL,
`sp_id` int(11) NOT NULL,
`k_id` int(11) NOT NULL,
`added` int(15) NOT NULL,
`prize` bigint(20) NOT NULL,
`killed` int(11) NOT NULL,
`kill_time` int(15) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
Create a new file in /tfs folder/mods/ named bountyhunters.xml and paste this:
Code:
<?xml version="1.0" encoding="UTF-8"?>
<mod name="bountyhunters" version="1.0" author="Pheenix" contact="otland.net" enabled="true">
<description><![CDATA[
______ _ _ ______ _
(_____ \ | | (_) /\ / _____) (_)
_____) )| | ____ _ ____ / \ _ _ _ ____ ___ ___ ____ ____ | / ___ ____ ____ _ ____ ____
| ____/ | | / _ || || _ \ / /\ \ | | | | / _ ) /___) / _ \ | \ / _ ) | | (___) / _ || \ | || _ \ / _ |
| | | |( ( | || || | | | | |__| || | | |( (/ / |___ || |_| || | | |( (/ / | \____/|( ( | || | | || || | | |( ( | |
|_| |_| \_||_||_||_| |_| |______| \____| \____)(___/ \___/ |_|_|_| \____) \_____/ \_||_||_|_|_||_||_| |_| \_|| |
______ (_____|
(_____ \ _
_____) ) ____ ____ ___ ____ ____ | |_ ___ _
| ____/ / ___) / _ ) /___) / _ )| _ \ | _) /___)(_)
| | | | ( (/ / |___ |( (/ / | | | || |__ |___ | _
|_| |_| \____)(___/ \____)|_| |_| \___)(___/ (_)
______ _ _ _
(____ \ _ | | | | _ | | _
____) ) ___ _ _ ____ | |_ _ _ | |__ | | _ _ ____ | |_ ____ ____ \ \ _ _ ___ | |_ ____ ____
| __ ( / _ \ | | | || _ \ | _) | | | | | __)| || | | || _ \ | _) / _ ) / ___) \ \ | | | | /___)| _) / _ )| \
| |__) )| |_| || |_| || | | || |__ | |_| | | | | || |_| || | | || |__ ( (/ / | | _____) )| |_| ||___ || |__ ( (/ / | | | |
|______/ \___/ \____||_| |_| \___) \__ | |_| |_| \____||_| |_| \___) \____)|_| (______/ \__ |(___/ \___) \____)|_|_|_|
(____/ (____/
------------------------------------------------------------------------------------------------------------------------------------
*Rewritten to mod
by Pheenix @otland.net
------------------------------------------------------------------------------------------------------------------------------------
Talkactions: Example:
!hunt [gold],[playername] !hunt 10000,Testcharacter
/hunt [gold],[playername] /hunt 10000,Testcharacter
!bounty [gold],[playername] !bounty 10000,Testcharacter
/bounty [gold],[playername] /bounty 10000,Testcharacter
------------------------------------------------------------------------------------------------------------------------------------
SQL Query (run in tfs database):
CREATE TABLE IF NOT EXISTS `bounty_hunters` (
`id` int(11) NOT NULL auto_increment,
`fp_id` int(11) NOT NULL,
`sp_id` int(11) NOT NULL,
`k_id` int(11) NOT NULL,
`added` int(15) NOT NULL,
`prize` bigint(20) NOT NULL,
`killed` int(11) NOT NULL,
`kill_time` int(15) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
------------------------------------------------------------------------------------------------------------------------------------
]]></description>
<config name="bounty-Conf"><![CDATA[
bConf = {
--Configuration--
------------------------------------------------------------------------------------------------------------------------------------
maxB = 999999999 -- Max Bounty
minB = 10000 -- Minimum Bounty
------------------------------------------------------------------------------------------------------------------------------------
--Configuration End--
}
]]></config>
<lib name="bounty-lib"><![CDATA[
]]></lib>
<event type="login" name="PlayerLogin" event="script"><![CDATA[
registerCreatureEvent(cid, "Bounty")
]]></event>
<event type="kill" name="Bounty"><![CDATA[
function onKill(cid, target)
if isPlayer(target) == TRUE then
pid = cid
pid2 = getPlayerGUID(target)
local result_plr = db.getResult("SELECT * FROM `bounty_hunters` WHERE `sp_id` = "..pid2.." AND `killed` = 0;")
if(result_plr:getID() ~= -1) then
prize = tonumber(result_plr:getDataInt("prize"))
bid = tonumber(result_plr:getDataInt("id"))
result_plr:free()
else
prize = 0
bid = 0
end
if (bid ~= 0 and prize ~= 0 and not(getTileInfo(getCreaturePosition(cid)).pvp)) then
db.executeQuery("UPDATE `bounty_hunters` SET `killed` = 1, `k_id`="..getPlayerGUID(cid)..", `kill_time` = " .. os.time() .. " WHERE `id` = "..bid..";")
doPlayerAddMoney(cid,prize)
doPlayerSendTextMessage(cid,MESSAGE_STATUS_CONSOLE_ORANGE,"[Bounty System]: You killed "..getPlayerName(target).."! You gained the bounty that was put on his/her head!")
doSendMagicEffect(getCreaturePosition(cid), 27)
doBroadcastMessage("[Bounty System]: "..getPlayerName(cid).." killed "..getPlayerName(target).." and gained the bounty! ("..prize.." gold)", MESSAGE_EVENT_ADVANCE)
end
end return TRUE
end
]]></event>
<talkaction words="/bounty;!bounty;!hunt;/hunt"><![CDATA[
domodlib('bounty-Conf')
function onSay(cid, words, param)
if(param == "") then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "[Bounty System]: Usage: \"!bounty [gold],[nick]\" where gold is at least "..bConf.minB..".")
return TRUE
end
local t = string.explode(param, ",")
if(not t[2]) then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "[Bounty System]: Usage: \"!bounty [gold],[nick]\" where gold is at least "..bConf.minB..".")
return TRUE
end
local sp_id = getPlayerGUIDByName(t[2])
if sp_id == nil then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "[Bounty System]: You cant put a bounty on imaginary people, your target doesn't exist.")
return TRUE
end local result_plr = db.getResult("SELECT * FROM `bounty_hunters` WHERE `sp_id` = "..sp_id.." AND `killed` = 0;")
if(result_plr:getID() ~= -1) then
is = tonumber(result_plr:getDataInt("sp_id"))
result_plr:free()
else
is = 0
end
prize = tonumber(t[1])
if(prize == nil or prize < bConf.minB) then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "[Bounty System]: Usage: \"!bounty [gold],[nick]\" where gold is at least 10000.")
return TRUE
end
if(prize >= bConf.maxB) then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "[Bounty System]: Sorry, bounty limit is at "..bConf.max.." gold!")
return TRUE
end if is ~= 0 then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, "[Bounty System]: "..t[2].." has already got a bounty on his/her head.")
return TRUE
end
if doPlayerRemoveMoney(cid, prize) == TRUE then
db.executeQuery("INSERT INTO `bounty_hunters` VALUES (NULL,"..getPlayerGUID(cid)..","..sp_id..",0," .. os.time() .. ","..prize..",0,0);")
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, "[Bounty System]: Bounty on "..t[2].."s head has been added successfully!")
doBroadcastMessage("[Bounty System]: A bounty of "..prize.." gold for "..t[2].."s head has been submitted by "..getPlayerName(cid)..". The first one to kill "..t[2].." will get the gold!", MESSAGE_EVENT_ADVANCE)
else
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "[Bounty System]: You dont have enough gold!")
end
return 1
end
]]></talkaction>
</mod>
Last edited: