Jump to content
  • 0

pomoc Rcon CMD - Start Serveru


Riko

Dotaz

Zdravím, chtěl bych vytvořit něco takového, že když se spustí nebo restartuje server, na 3 nebo 5 vteřin se zobrazí "Název Serveru - Vyčkejte prosím ..." a lockne se, a po 5 sec se zase vrátí do normálního stavu, ale jaksi se mi nedaří, mohl by mi někdo poradit, v čem dělám chybu? Díky moc.

 

#include <a_samp>

forward TimerRconOn();
forward TimerRconOff();

public OnGameModeInit()
	{
	    SetTimer("TimerRconOn", 1, false);
	    SetTimer("TimerRconOff", 3, false);
	    return 1;
	}

public TimerRconOn()
	{
	    SendRconCommand("gmx");
	    new szHostName[] = "[CZ/SK] Paradise World 1.1 - Vyčkejte prosím ...";
	    new szCmd[64];
	    format(szCmd, sizeof(szCmd), "hostname %s", szHostName);
	    SendRconCommand(szCmd);
		SendRconCommand("gmx");
		new szPassword[] = "asdgsfhdfjhdgjfgjm";
		new szCmd2[64];
		format(szCmd2, sizeof(szCmd2), "password %s", szPassword);
		SendRconCommand(szCmd2);
	}

public TimerRconOff()
	{
	    SendRconCommand("gmx");
	    new szHostName[] = "[CZ/SK] Paradise World 1.1";
	    new szCmd3[64];
	    format(szCmd3, sizeof(szCmd3), "hostname %s", szHostName);
	    SendRconCommand(szCmd3);
	    SendRconCommand("gmx");
	    new szPassword[] = "";
	    new szCmd4[64];
	    format (szCmd4, sizeof(szCmd4), "password %s", szPassword);
	    SendRconCommand(szCmd4);
	}
Link to comment
Share on other sites

7 odpovědí na tuto otázku

Recommended Posts

  • 0

nooo... tak bolo by fajn povedať čo presne to robí... nech vieme zhruba určiť v čom je problém... :/

 

ďalej, timer využíva milisekundy nie sekundy (1 = 1 milisekunda, 1000 = 1 sekunda)

a posledná vec, načo tam máš SendRconCommand("gmx")?? rozumieš tomu že ty stále dookola reštartuješ server že?

 

 

// EDIT

 

https://wiki.sa-mp.com/wiki/SendRconCommand

 

ak chceš odstrániť heslo, použi "password 0" (je to na tej stránke)

Edited by Quiter
Link to comment
Share on other sites

  • 0
  • Administrátor

Hele uplně jednoduše

 

GMInit 

SendRconCommand("hostname [CZ/SK] Paradise World 1.1 - Vyčkejte prosím ...");
SendRconCommand("password heslokterynikdonezna");
SetTImer("StartServeru", 5000 , false );

StartServeru

SendRconCommand("hostname [CZ/SK] Paradise World 1.1");
SendRconCommand("password 0");

Není třeba to cpát do proměných a dávat to do dvou timerů apodobně proč na to složitě když to jde jednoduše přece :)

Link to comment
Share on other sites

  • 0

Ok, na toto jsem již přišel, vše šlape, byla tam chyba v SendRconCommad(""gmx"") v tom gmx, malo tam byt hostname.

Ale teraz mi vrtá hlavou, jak udělat to, že se forwardy budou opakovat po sobě a ne zaroveň.
Timer1 a Timer2

Bo když dám SetTimer("ServerName1", 1000, true); - tak to opakuje co sekundu
                      SetTimer("ServerName2", 2000, true); - nelze opakovat, protože se opakuje Timer1 co sekundu, chtěl bych, aby to šlo po sebe ty forwardy.

Prostě že se 1 sekundu odešle prikaz Timer1 a 2 sec Timer2 a tak aby to šlo pořád dokola, lze to nějak provést?

Díky

 

public OnGameModeInit()
	{
	    SetTimer("TimerRconOn", 1, false);
	    SetTimer("TimerRconOff", 3000, false);
	    SetTimer("ServerName1", 1000, true);
	    SetTimer("ServerName2", 2000, true);
	    return 1;
	}
Edited by Waymoot
Link to comment
Share on other sites

  • 0
(funcname[], interval, repeating)
funcname[] Name of the function to call as a string. This must be a public function (forwarded). A null string here will crash the server.
interval Interval in milliseconds.
repeating Boolean (true/false) on whether the timer should repeat or not.
 
 
 

 

 

 

 

Ten poslední parametr "repeating" tzv. přesněji false/true tím vlastně umožnuješ jestli se ten timer má opakovat a nebo nemá, logicky true = opakuje false = neopakuje.Stačí se někdy mrknout na wiki, někdy dosti pomůže ;)

Edited by VolfikCZ
Link to comment
Share on other sites

  • 0

To já vím :d jenžé ja potrebuju odeslat rcon command ServerName1 a hnde 2 sec po ServerName2 a aby to šlo pořád dokola co 1 sec se odešlo to a co 2 sec se odešle to, bo když dám ServerName1, 1000, true tak se opakuje co sekundu a nelze pak opakovat ServerName2, 2000, true bo se opakuje první timer co 1 sec, špatně si ma pochopil, to já vím co to znamená :d

Napíšu to jinak, potřebuju, aby se měnil server name, čili aby tam bylo [CZ/SK] Paradise World 1.1 za 1 sec aby tam bylo MINIHRY|EVENTY|ZABAVA a pak zase [CZ/SK] Paradise World 1.1 a pořád dokola.

Edited by Waymoot
Link to comment
Share on other sites

  • 0
  • Globální moderátor
forward Change1();
forward Change2();

public Change1()
{
      SendRconCommand("hostname [CZ/SK] Paradise World 1.1");
      SetTimer("Change2",2000,false);
      return 1;
}
public Change2()
{
      SendRconCommand("hostname MINIHRY|EVENTY|ZABAVA");
      SetTimer("Change1",2000,false);
      return 1;
}

OnGameModeInit
SetTimer("Change1",1000,false);

-

 

A takhle se to loopne

Edited by HighPrint
Link to comment
Share on other sites

  • 0
new SNChange;

SetTimer("ServerNameChange",3000,true);

forward ServerNameChange();
public ServerNameChange()
{
if(SNChange == 0)
{
SendRconCommand(nazev jedna)
SNChange = 1;
}
else if(SNChange == 1)
{
SendRconCommand(nazev dva)
SNChange = 0;
}
}

Co říkáš na tohle ?

Link to comment
Share on other sites

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
×
×
  • Create New...