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

EXP for KILLERS (onKill)

scorpionfight

New Member
Joined
Sep 21, 2008
Messages
111
Reaction score
1
Location
Brazil
Hello, I wonder if anyone can help me in this script.

Its basically a enforced system, but I need it on creaturescripts.
I'm using creaturescript onKill(cid, target, damage, flags)

The easy part is:
Code:
function onKill(cid, target, damage, flags)
local exp = 100
if cid ~= target and isPlayer(target) then
doPlayerAddExperience(cid, exp)
doPlayerSendTextMessage(cid, 24, "You gained ".. exp .." experience.", exp, COLOR_WHITE)
end
end

But I can't figure how I can share the "exp" among the other killers.
Could anyone help me? Thanks anyway.
 
I don't think its possible, I think you need to use onDeath since it has the deathList, just with the onKill, I don't see how it's possible..
 
Hmm

Hum, I see an script here: http://otland.net/f82/frag-reward-trophy-heart-both-you-choose-147873/
But idk how I can transform it to a simple script that give exp for killers, can anyone help me?
Code:
local config = {
	useTrophy = "yes", -- "yes" or "no"
	useHeart = "yes", -- "yes" or "no"
	killers = 1 -- only the actual killer gets rewarded.
}
 
local BRONZE, SILVER, GOLD = 10129, 10128, 10127
 
function onDeath(cid, corpse, deathList)
	local reward = 0
 
	if(config.useTrophy) then
		config.useTrophy = getBooleanFromString(config.useTrophy)
	end
	if(config.useHeart) then
		config.useHeart = getBooleanFromString(config.useHeart)
	end
 
	local worldType = getConfigValue("worldType")
	if(worldType == "open") then
		for i = 1, config.killers do
			if(isPlayer(cid) and isPlayer(deathList[i])) then
				if(getPlayerIp(cid) ~= getPlayerIp(deathList[i])) then
 
					local var = {
						KILLER_NAME = getCreatureName(deathList[i]),
						TARGET_NAME = getCreatureName(cid),
						KILLER_LEVEL = getPlayerLevel(deathList[i]),
						TARGET_LEVEL = getPlayerLevel(cid)
					}
 
					if(var.TARGET_LEVEL > 8 and var.TARGET_LEVEL < 100) then 
						reward = BRONZE
					elseif(var.TARGET_LEVEL > 99 and var.TARGET_LEVEL < 200) then
						reward = SILVER
					elseif(var.TARGET_LEVEL > 199) then
						reward = GOLD
					end
 
					local trophy, heart = 0, 0
					if(config.useHeart) then
						heart = doAddContainerItem(corpse.uid, 5943, 1)
					end
 
					if(config.useTrophy) then
						trophy = doPlayerAddItem(deathList[i], reward, 1)
					end
 
					local killers = ""
					for i = 1, math.min(getConfigInfo('deathAssistCount') + 1, #deathList) do
						killers = killers .. (i == 1 and "" or ", ") .. (isMonster(deathList[i]) and "a " or "") .. getCreatureName(deathList[i])
					end
 
					if(config.useHeart) then
						doItemSetAttribute(heart, "name", "Heart of " .. var.TARGET_NAME)
						doItemSetAttribute(heart, "description", "It was taken from " .. var.TARGET_NAME .. "'s body. " .. (getPlayerSex(cid) == 0 and "She" or "He") .. " was killed at level " .. var.TARGET_LEVEL .. " by " .. var.KILLER_NAME .. ". " .. (getCreatureSkullType(cid) <= SKULL_GREEN and "(Unjustified)" or "(Justified)"))
					end
 
					if(config.useTrophy) then
						doItemSetAttribute(trophy, "description", "It was awarded to " .. var.KILLER_NAME .. " for killing " .. var.TARGET_NAME .. ". " .. (getPlayerSex(cid) == 0 and "She" or "He") .. " was killed at level " .. var.TARGET_LEVEL .. " by " .. var.KILLER_NAME .. " who was level " .. var.KILLER_LEVEL .. " at the time. " .. (getCreatureSkullType(cid) <= SKULL_GREEN and "(Unjustified)" or "(Justified)"))
					end
 
					doSendMagicEffect(getThingPosition(cid), CONST_ME_MAGIC_RED)
				end
			end
		end
	end
	return true
end
 
Try this:

Lua:
local config = {
	useTrophy = "yes", -- "yes" or "no"
	useHeart = "yes", -- "yes" or "no"
	killers = 1, -- only the actual killer gets rewarded.
	cyko_exp = 100
}
 
local BRONZE, SILVER, GOLD = 10129, 10128, 10127
 
function onDeath(cid, corpse, deathList)
	local reward = 0
 
	if(config.useTrophy) then
		config.useTrophy = getBooleanFromString(config.useTrophy)
	end
	if(config.useHeart) then
		config.useHeart = getBooleanFromString(config.useHeart)
	end
 
	local worldType = getConfigValue("worldType")
	if(worldType == "open") then
		for i = 1, config.killers do
			if(isPlayer(cid) and isPlayer(deathList[i])) then
				if(getPlayerIp(cid) ~= getPlayerIp(deathList[i])) then
 
					local var = {
						KILLER_NAME = getCreatureName(deathList[i]),
						TARGET_NAME = getCreatureName(cid),
						KILLER_LEVEL = getPlayerLevel(deathList[i]),
						TARGET_LEVEL = getPlayerLevel(cid)
					}
 
					if(var.TARGET_LEVEL > 8 and var.TARGET_LEVEL < 100) then 
						reward = BRONZE
					elseif(var.TARGET_LEVEL > 99 and var.TARGET_LEVEL < 200) then
						reward = SILVER
					elseif(var.TARGET_LEVEL > 199) then
						reward = GOLD
					end
 
					local trophy, heart = 0, 0
					if(config.useHeart) then
						heart = doAddContainerItem(corpse.uid, 5943, 1)
					end
 
					if(config.useTrophy) then
						trophy = doPlayerAddItem(deathList[i], reward, 1)
					end
 
					local killers = ""
					for i = 1, math.min(getConfigInfo('deathAssistCount') + 1, #deathList) do
						killers = killers .. (i == 1 and "" or ", ") .. (isMonster(deathList[i]) and "a " or "") .. getCreatureName(deathList[i])
					end
 
					if(config.useHeart) then
						doItemSetAttribute(heart, "name", "Heart of " .. var.TARGET_NAME)
						doItemSetAttribute(heart, "description", "It was taken from " .. var.TARGET_NAME .. "'s body. " .. (getPlayerSex(cid) == 0 and "She" or "He") .. " was killed at level " .. var.TARGET_LEVEL .. " by " .. var.KILLER_NAME .. ". " .. (getCreatureSkullType(cid) <= SKULL_GREEN and "(Unjustified)" or "(Justified)"))
					end
 
					if(config.useTrophy) then
						doItemSetAttribute(trophy, "description", "It was awarded to " .. var.KILLER_NAME .. " for killing " .. var.TARGET_NAME .. ". " .. (getPlayerSex(cid) == 0 and "She" or "He") .. " was killed at level " .. var.TARGET_LEVEL .. " by " .. var.KILLER_NAME .. " who was level " .. var.KILLER_LEVEL .. " at the time. " .. (getCreatureSkullType(cid) <= SKULL_GREEN and "(Unjustified)" or "(Justified)"))
					end
                                        doPlayerAddExp(deathList[i], config.cyko_exp)
					doSendMagicEffect(getThingPosition(cid), CONST_ME_MAGIC_RED)
				end
			end
		end
	end
	return true
end
 
Back
Top