Jump to content

Problem with MTA PHP SDK


Cadu12

Recommended Posts

Im creating trace and it gives me return "nil"

PHP Code:

  
<?php 
include ( "mta_sdk.php" ); 
  
/*echo "<br><br>Country name : " . $ip_data['country_name'] . "<br>"; 
echo "Region name : " . $ip_data['region_name'] . "<br>"; 
echo "City : " . $ip_data['city'] . "<br>";*/ 
  
function locateIp($ip){ 
   $d = file_get_contents("http://api.ipinfodb.com/v2/fraud_query.php?key=757a8e90b2d756dd4d4b3b15479ccd16b7d023475490e2fa70e6b44d3c7ccf5d&ip=$ip&country_code=br&district=-&city=-&area_code=-&mail_domain=-"); 
  
   if (!$d){ 
      $backup = file_get_contents("http://backup.ipinfodb.com/fraud_query.php?key=<757a8e90b2d756dd4d4b3b15479ccd16b7d023475490e2fa70e6b44d3c7ccf5d>&ip=$ip&country_code=br&district=-&city=-&area_code=-&mail_domain=-&enable_hostname=1"); 
      $answer = new SimpleXMLElement($backup); 
      if (!$backup) return false; 
   }else{ 
      $answer = new SimpleXMLElement($d); 
   } 
  
   $country_code = $answer->IpCountryCode; 
   $country_name = $answer->IpCountry; 
   $region_name = $answer->IpRegion; 
   $city = $answer->IpCity; 
  
    return array('country_code' => $country_code, 'country_name' => $country_name, 'region_name' => $region_name, 'city' => $city); 
    //return array($country_code, $country_name, $region_name, $city); 
} 
  
$input = mta::getInput(); 
$ip_data = locateIp($input[0]); 
  
mta::doReturn( $ip_data['country_name'] );  
  
?> 

LUA Code:

  
function getCity(getmessage) 
    outputChatBox(getmessage) 
end 
  
function InfoCityPlayer(ip) 
    callRemote("http://localhost/trace.php", getCity, ip) 
end 
  
function getPlayerCity(player, command, who) 
    if who then 
        local GetPlayer, PlayerName = findPlayer(who) 
        if GetPlayer then 
            local getIP = getPlayerIP ( GetPlayer ) 
            InfoCityPlayer(tostring(getIP)) 
        end 
    end 
end 
addCommandHandler("test",getPlayerCity) 
  

Link to comment

i had some troubles with sdk, so i just JSONed everything myself for this (dont need convertToObjects and all that anyway).

so where exactly it fails, in lua or in php? do you get any reply from the geoIP site?

Link to comment

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...