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

When monster dies...

shizo88

New Member
Joined
Mar 10, 2009
Messages
7
Reaction score
0
Hello, its possible to make something like this:
When monster named xxx dies send warning that player named yyy killed it.

Im using TFS 0.33
Please help me :)
 
Last edited:
Not tested, if you got any errors post here errors:

PHP:
local config = {
	broadCast = FALSE, -- Red broadcast = TRUE/FALSE
	monsterName = "Demon",
}
function onKill(cid, target)
	if isMonster(target) == TRUE and isPlayer(cid) == TRUE then
		if getCreatureName(target) == string.lower(config.monsterName) then
			if config.broadCast == TRUE then
				doBroadcastMessage(getPlayerName(cid).." killed a "..getCreatureName(target))
			else
				doPlayerSendTextMessage(cid, 22, "You killed a "..getCreatureName(target))
			end
		end
	end
	return TRUE
end
 
Last edited:
In data/creaturescripts/scripts create a file named warning.lua and paste this inside:
PHP:
local config = {
	message = "WARNING",
}
function onDeath(cid, corpse, killer)
	local position = getCreaturePosition(cid)
		if BOSSNAMEHERE == getCreatureName(cid) then
			doCreatureSay(cid, config.message, TALKTYPE_ORANGE_1)
		end
	return TRUE
end

[/php]

not bad, but config AND ->table<- for 1 variable? better just put the msg in the function. also, im pretty sure he wanted broacast, else its pretty useles. and since the only monster that has this script in its xml is the boss, you wont need that if-statement either. and what is that local for? you aint using the playerpos to anything.
 
Not tested, if you got any errors post here errors:

PHP:
local config = {
	broadCast = FALSE, -- Red broadcast = TRUE/FALSE
	monsterName = "Demon",
}
function onKill(cid, target)
	if isMonster(target) == TRUE and isPlayer(cid) == TRUE then
		if getCreatureName(target) == string.lower(config.monsterName) then
			if config.broadCast == TRUE then
				doBroadcastMessage(getPlayerName(cid).." killed a "..getCreatureName(target))
			else
				doPlayerSendTextMessage(cid, 22, "You killed a "..getCreatureName(target))
			end
		end
	end
	return TRUE
end

Thank you very much, its working, but is there any way i can add more than one monster?
 
Yeah:

PHP:
local config = {
    broadCast = FALSE, -- Red broadcast = TRUE/FALSE
    monsters = {"Demon", "Rat", "Dragon"},
}
function onKill(cid, target)
    if isMonster(target) == TRUE and isPlayer(cid) == TRUE then
        if isInArray(string.lower(config.monsters), getCreatureName(target)) == TRUE then
            if config.broadCast == TRUE then
                doBroadcastMessage(getPlayerName(cid).." killed a "..getCreatureName(target))
            else
                doPlayerSendTextMessage(cid, 22, "You killed a "..getCreatureName(target))
            end
        end
    end
    return TRUE
end

Not tested but it should work :D
 
Is it possible to make a script that broadcast's when a player dies?

PHP:
function onDeath(cid, corpse, lastHitKiller, mostDamageKiller)
	if isPlayer(lastHitKiller) == 1 then
	doBroadcastMessage("the player: ".. getPlayerName(cid) .." just die.") 
        else
	doBroadcastMessage("the player: ".. getPlayerName(cid) .." just drop dead by a ".. getCreatureName(lastHitKiller) .."") 
     end
    return TRUE
end
 
Last edited:
PHP:
function onDeath(cid, corpse, lastHitKiller, mostDamageKiller)
	if isPlayer(lastHitKiller) == 1 then
	doBroadcastMessage("the player: ".. getPlayerName(cid) .." just die.") 
        else
	doBroadcastMessage("the player: ".. getPlayerName(cid) .." just drop dead by a ".. getCreatureName(lastHitKiller) .."") 
     end
    return TRUE
end
I put this in and it doesnt seem to work. :/
Code:
<event type="death" name="death" event="script" value="death.lua"/>

Code:
function onDeath(cid, corpse, lastHitKiller, mostDamageKiller)
if isPlayer(lastHitKiller) == 1 then
doBroadcastMessage("the player: getPlayerName(cid) just die.") 
else
doBroadcastMessage("the player: getPlayerName(cid) just drop dead by a mob!.") 
end
return TRUE
end
 
Also I would like a script that I assume would be very similar, a script so it will broadcast every monster killed by every player as well? A broadcast such as "PlayerName just killed a MonsterName"

Thanks...
 
Back
Top