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

Who hit most get storage TFS 1.3

Solution
This is what I did for monster "Black Knight" in my server

monster/black_knight.xml
Code:
<script>
    <event name="BlackKnightDeath"/>
</script>

creaturescripts/creaturescripts.xml
Code:
<event type="death" name="BlackKnightDeath" script="other/black_knight_death.lua" />

creaturescripts/scripts/other/black_knight_death.lua
Code:
function onDeath(creature, corpse, killer, mostDamageKiller, unjustified, mostDamageUnjustified)
    local player = mostDamageKiller:getPlayer()
    
    if not player then
        return true
    end
    
    player:setStorageValue(Storage.BlackKnightKill, 1)
    
    return true
end
This is what I did for monster "Black Knight" in my server

monster/black_knight.xml
Code:
<script>
    <event name="BlackKnightDeath"/>
</script>

creaturescripts/creaturescripts.xml
Code:
<event type="death" name="BlackKnightDeath" script="other/black_knight_death.lua" />

creaturescripts/scripts/other/black_knight_death.lua
Code:
function onDeath(creature, corpse, killer, mostDamageKiller, unjustified, mostDamageUnjustified)
    local player = mostDamageKiller:getPlayer()
    
    if not player then
        return true
    end
    
    player:setStorageValue(Storage.BlackKnightKill, 1)
    
    return true
end
 
Solution
This is what I did for monster "Black Knight" in my server

monster/black_knight.xml
Code:
<script>
    <event name="BlackKnightDeath"/>
</script>

creaturescripts/creaturescripts.xml
Code:
<event type="death" name="BlackKnightDeath" script="other/black_knight_death.lua" />

creaturescripts/scripts/other/black_knight_death.lua
Code:
function onDeath(creature, corpse, killer, mostDamageKiller, unjustified, mostDamageUnjustified)
    local player = mostDamageKiller:getPlayer()
   
    if not player then
        return true
    end
   
    player:setStorageValue(Storage.BlackKnightKill, 1)
   
    return true
end
Only who hit more get storage?
 
Hi @guiismiti it is posible to make the storage last only 5 minutes after killing the monster? And send a message when player receives the storage, thanks in advance 😛
1 - to make it last for 5 minutes, you need to set the storage value as the current time.
Then, when you need to test the value of the storage, you get the time again and check if 5 min have passed.

To set the storage as the current time:
Lua:
player:setStorageValue(Storage.BlackKnightKill, os.time())
To check if 5 min have passed:
Lua:
local lastKill = player:getStorageValue(Storage.BlackKnightKill)
local interval = 5 * 60

if ((interval - (os.time() - lastKill)) > 0) then
    -- 5 minutes have not passed yet
else
    -- 5 minutes have passed
end

2 - send a message when player gets the storage - place this:
Lua:
player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You have beaten the black knight.")
after or before
Lua:
player:setStorageValue(Storage.BlackKnightKill, 1)
 
Back
Top