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

Lua DeathBroadcast on Default

Gothric

New Member
Joined
Feb 6, 2010
Messages
264
Reaction score
1
i want to do on my server deathbroadcast.. its mean that when xxx player kill yyy player on default will be shown message like "xxx(150) killed yyy(170)"

numbers in() are lvl

i already use this script but it doesnt work

function onDeath(cid, corpse, lastHitKiller, mostDamageKiller)
doBroadcastMessage(getCreatureName(lastHitKiller) .. " (level " .. getPlayerLevel(lastHitKiller) .. ") murdered " .. getCreatureName(cid) .. " (level " .. getPlayerLevel(cid) .. ")",MESSAGE_STATUS_DEFAULT)
end
 
Lua:
function onKill(cid, target)
        if isPlayer(target) == TRUE then   
                if ((isInParty(target) and isInParty(cid)) and (getPlayerParty(cid) == getPlayerParty(target))) and isPlayer(target)then
                        broadcastMessage(getCreatureName(cid) .. " just killed ".. getCreatureName(target).."",MESSAGE_STATUS_WARNING)
                elseif getCreatureSkullType(cid) == 4 or getCreatureSkullType(cid) == 3 and getCreatureSkullType(target) == 0 and isPlayer(target)then
                        broadcastMessage(getCreatureName(cid) .. " just killed ".. getCreatureName(target).." ",MESSAGE_STATUS_WARNING)
                elseif getCreatureSkullType(target) == 3 or getCreatureSkullType(target) == 4 and isPlayer(target) then
                        broadcastMessage(getCreatureName(cid) .. " just killed ".. getCreatureName(target).."",MESSAGE_STATUS_WARNING)      
                end
        end
        return TRUE
end

login.lua
Lua:
registerCreatureEvent(cid, "Killb")

creaturescript.xml
Lua:
<event type="kill" name="Killb" event="script" value="killb.lua"/>
 
09:15 Vesavas just killed Dance Makabr

This message is on Server Log :d is it possible to do this msg on default??

__________

This message is broadcast on screen :) is it possible to do that this message will be written on default?
 
Last edited:
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
                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 killed |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 = "|TARGETNAME| on level [|TARGETLEVEL|] just got killed  by |KILLERNAME| at level [|KILLERLEVEL|]!",
                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 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), config.broadcastMessage.messageClass)
								print('|KILLERNAME| did just kill |TARGETNAME|')
                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
 
man i write in creaturescript.xml ondeath but in console i have error

[01/05/2010 14:51:35] [Warning - Event::loadScript] Event onDeath not found (data/creaturescripts/scripts/defaultbroadcast.lua)
 
Back
Top