• 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 [TFS 0.X] Frag Reward Problem

potinho

Advanced OT User
Joined
Oct 11, 2009
Messages
1,402
Solutions
17
Reaction score
150
Location
Brazil
Hello everyone, everything good? I'm using the frag reward system from the topic below, but when I killed a player my console showed an error and the reward (heart with ID 5280) was not delivered.


frag reward.lua
Lua:
[LIST=1]
[*]local config = {
[*]    useTrophy = "no", -- Use the trophy reward system?
[*]    useHeart = "yes", -- Use the heart reward system?
[*]    killers = 1 -- The # of people whom receive the reward.
[*]}
[*]
[*]local BRONZE, SILVER, GOLD = 10129, 10128, 10127
[*]function onDeath(cid, corpse, deathList)
[*]    local reward, var = 0, {
[*]        KILLER_NAME = getCreatureName(deathList),
[*]        TARGET_NAME = getCreatureName(cid),
[*]        KILLER_LEVEL = getPlayerLevel(deathList),
[*]        TARGET_LEVEL = getPlayerLevel(cid)
[*]    }
[*]    config.useTrophy = getBooleanFromString(config.useTrophy)
[*]    config.useHeart = getBooleanFromString(config.useHeart)
[*]    local worldType = getConfigValue("worldType")
[*]    if(worldType == "open") then
[*]        for i = 1, config.killers do
[*]            if(isPlayer(cid) and isPlayer(deathList)) then
[*]                if(getPlayerIp(cid) ~= getPlayerIp(deathList)) then
[*]              
[*]                    if(var.TARGET_LEVEL > 8 and var.TARGET_LEVEL < 100) then
[*]                        reward = BRONZE
[*]                    elseif(var.TARGET_LEVEL > 99 and var.TARGET_LEVEL < 200) then
[*]                        reward = SILVER
[*]                    elseif(var.TARGET_LEVEL > 199) then
[*]                        reward = GOLD
[*]                    end
[*]                  
[*]                    local trophy, heart = 0, 0
[*]                    if(config.useHeart) then
[*]                        heart = doAddContainerItem(corpse.uid, 5280, 1)
[*]                    end
[*]                    if(config.useTrophy) then
[*]                        trophy = doPlayerAddItem(deathList, reward, 1)
[*]                    end
[*]                  
[*]                    local killers = ""
[*]                    for i = 1, math.min(getConfigInfo('deathAssistCount') + 1, #deathList) do
[*]                        killers = killers .. (i == 1 and "" or ", ") .. (isMonster(deathList) and "a " or "") .. getCreatureName(deathList)
[*]                    end
[*]                    if(config.useHeart) then
[*]                        doItemSetAttribute(heart, "name", "Heart of " .. var.TARGET_NAME)
[*]                        doItemSetAttribute(heart, "description", "It was taken from " .. var.TARGET_NAME .. "'s body. " .. (getPlayerSex(cid) == 0 and "She" or "He") .. " was killed at level " .. var.TARGET_LEVEL .. " by " .. var.KILLER_NAME .. ". " .. (getCreatureSkullType(cid) <= SKULL_GREEN and "(Unjustified)" or "(Justified)"))
[*]                    end
[*]                    if(config.useTrophy) then
[*]                        doItemSetAttribute(trophy, "description", "It was awarded to " .. var.KILLER_NAME .. " for killing " .. var.TARGET_NAME .. ". " .. (getPlayerSex(cid) == 0 and "She" or "He") .. " was killed at level " .. var.TARGET_LEVEL .. " by " .. var.KILLER_NAME .. " who was level " .. var.KILLER_LEVEL .. " at the time. " .. (getCreatureSkullType(cid) <= SKULL_GREEN and "(Unjustified)" or "(Justified)"))
[*]                    end
[*]                    doSendMagicEffect(getThingPosition(cid), CONST_ME_MAGIC_RED)
[*]                end
[*]            end
[*]        end
[*]    end
[*]    return true
[*]end
[/LIST]

Error in console:

[Error - CreatureScript Interface]
data/creaturescripts/scripts/frag_reward.lua:eek:nDeath
Description:
(luaGetCreatureName) Creature not found

[Error - CreatureScript Interface]
data/creaturescripts/scripts/frag_reward.lua:eek:nDeath
Description:
(internalGetPlayerInfo) Player not found when requesting player info #3
 
Back
Top