L3firD Posted January 18, 2021 Share Posted January 18, 2021 How to call a lua script function from a site? I don’t know what POST request to send to the server to get a response! I'm trying to do it like this: [LUA] function MTACheck(user) account = getAccount(user) if account then return "OK" else return "ERROR" end end [PYTHON] import requests ipp = '4*.17*.4*.4*:3***2' # it's my IP:PORT server adress user = '6E860E******************8E0F65F2' #it's my login from server req = requests.post(f'http://{ipp}/payment/call/MTAPaymentCheck', data = {'user': f'{user}'}) print( str(req.text) ) Received from the server: Access denied, please login Link to comment
Moderators Patrick Posted January 18, 2021 Moderators Share Posted January 18, 2021 Try to use this sdk, or check how it works: https://gitlab.com/OwlGamingCommunity/mta-python-sdk Link to comment
L3firD Posted January 23, 2021 Author Share Posted January 23, 2021 (edited) On 19/01/2021 at 05:52, Patrick said: Попробуйте использовать этот sdk или проверьте, как он работает: https://gitlab.com/OwlGamingCommunity/mta-python-sdk This works with `Django`, so it didn't work for me. I need to find out information about the server using regular `requests`. I need to know how to get the name of the server by its IP: PORT Edited January 23, 2021 by L3firD Link to comment
Moderators IIYAMA Posted January 23, 2021 Moderators Share Posted January 23, 2021 (edited) On 18/01/2021 at 20:25, L3firD said: Received from the server: Access denied, please login btw. How are you going to login without password? For each request you need to provide the username and password. Fields: "user", "password" (mta account) Also make sure that the function can be accessed (in the meta.xml), you probably already did that. Edited January 23, 2021 by IIYAMA Link to comment
L3firD Posted January 23, 2021 Author Share Posted January 23, 2021 17 minutes ago, IIYAMA said: кстати Как вы собираетесь входить без пароля? I can already access the resources, for this I use a GET request with a Login and Password. I cannot find out how many players are on the server and the server name. As far as I know, LOGIN and PASSWORD are not needed for this. How will monitoring services learn this information? Sorry if my question is not clear. I use a translator to communicate with you! def givePlayerDonatePoints(server_ip, server_http_port, player_login, bot_password, amount): req = requests.get(f'http://{server_ip}:{server_http_port}/payment/call/MTAPaymentData?user={player_login}::{amount}', auth=('MTAPaymentROBOT', bot_password)) answer = json.loads(req.text)[0] if answer == 'OK': return True else: return False To call a function using a URL, I do it like this Link to comment
Moderators IIYAMA Posted January 23, 2021 Moderators Share Posted January 23, 2021 (edited) 57 minutes ago, L3firD said: I cannot find out how many players are on the server and the server name. You can create a ` web page` in MTA, which helps you access resource data and that access can be scoped by the rights of the resource. This eliminates the 'log in' requirement. https://wiki.multitheftauto.com/wiki/Resource_Web_Access https://wiki.multitheftauto.com/wiki/HttpWrite * In there you can find the querystring variable. <* querystring *> Might be worth looking in to. Edited January 23, 2021 by IIYAMA Link to comment
AaroN⍩ Posted January 24, 2021 Share Posted January 24, 2021 Easy, Make a call to the api of the master server and extract the server you want. API: https://mtasa.com/api/ 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