-
Notifications
You must be signed in to change notification settings - Fork 9
/
killed-monsters-counter.xml
46 lines (41 loc) · 1.49 KB
/
killed-monsters-counter.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
<?xml version="1.0" encoding="UTF-8"?>
<mod name="killed-monsters-counter" version="1.0" author="slawkens" contact="slawkens@gmail.com" enabled="yes">
<!--
TODO:
- automatically assign storages in TFS 0.4 that supports string as a key
- configurable message interval that will prevent spam in the console (i.e. inform player each X kills)
- rewards for killing monsters
-->
<event type="kill" name="killed-monsters-counter-event" event="script"><![CDATA[
local monsters = {
--name = storage
["rat"] = 3200,
["troll"] = 3201,
["rotworm"] = 3202,
["dragon"] = 3203,
["dragon lord"] = 3204,
["demon"] = 3205,
}
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
]]></event>
<event type="login" name="killed-monsters-counter-login" event="buffer"><![CDATA[
registerCreatureEvent(cid, "killed-monsters-counter-event")
_result = true
]]></event>
</mod>