Load filterscript on Gamemode restart
#1

Hi. I wonder if it's possible to load a certain filterscript when I restart my gamemode in-game with a command like this;
pawn Code:
if(strcmp(cmd, "/gmx", true) == 0)
    {
      if(IsPlayerConnected(playerid))
      {
            if(PlayerInfo[playerid][pAdmin] >= 5)
            {
                GameModeRestart();
            }
            else
            {
                SendClientMessage(playerid, COLOR_GREY, "You are not authorized to use that command");
            }
        }
        return 1;
    }
And if that doesn't work, is it possible to make the gamemode quit by itself (the same way when you type "exit" in samp-server.exe) and then after a short time let it start again?

Thanks.
Reply
#2

Well, you can save a value into a file and read it in OnGameModeInit, if value is for example 0 don't load else SendRconCommand("loadfs blablabla");
Reply
#3

pawn Code:
SendRconCommand("gmx");
pawn Code:
SendRconCommand("loadfs filterscriptnamehere");
Reply
#4

My problem is that I use a car dealership (ping's one) as a filterscript like an add-on to my gamemode. When I restart the server in-game with the command I showed you the cars in the FS doesn't appear.

Quote:
Originally Posted by Zimon95
Well, you can save a value into a file and read it in OnGameModeInit, if value is for example 0 don't load else SendRconCommand("loadfs blablabla");
This would be the best way in solving this but I'm not really sure how to execute this.
Reply
#5

Quote:
Originally Posted by TheInnocentOne
pawn Code:
SendRconCommand("gmx");
pawn Code:
SendRconCommand("loadfs filterscriptnamehere");
That wouldn't really work since all the FSs' are reloaded once the gamemode restarts. You should instead use

Code:
SendRconCommand("reloadfs filterscriptnamehere");
Reply
#6

Quote:
Originally Posted by ·!¦[·MaykoX·
¦!· ]
You should also make timer.. otherways it will be useless.
Yes exactly.

Code:
if(strcmp(cmd, "/gmx", true,4) == 0)
{
	
	if(PlayerInfo[playerid][pAdmin] < 5) return SendClientMessage(playerid, COLOR_GREY, "You are not authorized to use that command");
	
	SendRconCommand("gmx");
	SetTimer("reloadfs",5000,0);
	return 1;
}


forward reloadfs();
public reloadfs()
{
	SendRconCommand("reloadfs filterscriptnamehere");
	return 1;
}



Reply
#7

Thanks for the help, I'm starting to understand this now. It doesn't work the way I want it to, though. Is it possible to use the functions mentioned above but instead I SendRconCommand("exit"); and with a timer I start the server again? I tried doing it but it failed hard. I'm almost certain this should work, seen it on numerous servers before.

pawn Code:
forward reloadgm();
----
if(strcmp(cmd, "/gmx", true) == 0)
{
   if(IsPlayerConnected(playerid))
   {
      if(PlayerInfo[playerid][pAdmin] >= 5)
      {
          SendRconCommand("exit");
          SetTimer("reloadgm", 5000, 0);
      }
bla bla bla
-----

public reloadgm()
{
   SendRconCommand("gmx");
   return 1;
}

Reply
#8

That's not possible. In your code, you are closing down the server completely and then restarting it. It needs to be running to restart it.
Reply
#9

Quote:

C:\Users\Michael\Desktop\SA-MP SERVER\gamemodes\gf.pwn(26207) : warning 235: public function lacks forward declaration (symbol "OnPlayerPrivmsg")
C:\Users\Michael\Desktop\SA-MP SERVER\gamemodes\gf.pwn(26244) : error 021: symbol already defined: "SendRconCommand"
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase


1 Error.

this is what I get after adding SendRconCommand("loadfs blahblahblah");
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)