• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

Solved DeathBroadcast

Ghazer

Member
Joined
Mar 13, 2009
Messages
350
Reaction score
6
Hello I have that script but dont found... can check this please?
Code:
local config = {
   affected = 10, -- how many players (deathAssits) from table deathList should this script be executed for?

   killStorageValue = 3943,
   deathStorageValue = 3944,

   -- commands for the texts (those inside of ||, example: |KILLS| to show skills): KILLS, KILLERNAME, TARGETNAME
   rewardItem = {
      use = false,
      itemid = 2152,
      minLevel = false, -- false if you don't want any level req
      minLevelDiff = false, -- false if you don't want any level diff req (negative numbers allowed).
   },

   killMessage = {
      use = true,
      text = "You owned |TARGETNAME|! You have now |KILLERKILLS| kills!",
      messageClass = MESSAGE_STATUS_CONSOLE_BLUE
   },

   broadcastMessage = {
      use = true,
      minLevel = false, -- false if you don't want any level req
      minLevelDiff = false, -- false if you don't want any level diff req (negative numbers allowed).
      text = "|KILLERNAME| [|KILLERLEVEL|] just killed |TARGETNAME| [|TARGETLEVEL|]!",
      messageClass = MESSAGE_STATUS_WARNING
   },

   killerAnimation = {
      use = true,
      text = "Frag!", -- Only 9 letters! No "commands" here.
      color = 144
   },

   targetAnimation = {
      use = true,
      text = "Owned!", -- Only 9 letters! No "commands" here.
      color = 180
   }
}

function onDeath(cid, corpse, deathList)
   for i = 1, math.min(config.affected, getConfigInfo('deathAssistCount')) do
      local killer = deathList[i]
      if(isPlayer(killer) == TRUE) then
         local targetKills = math.max(0, getPlayerStorageValue(cid, config.killStorageValue)) + 1
         local targetDeaths = math.max(0, getPlayerStorageValue(cid, config.deathStorageValue)) + 1
      
         local killerKills = math.max(0, getPlayerStorageValue(killer, config.killStorageValue)) + 1
         local killerDeaths = math.max(0, getPlayerStorageValue(killer, config.deathStorageValue)) + 1
      
         setPlayerStorageValue(killer, config.killStorageValue, targetKills)
         setPlayerStorageValue(cid, config.deathStorageValue, targetDeaths)

         local killerLevel = getPlayerLevel(killer)
         local targetLevel = getPlayerLevel(cid)
         local levelDiff = targetLevel - killerLevel

         local values = {
            ["KILLERKILLS"]        = killerKills,
            ["KILLERDEATHS"]        = killerDeaths,
            ["KILLERNAME"]          = getCreatureName(killer),
            ["KILLERLEVEL"]        = killerLevel,
         
            ["TARGETKILLS"]        = targetKills,
            ["TARGETDEATHS"]        = targetDeaths,
            ["TARGETNAME"]          = getCreatureName(cid),
            ["TARGETLEVEL"]        = targetLevel
         }

         function formateString(str)
            return(str:gsub("|([A-Z]+)|", (function(a) return values[a] end)))
         end
      
         if(config.rewardItem.use and (not config.rewardItem.minLevel or targetLevel >= config.rewardItem.minLevel) and (not config.rewardItem.minLevelDiff or levelDiff >= config.rewardItem.minLevelDiff)) then
            local uid = doPlayerAddItem(killer, config.rewardItem.itemid, 5)
         end
         if(config.killMessage.use) then
            doPlayerSendTextMessage(killer, config.killMessage.messageClass, formateString(config.killMessage.text))
         end
         if(config.broadcastMessage.use and (not config.broadcastMessage.minLevel or getPlayerLevel(cid) >= config.broadcastMessage.minLevel) and (not config.broadcastMessage.minLevelDiff or levelDiff >= config.broadcastMessage.minLevelDiff)) then
            broadcastMessage(formateString(config.broadcastMessage.text), config.broadcastMessage.messageClass)
         end
         if(config.killerAnimation.use) then
            doSendAnimatedText(getCreaturePosition(killer), config.killerAnimation.text, config.killerAnimation.color)
         end
         if(config.targetAnimation.use) then
            doSendAnimatedText(getCreaturePosition(cid), config.targetAnimation.text, config.targetAnimation.color)
         end
      end
   end

   return true
end


ERROR:
Code:
[2/9/2012 20:29:36] [Error - CreatureScript Interface] 
[2/9/2012 20:29:36] data/creaturescripts/scripts/deathBroadcast.lua:onDeath
[2/9/2012 20:29:36] Description: 
[2/9/2012 20:29:36] data/creaturescripts/scripts/deathBroadcast.lua:46: bad argument #3 to 'max' (number expected, got nil)
[2/9/2012 20:29:36] stack traceback:
[2/9/2012 20:29:36] 	[C]: in function 'max'
[2/9/2012 20:29:36] 	data/creaturescripts/scripts/deathBroadcast.lua:46: in function <data/creaturescripts/scripts/deathBroadcast.lua:42>

[2/9/2012 20:29:45] [Error - CreatureScript Interface] 
[2/9/2012 20:29:45] data/creaturescripts/scripts/deathBroadcast.lua:onDeath
[2/9/2012 20:29:45] Description: 
[2/9/2012 20:29:45] data/creaturescripts/scripts/deathBroadcast.lua:46: bad argument #3 to 'max' (number expected, got nil)
[2/9/2012 20:29:45] stack traceback:
[2/9/2012 20:29:45] 	[C]: in function 'max'
[2/9/2012 20:29:45] 	data/creaturescripts/scripts/deathBroadcast.lua:46: in function <data/creaturescripts/scripts/deathBroadcast.lua:42>


PD: The OTX Server Version: (2.32 - 1303) -

- - - Updated - - -

BUMP, anyone can update that script? I use OTX 2
 
Try with another script :
http://otland.net/f82/kill-broadcast-j-uj-41030/

or:
LUA:
local config = {
        killStorageValue = 3943,
        deathStorageValue = 3944,
        -- commands for the texts (those inside of ||, example: |KILLS| to show skills): KILLS, KILLERNAME, TARGETNAME
        rewardItem = {
                use = true,
                itemid = 8698,
                minLevel = 100, -- false if you don't want any level req
                text = "This is a gift to |KILLERNAME| [|KILLERLEVEL|] for killing |TARGETNAME| [|TARGETLEVEL|]"
        },
        
        killMessage = {
                use = true,
                text = "You owned |TARGETNAME|! You have now |KILLERKILLS| kills!",
                messageClass = MESSAGE_STATUS_CONSOLE_BLUE
        },
               broadcastMessage = {
                use = true,
                text = "|KILLERNAME| [|KILLERLEVEL|] just killed |TARGETNAME| [|TARGETLEVEL|]!",
                messageClass = MESSAGE_STATUS_WARNING
        },
               killerAnimation = {
                use = true,
                text = "Frag!", -- Only 9 letters! No "commands" here.
                color = 215
        },
               targetAnimation = {
                use = true,
                text = "Owned!", -- Only 9 letters! No "commands" here.
                color = 215
        }
}
function onDeath(cid, corpse, killer)
        if(isPlayer(killer) == TRUE) then
                local targetKills = math.max(0, getPlayerStorageValue(cid, config.killStorageValue)) + 1
                local targetDeaths = math.max(0, getPlayerStorageValue(cid, config.deathStorageValue)) + 1
                
                local killerKills = math.max(0, getPlayerStorageValue(killer, config.killStorageValue)) + 1
                local killerDeaths = math.max(0, getPlayerStorageValue(killer, config.deathStorageValue)) + 1
                
                setPlayerStorageValue(killer, config.killStorageValue, targetKills)
                setPlayerStorageValue(cid, config.deathStorageValue, targetDeaths)
               
                local values = {
                        ["KILLERKILLS"]         = killerKills,
                        ["KILLERDEATHS"]        = killerDeaths,
                        ["KILLERNAME"]          = getCreatureName(killer),
                        ["KILLERLEVEL"]         = getPlayerLevel(killer),
                       
                        ["TARGETKILLS"]         = targetKills,
                        ["TARGETDEATHS"]        = targetDeaths,
                        ["TARGETNAME"]          = getCreatureName(cid),
                        ["TARGETLEVEL"]         = getPlayerLevel(cid)
                }
                function formateString(str)
                        return(str:gsub("|([A-Z]+)|", (function(a) return values[a] end)))
                end
               
                if(config.rewardItem.use and (not config.rewardItem.level or getPlayerLevel(cid) >= config.rewardItem.level)) then
                        local uid = doPlayerAddItem(killer, config.rewardItem.itemid)
                        doSetItemSpecialDescription(uid, formateString(config.rewardItem.text))
                end
                if(config.killMessage.use) then
                        doPlayerSendTextMessage(killer, config.killMessage.messageClass, formateString(config.killMessage.text))
                end
                if(config.broadcastMessage.use) then
                        broadcastMessage(formateString(config.broadcastMessage.text), (config.broadcastMessage.messageClass))
                end
                if(config.killerAnimation.use) then
                        doSendAnimatedText(getCreaturePosition(killer), config.killerAnimation.text, config.killerAnimation.color)
                end
                if(config.targetAnimation.use) then
                        doSendAnimatedText(getCreaturePosition(cid), config.targetAnimation.text, config.targetAnimation.color)
                end
        end
               return TRUE
end
 
LUA:
local config = {
	affected = 1, -- how many players (deathAssits) from table deathList should this script be executed for?

	killStorageValue = 3943,
	deathStorageValue = 3944,

	-- commands for the texts (those inside of ||, example: |KILLS| to show skills): KILLS, KILLERNAME, TARGETNAME
	rewardItem = {
		use = false,
		itemid = 8698,
		minLevel = 100, -- false if you don't want any level req
		minLevelDiff = 20, -- false if you don't want any level diff req (negative numbers allowed).
		text = "This is a gift to |KILLERNAME| [|KILLERLEVEL|] for killing |TARGETNAME| [|TARGETLEVEL|]"
	},

	killMessage = {
		use = true,
		text = "You owned |TARGETNAME|! You have now |KILLERKILLS| kills!",
		messageClass = MESSAGE_STATUS_CONSOLE_BLUE
	},

	broadcastMessage = {
		use = true,
		minLevel = 100, -- false if you don't want any level req
		minLevelDiff = 0, -- false if you don't want any level diff req (negative numbers allowed).
		text = "|KILLERNAME| [|KILLERLEVEL|] just killed |TARGETNAME| [|TARGETLEVEL|]!",
		messageClass = MESSAGE_STATUS_WARNING
	},

	killerAnimation = {
		use = true,
		text = "Frag!", -- Only 9 letters! No "commands" here.
		color = 215
	},

	targetAnimation = {
		use = true,
		text = "Owned!", -- Only 9 letters! No "commands" here.
		color = 215
	}
}

function onDeath(cid, corpse, deathList)
	for i = 1, math.min(config.affected, getConfigInfo('deathAssistCount')) do
		local killer = deathList[i]
		if(isPlayer(killer) == TRUE) then
			local targetKills = math.max(0, getPlayerStorageValue(cid, config.killStorageValue)) + 1
			local targetDeaths = math.max(0, getPlayerStorageValue(cid, config.deathStorageValue)) + 1
		
			local killerKills = math.max(0, getPlayerStorageValue(killer, config.killStorageValue)) + 1
			local killerDeaths = math.max(0, getPlayerStorageValue(killer, config.deathStorageValue)) + 1
		
			setPlayerStorageValue(killer, config.killStorageValue, targetKills)
			setPlayerStorageValue(cid, config.deathStorageValue, targetDeaths)

			local killerLevel = getPlayerLevel(killer)
			local targetLevel = getPlayerLevel(cid)
			local levelDiff = targetLevel - killerLevel

			local values = {
				["KILLERKILLS"]         = killerKills,
				["KILLERDEATHS"]        = killerDeaths,
				["KILLERNAME"]          = getCreatureName(killer),
				["KILLERLEVEL"]         = killerLevel,
			
				["TARGETKILLS"]         = targetKills,
				["TARGETDEATHS"]        = targetDeaths,
				["TARGETNAME"]          = getCreatureName(cid),
				["TARGETLEVEL"]         = targetLevel
			}

			function formateString(str)
				return(str:gsub("|([A-Z]+)|", (function(a) return values[a] end)))
			end
		
			if(config.rewardItem.use and (not config.rewardItem.minLevel or targetLevel >= config.rewardItem.minLevel) and (not config.rewardItem.minLevelDiff or levelDiff >= config.rewardItem.minLevelDiff)) then
				local uid = doPlayerAddItem(killer, config.rewardItem.itemid, 1)
				doSetItemSpecialDescription(uid, formateString(config.rewardItem.text))
			end
			if(config.killMessage.use) then
				doPlayerSendTextMessage(killer, config.killMessage.messageClass, formateString(config.killMessage.text))
			end
			if(config.broadcastMessage.use and (not config.broadcastMessage.minLevel or getPlayerLevel(cid) >= config.broadcastMessage.minLevel) and (not config.broadcastMessage.minLevelDiff or levelDiff >= config.broadcastMessage.minLevelDiff)) then
				broadcastMessage(formateString(config.broadcastMessage.text))
			end
			if(config.killerAnimation.use) then
				doSendAnimatedText(getCreaturePosition(killer), config.killerAnimation.text, config.killerAnimation.color)
			end
			if(config.targetAnimation.use) then
				doSendAnimatedText(getCreaturePosition(cid), config.targetAnimation.text, config.targetAnimation.color)
			end
		end
	end

	return true
end
 
/\ this one I just tested and it's working, my script gave error tho so I tried to write new one of 'Cronox'.

Ghazer good luck.
 
This error )= (I use otx 2)

Code:
[4/9/2012 19:59:42] [Error - CreatureScript Interface] 
[4/9/2012 19:59:42] data/creaturescripts/scripts/deathBroadcast.lua:onDeath
[4/9/2012 19:59:42] Description: 
[4/9/2012 19:59:42] data/creaturescripts/scripts/deathBroadcast.lua:47: bad argument #3 to 'max' (number expected, got nil)
[4/9/2012 19:59:42] stack traceback:
[4/9/2012 19:59:42] 	[C]: in function 'max'
[4/9/2012 19:59:42] 	data/creaturescripts/scripts/deathBroadcast.lua:47: in function <data/creaturescripts/scripts/deathBroadcast.lua:43>
 
why is getCreatureStorage returning nil?
Code:
			local targetKills = (getCreatureStorage(cid, config.killStorageValue) or 0) + 1
			local targetDeaths = (getCreatureStorage(cid, config.deathStorageValue) or 0) + 1

			local killerKills = (getCreatureStorage(killer, config.killStorageValue) or 0) + 1
			local killerDeaths = (getCreatureStorage(killer, config.deathStorageValue) or 0) + 1
 
Hmm my scripts works fine, what rev TFS have you?
Try this:
LUA:
local config = {
	affected = 10, -- how many players (deathAssits) from table deathList should this script be executed for?
 
	killStorageValue = 3943,
	deathStorageValue = 3944,
 
	-- commands for the texts (those inside of ||, example: |KILLS| to show skills): KILLS, KILLERNAME, TARGETNAME
	rewardItem = {
		use = true,
		itemid = 8698,
		minLevel = false, -- false if you don't want any level req
		minLevelDiff = false, -- false if you don't want any level diff req (negative numbers allowed).
		text = "This is a gift to |KILLERNAME| [|KILLERLEVEL|] for killing |TARGETNAME| [|TARGETLEVEL|]"
	},
 
	killMessage = {
		use = true,
		text = "You owned |TARGETNAME|! You have now |KILLERKILLS| kills!",
		messageClass = MESSAGE_STATUS_CONSOLE_BLUE
	},
 
	broadcastMessage = {
		use = true,
		minLevel = false, -- false if you don't want any level req
		minLevelDiff = false, -- false if you don't want any level diff req (negative numbers allowed).
		text = "|KILLERNAME| [|KILLERLEVEL|] just killed |TARGETNAME| [|TARGETLEVEL|]!",
		messageClass = MESSAGE_STATUS_WARNING
	},
 
	killerAnimation = {
		use = true,
		text = "Frag!", -- Only 9 letters! No "commands" here.
		color = 215
	},
 
	targetAnimation = {
		use = true,
		text = "Owned!", -- Only 9 letters! No "commands" here.
		color = 215
	}
}
 
function onDeath(cid, corpse, deathList)
	for i = 1, math.min(config.affected, getConfigInfo('deathAssistCount')) do
		local killer = deathList[i]
		if(isPlayer(killer) == TRUE) then
			local targetKills = math.max(0, getPlayerStorageValue(cid, config.killStorageValue)) + 1
			local targetDeaths = math.max(0, getPlayerStorageValue(cid, config.deathStorageValue)) + 1
 
			local killerKills = math.max(0, getPlayerStorageValue(killer, config.killStorageValue)) + 1
			local killerDeaths = math.max(0, getPlayerStorageValue(killer, config.deathStorageValue)) + 1
 
			setPlayerStorageValue(killer, config.killStorageValue, targetKills)
			setPlayerStorageValue(cid, config.deathStorageValue, targetDeaths)
 
			local killerLevel = getPlayerLevel(killer)
			local targetLevel = getPlayerLevel(cid)
			local levelDiff = targetLevel - killerLevel
 
			local values = {
				["KILLERKILLS"] = killerKills,
				["KILLERDEATHS"] = killerDeaths,
				["KILLERNAME"] = getCreatureName(killer),
				["KILLERLEVEL"] = killerLevel,
 
				["TARGETKILLS"] = targetKills,
				["TARGETDEATHS"] = targetDeaths,
				["TARGETNAME"] = getCreatureName(cid),
				["TARGETLEVEL"] = targetLevel
			}
 
			function formateString(str)
				return(str:gsub("|([A-Z]+)|", (function(a) return values[a] end)))
			end
 
			if(config.rewardItem.use and (not config.rewardItem.minLevel or targetLevel >= config.rewardItem.minLevel) and (not config.rewardItem.minLevelDiff or levelDiff >= config.rewardItem.minLevelDiff)) then
				local uid = doPlayerAddItem(killer, config.rewardItem.itemid, 1)
			 doItemSetAttribute(uid, "description", formateString(config.rewardItem.text))
			 doItemSetAttribute(uid, "aid", "2222")
			end
			if(config.killMessage.use) then
				doPlayerSendTextMessage(killer, config.killMessage.messageClass, formateString(config.killMessage.text))
			end
			if(config.broadcastMessage.use and (not config.broadcastMessage.minLevel or getPlayerLevel(cid) >= config.broadcastMessage.minLevel) and (not config.broadcastMessage.minLevelDiff or levelDiff >= config.broadcastMessage.minLevelDiff)) then
				broadcastMessage(formateString(config.broadcastMessage.text), config.broadcastMessage.messageClass)
			end
			if(config.killerAnimation.use) then
				doSendAnimatedText(getCreaturePosition(killer), config.killerAnimation.text, config.killerAnimation.color)
			end
			if(config.targetAnimation.use) then
				doSendAnimatedText(getCreaturePosition(cid), config.targetAnimation.text, config.targetAnimation.color)
			end
		end
	end
 
	return true
end
 
OTX 2.4
The OTX Server es una distribución de OpenTibia Server basada en The Forgotten Server 0.3.7 codigo abierto en constante mantenimiento y soporte en múltiples protocolos (Tibia Versions).

- - - Updated - - -

HELP!
 
Work perfect on otx 2.4,
data/creaturescripts/scripts/deathBroadcast.lua
LUA:
local config = {
	affected = 1, -- how many players (deathAssits) from table deathList should this script be executed for?
 
	killStorageValue = 3943,
	deathStorageValue = 3944,
 
	-- commands for the texts (those inside of ||, example: |KILLS| to show skills): KILLS, KILLERNAME, TARGETNAME
	rewardItem = {
		use = false,
		itemid = 8698,
		minLevel = 100, -- false if you don't want any level req
		minLevelDiff = 20, -- false if you don't want any level diff req (negative numbers allowed).
		text = "This is a gift to |KILLERNAME| [|KILLERLEVEL|] for killing |TARGETNAME| [|TARGETLEVEL|]"
	},
 
	killMessage = {
		use = true,
		text = "You owned |TARGETNAME|! You have now |KILLERKILLS| kills!",
		messageClass = MESSAGE_STATUS_CONSOLE_BLUE
	},
 
	broadcastMessage = {
		use = true,
		minLevel = 100, -- false if you don't want any level req
		minLevelDiff = 0, -- false if you don't want any level diff req (negative numbers allowed).
		text = "|KILLERNAME| [|KILLERLEVEL|] just killed |TARGETNAME| [|TARGETLEVEL|]!",
		messageClass = MESSAGE_STATUS_WARNING
	},
 
	killerAnimation = {
		use = true,
		text = "Frag!", -- Only 9 letters! No "commands" here.
		color = 215
	},
 
	targetAnimation = {
		use = true,
		text = "Owned!", -- Only 9 letters! No "commands" here.
		color = 215
	}
}
 
function onDeath(cid, corpse, deathList)
	for i = 1, math.min(config.affected, getConfigInfo('deathAssistCount')) do
		local killer = deathList[i]
		if(isPlayer(killer) == TRUE) then
			local targetKills = (getCreatureStorage(cid, config.killStorageValue) or 0) + 1
			local targetDeaths = (getCreatureStorage(cid, config.deathStorageValue) or 0) + 1

			local killerKills = (getCreatureStorage(killer, config.killStorageValue) or 0) + 1
			local killerDeaths = (getCreatureStorage(killer, config.deathStorageValue) or 0) + 1
 
			setPlayerStorageValue(killer, config.killStorageValue, targetKills)
			setPlayerStorageValue(cid, config.deathStorageValue, targetDeaths)
 
			local killerLevel = getPlayerLevel(killer)
			local targetLevel = getPlayerLevel(cid)
			local levelDiff = targetLevel - killerLevel
 
			local values = {
				["KILLERKILLS"] = killerKills,
				["KILLERDEATHS"] = killerDeaths,
				["KILLERNAME"] = getCreatureName(killer),
				["KILLERLEVEL"] = killerLevel,
 
				["TARGETKILLS"] = targetKills,
				["TARGETDEATHS"] = targetDeaths,
				["TARGETNAME"] = getCreatureName(cid),
				["TARGETLEVEL"] = targetLevel
			}
 
			function formateString(str)
				return(str:gsub("|([A-Z]+)|", (function(a) return values[a] end)))
			end
 
			if(config.rewardItem.use and (not config.rewardItem.minLevel or targetLevel >= config.rewardItem.minLevel) and (not config.rewardItem.minLevelDiff or levelDiff >= config.rewardItem.minLevelDiff)) then
				local uid = doPlayerAddItem(killer, config.rewardItem.itemid, 1)
				doSetItemSpecialDescription(uid, formateString(config.rewardItem.text))
			end
			if(config.killMessage.use) then
				doPlayerSendTextMessage(killer, config.killMessage.messageClass, formateString(config.killMessage.text))
			end
			if(config.broadcastMessage.use and (not config.broadcastMessage.minLevel or getPlayerLevel(cid) >= config.broadcastMessage.minLevel) and (not config.broadcastMessage.minLevelDiff or levelDiff >= config.broadcastMessage.minLevelDiff)) then
				broadcastMessage(formateString(config.broadcastMessage.text))
			end
			if(config.killerAnimation.use) then
				doSendAnimatedText(getCreaturePosition(killer), config.killerAnimation.text, config.killerAnimation.color)
			end
			if(config.targetAnimation.use) then
				doSendAnimatedText(getCreaturePosition(cid), config.targetAnimation.text, config.targetAnimation.color)
			end
		end
	end
 
	return true
end

creaturescripts.xml
XML:
<event type="death" name="DeathBroadcast" event="script" value="deathBroadcast.lua"/>

and on login.lua:
LUA:
registerCreatureEvent(cid, "DeathBroadcast")

is everything works 100% :)
cj08wSs.png
 
Last edited:
I am using The Forgotten Server - Version 0.2.14 (Mystic Spirit) and the script I tried using from this thread is not working for me...I used the last one Cronox posted last since no min reqs for it to broadcast. Anyway, I see most people say to put

Code:
<event type="death" name="DeathBroadcast" event="script" value="deathBroadcast.lua"/>

.... I get no error like that and it does not work...

but when I put

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

I get error

Code:
[11/11/2012 07:58:55] Lua Script Error: [CreatureScript Interface] 
[11/11/2012 07:58:55] data/creaturescripts/scripts/deathBroadcast.lua:onDeath
[11/11/2012 07:58:55] data/creaturescripts/scripts/deathBroadcast.lua:44: bad argument #2 to 'min' (number expected, got nil)
[11/11/2012 07:58:55] stack traceback:
[11/11/2012 07:58:55] 	[C]: ?
[11/11/2012 07:58:55] 	[C]: in function 'min'
[11/11/2012 07:58:55] 	data/creaturescripts/scripts/deathBroadcast.lua:44: in function <data/creaturescripts/scripts/deathBroadcast.lua:43>


Also, I don't want the gift at all...but I would like a death broadcast even when a monster kills a person...I have an old script from TFS 0.2.3 or so....I actually just removed a couple of lines and now it works for killing players, but i would like for it to work with dying by monsters as well.

Code:
local config = {
killStorageValue = 3943,
deathStorageValue = 3944,

-- commands for the texts (those inside of ||, example: |KILLS| to show skills): KILLS, KILLERNAME, TARGETNAME


killMessage = {
use = true,
text = "You owned |TARGETNAME|! You have now |KILLERKILLS| kills!",
messageClass = MESSAGE_STATUS_CONSOLE_BLUE
},

broadcastMessage = {
use = true,
text = "|KILLERNAME| [|KILLERLEVEL|] just killed |TARGETNAME| [|TARGETLEVEL|]!",
messageClass = MESSAGE_STATUS_WARNING
},

killerAnimation = {
use = true,
text = "Frag!", -- Only 9 letters! No "commands" here.
color = 215
},

targetAnimation = {
use = true,
text = "Owned!", -- Only 9 letters! No "commands" here.
color = 215
}
}


function onDeath(cid, corpse, killer)
if(isPlayer(killer) == TRUE) then
local targetKills = math.max(0, getPlayerStorageValue(cid, config.killStorageValue)) + 1
local targetDeaths = math.max(0, getPlayerStorageValue(cid, config.deathStorageValue)) + 1

local killerKills = math.max(0, getPlayerStorageValue(killer, config.killStorageValue)) + 1
local killerDeaths = math.max(0, getPlayerStorageValue(killer, config.deathStorageValue)) + 1

setPlayerStorageValue(killer, config.killStorageValue, targetKills)
setPlayerStorageValue(cid, config.deathStorageValue, targetDeaths)

local values = {
["KILLERKILLS"] = killerKills,
["KILLERDEATHS"] = killerDeaths,
["KILLERNAME"] = getCreatureName(killer),
["KILLERLEVEL"] = getPlayerLevel(killer),

["TARGETKILLS"] = targetKills,
["TARGETDEATHS"] = targetDeaths,
["TARGETNAME"] = getCreatureName(cid),
["TARGETLEVEL"] = getPlayerLevel(cid)
}

function formateString(str)
return(str:gsub("|([A-Z]+)|", (function(a) return values[a] end)))
end


if(config.killMessage.use) then
doPlayerSendTextMessage(killer, config.killMessage.messageClass, formateString(config.killMessage.text))
end
if(config.broadcastMessage.use) then
broadcastMessage(formateString(config.broadcastMessage.text), config.broadcastMessage.messageClass)
end

end

return TRUE
end
 
Last edited:
LUA:
local config = {
	killStorageValue = 3943,
	deathStorageValue = 3944,
	-- commands for the texts (those inside of ||, example: |KILLS| to show skills): KILLS, KILLERNAME, TARGETNAME


	killMessage = {
		use = true,
		text = "You owned |TARGETNAME|! You have now |KILLERKILLS| kills!",
		messageClass = MESSAGE_STATUS_CONSOLE_BLUE
	},

	broadcastMessage = {
		use = true,
		text = "|KILLERNAME| [|KILLERLEVEL|] just killed |TARGETNAME| [|TARGETLEVEL|]!",
		messageClass = MESSAGE_STATUS_WARNING
	},

	killerAnimation = {
		use = true,
		text = "Frag!", -- Only 9 letters! No "commands" here.
		color = 215
	},

	targetAnimation = {
		use = true,
		text = "Owned!", -- Only 9 letters! No "commands" here.
		color = 215
	}
}


function onDeath(cid, corpse, killer)
	local targetKills = math.max(0, getPlayerStorageValue(cid, config.killStorageValue)) + 1
	local targetDeaths = math.max(0, getPlayerStorageValue(cid, config.deathStorageValue)) + 1

	local killerKills = math.max(0, getPlayerStorageValue(killer, config.killStorageValue)) + 1
	local killerDeaths = math.max(0, getPlayerStorageValue(killer, config.deathStorageValue)) + 1

	setPlayerStorageValue(killer, config.killStorageValue, targetKills)
	setPlayerStorageValue(cid, config.deathStorageValue, targetDeaths)

	local values = {
		["KILLERKILLS"] = killerKills,
		["KILLERDEATHS"] = killerDeaths,
		["KILLERNAME"] = getCreatureName(killer),
		["KILLERLEVEL"] = getPlayerLevel(killer),

		["TARGETKILLS"] = targetKills,
		["TARGETDEATHS"] = targetDeaths,
		["TARGETNAME"] = getCreatureName(cid),
		["TARGETLEVEL"] = getPlayerLevel(cid)
	}

	function formateString(str)
		return(str:gsub("|([A-Z]+)|", (function(a) return values[a] end)))
	end

	if(config.killMessage.use) then
		doPlayerSendTextMessage(killer, config.killMessage.messageClass, formateString(config.killMessage.text))
	end
	if(config.broadcastMessage.use) then
		broadcastMessage(formateString(config.broadcastMessage.text), config.broadcastMessage.messageClass)
	end

	return TRUE
end
 
LUA:
local config = {
	killStorageValue = 3943,
	deathStorageValue = 3944,
	-- commands for the texts (those inside of ||, example: |KILLS| to show skills): KILLS, KILLERNAME, TARGETNAME


	killMessage = {
		use = true,
		text = "You owned |TARGETNAME|! You have now |KILLERKILLS| kills!",
		messageClass = MESSAGE_STATUS_CONSOLE_BLUE
	},

	broadcastMessage = {
		use = true,
		text = "|KILLERNAME| [|KILLERLEVEL|] just killed |TARGETNAME| [|TARGETLEVEL|]!",
		messageClass = MESSAGE_STATUS_WARNING
	},

	killerAnimation = {
		use = true,
		text = "Frag!", -- Only 9 letters! No "commands" here.
		color = 215
	},

	targetAnimation = {
		use = true,
		text = "Owned!", -- Only 9 letters! No "commands" here.
		color = 215
	}
}


function onDeath(cid, corpse, killer)
	local targetKills = math.max(0, getPlayerStorageValue(cid, config.killStorageValue)) + 1
	local targetDeaths = math.max(0, getPlayerStorageValue(cid, config.deathStorageValue)) + 1

	local killerKills = math.max(0, getPlayerStorageValue(killer, config.killStorageValue)) + 1
	local killerDeaths = math.max(0, getPlayerStorageValue(killer, config.deathStorageValue)) + 1

	setPlayerStorageValue(killer, config.killStorageValue, targetKills)
	setPlayerStorageValue(cid, config.deathStorageValue, targetDeaths)

	local values = {
		["KILLERKILLS"] = killerKills,
		["KILLERDEATHS"] = killerDeaths,
		["KILLERNAME"] = getCreatureName(killer),
		["KILLERLEVEL"] = getPlayerLevel(killer),

		["TARGETKILLS"] = targetKills,
		["TARGETDEATHS"] = targetDeaths,
		["TARGETNAME"] = getCreatureName(cid),
		["TARGETLEVEL"] = getPlayerLevel(cid)
	}

	function formateString(str)
		return(str:gsub("|([A-Z]+)|", (function(a) return values[a] end)))
	end

	if(config.killMessage.use) then
		doPlayerSendTextMessage(killer, config.killMessage.messageClass, formateString(config.killMessage.text))
	end
	if(config.broadcastMessage.use) then
		broadcastMessage(formateString(config.broadcastMessage.text), config.broadcastMessage.messageClass)
	end

	return TRUE
end



Dying from a player worked fine still. Thanks for trying. I tried versus a monster, and I got the following errors:

Code:
[13/11/2012 00:45:10] Test One has logged in.

[13/11/2012 00:45:30] Lua Script Error: [CreatureScript Interface] 
[13/11/2012 00:45:30] data/creaturescripts/scripts/deathBroadcast.lua:onDeath
[13/11/2012 00:45:30] LuaScriptInterface::luaGetPlayerStorageValue(). Player not found
[13/11/2012 00:45:30] stack traceback:
[13/11/2012 00:45:30] 	[C]: in function 'getPlayerStorageValue'
[13/11/2012 00:45:30] 	data/creaturescripts/scripts/deathBroadcast.lua:37: in function <data/creaturescripts/scripts/deathBroadcast.lua:33>

[13/11/2012 00:45:30] Lua Script Error: [CreatureScript Interface] 
[13/11/2012 00:45:30] data/creaturescripts/scripts/deathBroadcast.lua:onDeath
[13/11/2012 00:45:30] data/creaturescripts/scripts/deathBroadcast.lua:37: bad argument #2 to 'max' (number expected, got boolean)
[13/11/2012 00:45:30] stack traceback:
[13/11/2012 00:45:30] 	[C]: ?
[13/11/2012 00:45:30] 	[C]: in function 'max'
[13/11/2012 00:45:30] 	data/creaturescripts/scripts/deathBroadcast.lua:37: in function <data/creaturescripts/scripts/deathBroadcast.lua:33>
[13/11/2012 00:45:30] Test One has logged out.
 
Last edited:
LUA:
local config = {
	killStorageValue = 3943,
	deathStorageValue = 3944,
	-- commands for the texts (those inside of ||, example: |KILLS| to show skills): KILLS, KILLERNAME, TARGETNAME
 
 
	killMessage = {
		use = true,
		text = "You owned |TARGETNAME|! You have now |KILLERKILLS| kills!",
		messageClass = MESSAGE_STATUS_CONSOLE_BLUE
	},
 
	broadcastMessage = {
		use = true,
		text = "|KILLERNAME| [|KILLERLEVEL|] just killed |TARGETNAME| [|TARGETLEVEL|]!",
		messageClass = MESSAGE_STATUS_WARNING
	},
 
	killerAnimation = {
		use = true,
		text = "Frag!", -- Only 9 letters! No "commands" here.
		color = 215
	},
 
	targetAnimation = {
		use = true,
		text = "Owned!", -- Only 9 letters! No "commands" here.
		color = 215
	}
}
 
 
function onDeath(cid, corpse, killer)
	local targetKills = math.max(0, getPlayerStorageValue(cid, config.killStorageValue)) + 1
	local targetDeaths = math.max(0, getPlayerStorageValue(cid, config.deathStorageValue)) + 1
 
	local killerKills = 0
	local killerDeaths = 0
    if isPlayer(killer) then
		killerKills = math.max(0, getPlayerStorageValue(killer, config.killStorageValue)) + 1
		killerDeaths = math.max(0, getPlayerStorageValue(killer, config.deathStorageValue)) + 1
	
		setPlayerStorageValue(killer, config.killStorageValue, targetKills)
	end
	
	setPlayerStorageValue(cid, config.deathStorageValue, targetDeaths)
 
	local values = {
		["KILLERKILLS"] = killerKills,
		["KILLERDEATHS"] = killerDeaths,
		["KILLERNAME"] = getCreatureName(killer),
		["KILLERLEVEL"] = (isPlayer(killer) and getPlayerLevel(killer) or 0),
 
		["TARGETKILLS"] = targetKills,
		["TARGETDEATHS"] = targetDeaths,
		["TARGETNAME"] = getCreatureName(cid),
		["TARGETLEVEL"] = getPlayerLevel(cid)
	}
 
	function formateString(str)
		return(str:gsub("|([A-Z]+)|", (function(a) return values[a] end)))
	end
 
	if(config.killMessage.use) then
		doPlayerSendTextMessage(killer, config.killMessage.messageClass, formateString(config.killMessage.text))
	end
	if(config.broadcastMessage.use) then
		broadcastMessage(formateString(config.broadcastMessage.text), config.broadcastMessage.messageClass)
	end
 
	return TRUE
end
 
Back
Top