GTX Posted April 9, 2012 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); ?> Do you require a paid scripter? Contact me! (Unavailable) Currently I am experienced in Lua, PHP, HTML, CSS, SQL and JS. Developer and owner of https://projectbea.st - Project Beast
drk Posted April 9, 2012 Posted April 9, 2012 And what is the problem?? EPT Team Server Development: 0% Learning C++ | C++ is amazing
GTX Posted April 9, 2012 Author Posted April 9, 2012 Oh, forgot to ment. Well, it doesn't write anything in servers.txt. Also, doesn't return "1". Do you require a paid scripter? Contact me! (Unavailable) Currently I am experienced in Lua, PHP, HTML, CSS, SQL and JS. Developer and owner of https://projectbea.st - Project Beast
drk Posted April 9, 2012 Posted April 9, 2012 Is file servers.txt created? EPT Team Server Development: 0% Learning C++ | C++ is amazing
GTX Posted April 9, 2012 Author Posted April 9, 2012 Yes, it is. Do you require a paid scripter? Contact me! (Unavailable) Currently I am experienced in Lua, PHP, HTML, CSS, SQL and JS. Developer and owner of https://projectbea.st - Project Beast
drk Posted April 9, 2012 Posted April 9, 2012 If doesn't return nothing, your MTA PHP SDK is not working, or is something about the php. EPT Team Server Development: 0% Learning C++ | C++ is amazing
drk Posted April 9, 2012 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 EPT Team Server Development: 0% Learning C++ | C++ is amazing
GTX Posted April 9, 2012 Author Posted April 9, 2012 Ah yes, I noticed. Thank you! But it still doesn't write to servers.txt Do you require a paid scripter? Contact me! (Unavailable) Currently I am experienced in Lua, PHP, HTML, CSS, SQL and JS. Developer and owner of https://projectbea.st - Project Beast
drk Posted April 9, 2012 Posted April 9, 2012 Copy my code again. EPT Team Server Development: 0% Learning C++ | C++ is amazing
GTX Posted April 9, 2012 Author Posted April 9, 2012 Ah, I was a bit confused... Thank you! Do you require a paid scripter? Contact me! (Unavailable) Currently I am experienced in Lua, PHP, HTML, CSS, SQL and JS. Developer and owner of https://projectbea.st - Project Beast
drk Posted April 9, 2012 Posted April 9, 2012 So? Worked? EPT Team Server Development: 0% Learning C++ | C++ is amazing
50p Posted April 9, 2012 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. - MTA Script Editor - Ask your scripting questions properly, please. - 50p's public resources - Meta.xml - what is it for? How is it possible LOL
drk Posted April 9, 2012 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. EPT Team Server Development: 0% Learning C++ | C++ is amazing
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