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

Set player storage on death

Joined
Mar 14, 2020
Messages
139
Solutions
3
Reaction score
11
How can i set a storage when player die? I'm trying to put that on death.lua and login.lua, but if the player die, then alt+f4 the game the storage ins't setted. Any tips?
 
Solution
Lua:
local storage = 85987 -- Storage here
function onPrepareDeath(creature, killer)
    creature:setStorageValue(storage, creature:getStorageValue(storage) + 1) -- + or -
    return true
end

or you put this in playerdeath.lua

Lua:
 player:setStorageValue(STORAGE HERE, player:getStorageValue(STORAGE HERE) + 1)
I think to avoid this you'll have to use event type PrepareDeath instead of death
 
You can try something like this
Lua:
function onPrepareDeath(creature, killer)
    player:setStorageValue(110000, -1)
    return true
end
XML:
 <event type="preparedeath" name="anyname" script="scriptname.lua" />
 
Lua:
local storage = 85987 -- Storage here
function onPrepareDeath(creature, killer)
    creature:setStorageValue(storage, creature:getStorageValue(storage) + 1) -- + or -
    return true
end

or you put this in playerdeath.lua

Lua:
 player:setStorageValue(STORAGE HERE, player:getStorageValue(STORAGE HERE) + 1)
 
Solution
login.lua
player:registerEvent("DeathStorage")
creaturescripts.xml
<event type="death" name="DeathStorage" script="DeathStorage.lua" />
DeathStorage.lua
Lua:
function onDeath(player, corpse, killer, mostDamage, unjustified, mostDamage_unjustified)
player:setStorageValue(110000, -1)
return
end
 
Back
Top