• 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 How many times the player killed and died for each other

Chady Chaito

New Member
Joined
Nov 25, 2013
Messages
11
Reaction score
1
Good evening , I need help because I am implementing a system , and need to know how many times " in life " the player killed and died for another player. How to do this ?
 
Code:
function onKill(...)
    if target:isPlayer() then
        player:setStorageValue(12345, math.max(0, player:getStorageValue(12345)) + 1)
    end
end

Similar for onDeath.
 
cant you have get:player~~ or 0 instead of math max? since it returns nil if its not been set it should default to 0
 
i mean like
Code:
function onKill(...)
if target:isPlayer() then
player:setStorageValue(12345, (player:getStorageValue(12345) or 0) + 1)
end
end
if
Code:
player:getStorageValue(...)
returns nil which it will if its in default state, the code above will return 0
its a very minor thing but it removes the need of math.max() call
 
It does not return nil if not set... It returns -1.

Code:
    if (player->getStorageValue(key, value)) {
        lua_pushnumber(L, value);
    } else {
        lua_pushnumber(L, -1);
    }
 
Back
Top