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

Solved Function onDeath add storagevalue

Shackal

Alien Project
Joined
Feb 7, 2009
Messages
211
Reaction score
17
Location
Brazil
Hello guys,

I'm using Dev 0.4
I wonder what's wrong in my script:

Code:
local c = {
    storage = 1889,
    storageValueToCheckFor = 31
}

function onDeath(cid, corpse, killer)
    if getPlayerStorageValue(killer, c.storage) == c.storageValueToCheckFor then
        setPlayerStorageValue(killer, c.storage, c.storageValueToCheckFor + 1)
    end
end

In my distro, returns the following error:

Code:
[Error - CreatureScript Interface]
data/creaturescripts/inq/ungreez.lua:onDeath
Description:
(luaGetCreatureStorage) Creature not found

But if already I configured an event in monster/Ungreez.lua, why not find?

Thank you in advance!
 
Last edited:
The script is to run as follows:
When a player kill Ungreez, your Storage goes from x to y
Then your script is wrong, it should be a onKill script
Code:
function onKill(cid, target, lastHit)
local c = {
storage = 1889,
storageValueToCheckFor = 31
}
local monster = 'ungreez'
    if getCreatureName(target):lower() == monster:lower() then
if getPlayerStorageValue(killer, c.storage) == c.storageValueToCheckFor then
setPlayerStorageValue(killer, c.storage, c.storageValueToCheckFor + 1)
    end
end
    return true
end


Inside creaturescripts.xml and login.lua make sure ungreez is spelled the same way as the monster is.
 
friend, no error but does not work:
Recalling that use the dev version 0.4


-- monster/ungreez.xml
Code:
<script>
                <event name="ungreez"/>
</script>

-- login.lua
Code:
registerCreatureEvent(cid, "ungreez")

-- creaturescript.xml
Code:
<event type="kill" name="ungreez" event="script" value="ungreez.lua"/>

-- creaturescript/scripts/inq/ungreez.lua
Code:
function onKill(cid, target, lastHit)
      local c = {
            storage = 1889,
            storageValueToCheckFor = 31
}
      local monster = 'ungreez'
            if getCreatureName(target):lower() == monster:lower() then
                     if getPlayerStorageValue(killer, c.storage) == c.storageValueToCheckFor then
                              setPlayerStorageValue(killer, c.storage, c.storageValueToCheckFor + 1)
                     end
            end
    return true
end
 
i try and:
M8Y2Q52.png
 
Code:
function onKill(cid, target, lastHit)
local c = {
storage = 1889,
storageValueToCheckFor = 19
}
local monster = 'ungreez'
    if getCreatureName(target):lower() == monster:lower() then
        if getCreatureStorageValue(killer, c.storage) == c.storageValueToCheckFor then
            setPlayerStorageValue(killer, c.storage, c.storageValueToCheckFor + 1)
        end
    end
    return true
end

This bug now:

S4dkTWV.png


and distro:

miJDPdu.png
 
Try this:

function onKill(cid, target, lastHit)
local c = {
storage = 1889,
storageValueToCheckFor = 19
}
local monster = "ungreez"
if string.lower(getCreatureName(target)) == string.lower(monster) then
if getPlayerStorageValue(cid, c.storage) == c.storageValueToCheckFor then
setPlayerStorageValue(cid, c.storage, c.storageValueToCheckFor + 1)
end
end
return true
end
 
Code:
function onKill(cid, target)
    if string.lower(getCreatureName(target) == string.lower("ungreez") then
        if getCreatureStorage(cid, 1889) == 19 then
            doCreatureSetStorage(cid, 1889, 20)
        end
    end
return true
end

There's zero reason this should not work. If it does not, that means you either haven't registered things correctly, or you just need to restart your server.
 
How many ppl does it take to write a simple script lol?

Since you diden't write what tfs you are using I suppose its 1.0?
Code:
local monsters = {
    ["demon"] = 23522
}

function onKill(creature, target)
    local targetMonster = target:getMonster()
    if(not targetMonster) then
        return true
    end
   
    local monster = monsters[targetMonster:getName():lower()]
    if(not monster) then
        return true
    end
   
    for pid, _ in pairs(targetMonster:getDamageMap()) do
        local attackerPlayer = Player(pid)
        if(attackerPlayer) then
            if(attackerPlayer:getStorageValue(monster) == 31) then
                attackerPlayer:setStorageValue(monster, attackerPlayer:getStorageValue(monster) + 1)
            end
        end
    end
end
 
How many ppl does it take to write a simple script lol?

Since you diden't write what tfs you are using I suppose its 1.0?
Code:
local monsters = {
    ["demon"] = 23522
}

function onKill(creature, target)
    local targetMonster = target:getMonster()
    if(not targetMonster) then
        return true
    end
  
    local monster = monsters[targetMonster:getName():lower()]
    if(not monster) then
        return true
    end
  
    for pid, _ in pairs(targetMonster:getDamageMap()) do
        local attackerPlayer = Player(pid)
        if(attackerPlayer) then
            if(attackerPlayer:getStorageValue(monster) == 31) then
                attackerPlayer:setStorageValue(monster, attackerPlayer:getStorageValue(monster) + 1)
            end
        end
    end
end
He stated the that the version was 0.4 and I solved his problem.
 
How many ppl does it take to write a simple script lol?

Since you diden't write what tfs you are using I suppose its 1.0?
Code:
local monsters = {
    ["demon"] = 23522
}

function onKill(creature, target)
    local targetMonster = target:getMonster()
    if(not targetMonster) then
        return true
    end
  
    local monster = monsters[targetMonster:getName():lower()]
    if(not monster) then
        return true
    end
  
    for pid, _ in pairs(targetMonster:getDamageMap()) do
        local attackerPlayer = Player(pid)
        if(attackerPlayer) then
            if(attackerPlayer:getStorageValue(monster) == 31) then
                attackerPlayer:setStorageValue(monster, attackerPlayer:getStorageValue(monster) + 1)
            end
        end
    end
end

nice u wrote this? xD https://github.com/PrinterLUA/FORGO...scripts/quests/bigfoot burden/WarzoneKill.lua

also by looking at his script you can clearly see it's for 0.4
 
Back
Top