• 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 Killed monsters counter!

slaw

Software Developer
Joined
Aug 27, 2007
Messages
3,667
Solutions
125
Reaction score
1,114
Location
Germany
GitHub
slawkens
How it looks in game: (screenshot is gone, you can make a new one and send me)
killed_monsters.JPG



1. data/creaturescripts/scripts/monster_counter.lua
Code:
local monsters = {
	--name = storage
	["rat"] = 35001,
	["troll"] = 35002,
	["rotworm"] = 35003,
	["dragon"] = 35004,
	["dragon lord"] = 35005,
	["demon"] = 35006,
}

function onKill(cid, target)
	if(isPlayer(target) ~= TRUE) then
		local master = getCreatureMaster(target)
		if(master and master ~= target) then return FALSE end

		local name = getCreatureName(target)
		local monster = monsters[string.lower(name)]
		if(monster) then
			local killedMonsters = getPlayerStorageValue(cid, monster)
			if(killedMonsters == -1) then
				killedMonsters = 1
			end
			doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "You killed " .. killedMonsters .. " " .. name .. "'s.")
			setPlayerStorageValue(cid, monster, killedMonsters + 1)
		end
	end
	return TRUE
end

2. data/creaturescripts/creaturescripts.xml
* TFS 0.2
Code:
<event type="kill" name="KilledMonstersCounter" script="monster_counter.lua"/>
* TFS 0.3 (RC2+)
Code:
<event type="kill" name="KilledMonstersCounter" event="script" value="monster_counter.lua"/>

3. Add this at bottom of your login.lua (before return TRUE)
Code:
registerCreatureEvent(cid, "KilledMonstersCounter")

UPDATE:
Available as mod: http://tfs-mods.googlecode.com/svn/trunk/killed-monsters-counter.xml
 
Last edited:
I love this escript but there is something I wanted to ask
so that when the char is desloguee the counter is set to 0 zero again? if you know pls help me plis
 
I love this escript but there is something I wanted to ask
so that when the char is desloguee the counter is set to 0 zero again? if you know pls help me plis

Yes, its saved. So if you kill 5 dragons, logout, login again and kill dragon - kills = 6.

#Master-m aka crazy spamer TY man! :D

PS Those monsters are just examples, you can add more.

If someone could do all monsters in alphabetically order, it will be really nice!
 
Yes, its saved. So if you kill 5 dragons, logout, login again and kill dragon - kills = 6.

#Master-m aka crazy spamer TY man! :D

PS Those monsters are just examples, you can add more.

If someone could do all monsters in alphabetically order, it will be really nice!


not explain excuse me! example: i kill 5 dragons and deslogueo and enter and kill 1 dragon! you have a 6 kill dragons! that have formed andalusia desloguiar the counter is set to zero to reset the account?

"sorry I do not speak English very well" :s
 
Yeah don't know what you exactly mean, but its saved to player. NOT account ;) Same as quests.
 
Yeah don't know what you exactly mean, but its saved to player. NOT account ;) Same as quests.

Considering you already gave him the answer, Im guessing he's asking for a similar type of script where the counter resets when you logout. Just a guess, might be wrong tho :p

Anyways great script mate, very creative ;)
 
Its nice, but better is make to send player msg just in console, cause every monster its rly pissing of after 1h of killing drags or whate~ monster xP
I think I will use it only for bosses :p Thank you for sharing
 
Its nice, but better is make to send player msg just in console, cause every monster its rly pissing of after 1h of killing drags or whate~ monster xP
I think I will use it only for bosses :p Thank you for sharing

ok, changed to MESSAGE_STATUS_CONSOLE_ORANGE ;)

Doesn't work for me. No error, I'm using TFS 0.3.1

Probably not done part 2 or 3?
 
How to make that it shows the message only when killed 1, 100, 1000, 2k, 3k... monsters? And what will be when storage reaches it's maximum value (65535)?
 
Dunno if limit is 65535, its propably 2,147,483,647

For showing message:

doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "You killed " .. killedMonsters .. " " .. name .. "'s.")

to
Code:
if(killed == 1 or killed == 100 or killed % 1000 == 0) then
	doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "You killed " .. killedMonsters .. " " .. name .. "'s.")
end
 
Uuuuh, nice script but doesn't work for me.. The counter is working but no creatures are dying when they die, they are just standing there, impossible to attack them and no hp bar ^^
What's the problem? (I use TFS 0.3)
 
Back
Top