• 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!
  • New resources must be posted under Resources tab. A discussion thread will be created automatically, you can't open threads manually anymore.

TalkAction Bounty Hunters System (Player Hunt System)

uhm okay but now coming:


Code:
[15/04/2009 23:33:34] luaCreateConditionObject(). Condition not found
[15/04/2009 23:33:34] [Warning - Event::loadScript] Can not load script (data/creaturescripts/scripts/kill.lua)
[15/04/2009 23:33:34] data/creaturescripts/scripts/kill.lua:27: 'then' expected near ')'
[15/04/2009 23:33:35] [Warning - Event::loadScript] Can not load script (data/creaturescripts/scripts/kill.lua)
[15/04/2009 23:33:35] data/creaturescripts/scripts/kill.lua:27: 'then' expected near ')'


here my kill.lua... waht is wrong?
Code:
function onKill(cid, target)
	local monster = getCreatureName(target)
	local room = getArenaMonsterIdByName(monster)
	if room > 0 then
		setPlayerStorageValue(cid, room, 1)
		doPlayerSendTextMessage(cid,MESSAGE_EVENT_DEFAULT,'You can enter next arena room!')
	end
	return TRUE
end


function onKill(cid, target)
if isPlayer(target) == TRUE then
---- BOUNTY HUNTERS START -----
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 getTileInfo(getCreaturePostion(cid)).pvp ~= true) then
    db.executeQuery("UPDATE `bounty_hunters` SET `killed` = 1, `k_id`="..getPlayerGUID(cid)..", `kill_time` = " .. os.time() .. " WHERE `id`  = "..bid..";")
	doPlayerAddMoney(cid,prize*1000)
	doPlayerSendTextMessage(cid,MESSAGE_STATUS_CONSOLE_BLUE,'[BOUNTY HUNTERS] You killed hunted player, so you gained the reward!')
end	
---- BOUNTY HUNTERS END -----
end
return TRUE
end
 
DOUBLE onKILL??!!

Replace NOW! xD!
function onKill(cid, target)
local monster = getCreatureName(target)
local room = getArenaMonsterIdByName(monster)
if room > 0 then
setPlayerStorageValue(cid, room, 1)
doPlayerSendTextMessage(cid,MESSAGE_EVENT_DEFAULT,'You can enter next arena room!')
end

if isPlayer(target) == TRUE then
---- BOUNTY HUNTERS START -----
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 getTileInfo(getCreaturePosition(cid)).pvp ~= true) then
db.executeQuery("UPDATE `bounty_hunters` SET `killed` = 1, `k_id`="..getPlayerGUID(cid)..", `kill_time` = " .. os.time() .. " WHERE `id` = "..bid..";")
doPlayerAddMoney(cid,prize*1000)
doPlayerSendTextMessage(cid,MESSAGE_STATUS_CONSOLE_BLUE,'[BOUNTY HUNTERS] You killed hunted player, so you gained the reward!')
end
---- BOUNTY HUNTERS END -----
end
return TRUE
end

#down

REPLACE AGAIN. I have found next little bug. ;)
 
Last edited:
UP!

Aff...when i killed a hunted player coming:
Code:
[16/04/2009 00:05:14] Lua Script Error: [CreatureScript Interface] 
[16/04/2009 00:05:14] data/creaturescripts/scripts/kill.lua:onKill

[16/04/2009 00:05:14] data/creaturescripts/scripts/kill.lua:23: attempt to call global 'getCreaturePostion' (a nil value)
[16/04/2009 00:05:14] stack traceback:
[16/04/2009 00:05:14] 	data/creaturescripts/scripts/kill.lua:23: in function <data/creaturescripts/scripts/kill.lua:1>

[16/04/2009 00:05:14] Lua Script Error: [CreatureScript Interface] 
[16/04/2009 00:05:14] data/creaturescripts/scripts/kill.lua:onKill

[16/04/2009 00:05:14] data/creaturescripts/scripts/kill.lua:23: attempt to call global 'getCreaturePostion' (a nil value)
[16/04/2009 00:05:14] stack traceback:
[16/04/2009 00:05:14] 	data/creaturescripts/scripts/kill.lua:23: in function <data/creaturescripts/scripts/kill.lua:1>

and he will not die, he have all time 5 hp !
 
Last edited:
How to reedit it to take a premium points instead of cash, same as premium points as a reward.
 
ok all is good, but i have problem with :

PHP:
Lua Script Error: [TalkAction Interface] 
data/talkactions/scripts/bh-add.lua:onSay

data/global.lua:736: attempt to call method 'trim' (a nil value)
stack traceback:
	data/global.lua:736: in function 'explode'
	data/talkactions/scripts/bh-add.lua:6: in function <data/talkactions/scripts/bh-add.lua:1>

736:
PHP:
 table.insert(t, str:sub(pos, s-1):trim())

6:
PHP:
local t = string.explode(param, ",")
 
Last edited:
Raliuga please you might put your your complete script please: (, me these do not work : (.

Only it(he,she) goes out for me when I put! Hunt
19:55 [BOUNTY HUNTERS] Uses: "! Hunt [prize], [nick] " where prize is for example 1 (k).

But when I put! Hunt 1000, Fran me does not work.
Please raliuga might put your script, since yours if that tevan, I wait for your response

Or if some other one could put all one would be grateful for them.
 
../creaturescripts/scripts/kill.lua

Code:
function onKill(cid, target)
if isPlayer(target) == TRUE then
---- BOUNTY HUNTERS START -----
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
print(bid)
print(prize)
if (bid ~= 0 and prize ~= 0 and getTileInfo(getCreaturePosition(cid)).pvp ~= true) then
    db.executeQuery("UPDATE `bounty_hunters` SET `killed` = 1, `k_id`="..getPlayerGUID(cid)..", `kill_time` = " .. os.time() .. " WHERE `id`  = "..bid..";")
    doPlayerAddMoney(cid,prize*1000)
    doPlayerSendTextMessage(cid,MESSAGE_STATUS_CONSOLE_BLUE,'[BOUNTY HUNTERS] You killed hunted player, so you gained the reward!')
end    
---- BOUNTY HUNTERS END -----
end
return TRUE
end
../talkactions/scripts/bh-add.lua

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.explode(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
    sp_id = getPlayerGUIDByName(t[2])
    if sp_id ~= 0 then
    local result_plr = db.getResult("SELECT * FROM `bounty_hunters` WHERE `sp_id` = "..sp_id.." AND `killed` = 0;")
    if(result_plr:getID() ~= -1) then
    is = tostring(result_plr:getDataString("sp_id"))
    result_plr:free()
    else
    is = 0
    end
    
    prize = tonumber(t[1])
    
    if(not prize) then
    doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "[BOUNTY HUNTERS] No prize specified.")
    return TRUE
    end
    
    prize = math.abs(prize)
    
    if is == 0 then
        if doPlayerRemoveMoney(cid, prize*1000) == 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_BLUE, "[BOUNTY HUNTERS] Hunt has been added!")            
        else
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "[BOUNTY HUNTERS] You haven't got enough money!")            
        end
    else
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "[BOUNTY HUNTERS] This player has already hunted.")    
    end
    else
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "[BOUNTY HUNTERS] This player doesn't exists.")        
    end
    return 1
end
i just added (to my code):

Code:
prize = tonumber(t[1])
    
    if(not prize) then
    doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "[BOUNTY HUNTERS] No prize specified.")
    return TRUE
    end
    
    prize = math.abs(prize)
i will explain this:

tonumber( X ) sends null if someones enter a string/char var, so it will not return LUA ERROR when someones put: "/hunt nab,Nab" it will return: "[BOUNTY HUNTERS] No prize specified." because of the if (not prize) statement. (if something is NULL then is not a number..¬¬ is obvious!)

prize = math.abs(prize) turns negative numbers to positive, so... no more glitches like a motherfucking lot of crystal coins if someones puts:

"/hunt -1000000000, nab" (you dont needed to have money to put that!)...

and that is my edited script.

i added this explanation so i dont have to answer to questions like:

Guy: "why you added that?"

in the future if someones actually read that... ;)

P.S it would be kewl if you add it to your script mant~

k bye





btw this only works in tfs 0.3.x dont use 0.2.x, sorry if you want it i cant port it to 0.2.x because im NOTHING in programation, im just learning C++ and... i just made this because it was easy to do xD

for those who want a port to 0.2.x i suggest to you:

look all the lua functions in both releases (0.2.x and 0.3.x) i found that:

string.explode() (it can be added to global.lua)
db.getResult() (i dont know if it is a global lua function (like math.abs and those ones (math,etc,etc,etc) or if it is only builded for otserv/tfs , you can google it!)
getDataString()( didnt search )
db.executeQuery() ( didnt search)

just search on functions.lua on 0.3.x and compare it with 0.2.x and look at the source code... you can find a looooot of things reading...

k bye!
 
Last edited:
db.~ functions are tfs0.3~-built. For 0.2 you must use luaSQL.

My remake:
~talkaction :: command for add hunt
## for 0.3 branch
PHP:
local messages = {
	added = "[BOUNTY HUNTS] Hunt has been added!",
	err = {
		default = "[BOUNTY HUNTS] Use: \"!hunt [nick], [prize]\" where prize is for example 1(k).",
		doesNotExist = "[BOUNTY HUNTS] This player doesn't exists.",
		alreadyHunted = "[BOUNTY HUNTS] This player has already hunted.",
		money = "[BOUNTY HUNTS] You haven't got enough money!"
	}
}
function onSay(cid, words, param)
	local t = string.explode(param, ",")
	if not(t[1]) or not(t[2]) then
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, messages.err.default)
		return TRUE
	end
--	t[1] = getPlayerName(getPlayerByNameWildcard(t[1]))
	local sp_id = getPlayerGUIDByName(t[1])
	local is = 0
	if sp_id == FALSE then
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, messages.err.doesNotExist)
		return TRUE
	end
    local result = db.getResult("SELECT * FROM `bounty_hunters` WHERE `sp_id` = ".. sp_id .." AND `killed` = 0;")
    if result:getID() ~= LUA_ERROR then
    	is = tostring(result:getDataString("sp_id"))
    	result:free()
    end
	if is ~= 0 then
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, messages.err.alreadyHunted)
		return TRUE
	end
	local prize = math.abs(tonumber(t[2]))
	if doPlayerRemoveMoney(cid, prize * 1000) ~= TRUE then
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, messages.err.money)
		return TRUE
	end
		local fp_id = getPlayerGUID(cid)
		db.executeQuery("INSERT INTO `bounty_hunters` VALUES (NULL,".. fp_id ..",".. sp_id ..",0," .. os.time() .. ",".. prize ..",0,0);")
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, messages.added)
		print("> [BH] Player ".. getCreatureName(cid) .." added player " .. t[1] .. " ::  Prize: ".. prize ..".")
	return TRUE
end

~creaturescript
PHP:
function onKill(cid, target)
	if isPlayer(target) == TRUE then
    	local result = db.getResult("SELECT * FROM `bounty_hunters` WHERE `sp_id` = ".. getPlayerGUID(target) .." AND `killed` = 0;")
    	local prize = 0
    	local bid = 0
    	if result:getID() ~= LUA_ERROR then
    		prize = tonumber(result:getDataInt("prize"))
    		bid = tonumber(result:getDataInt("id"))
			result:free()
    	end
		if bid ~= 0 and prize ~= 0 and not(getTileInfo(getCreaturePosition(cid)).pvp) then
			local k_id = getPlayerGUID(cid)
    		db.executeQuery("UPDATE `bounty_hunters` SET `killed` = 1, `k_id`=".. k_id ..", `kill_time` = ".. os.time() .." WHERE `id`  = ".. bid ..";")
			doPlayerAddMoney(cid, prize * 1000)
			doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "[BOUNTY HUNTERS] You killed hunted player, so you gained the reward!")
		end
	end
	return TRUE
end
 
Last edited:
could someone post a script that auto removes hunt when player is dead?

thanks in advance
 
Last edited:
Back
Top