Jump to content

PHP SDK problem


GTX

Recommended Posts

Hello. I wanted to insert server name to servers.txt file. And now I had problem:

LUA:

  
function result(str) 
    outputChatBox("#FF8800[TOPTIMES] #FF6565Fetching data...", getRootElement(), 255, 255, 255, true) 
    if str ~= nil then 
        if str == "ua" then 
            outputChatBox("#FF8800[TOPTIMES] #FF6565Your license is not valid! Please, contact GTX#!", getRootElement(), 255, 255, 255, true) 
            if str == "1" then 
                outputChatBox("#FF8800[TOPTIMES] #FF6565Data fetched! Welcome!", getRootElement(), 255, 255, 255, true) 
                if str == "0" then 
                    outputChatBox("#FF8800[TOPTIMES] #FF6565Terminating script...", getRootElement(), 255, 255, 255, true) 
                    outputChatBox("#FF8800[TOPTIMES] #FF6565STEALERS ARE NOT WELCOME!", getRootElement(), 255, 255, 255, true) 
                    outputChatBox("#FF8800[TOPTIMES] #FF6565PLEASE, RE-LICENSE THIS BY ASKING GTX#!", getRootElement(), 255, 255, 255, true) 
                    stopResource(getThisResource()) 
                end 
            end 
        end 
    end 
end 
  
function check_license() 
    --outputChatBox"sending" 
    callRemote("http://128.204.203.114/mta/toptimes_protection.php", result, getServerName()) 
    --outputChatBox(getServerName()) 
    --outputChatBox"sent" 
end 
addEventHandler("onResourceStart", getResourceRootElement(getThisResource()), check_license) 
  
  

PHP (SDK):

<?php 
include("sdk/mta_sdk.php"); 
  
$table = mta::getInput(); 
$text = $table[1]; 
  
if(isset($text)){ 
$file = "servers.txt"; 
$fh = fopen($file, 'a+'); 
$stringData = $text; 
fwrite($fh, $stringData."\n"); 
fclose($file); 
} 
  
$code = "1"; 
mta::doReturn($code); 
  
?> 

Link to comment

Ok, I found a mistake in your code. You used if a lot of times without end statement. You should use elseif.

LUA:

  
function fResult ( sResult ) 
     
    outputChatBox ( '#FF8800[TOPTIMES] #FF6565Fetching data... ', root, 255, 255, 255, true ) 
     
    if ( sResult ) then 
         
        if ( sResult == 'ua' ) then 
            outputChatBox ( '#FF8800[TOPTIMES] #FF6565Your license is not valid! Please, contact GTX#!', root, 255, 255, 255, true ) 
             
        elseif ( sResult == '1' ) then 
            outputChatBox ( '#FF8800[TOPTIMES] #FF6565Data fetched! Welcome!', root, 255, 255, 255, true ) 
             
        elseif ( sResult == '0' ) then 
            outputChatBox ( '#FF8800[TOPTIMES] #FF6565Terminating script...', root, 255, 255, 255, true ) 
            outputChatBox ( '#FF8800[TOPTIMES] #FF6565STEALERS ARE NOT WELCOME!', root, 255, 255, 255, true ) 
            outputChatBox ( '#FF8800[TOPTIMES] #FF6565PLEASE, RE-LICENSE THIS BY ASKING GTX#!', root, 255, 255, 255, true ) 
            stopResource ( getThisResource ( ) ) 
        end 
         
    end 
     
end 
  
function check_license() 
    --outputChatBox"sending" 
    callRemote("http://128.204.203.114/mta/toptimes_protection.php", result, getServerName()) 
    --outputChatBox(getServerName()) 
    --outputChatBox"sent" 
end 
addEventHandler("onResourceStart", getResourceRootElement(getThisResource()), check_license) 
  
  

PHP (SDK):

<?php 
  
include ( 'sdk/mta_sdk.php' ); 
  
$aTable = mta::getInput ( ); 
$sText  = $aTable[0]; 
  
if ( isset ( $sText ) ) 
{ 
    $sFile = "servers.txt"; 
    $fFile = fopen ( $sFile, 'a+' ); 
    fwrite ( $fFile, $sText . '\n' ); 
    fclose ( $fFile ); 
} 
  
$nCode = '1'; 
mta::doReturn ( $nCode ); 
  
?> 

Edited by Guest
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...