• 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 OnKill PROBLEM TFS 1.2

lucastiond

New Member
Joined
Jul 14, 2013
Messages
35
Reaction score
0
I'm trying to make the creature Renegade Orc give me a StorageValue when I kill him, but to do that, i need to have a StorageValue. But when i kill it, nothing happens. Not even an error on console.

This is the script in creaturescripts

Code:
function onKill(creature, target)
    local targetMonster = target:getMonster()
    if not targetMonster then
        return true
    end

    if(string.lower(getCreatureName(target)) == "renegade orc") then
        return true
    end

    local player = creature:getPlayer()
    if (player:getStorageValue(46120) == 1) then
        player:setStorageValue(46120, 2)
    end
    return true
end


I already registered the storage Value in quests.xml and I also registered the event name "Renegade Orc" in login.lua, as I did in creaturescripts.xml

I really have no idea of what to do now. I've already searched on OTland but I can't find anything useful. I highly appreciate it if somebody has any idea how I can solve this.

Thanks
 
Last edited:
function onKill(creature, target)
local targetMonster = target:getMonster()
if not targetMonster then
return true
end

if(string.lower(getCreatureName(target)) == "renegade orc") then
return true <---------------
end

local player = creature:getPlayer()
if (player:getStorageValue(46120) == 1) then
player:setStorageValue(46120, 2)
end

return true
end

function onKill(creature, target)
local targetMonster = target:getMonster()
if not targetMonster then
return true
end

if(string.lower(getCreatureName(target)) == "renegade orc") then
local player = creature:getPlayer()
if (player:getStorageValue(46120) == 1) then
player:setStorageValue(46120, 2)
end
end

return true
end
 
@silveralol

Could you tell me which changes in the script I would have to do?

@president vankk

I already tried to debug the script. I took out the "getStorageValue" and left only the "setStorageValue" but still get no error and no response.
It seems the creature is not responding to the script, idk.

@Colors
@Beto06

Any suggestions?
 
SOLVED.

I did a remake of all scripts from zero, and now it's working.
For some reason the creature Renegade Orc wasn't responding because i didn't write his first letters name with Caps On

Thanks for everyone who tried to help.
 
using function onDeath() seems like it:
Code:
function onDeath(creature, corpse, lasthitkiller, mostdamagekiller, lasthitunjustified, mostdamageunjustified)
    local targetMonster = creature:getMonster()
    if not targetMonster or targetMonster:getName():lower() ~= 'your monster' then
        return true
    end
    mostdamagekiller:setStorageValue(key)
    return true
end
function onDeath has alot of user data :)
would be better use it
advice: use metamethod to program, seems too much better to read and write
 
Last edited:
Back
Top