KillerX Posted October 26, 2018 Posted October 26, 2018 (edited) getPlayerCountry always return false :\ addCommandHandler("1", function ( player ) local county = exports["admin"]:getPlayerCountry(player) print( county ) end ) pls help !!! thanks ; ) @IIYAMA Edited October 26, 2018 by KillerX 1
Moderators IIYAMA Posted October 26, 2018 Moderators Posted October 26, 2018 Debug console doesn't show a warning/error at all? Script is serverside? Did you also tried the call function instead of exports? https://wiki.multitheftauto.com/wiki/Call @KillerX 1
KillerX Posted October 26, 2018 Author Posted October 26, 2018 Just now, IIYAMA said: Debug console doesn't show a warning/error at all? no Just now, IIYAMA said: Script is serverside? yes Just now, IIYAMA said: Did you also tried the call function instead of exports? yes addCommandHandler( '1' , function( player ) print( call ( getResourceFromName ( "admin" ), "getPlayerCountry", player ) ) end )
Moderators IIYAMA Posted October 26, 2018 Moderators Posted October 26, 2018 (edited) yea, that seems to be the case. KillerX, you can edit the source code of this function here: admin/server/admin_ip2c.lua local aCountries = {} local IP2C_FILENAME = "conf/IpToCountryCompact.csv" local IP2C_UPDATE_URL = "https://mirror.multitheftauto.com/mtasa/scripts/IpToCountryCompact.csv" local IP2C_UPDATE_INTERVAL_SECONDS = 60 * 60 * 24 * 1 -- Update no more than once a day function getPlayerCountry ( player ) return getIpCountry ( getPlayerIP ( player ) ) end function getIpCountry ( ip ) if not loadIPGroupsIsReady() then return false end local ip_group = tonumber ( gettok ( ip, 1, 46 ) ) local ip_code = ( gettok ( ip, 2, 46 ) * 65536 ) + ( gettok ( ip, 3, 46 ) * 256 ) + ( gettok ( ip, 4, 46 ) ) if ( not aCountries[ip_group] ) then return false end for id, group in ipairs ( aCountries[ip_group] ) do local buffer = ByteBuffer:new( group ) local rstart = buffer:readInt24() if ip_code >= rstart then local rend = buffer:readInt24() if ip_code <= rend then local rcountry = buffer:readBytes( 2 ) return rcountry ~= "ZZ" and rcountry end end end return false end -- ... @KillerX Edited October 26, 2018 by IIYAMA 1
Jonas^ Posted October 26, 2018 Posted October 26, 2018 (edited) 57 minutes ago, KillerX said: getPlayerCountry always return false :\ addCommandHandler("1", function ( player ) local county = exports["admin"]:getPlayerCountry(player) print( county ) end ) pls help !!! thanks ; ) @IIYAMA call(getResourceFromName("admin"), "getPlayerCountry", player) Edited October 26, 2018 by OverKILL
KillerX Posted October 27, 2018 Author Posted October 27, 2018 Just now, N3xT said: localhost server always returns false. Just now, IIYAMA said: yea, that seems to be the case. KillerX, you can edit the source code of this function here: admin/server/admin_ip2c.lua local aCountries = {} local IP2C_FILENAME = "conf/IpToCountryCompact.csv" local IP2C_UPDATE_URL = "https://mirror.multitheftauto.com/mtasa/scripts/IpToCountryCompact.csv" local IP2C_UPDATE_INTERVAL_SECONDS = 60 * 60 * 24 * 1 -- Update no more than once a day function getPlayerCountry ( player ) return getIpCountry ( getPlayerIP ( player ) ) end function getIpCountry ( ip ) if not loadIPGroupsIsReady() then return false end local ip_group = tonumber ( gettok ( ip, 1, 46 ) ) local ip_code = ( gettok ( ip, 2, 46 ) * 65536 ) + ( gettok ( ip, 3, 46 ) * 256 ) + ( gettok ( ip, 4, 46 ) ) if ( not aCountries[ip_group] ) then return false end for id, group in ipairs ( aCountries[ip_group] ) do local buffer = ByteBuffer:new( group ) local rstart = buffer:readInt24() if ip_code >= rstart then local rend = buffer:readInt24() if ip_code <= rend then local rcountry = buffer:readBytes( 2 ) return rcountry ~= "ZZ" and rcountry end end end return false end -- ... @KillerX Thank you very very very very very very (very) + 25* 4 * 100 Much
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now