• 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 [Tibiando]Send music if monster was killed(to killer or to all have seen death)

Ksisio

New Member
Joined
Feb 21, 2008
Messages
54
Reaction score
0
Location
Stalowa Wola
Send music if monster was killed ;).

It sends sound only to player who killed monster.
monster_die.lua:
Code:
local monsters = {
					['demon'] = {"demonDie00.wav","demonDie01.wav"},
					['dragon'] = {"dragonDie00.mp3"},
					['tiger'] = {"tigerDie.wav"}
				}
function onKill(cid, target)
	if(not isPlayer(target)) and (isPlayer(cid)) then
		local name = getCreatureName(target)
		local monster = monsters[string.lower(name)]
		if(monster) then
			local sound = monster[math.random(1, #monster)]
			local sock = getSocket(cid)
			if sock then
				sock:send('EF='..sound..'\n')
			end
		end
	end
	return TRUE
end

It sends sound to all players who have seen death.
Code:
local monsters = {
					['demon'] = {"demonDie00.wav","demonDie01.wav"},
					['dragon'] = {"dragonDie00.mp3"},
					['tiger'] = {"tigerDie.wav"}
				}
function onKill(cid, target)
local players = {}
local creaturePos = {}
	if not isPlayer(target) then
		local monsterPos = getCreaturePos(target)
		local area = getArea(monsterPos, 5, 7)

		for k,v in pairs(area) do
			creaturePos = {x=v.x,y=v.y,z=v.z}
			local creature = getTopCreature(creaturePos)
			if creature.type ~= 0 and isPlayer(creature.uid) then
				table.insert(players, creature.uid)	
			end
		end
		
		if #players > 0 then
			local name = string.lower(getCreatureName(target))
			local monster = monsters[name]
			if monster then
				local sound = monster[math.random(1,#monster)]
				for i = 1, #players do
					player = players[i]
					local sock = getSocket(player)
					if sock then
						sock:send('EF='..sound..'\n')
					end
				end
			end
		end
	end
	return TRUE
end
creaturescripts.xml:
Code:
<event type="kill" name="MonsterDie" event="script" value="monster_die.lua"/>

login.lua:
Code:
registerCreatureEvent(cid, "MonsterDie")
 
Last edited:
Yes but wait few minutes.I wrote a script that sends sound to all players who have seen death. I testing it now.
 
it giving errors... and script not working in 0.2 and 0.3
Code:
[10/03/2011 13:19:21] [Error - CreatureScript Interface] 
[10/03/2011 13:19:21] data/creaturescripts/scripts/monster_die.lua:onKill
[10/03/2011 13:19:21] Description: 
[10/03/2011 13:19:21] data/creaturescripts/scripts/monster_die.lua:12: attempt to call global 'getSocket' (a nil value)
[10/03/2011 13:19:21] stack traceback:
[10/03/2011 13:19:21] 	data/creaturescripts/scripts/monster_die.lua:12: in function <data/creaturescripts/scripts/monster_die.lua:6>
 
[10/03/2011 18:28:50] [Error - CreatureScript Interface]
[10/03/2011 18:28:50] data/creaturescripts/scripts/monster_die.lua:eek:nKill
[10/03/2011 18:28:50] Description:
[10/03/2011 18:28:50] data/creaturescripts/scripts/monster_die.lua:24: attempt to get length of local 'monster' (a nil value)
[10/03/2011 18:28:50] stack traceback:
[10/03/2011 18:28:50] data/creaturescripts/scripts/monster_die.lua:24: in function <data/creaturescripts/scripts/monster_die.lua:6>


Its a real error /\ haha'
 
Back
Top