File tree Expand file tree Collapse file tree 3 files changed +7
-1
lines changed Expand file tree Collapse file tree 3 files changed +7
-1
lines changed Original file line number Diff line number Diff line change @@ -154,7 +154,9 @@ function updatePlayerCountry(player)
154154 local isIP2CResourceRunning = getResourceFromName ( " ip2c" )
155155 isIP2CResourceRunning = isIP2CResourceRunning and getResourceState ( isIP2CResourceRunning ) == " running"
156156 aPlayers [player ].country = isIP2CResourceRunning and exports .ip2c :getPlayerCountry (player ) or false
157- aPlayers [player ].countryname = isIP2CResourceRunning and exports .ip2c :getCountryName (aPlayers [player ].country ) or false
157+ if aPlayers [player ].country then
158+ aPlayers [player ].countryname = isIP2CResourceRunning and exports .ip2c :getCountryName (aPlayers [player ].country ) or false
159+ end
158160end
159161
160162function aPlayerInitialize (player )
Original file line number Diff line number Diff line change @@ -20,6 +20,7 @@ local IP2C_UPDATE_INTERVAL_SECONDS = 60 * 60 * 24 * 1 -- Update no more than onc
2020
2121-- [Exported]
2222function getPlayerCountry ( player )
23+ if not (isElement (player ) and getElementType (player ) == " player" ) then return false end
2324 if not loadIPGroupsIsReady () then return false end
2425 local ip = getPlayerIP (player )
2526 local ip_group = tonumber ( gettok ( ip , 1 , 46 ) )
Original file line number Diff line number Diff line change @@ -255,5 +255,8 @@ local countryListAlpha2 = {
255255
256256-- [Exported]
257257function getCountryName ( country )
258+ if type (country ) ~= " string" then
259+ return " Invalid country code"
260+ end
258261 return countryListAlpha2 [ (string.upper (country )) ] or " Unknown"
259262end
You can’t perform that action at this time.
0 commit comments