• 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 Frag reward

Code:
function onPrepareDeath(cid, killer)
	if(isPlayer(killer) == TRUE) then
		local levelDiff = getPlayerLevel(killer) * 1.1
		if(levelDiff >= getPlayerLevel(cid)) then
			local item = doPlayerAddItem(killer,5943,1)
			doSetItemSpecialDescription(item, "This is the heart of "..getPlayerName(cid).."["..getPlayerLevel(cid).."]. He or She was killed by ".. getPlayerName(killer) .."["..getPlayerLevel(killer).."].")
		end	
	end	
end

This script shows killer's name and what level he died, victim's name and what level he died, also, it does not give the killer an item if he's 10% higher in level
 
Last edited:
I also added
if getPlayerLevel(killer) >= getPlayerLevel(killer) / 2 then
so if a level 100 kills a level 8 they don't get an item. :)
It should be getPlayerLevel(killer), sorry

function onPrepareDeath(cid, killer)
if(isPlayer(killer) == TRUE) then
local levelDiff = getPlayerLevel(cid) * 1.1
if(levelDiff >= getPlayerLevel(killer)) then
local item = doPlayerAddItem(killer,5943,1)
doSetItemSpecialDescription(item, "This is the heart of "..getPlayerName(cid).."["..getPlayerLevel(cid).."]. He or She was killed by ".. getPlayerName(killer) .."["..getPlayerLevel(killer).."].")
end
end
end

This script shows killer's name and what level he died, victim's name and what level he died, also, it does not give the killer an item if he's 10% higher in level

Wrong way around. :p
Should be this since you are getting the level of the player:
if (levelDiff <= getPlayerLevel(killer)) then

That just made it you could only get an item if your were over 10% of their level. eg. You only got an item if you killed a level 50 if you were equal or over level 55. :p
Now it makes it that you have to be 55 or under to get an item from killing the level 50. :p

Use mine :p
Code:
if getPlayerLevel(killer) >= (getPlayerLevel(killer) / 2) then

So..


This is the latest code. :)

Code:
function onPrepareDeath(cid, killer)
if(isPlayer(killer) == TRUE) then
if getPlayerLevel(killer) >= (getPlayerLevel(killer)/2) then
doSetItemSpecialDescription(doPlayerAddItem(killer,5943,1), "This is the heart of "..getPlayerName(cid).."["..getPlayerLevel(cid).."]. He or She was killed by ".. getPlayerName(killer) .."["..getPlayerLevel(killer).."].")
end 
end 
end
 
Last edited:
is there a way to change it so it can work like:
When you kill 5 ppl, u get like.... 2crystal coins?
 
It should be getPlayerLevel(killer), sorry



Wrong way around. :p
Should be this since you are getting the level of the player:
if (levelDiff <= getPlayerLevel(killer)) then

That just made it you could only get an item if your were over 10% of their level. eg. You only got an item if you killed a level 50 if you were equal or over level 55. :p
Now it makes it that you have to be 55 or under to get an item from killing the level 50. :p

Use mine :p
Code:
if getPlayerLevel(killer) >= (getPlayerLevel(killer) / 2) then

So..


This is the latest code. :)

Code:
function onPrepareDeath(cid, killer)
if(isPlayer(killer) == TRUE) then
if getPlayerLevel(killer) >= (getPlayerLevel(killer)/2) then
doSetItemSpecialDescription(doPlayerAddItem(killer,5943,1), "This is the heart of "..getPlayerName(cid).."["..getPlayerLevel(cid).."]. He or She was killed by ".. getPlayerName(killer) .."["..getPlayerLevel(killer).."].")
end 
end 
end
On real tibia, you don't get exp for killing someone if he's 10% lower than you(so a level 100 can't get exp on a level 89, but he would get exp if he kills a level 90). This is the way I did it, you'll get an item if you kill someone that's either higher or 10% lower than you.
Btw, I did a fix to the post now. It should work as I intended.
 
Cool script!
I'm going to try to make it show the level you had when you killed that player so you can say:
"Ha! I Killed you when I was just level 140"

"This is the skull of AGS at Level 250, he/she was killed by Lord Sorcerer(Level 140)."
 
Thanks this is really cool, my idea for this is since you get one when the player is only in 10% you make an NPC that takes those for a reward, the item id of course and he either pays you with gold or else he takes like 5 hearts for MPA, and 10 hearts for an armor only available through this.
 
When I get the reward, and I move it, the description dissapear :S
Using the last TFS.
 
Umby's OT (PVP-E) has a system like this except it gives out the servers currency upon a persons death as a reward to buy stuff from the various npcs.
 
Someone said 10%? :)
Try this:
Code:
fragReward = "yes"

function onPrepareDeath(cid, killer)
	if fragReward == "yes" then
		if isPlayer(killer) == TRUE then
			local levelDiffHigh = getPlayerLevel(killer) * 1.1
			local levelDiffLow = getPlayerLevel(killer) * 0.9
			if getPlayerLevel(killer) <= 20 and getPlayerLevel(killer) >= 1 then
				addReward = TRUE
			else
				if getPlayerLevel(cid) >= levelDiffLow and getPlayerLevel(cid) <= levelDiffHigh then
					addReward = TRUE
				else
					addReward = FALSE
				end
			end
			if addReward == TRUE then
				if getPlayerSex(cid) == 0 then
					cidGender = 'She'
				else
					cidGender = 'He'
				end
				doSendMagicEffect(getPlayerPosition(cid),CONST_ME_MAGIC_RED)
				doSetItemSpecialDescription(doPlayerAddItem(killer,5943,1), 'This is a heart of ' .. getPlayerName(cid) .. '. ' .. cidGender .. ' was killed at level ' .. getPlayerLevel(cid) .. ' by ' .. getPlayerName(killer) .. ' (Level ' .. getPlayerLevel(killer) .. ').')
				doSendMagicEffect(getPlayerPosition(killer),CONST_ME_MAGIC_RED)
			end 
		end
	end
end
You may also put the fragReward = "yes" in config.lua, but You will need to place on begining of the script a dofile("./config.lua")
 
Last edited:
@Elf
I tryed add your edited script to TFS trunk(740 rev) and look: >
[03/05/2008 23:07:10] Error: [CreatureEvent::configureEvent] No valid type for creature event.preparedeath
[03/05/2008 23:07:10] Warning: [BaseEvents::loadFromXml] Can not configure event
what should i do? ;D

edit:

Removed onPrepareDeath from trunk

saw this)

how can i make it works? are there any event type for this?
 
Last edited:
this one is with onKill(for trunk, elf deleted preparedeath):

PHP:
function onKill(cid, target)
if isPlayer(cid) == 1 and isPlayer(target) == 1 then

medal = doPlayerAddItem(cid,5785,1)
doSetItemSpecialDescription(medal,"This medal was given to " ..getCreatureName(cid).. " for killing " .. getCreatureName(target) .." at level " .. getPlayerLevel(target) .. "")

end
return 1
end
 
Thanks a lot this helped me with the script i was making:
12:06 You see a skull.
It weighs 21.80 oz.
This is Test's skull, he was killed by Test at Level 101.
=)
 
Actually, onKill is not supported by the tfs version i use, 0.2.12 so when i looked into this code it helped me fix it since i didn't know onPrepareDeath so i gived it a try... and it worked, and im not posting it since it's not yet finished i need to do some stuff first
 
Back
Top