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

CreatureEvent Reward for killing players. Block number of kills.

PhoOwned

^_^
Joined
Nov 11, 2010
Messages
375
Reaction score
66
Reward for killing players. Block number of kills.

creatureevent type="kill"
don't forget to register in login.lua

Lua:
local block_kills = {}
local max_kills_per_target_player = 3

function onKill(cid, target)
	if(isPlayer(target)) then
		if(block_kills[getPlayerGUID(cid)] == nil) then
			block_kills[getPlayerGUID(cid)] = {}
		end
		if(block_kills[getPlayerGUID(cid)][getPlayerGUID(target)] == nil) then
			block_kills[getPlayerGUID(cid)][getPlayerGUID(target)] = 0
		end
		block_kills[getPlayerGUID(cid)][getPlayerGUID(target)] = block_kills[getPlayerGUID(cid)][getPlayerGUID(target)] + 1
		if(block_kills[getPlayerGUID(cid)][getPlayerGUID(target)] <= max_kills_per_target_player) then
			doPlayerAddItem(cid,2152,20)
			doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE,"You have Owned " .. getCreatureName(target) .. ". You get 2k.")
		else
			doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE,"You killed " .. getCreatureName(target) .. " too many times. NO REWARD!")
		end
	end
return TRUE
end

REPORT BUGS. NOT TESTED. SOMEONE REQUESTED ON MSN ;)
 
Version that check AccountID and IP of player, not his GUID:
Lua:
local block_kills_acc = {}
local block_kills_ip = {}
local max_kills_per_target_account = 3
local max_kills_per_target_ip = 5

function onKill(cid, target)
	if(isPlayer(target)) then
		if(block_kills_acc[getPlayerGUID(cid)] == nil) then
			block_kills_acc[getPlayerGUID(cid)] = {}
		end
		if(block_kills_acc[getPlayerGUID(cid)][getPlayerAccountId(target)] == nil) then
			block_kills_acc[getPlayerGUID(cid)][getPlayerAccountId(target)] = 0
		end
		block_kills_acc[getPlayerGUID(cid)][getPlayerAccountId(target)] = block_kills_acc[getPlayerGUID(cid)][getPlayerAccountId(target)] + 1
		if(block_kills_ip[getPlayerGUID(cid)] == nil) then
			block_kills_ip[getPlayerGUID(cid)] = {}
		end
		if(block_kills_ip[getPlayerGUID(cid)][getPlayerIp(target)] == nil) then
			block_kills_ip[getPlayerGUID(cid)][getPlayerIp(target)] = 0
		end
		block_kills_ip[getPlayerGUID(cid)][getPlayerIp(target)] = block_kills_ip[getPlayerGUID(cid)][getPlayerIp(target)] + 1
		if(block_kills_acc[getPlayerGUID(cid)][getPlayerAccountId(target)] <= max_kills_per_target_account and block_kills_ip[getPlayerGUID(cid)][getPlayerIp(target)] <= max_kills_per_target_ip) then
			doPlayerAddItem(cid,2152,20)
			doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE,"You have Owned " .. getCreatureName(target) .. ". You get 2k.")
		else
			doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE,"You killed " .. getCreatureName(target) .. " too many times. NO REWARD!")
		end
	end
return TRUE
end
 
and may not receive a level 100 reward if you kill a level 55?
is possible?
config.lua

----
shortened a bit, but it's still full of memory leaks
Lua:
local block_kills_acc = {}
local block_kills_ip = {}
local max_kills_per_target_account = 3
local max_kills_per_target_ip = 5

function onKill(cid, target, lastHit)
	if isPlayer(target) then
		local g, a, ip = getPlayerGUID(cid), getPlayerAccountId(target), getPlayerIp(target)
		if not block_kills_acc[g] then
			block_kills_acc[g] = {}
			block_kills_ip[g] = {}
		end
		block_kills_acc[g][a] = (block_kills_acc[g][a] or 0) + 1
		block_kills_ip[g][ip] = (block_kills_ip[g][ip] or 0) + 1
		if block_kills_acc[g][a] <= max_kills_per_target_account and block_kills_ip[g][ip] <= max_kills_per_target_ip then
			doPlayerAddItem(cid, 2152, 20)
			doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE,"You have Owned " .. getCreatureName(target) .. ". You get 2k.")
		else
			doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE,"You killed " .. getCreatureName(target) .. " too many times. NO REWARD!")
		end
	end
	return true
end
 
I Want this script except no block even if you killed someone 1000 times, and no reward if you kill someone in same guild or 50 levels below yourself, is it possible? :$
 
Back
Top