• 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 Broadcasting when someone's dying. 0.3.6!

niti

New Member
Joined
Nov 22, 2009
Messages
258
Reaction score
2
Hello all. I got this script:

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 = true, 
        itemid = 5953, 
        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.item, 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

It broadcastes when someone dies but I get those errors aswell



[09/12/2014 00:02:14] [Error - CreatureScript Interface]
[09/12/2014 00:02:14] data/creaturescripts/scripts/deathbc.lua:eek:nDeath
[09/12/2014 00:02:14] Description:
[09/12/2014 00:02:14] (luaDoPlayerAddItem) Item not found

[09/12/2014 00:02:14] [Error - CreatureScript Interface]
[09/12/2014 00:02:14] data/creaturescripts/scripts/deathbc.lua:eek:nDeath
[09/12/2014 00:02:14] Description:
[09/12/2014 00:02:14] (luaDoItemSetAttribute) Item not found

[09/12/2014 00:02:14] [Error - CreatureScript Interface]
[09/12/2014 00:02:14] data/creaturescripts/scripts/deathbc.lua:eek:nDeath
[09/12/2014 00:02:14] Description:
[09/12/2014 00:02:14] (luaDoItemSetAttribute) Item not found
[09/12/2014 00:02:14] > Broadcasted message: "Dash Bror [919] just killed Dash Brush [610]!".

What am I missing?
 
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 = true,
itemid = 5953,
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
 
What kimokimo wrote is not the same as yours;

local uid = doPlayerAddItem(killer, config.rewardItem.item, 1) <-- Original
local uid = doPlayerAddItem(killer, config.rewardItem.itemid, 1) <-- Edited

which is the correct path;
local config = {.. rewardItem = {.. itemid = 5953,..

just change that line and the error should disappear.
Also, I wouldn't use "uid" as a parameter, since it could create confusion when reading the script. Rather use "item" or "id" or "reward" etc. you get the idea.
 
It worked. I took the script that Kimo edited for me. One more thing! How do I make that if you kill one you'll be rewarded with 1 crystal coin. And when you right click on someone you can see how many kills he has?
 
to see ow many kills and frags use it
Code:
function onLook(cid, thing, position, lookDistance)
function getDeathsAndKills(cid, type) -- by vodka
local query,d = db.getResult("SELECT `player_id` FROM "..(tostring(type) == "kill" and "`player_killers`" or "`player_deaths`").." WHERE `player_id` = "..getPlayerGUID(cid)),0
if (query:getID() ~= -1) then
repeat
d = d+1
until not query:next()
query:free()
end
return d
end
if isPlayer(thing.uid) then
doPlayerSetSpecialDescription(thing.uid, "\n"..(getPlayerSex(thing.uid) == 0 and "She" or "He").." has Killed: ["..getDeathsAndKills(thing.uid, "kill").."] Players.\n"..(getPlayerSex(thing.uid) == 0 and "She" or "He").." has Died: ["..getDeathsAndKills(thing.uid, "death").."] Times")
end
return true
end

Code:
<event type="look" name="deathshow" event="script" value="KillsandDeath.lua"/>

Code:
registerCreatureEvent(cid, "deathshow")

for reward use this

Code:
  function onKill(cid, target, lastHitKiller)
        if(isPlayer(lastHitKiller)) then
            local values = { KILLER_NAME = getCreatureName(lastHitKiller), KILLER_LEVEL = getPlayerLevel(lastHitKiller), TARGET_NAME = getCreatureName(target), TARGET_LEVEL = getPlayerLevel(target) }
            local reward = doPlayerAddItem(lastHitKiller, 2160, 3)
            doSendMagicEffect(getCreaturePosition(lastHitKiller), CONST_ME_GIFT_WRAPS)
            doSetItemSpecialDescription(reward, isPlayer(lastHitKiller) and "This is the heart of ".. values.TARGET_NAME ..". He was killed at level ".. values.TARGET_LEVEL .." by ".. values.KILLER_NAME .." who was level ".. values.KILLER_LEVEL .." at the time. " .. (getCreatureSkullType(target) <= SKULL_GREEN and "[Unjustified]" or "[Justified]") or "This is the heart of ".. values.TARGET_NAME ..". He was killed at level ".. values.TARGET_LEVEL .." by a ".. values.KILLER_NAME ..".")
            setItemName(reward, "".. values.TARGET_NAME .."'s Heart.")
        end
        return true
end

Code:
    <event type="kill" name="FragReward" script="fragreward.lua"/>

Code:
    registerCreatureEvent(cid, "FragReward")

for heart in human
Code:
function onDeath(cid, corpse, deathList)
     if isPlayer(deathList[1]) then
         local item = doAddContainerItem(corpse.uid, 5943, 1)
        
doItemSetAttribute(item, "description", "This is the heart of "..getPlayerName(cid).." killed at Level "..getPlayerLevel(cid).." by "..getPlayerName(deathList[1]).." at level "..getPlayerLevel(deathList[1]).." on "..os.date("%A %B %d %X %Y", os.time()).." "..(getCreatureSkullType(cid) <= SKULL_GREEN and "(Unjustified)" or "(Justified)")..".")
         doPlayerSendTextMessage(deathList[1], MESSAGE_STATUS_CONSOLE_ORANGE, "You killed " .. getCreatureName(cid) .. ".")
         doSendMagicEffect(getPlayerPosition(deathList[1]), CONST_ME_MAGIC_BLUE)
     end
     return true
end

Code:
<event type="death" name="heartReward" script="hartreward.lua"/>

Code:
registerCreatureEvent(cid, "heartReward")

now u have full death system use it and enjoy any error tell me u must restart ur pc after puting script
 
Last edited:
Back
Top