• 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 TFS 0.4 Players level

Blade33711

Member
Joined
Aug 6, 2012
Messages
133
Solutions
1
Reaction score
5
Location
Poland
How to get players level with storage = 1234.
How to add these levels to yourself?
Lua:
function onSay(cid, words, param, channel)
for _, pid in ipairs(getPlayersOnline()) do
    if getPlayerStorageValue(pid, 1234) == -1 then
        doPlayerPopupFYI(cid, getPlayerLevel(pid))
    end
end
end
 
Solution
In the variable x I want to have joined player levels which have storage 1234.
Player1 = level 100, storage 1234 = 1
Player2 = level 123, storage 1234 = 1
Player10 = level 20, storage 1234 = 1
variable x = 100+123, ... , + 20 then variable x = 243

Lua:
function onSay(cid, words, param, channel)
    local level = 0
    for _, pid in ipairs(getPlayersOnline()) do
        if getPlayerStorageValue(pid, 1234) == 1 then
            level = level + getPlayerLevel(pid)
        end
    end

    doPlayerPopupFYI(cid, level)
    return true
end
You want to display all the players level who has storage value 1234?
In that case set the 1234 storage to ex 1, then check if it's 1 not -1
Lua:
function onSay(cid, words, param, channel)
    for _, pid in ipairs(getPlayersOnline()) do
        if getPlayerStorageValue(pid, 1234) == 1 then
            doPlayerPopupFYI(cid, getPlayerLevel(pid))
        end
    end

    return true
end
 
Yes, I know it should be 1. But I mean that all levels of these players add to the new variable.
local x = getPlayerLevel(pid) + getPlayerLevel(pid)
 
Yes, I know it should be 1. But I mean that all levels of these players add to the new variable.
local x = getPlayerLevel(pid) + getPlayerLevel(pid)

And what are you gonna do with the variable x?
Or do you mean count every players level and then print it?

Like 3 x 100 lvls = 300 lvls?
 
In the variable x I want to have joined player levels which have storage 1234.
Player1 = level 100, storage 1234 = 1
Player2 = level 123, storage 1234 = 1
Player10 = level 20, storage 1234 = 1
variable x = 100+123, ... , + 20 then variable x = 243
 
In the variable x I want to have joined player levels which have storage 1234.
Player1 = level 100, storage 1234 = 1
Player2 = level 123, storage 1234 = 1
Player10 = level 20, storage 1234 = 1
variable x = 100+123, ... , + 20 then variable x = 243

Lua:
function onSay(cid, words, param, channel)
    local level = 0
    for _, pid in ipairs(getPlayersOnline()) do
        if getPlayerStorageValue(pid, 1234) == 1 then
            level = level + getPlayerLevel(pid)
        end
    end

    doPlayerPopupFYI(cid, level)
    return true
end
 
Solution
Back
Top