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

CreatureEvent FragReward working on (TFS 0.2.13)

apockalyptik

New Member
Joined
Jun 17, 2007
Messages
47
Reaction score
0
Ive been looking for an update version of this script, coz the previous one wouldnt work with TFS 0.2.13. I finnaly found it on other forum and edited it so that it shows the level of the killer and the level of the killed person at the time.

This will give 3 kinds of goblets, depending of the victim's level:
Bronze to lv 1-99
Silver to lv 100-199
Golden to lv 200+

It will show like:
22:05 You see a silver goblet.
It weighs 15.00 oz.
It was awarded to Admin at level 101 for killing Cobaia at level 130.


login.lua
PHP:
function onLogin(cid)
	registerCreatureEvent(cid, "PlayerDeath")
	registerCreatureEvent(cid, "Killed")
	return TRUE
end

creaturescripts.xml
PHP:
<?xml version="1.0" encoding="UTF-8"?>
<creaturescripts>
	<event type="login" name="PlayerLogin" script="login.lua"/>
	<event type="login" name="FirstItems" script="firstitems.lua"/>
	<event type="death" name="PlayerDeath" script="playerdeath.lua"/>
	<event type="preparedeath" name="Killed" script="reward.lua"/>
</creaturescripts>

reward.lua
PHP:
function onPrepareDeath(cid, killer)
	--broadcastMessage(getCreatureName(killer).." killed "..getCreatureName(cid), 18)
	onKill(killer, cid)
end 

function onKill(cid, target)
	if isPlayer(cid) then
		killerName = getCreatureName(cid)
		name = getCreatureName(target)
		lvl = getPlayerLevel(target)
		
		if lvl > 0 and lvl < 100 then
			loot = 5807
		elseif lvl > 99 and lvl < 200 then
			loot = 5806
		elseif lvl > 199 then
			loot = 5805
		else
			loot = 5807
		end
		
		item = doPlayerAddItem(cid, loot, 1)
		doSetItemSpecialDescription(item,"It was awarded to "..getCreatureName(cid).." at level "..getPlayerLevel(cid).." for killing "..getCreatureName(target).." at level "..getPlayerLevel(target)..".")
		doPlayerSendTextMessage(killer, 22, "You killed "..name..".")
	end
end

This is the original, simpliest version of reward.lua, fixed by Ruda to work with the lastest tfs.
PHP:
function onPrepareDeath(cid, killer)

	if isPlayer(killer) == true then
		killerName = getCreatureName(killer)
		name = getCreatureName(cid)
		lvl = getPlayerLevel(cid)
		
		if lvl > 0 and lvl < 100 then
			loot = 5807
		elseif lvl > 99 and lvl < 200 then
			loot = 5806
		elseif lvl > 199 then
			loot = 5805
		else
			loot = 5807
		end

		item = doPlayerAddItem(killer, loot, 1)
		doSetItemSpecialDescription(item, name.." was killed by "..killerName.." at Level "..lvl..".")
		doPlayerSendTextMessage(killer, 22, "You killed "..name..".")
	end
end
 
Last edited:
Nice, but there is a problem, on your reward.lua says
Code:
  doPlayerSendTextMessage(cid, 22, "You killed "..name)
and it should be
Code:
doPlayerSendTextMessage(killer, 22, "You killed "..name..".")
.

Hummmmm it isnt working :S
 
Last edited by a moderator:
Is there anyway to make the item permantly have the description o_O it dispears if you reset the server

and nice work :D
 
Last edited:
Could you make it? That keeps having the description always, maybe in a SQL table?
 
[08/11/2008 17:48:15] data/creaturescripts/scripts/reward.lua:eek:nPrepareDeath

[08/11/2008 17:48:15] luaDoPlayerSendTextMessage(). Player not found

[08/11/2008 17:48:15] Lua Script Error: [CreatureScript Interface]
[08/11/2008 17:48:15] data/creaturescripts/scripts/reward.lua:eek:nPrepareDeath

[08/11/2008 17:48:15] luaDoPlayerAddItem(). Player not found


Helpp ;/
 
Or rather you used isPlayer function wrong. It doesn't return true, it returns 1/0 (TRUE/FALSE).

TRUE is not true...

if isPlayer(cid) then equals to if isPlayer(cid) == true then, a value is true if it's not false or nil. So TRUE and FALSE are both true.
 
Well the idea is oke but ur missing a HUGE add
u should also add a pie so he can celibrate his kill
 
it still dont work, if i kill one, he have 0 hp and can move, and he drops all 2 sec a trophy...
-> try this, it is a much better
 
I HAVE THIS PROBLEM:

[13/02/2009 22:44:22] Warning: [Event::loadScript] Can not load script. data/creaturescripts/scripts/reward.lua
[13/02/2009 22:44:22] data/creaturescripts/scripts/reward.lua:20: 'end' expected (to close 'if' at line 3) near '<eof>'
 
when i kill someone with my character sometimes i got 2 or 3 trophys at the same time and i get and error on my tfs .02

[12/04/2009 20:24:12] Lua Script Error: [CreatureScript Interface]
[12/04/2009 20:24:12] data/creaturescripts/scripts/reward.lua:eek:nPrepareDeath

[12/04/2009 20:24:12] luaDoPlayerSendTextMessage(). Player not found

[12/04/2009 20:24:13] Lua Script Error: [CreatureScript Interface]
[12/04/2009 20:24:13] data/creaturescripts/scripts/reward.lua:eek:nPrepareDeath

[12/04/2009 20:24:13] luaDoPlayerSendTextMessage(). Player not found
 
dosen't work fuck
Lua:
function isBetweenRange(value, from, to)
    return from <= value and value <= to
end

function onPrepareDeath(cid, deathList)
    if not isPlayer(cid) or not isPlayer(deathList[1]) then
        return true
    end
    
    local killerName = getCreatureName(deathList[1])
    local name = getCreatureName(cid)
    local lvl = getPlayerLevel(cid)
    local loot = isBetweenRange(lvl, 1, 99) and 5807 or isBetweenRange(lvl, 100, 199) and 5806 or lvl > 199 and 5805 or 5807          
    local item = doPlayerAddItem(deathList[1], loot, 1)
    doSetItemSpecialDescription(item, 'It was awarded to '.. killerName ..' at level '.. getPlayerLevel(deathList[1]) ..' for killing '.. name ..' at level '.. lvl ..'.')
    doPlayerSendTextMessage(deathList[1], 22, 'You killed '.. name ..'.')
    return true
end

XML:
<event type="preparedeath" name="reward" event="script" value="reward.lua"/>

Lua:
registerCreatureEvent)cid, "reward")
 
Back
Top