Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion [admin]/admin2/server/admin_server.lua
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,9 @@ function updatePlayerCountry(player)
local isIP2CResourceRunning = getResourceFromName( "ip2c" )
isIP2CResourceRunning = isIP2CResourceRunning and getResourceState( isIP2CResourceRunning ) == "running"
aPlayers[player].country = isIP2CResourceRunning and exports.ip2c:getPlayerCountry(player) or false
aPlayers[player].countryname = isIP2CResourceRunning and exports.ip2c:getCountryName(aPlayers[player].country) or false
if aPlayers[player].country then
aPlayers[player].countryname = isIP2CResourceRunning and exports.ip2c:getCountryName(aPlayers[player].country) or false
end
end

function aPlayerInitialize(player)
Expand Down
1 change: 1 addition & 0 deletions [admin]/ip2c/server.lua
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ local IP2C_UPDATE_INTERVAL_SECONDS = 60 * 60 * 24 * 1 -- Update no more than onc

-- [Exported]
function getPlayerCountry ( player )
if not (isElement(player) and getElementType(player) == "player") then return false end
if not loadIPGroupsIsReady() then return false end
local ip = getPlayerIP(player)
local ip_group = tonumber ( gettok ( ip, 1, 46 ) )
Expand Down
3 changes: 3 additions & 0 deletions [admin]/ip2c/shared.lua
Original file line number Diff line number Diff line change
Expand Up @@ -255,5 +255,8 @@ local countryListAlpha2 = {

-- [Exported]
function getCountryName( country )
if type(country) ~= "string" then
return "Invalid country code"
end
return countryListAlpha2[ (string.upper(country)) ] or "Unknown"
end