• 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!

Need help with this script (Help)

LucasFerraz

Systems Analyst
Joined
Jun 10, 2010
Messages
2,857
Reaction score
96
Location
Brazil
EDIT: Credits do Santi for help me here.

Description: GM talk '/hunt 100, NICKNAME'. Who kills the 'hunted player' will receive 100k.
LUA:
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*1000)
	doPlayerSendTextMessage(cid,MESSAGE_STATUS_CONSOLE_BLUE,'You received this reward..')
	doBroadcastMessage(" " .. getPlayerName(cid) .. " killed " .. getPlayerName(target) .. "!")
end	
end
return TRUE
end

I need now a NPC, if player is 'hunted' he talk 'payment' to NPC and his 'hunted' is removed.
 
Last edited:
LUA:
function onSay(cid, words, param, channel)
	if not param or param == '' then
		return doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, 'Use: "!hunt [prize],[nick]" where prize is for example 1(k).')
	end

	local t = string.explode(param, ',')
	if not t[1] or not t[2] then
		return doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, 'Use: "!hunt [prize],[nick]" where prize is for example 1(k).')
	end

	t[1] = tonumber(t[1])
	if not t[1] or t[1] < 1 then
		return doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, 'Use: "!hunt [prize],[nick]" where prize is for example 1(k).')
	elseif t[1] > 99999999999999 then
		return doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, 'Sorry, you typed too big number!')
	elseif getPlayerMoney(cid) < t[1]*1000 then
		return doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You haven't got enough money!")
	end

	t[2] = getPlayerGUIDByName(t[2])
	if not t[2] then
		return doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, 'This player doesn\'t exist.')
	end

	local q = db.getResult('SELECT sp_id FROM bounty_hunters WHERE sp_id='..t[2]..' AND killed=0 LIMIT 1')
	if q:getID() ~= -1 then
		q:free()
		return doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, 'This bandit is already hunted!')
	end

	doPlayerRemoveMoney(cid, t[1]*1000)
	db.executeQuery('INSERT INTO bounty_hunters VALUES (NULL,'..getPlayerGUID(cid)..','..t[2]..',0,' .. os.time() .. ','..t[1]..',0,0)')
	doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, 'This bandit will be hunted and defeated now!')
	doBroadcastMessage(getCreatureName(cid) .. ' is paying '..t[1]..'k to the killer of ', MESSAGE_EVENT_ADVANCE)

	return true
end
 
"12:25 Lucas Olzon is paying 100k to the killer of "

It must show like this: "12:25 Lucas Olzon is paying 100k to the killer of Character Test"
 
Change
LUA:
	doBroadcastMessage(getCreatureName(cid) .. ' is paying '..t[1]..'k to the killer of ', MESSAGE_EVENT_ADVANCE)
to
LUA:
	doBroadcastMessage(getCreatureName(cid) .. ' is paying '..t[1]..'k to the killer of '..t[2]..'.', MESSAGE_EVENT_ADVANCE)
 
Problem
"13:03 Lucas Olzon is paying 100k to the killer of 2017" :S



It must show like this: "12:25 Lucas Olzon is paying 100k to the killer of Character Test"
 
Cant this system be abused by very wanted people? Like someone wanna place 100CC on a wanted player, but someone already placed a wanted on him on only 1k. And soon as he dies someone he knows, his friend or something places a new bet on 1k. To make sure he never gets attracted on the wanted list?

Anyway heres the script, should work:
LUA:
function onSay(cid, words, param, channel)
	if not param or param == '' then
		return doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, 'Use: "!hunt [prize],[nick]" where prize is for example 1(k).')
	end
 
	local t = string.explode(param, ',')
	if not t[1] or not t[2] then
		return doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, 'Use: "!hunt [prize],[nick]" where prize is for example 1(k).')
	end
 
	t[1] = tonumber(t[1])
	if not t[1] or t[1] < 1 then
		return doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, 'Use: "!hunt [prize],[nick]" where prize is for example 1(k).')
	elseif t[1] > 99999999999999 then
		return doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, 'Sorry, you typed too big number!')
	elseif getPlayerMoney(cid) < t[1]*1000 then
		return doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You haven't got enough money!")
	end
 
	t[2] = getPlayerGUIDByName(t[2])
	if not t[2] then
		return doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, 'This player doesn\'t exist.')
	end
 
	local q = db.getResult('SELECT sp_id FROM bounty_hunters WHERE sp_id='..t[2]..' AND killed=0 LIMIT 1')
	if q:getID() ~= -1 then
		q:free()
		return doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, 'This bandit is already hunted!')
	end
 
	doPlayerRemoveMoney(cid, t[1]*1000)
	db.executeQuery('INSERT INTO bounty_hunters VALUES (NULL,'..getPlayerGUID(cid)..','..t[2]..',0,' .. os.time() .. ','..t[1]..',0,0)')
	doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, 'This bandit will be hunted and defeated now!')
	doBroadcastMessage(getCreatureName(cid) .. ' is paying '..t[1]..'k to the killer of '..getPlayerNameByGUID(t[2])..'.', MESSAGE_EVENT_ADVANCE)
 
	return true
end
 
Last edited:
Here is the creatureevent(that gives the reward to killer)

Can someone fix this part?
"doBroadcastMessage('KILLERNAME killed PLAYERDEAD.', MESSAGE_EVENT_ADVANCE)"

LUA:
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*1000)
	doPlayerSendTextMessage(cid,MESSAGE_STATUS_CONSOLE_BLUE,'You received this reward..')
end	
end
return TRUE
end
 
LUA:
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*1000)
	doPlayerSendTextMessage(cid,MESSAGE_STATUS_CONSOLE_BLUE,'You received this reward..')
	doBroadcastMessage(" " .. getPlayerName(cid) .. " killed " .. getPlayerName(target) .. "!")
end	
end
return TRUE
end
 
Last edited:
Don't works

...lua:19: attempt to call global 'dobroadcastMessage' (a nil value)


doBroadCastMessage('" .. getPlayerName(cid) .. " killed the outlaw bandit " .. getPlayerName(target) .. "!', MESSAGE_EVENT_ADVANCE)
 
EDIT: Credits do Santi for help me here.

Description: GM talk '/hunt 100, NICKNAME'. Who kills the 'hunted player' will receive 100k.
LUA:
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*1000)
	doPlayerSendTextMessage(cid,MESSAGE_STATUS_CONSOLE_BLUE,'You received this reward..')
	doBroadcastMessage(" " .. getPlayerName(cid) .. " killed " .. getPlayerName(target) .. "!")
end	
end
return TRUE
end

I need now a NPC, if player is 'hunted' he talk 'payment' to NPC and his 'hunted' is removed.
 
EDIT: Credits do Santi for help me here.

Description: GM talk '/hunt 100, NICKNAME'. Who kills the 'hunted player' will receive 100k.
LUA:
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*1000)
	doPlayerSendTextMessage(cid,MESSAGE_STATUS_CONSOLE_BLUE,'You received this reward..')
	doBroadcastMessage(" " .. getPlayerName(cid) .. " killed " .. getPlayerName(target) .. "!")
end	
end
return TRUE
end

I need now a NPC, if player is 'hunted' he talk 'payment' to NPC and his 'hunted' is removed.

bump
 
EDIT: Credits do Santi for help me here.

Description: GM talk '/hunt 100, NICKNAME'. Who kills the 'hunted player' will receive 100k.
LUA:
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*1000)
	doPlayerSendTextMessage(cid,MESSAGE_STATUS_CONSOLE_BLUE,'You received this reward..')
	doBroadcastMessage(" " .. getPlayerName(cid) .. " killed " .. getPlayerName(target) .. "!")
end	
end
return TRUE
end

I need now a NPC, if player is 'hunted' he talk 'payment' to NPC and his 'hunted' is removed.

bump
 
EDIT: Credits do Santi for help me here.

Description: GM talk '/hunt 100, NICKNAME'. Who kills the 'hunted player' will receive 100k.
LUA:
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*1000)
	doPlayerSendTextMessage(cid,MESSAGE_STATUS_CONSOLE_BLUE,'You received this reward..')
	doBroadcastMessage(" " .. getPlayerName(cid) .. " killed " .. getPlayerName(target) .. "!")
end	
end
return TRUE
end

I need now a NPC, if player is 'hunted' he talk 'payment' to NPC and his 'hunted' is removed.

bump
 
Back
Top