Jump to content

How to call a lua script function from a site?


L3firD

Recommended Posts

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
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 by L3firD
Link to comment
  • Moderators
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 by IIYAMA
Link to comment
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
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 by IIYAMA
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...