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

onKill for TFS

Virgel

New Member
Joined
Jun 14, 2007
Messages
150
Reaction score
2
Im searching for an onKill script for TFS.

I try to use this, but didnt work:

[12/05/2008 12:05:00] Error: [CreatureEvent::configureEvent] No valid type for creature event.kill
[12/05/2008 12:05:00] Warning: [BaseEvents::loadFromXml] Can not configure event

Code:
function onKill(cid, target)
	if(getPlayerStorageValue(cid, 10004) == 1) then
		if(getCreatureName(target) == "wolf") then
			local store = getPlayerStorageValue(cid, 100041)
			setPlayerStorageValue(cid, 100041, ((store==-1 and 1) or store+1))
			if(getPlayerStorageValue(cid, 100041) == 2) then
				doPlayerSendTextMessage(cid, MSG_INFO_DESCR, "You killed all wolves! GRATZ!")
				setPlayerStorageValue(cid, 10004, 2)
			end
		end
	end
	return TRUE
end

and in login.lua

Code:
if(getPlayerPlayerStorageValue(cid, 10004) == 1) then
	registerCreatureEvent(cid, "WOLF_KILL")
	end

and in xml
Code:
<event name="WOLF_KILL" type="kill" script="wolf_kill.lua"/>

Can anyone help?
 
Last edited:
What u Could do is....
Make a custom creature like wolf 2
(but u can make it have the same name as wolf It will just be saved as something different)
And Add this somehwere in it!

Code:
 <script>
<event name="wolf_kill"/>
<script>


For example save this as wolf 2.xml (it has the event script in)
Code:
<?xml version="1.0" encoding="UTF-8"?>
<monster name="Wolf" nameDescription="a wolf" race="blood" experience="18" speed="164" manacost="255">
	<health now="25" max="25"/>
	<look type="27" head="0" body="0" legs="0" feet="0" corpse="2826"/>
	<targetchange interval="2000" chance="0"/>
	<strategy attack="100" defense="0"/>
	<flags>
		<flag summonable="1"/>
		<flag attackable="1"/>
		<flag hostile="1"/>
		<flag illusionable="1"/>
		<flag convinceable="1"/>
		<flag pushable="1"/>
		<flag canpushitems="0"/>
		<flag canpushcreatures="0"/>
		<flag targetdistance="1"/>
		<flag runonhealth="8"/>
	</flags>
	<attacks>
		<attack name="melee" interval="2000" skill="19" attack="12"/>
	</attacks>
	<defenses armor="1" defense="4"/>
	<immunities>
		<immunity physical="0"/>
		<immunity energy="0"/>
		<immunity fire="0"/>
		<immunity poison="0"/>
		<immunity lifedrain="0"/>
		<immunity paralyze="0"/>
		<immunity outfit="0"/>
		<immunity drunk="0"/>
		<immunity invisible="0"/>
	</immunities>
<script>
<event name="wolf_kill"/>
	<loot capacity="100">
		<item id="2666" countmax="2" chance="500000"/>
		<item id="3976" countmax="1" chance="100000"/>
	</loot>
</monster>


Then go to data/monster/monsters.xml
and add this line
Code:
<monster name="wolf 2" file="wolf 2.xml"/>


Then Go into data/creaturescripts and find you creaturescripts.xml and add this

Code:
<event name="wolf_kill" type="death" script="wolf_kill.lua"/>


Then go into data/creaturescripts/scripts and save this as wolf_kill.lua

Code:
function onKill(cid, target)
	if(getPlayerStorageValue(cid, 10004) == 1) then
			local store = getPlayerStorageValue(cid, 100041)
			setPlayerStorageValue(cid, 100041, ((store==-1 and 1) or store+1))
			if(getPlayerStorageValue(cid, 100041) == 2) then
				doPlayerSendTextMessage(cid, MSG_INFO_DESCR, "You killed all wolves! GRATZ!")
				setPlayerStorageValue(cid, 10004, 2)
			end
		end
	end
	return TRUE
end


Didnt have time to test it but i can't see anything wrong with it :S
Hope it wrks :D


If it wrked rep me :D
 
Last edited:
Thx :) Ive done it allready with onDeath :)

Code:
function onDeath(cid, corpse, killer)
	if(getPlayerStorageValue(killer, 10004) == 1) then
		if(isPlayer(killer) == TRUE) then
			local store = getPlayerStorageValue(killer, 100041)
			setPlayerStorageValue(killer, 100041, ((store==-1 and 1) or store+1))
			if(getPlayerStorageValue(killer, 100041) < 5) then
				wolfs = getPlayerStorageValue(killer, 100041)
				doPlayerSendTextMessage(killer, 22, "You killed "..wolfs.."/5 wolfs!")
			else
				wolfs = getPlayerStorageValue(killer, 100041)
				doPlayerSendTextMessage(killer, 22, "You killed "..wolfs.."/5 wolfs! Go back to get your reward!")
				setPlayerStorageValue(killer, 10004, 2)
			end
		end
	end
	return TRUE
end
 
Last edited:
Yes :) i know.
Ive take a look at all (most) .cpp and .h files... but i didnt know how to start it (thats why i used type="kill" and not tyle="death")

:p

But thx you its a damn great server :)
 
Back
Top