GTX Posted April 9, 2012 Share Posted April 9, 2012 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
GTX Posted April 9, 2012 Author Share Posted April 9, 2012 Oh, forgot to ment. Well, it doesn't write anything in servers.txt. Also, doesn't return "1". Link to comment
drk Posted April 9, 2012 Share Posted April 9, 2012 If doesn't return nothing, your MTA PHP SDK is not working, or is something about the php. Link to comment
drk Posted April 9, 2012 Share Posted April 9, 2012 (edited) 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 April 9, 2012 by Guest Link to comment
GTX Posted April 9, 2012 Author Share Posted April 9, 2012 Ah yes, I noticed. Thank you! But it still doesn't write to servers.txt Link to comment
GTX Posted April 9, 2012 Author Share Posted April 9, 2012 Ah, I was a bit confused... Thank you! Link to comment
50p Posted April 9, 2012 Share Posted April 9, 2012 Also, according to your PHP script, in Lua the result function: sResult will always be "1". Make sure you return correct value in your PHP script. Link to comment
drk Posted April 9, 2012 Share Posted April 9, 2012 Also, according to your PHP script, in Lua the result function: sResult will always be "1". Make sure you return correct value in your PHP script. Maybe it's only to test if work. Link to comment
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