Jump to content

Tutorial - Server Query and RCON API


L0K3D
 Share

Recommended Posts

  • Manager

Folosind acest API putem apela la orice functie din gamemode de pe o pagina web.

Link download API: sa-mp.com

Pagina web

Pentru inceput vom crea pagina web

image.png.9ef516ba45cadec3118734e34e341e4b.png

<?php
include 'SampRconAPI.php';
if(isset($_POST['apeleaza'])) {
	$rcon = new SampRconAPI('127.0.0.1', 7777, 'pass'); // parametri: ip, port, rcon password
	$rcon->Call('rconFunct');
}
?>

<!DOCTYPE html>
<html>
	<head>
		<title>Apelarea functiei</title>
	</head>
	<body>
		<center>
		<h1>Server Query and RCON API</h1>
		<form action="" method="post">
			  <button type="submit" name="apeleaza">Apeleaza functia</button>
		</form>
		</center>
	</body>
</html>

Cream un filterscript

Din cauza nu stiu carui bug, ca callback-ul OnRconCommand sa fie apelat, trebuie pus intr-un filterscript, vom crea unul:

#include <a_samp>

main() {
	print("\n----------------------------------");
	print(" Blank Gamemode by your name here");
	print("----------------------------------\n");
}

public OnGameModeInit() {
	return 1;
}

public OnGameModeExit() {
	return 1;
}

public OnRconCommand(cmd[]) {
	if(!strcmp(cmd, "rconFunct", true))
    {
        CallRemoteFunction("FunctiaApelata", "s", "un simplu text");
      	// parametrii: numele functiei din gamemode, descriptorii de format, si restul parametrilor ce ii are functia din gamemode.
    }
	return 1;
}

Y_Less avea rezolvarea pe contul sau de github.

Recomand sa cititi pe wikipedia ce este si ce reprezinta functia CallRemoteFunction ????

Functia din gamemode

Odata ce am creat un filterscript ce contine callback-ul OnRconCommand ne mai ramane sa cream si functia ce dorim sa o apelam:

forward FunctiaApelata(string[]);
public FunctiaApelata(string[])
{
    printf("%s.", string);
    return 1;
}

Final

Intr-un final functia a fost apelata si s-a executat cu succes.

image.png.cb09a591f48e444f793a9631115884aa.png

© L0K3D_Hokage

Edited by L0K3D_Hokage
Link to comment
Share on other sites

hmm, interesant multumim pentru postare

am o ideie, o sa fac cv mersi ????

    _________________________________________________
    |                                                        _________             |
    |    |    /          /|        |\            |      /                   \          |
    |    |  /        /   |          |  \          |      |                              |
    |    |/       /     |           |    \        |      |                              |   
    |    |\              |           |      \      |      |        _____            |
    |    |  \            |           |        \    |      |                 \           |
    |    |    \          |           |          \  |      |                   |          |
    |    |      \        |           |            \|      \_________/           |
    |_______________________________________________|

Link to comment
Share on other sites

  • keNN. featured this topic

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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...