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

TFS 1.X+ Tfs 1.x get player Name by Guid?!?

roriscrave

Advanced OT User
Joined
Dec 7, 2011
Messages
1,188
Solutions
34
Reaction score
200
If i have this table:
Lua:
players_guid = {1, 13, 14, 22}

is possible to get player name by Guid? i tried
i tried something like this, but no success:
Code:
print(players_guid[1]:getName())
 
Solution
print(Player(players_guid[1]):getName())

Lua:
04:29 Lee: > test=Player(player:getGuid()); print(test:getName())
04:29 Lee

But as mentioned above. if they are offline you won't get anything.
I don't think so, specially if they are offline, you better do a SQL function:

just revert this one to id instead of name:
Lua:
function getPlayerGUIDByName(name)
    local player = Player(name)
    if player then
        return player:getGuid()
    end

    local resultId = db.storeQuery("SELECT `id` FROM `players` WHERE `name` = " .. db.escapeString(name))
    if resultId ~= false then
        local guid = result.getNumber(resultId, "id")
        result.free(resultId)
        return guid
    end
    return 0
end
 
print(Player(players_guid[1]):getName())

Lua:
04:29 Lee: > test=Player(player:getGuid()); print(test:getName())
04:29 Lee

But as mentioned above. if they are offline you won't get anything.
 
Solution
Back
Top