AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Detect "restart" command (https://forums.alliedmods.net/showthread.php?t=92606)

grankee 05-17-2009 09:42

Detect "restart" command
 
How to detect command "restart" typed in server console(or player by rcon/hlsw by rcon)?

Hunter-Digital 05-17-2009 09:47

Re: Detect "restart" command
 
the "restart" command or "sv_restart" / "sv_restartround" ?

for "restart", you just register it...

PHP Code:

plugin_init()
{
      
register_srvcmd("restart""cmd_restart")
}
 
public 
cmd_restart()
{
      
server_print("The command ^"restart^" used!")
 
      return 
PLUGIN_CONTINUE // use PLUGIN_HANDLED if you want to block the command


And I think it works also for sv_restart[round] :?

grankee 05-17-2009 09:51

Re: Detect "restart" command
 
Doesn't work

joaquimandrade 05-17-2009 09:56

Re: Detect "restart" command
 
Does this helps you?

PHP Code:


public plugin_init()
{    
    
register_forward(FM_ServerDeactivate,"serverDeactivate");
}

public 
serverDeactivate()
{
    



grankee 05-17-2009 10:06

Re: Detect "restart" command
 
register_srvcmd("restart","cmd_restart")

if function cmd_restart doesn't exist then console show error
if function exist then not work




FM_ServerDeactivate works:
- when restart is typed?
- when server reserved?


joaquimandrade 05-17-2009 12:10

Re: Detect "restart" command
 
Quote:

Originally Posted by grankee (Post 829240)

FM_ServerDeactivate works:
- when restart is typed?
- when server reserved?


I guess it happens on restart, map change. The question is: what exactly do you want to happen?

Hunter-Digital 05-17-2009 14:36

Re: Detect "restart" command
 
Well, you can detect restart this way:
PHP Code:

#include <amxmodx>

public plugin_init()
      
register_logevent("event_restart"2"1&Restart_Round")

public 
event_restart()
{
      
server_print("Game is restarting...")



joaquimandrade 05-17-2009 18:43

Re: Detect "restart" command
 
Quote:

Originally Posted by Hunter-Digital (Post 829443)
Well, you can detect restart this way:
PHP Code:

#include <amxmodx>

public plugin_init()
      
register_logevent("event_restart"2"1&Restart_Round")

public 
event_restart()
{
      
server_print("Game is restarting...")



That's not "restart". That's "sv_restart".

-=hunter=- 05-18-2009 06:26

Re: Detect "restart" command
 
grankee
What for you need it? When you write "restart" then all plugins stop, and then renew work at map loading.

grankee 05-19-2009 18:14

Re: Detect "restart" command
 
Quote:

Originally Posted by -=hunter=- (Post 829797)
grankee
When you write "restart" then all plugins stop

Good idea :)

but first exec plugin_end() func, right?

but when server crash and stand up trice, no functions are executed, right?


Sometimes server just automatically restart and I need to detect what option is true
-server crash and stand up trice
-wicked guy, who borrow me one of four dedicated server on machine, type restart


All times are GMT -4. The time now is 01:30.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.