dewu Posted May 18, 2014 Share Posted May 18, 2014 Hi guys. I got the question: Is this possible to add game money $ to some player from website? If yes, what should I use to do that? Link to comment
Mr_Moose Posted May 18, 2014 Share Posted May 18, 2014 I guess the PHP SDK is what you're looking for: https://wiki.multitheftauto.com/wiki/PHP_SDK, my experience in that isn't that good currently but it's pretty simple to use as long you have some php and lua experience. Link to comment
Karuzo Posted May 18, 2014 Share Posted May 18, 2014 Or you just add one databasr for server and website together. Link to comment
tosfera Posted May 18, 2014 Share Posted May 18, 2014 Or you just add one databasr for server and website together. I would not recommend this, if some people aim for your website while hacking. Your game won't be safe either, would be a bummer. Another thing, if your server is hosted on a different place than your website, it will cause some lag to retrieve the money of a player. Just use the PHP SDK to call a php function ( or a lua function ) to give the money, it's not that hard. People with a little knowledge of PHP and Lua can do it. ^^ Link to comment
dewu Posted May 19, 2014 Author Share Posted May 19, 2014 I guess the PHP SDK is what you're looking for: https://wiki.multitheftauto.com/wiki/PHP_SDK, my experience in that isn't that good currently but it's pretty simple to use as long you have some php and lua experience. Okay, it's look pretty nice. I read some tutorial, but still I don't know how to use that to add money. Any tips? Link to comment
Mr_Moose Posted May 19, 2014 Share Posted May 19, 2014 Try the included sample on the wiki page which takes two numbers from a lua resource, pass it to the php page and then send the result back. The sdk is placed on your webserver together with your php script file and can be called from anywhere. Link to comment
xXMADEXx Posted May 19, 2014 Share Posted May 19, 2014 You could do something like this: money.php -- Your PHP Code <?php if ( isset ( $_GET['m'] ) && isset ( $_GET['a'] ) ) { $money = $_GET['m']; $account = $_GET['a']; include "mta/mta_sdk.php"; $mta = new mta ( "server ip", port, username, password ); $mta->getResource("PHP_Callback")->call("giveTheMoneyToAccount", $account, $money ); } ?> Lua: -- for PHP_Callback resource -- make sure to export "giveTheMoneyToAccount" on http also -- function giveTheMoneyToAccount ( account, money ) for i, v in pairs ( getElementsByType ( "player" ) ) do local a = getPlayerAccount ( v ) if ( not isGuestAccount ( a ) and getAccountName ( a ) == acount ) then givePlayerMoney ( v, money ) return true end end return false end and the url would be: http://yourwebsite/money.php?a=accountName&m=1000 Link to comment
dewu Posted August 13, 2014 Author Share Posted August 13, 2014 Url looks simply to hack Maybe any other script or system? ;/ I'll be grateful. Link to comment
Neproify Posted August 14, 2014 Share Posted August 14, 2014 You have the code. Just edit it. Link to comment
dewu Posted August 14, 2014 Author Share Posted August 14, 2014 (edited) Refresh Edited August 16, 2014 by Guest Link to comment
dewu Posted August 16, 2014 Author Share Posted August 16, 2014 It will works? Server isn't started yet so i can't test this. <?php if(!isset($_POST['submit'])) { ?> "" method="post">Login: "text" name="a"> "submit" name="submit"> <?php if ( isset ( $_GET['m'] ) && isset ( $_GET['a'] ) ) { $login = $_POST['a']; $money = $_GET['m']; $account = $_GET['a']; include "mta/mta_sdk.php"; $mta = new mta ( "server ip", port, username, password ); $mta->getResource("PHP_Callback")->call("giveTheMoneyToAccount", $account, $money ); }?> And how to set money amount in script? Something like: givePlayerMoney ( v, 99999 ) will works? I want few scripts like that, mean who gives 1000, 2000, 3000$ etc. Link to comment
Et-win Posted August 16, 2014 Share Posted August 16, 2014 If your server isn't even started yet, then what's the point of making it when you are not even sure it works directly? Link to comment
dewu Posted August 16, 2014 Author Share Posted August 16, 2014 (edited) If your server isn't even started yet, then what's the point of making it when you are not even sure it works directly? What's the point of your post? I'm newbie, i try to write something and I asked did I do it correctly. I started server on LAN and I got that error from website: Parse error: syntax error, unexpected $end in /home/dewu/domains/ddesign.webt.pl/public_html/mta/addmoney.php on line 21 Line 21: ?> Edited August 16, 2014 by Guest Link to comment
Et-win Posted August 16, 2014 Share Posted August 16, 2014 I started server on LAN You didn't say that before. Link to comment
dewu Posted August 16, 2014 Author Share Posted August 16, 2014 (edited) Because i just do it few minutes ago, after you post, you're not helping. Maybe i do something wrong: 1. Send PHP file by FTP to website server (http://www.ddesign.webt.pl/mta/addmoney.php - there it is) 2. Make a new resource with LUA file called PHP_Callback and add it on server. 3. Add MTA_SDK files by FTP to website server (http://www.design.webt.pl/mta/mta) 4. Edit PHP file $mta = new mta ( "192.168.137.2", 22003); 5. Add resource Admin permissions in ACL.xml 6. Run server, open browser, type http://www.ddesign.webt.pl/mta/addmoney ... ewu&m=1000 and got these syntax error. Edited August 16, 2014 by Guest Link to comment
Dealman Posted August 16, 2014 Share Posted August 16, 2014 You can't expect us to magically know if it's going to work or not. Test it out yourself first, if it doesn't work - post the errors if there are any here. And don't start with that "you're not helping" attitude, you'll only make people less likely to help you. Link to comment
dewu Posted August 16, 2014 Author Share Posted August 16, 2014 post the errors if there are any here. Check first page. Parse error: syntax error, unexpected $end in /home/dewu/domains/ddesign.webt.pl/public_html/mta/addmoney.php on line 21 What's wrong with my code? Link to comment
Dealman Posted August 16, 2014 Share Posted August 16, 2014 I'm confused. I'm assuming your website is a rented hosting solution, yes? If that is the case, you can't connect it to your local server using its local IP. You'll need to use your external IP. Link to comment
dewu Posted August 16, 2014 Author Share Posted August 16, 2014 Okay, i got something. I hosted website server local on my computer by use program call Webserv. but in browser still same error: Parse error: syntax error, unexpected $end in D:\WebServ\httpd\mm\addmoney.php on line 21 and no connection with server. I got connection by use clean script posted by xXMADEXx: [2014-08-16 13:51:55] HTTP: 'dewu' entered correct password from 192.168.137.2 but still something is wrong: Fatal error: Uncaught exception 'Exception' with message 'Not Found' in D:\WebServ\httpd\mm\sdk\mta_sdk.php:203 Stack trace: #0 D:\WebServ\httpd\mm\sdk\mta_sdk.php(79): mta->do_post_request('192.168.137.2', 22005, '/PHP_Callback/c...', '["dewu","1000"]') #1 D:\WebServ\httpd\mm\sdk\mta_sdk.php(257): mta->callFunction('PHP_Callback', 'giveTheMoneyToA...', Array) #2 D:\WebServ\httpd\mm\addmoney.php(10): Resource->call('giveTheMoneyToA...', 'dewu', '1000') #3 {main} thrown in D:\WebServ\httpd\mm\sdk\mta_sdk.php on line 203 It's my first contact with PHP_SDK. To everything I had to walk alone. So, please help familiar users with it ;/ Link to comment
Smart. Posted August 16, 2014 Share Posted August 16, 2014 Okay, i got something.I hosted website server local on my computer by use program call Webserv. but in browser still same error: Parse error: syntax error, unexpected $end in D:\WebServ\httpd\mm\addmoney.php on line 21 and no connection with server. I got connection by use clean script posted by xXMADEXx: [2014-08-16 13:51:55] HTTP: 'dewu' entered correct password from 192.168.137.2 but still something is wrong: Fatal error: Uncaught exception 'Exception' with message 'Not Found' in D:\WebServ\httpd\mm\sdk\mta_sdk.php:203 Stack trace: #0 D:\WebServ\httpd\mm\sdk\mta_sdk.php(79): mta->do_post_request('192.168.137.2', 22005, '/PHP_Callback/c...', '["dewu","1000"]') #1 D:\WebServ\httpd\mm\sdk\mta_sdk.php(257): mta->callFunction('PHP_Callback', 'giveTheMoneyToA...', Array) #2 D:\WebServ\httpd\mm\addmoney.php(10): Resource->call('giveTheMoneyToA...', 'dewu', '1000') #3 {main} thrown in D:\WebServ\httpd\mm\sdk\mta_sdk.php on line 203 It's my first contact with PHP_SDK. To everything I had to walk alone. So, please help familiar users with it ;/ <form action="#" method="post"> Account: <input type="text" name="account"> <br> Amount: <input type="text" name="amount"> <input type="submit" name="submit"> </form> <? if (isset($_POST["account"]) && isset($_POST["amount"])) { $amount = $_POST["amount"]; $account = $_POST["account"]; print $amount . "<br>" . $account; include("mta/mta_sdk.php"); $mtaServer = new mta("host", port, "user", "password" ); $mtaServer->getResource("PHP_Callback")->call("giveTheMoneyToAccount", $account, $amount); } ?> Try this and post result, might not work cause I haven't done any scripting in more than half a year Link to comment
ViRuZGamiing Posted August 17, 2014 Share Posted August 17, 2014 The if statement isn't ended [and no 'then' ?(or I don't see how)]... if (isset($_POST["account"]) && isset($_POST["amount"])) nevermind if above is PHP and not LUA Link to comment
dewu Posted August 17, 2014 Author Share Posted August 17, 2014 <form action="#" method="post"> Account: <input type="text" name="account"> <br> Amount: <input type="text" name="amount"> <input type="submit" name="submit"> </form> <? if (isset($_POST["account"]) && isset($_POST["amount"])) { $amount = $_POST["amount"]; $account = $_POST["account"]; print $amount . "<br>" . $account; include("mta/mta_sdk.php"); $mtaServer = new mta("host", port, "user", "password" ); $mtaServer->getResource("PHP_Callback")->call("giveTheMoneyToAccount", $account, $amount); } ?> Try this and post result, might not work cause I haven't done any scripting in more than half a year Now is connection but still the same error: Fatal error: Uncaught exception 'Exception' with message 'Not Found' in D:\WebServ\httpd\mm\sdk\mta_sdk.php:203 Stack trace: #0 D:\WebServ\httpd\mm\sdk\mta_sdk.php(79): mta->do_post_request('192.168.137.2', 22005, '/PHP_Callback/c...', '["testujep","99...') #1 D:\WebServ\httpd\mm\sdk\mta_sdk.php(257): mta->callFunction('PHP_Callback', 'giveTheMoneyToA...', Array) #2 D:\WebServ\httpd\mm\addmoney.php(19): Resource->call('giveTheMoneyToA...', 'testujep', '9999') #3 {main} thrown in D:\WebServ\httpd\mm\sdk\mta_sdk.php on line 203 Link to comment
dewu Posted August 17, 2014 Author Share Posted August 17, 2014 Lua: -- for PHP_Callback resource -- make sure to export "giveTheMoneyToAccount" on http also -- What's mean that? Where I should paste this? Link to comment
Smart. Posted August 18, 2014 Share Posted August 18, 2014 The if statement isn't ended [and no 'then' ?(or I don't see how)]... if (isset($_POST["account"]) && isset($_POST["amount"])) nevermind if above is PHP and not LUA clearly it's PHP Lua: -- for PHP_Callback resource -- make sure to export "giveTheMoneyToAccount" on http also -- What's mean that? Where I should paste this? Duhh, ofc it's not going to work if you haven't added the function as an export http, you need to paste in into your meta.xml uncommented. so; Also, i would REALLY suggest to add some security to the .php or you'll have tons and tons of money exploiters. Either you make your own login system which can be hard if you're not enough experienced with php so what I'd recommend is install SMF as your forum and then add a custom smf page and check the user-group OR make a simple IP check: <?php $IP = $_SERVER["REMOTE_ADDR"]; if ($IP !== "YOURIP") { header("Location: fak_off.php"); } ?> 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