AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Serwer start event (https://forums.alliedmods.net/showthread.php?t=82598)

GoGoGo 12-26-2008 10:51

Serwer start event
 
What event is called when serwer i starting? Not map, for example after crash I'm turning on server (this event).

hleV 12-26-2008 10:53

Re: Serwer start event
 
There's no such event.

AFAIK this is the first event which is called on AMX Mod X start (that means on every map start) although it's not what you're asking.
Code:
plugin_precache()

GoGoGo 12-26-2008 11:17

Re: Serwer start event
 
No. There isn't any solution?

hleV 12-26-2008 11:24

Re: Serwer start event
 
Well, server.cfg is executed on server start, maybe you can do something with it.

YamiKaitou 12-26-2008 11:37

Re: Serwer start event
 
Quote:

Originally Posted by GoGoGo (Post 733454)
No. There isn't any solution?

There are a couple of ways you can check it. Such as registering a cvar in plugin_init and checking to see if it exists in plugin_precache. If it doesn't, then the server just started up. This should work, but I have never tested it.

Another method is to write something (such as a 1) to vault/nvault/sqlite on plugin_init. Then on plugin_end, change it to a 0. Then, in plugin_precache, check the value of it. If it is still a 1, the server crashed.

GoGoGo 12-26-2008 12:26

Re: Serwer start event
 
Can you give me an example using it?

|PJ| Shorty 12-26-2008 21:39

Re: Serwer start event
 
i´m using this, small and usefull for me.
PHP Code:

new pcvar
public plugin_init() {
 
register_plugin("PLUGIN""VERSION""AUTHOR")
 
pcvar=register_cvar("server_restart","0")
}
public 
plugin_cfg() { 
 if(!
get_pcvar_num(pcvar)) {
  
log_amx("### server has restarted ###")
  
set_pcvar_num(pcvar,1)
 }



GoGoGo 12-27-2008 02:45

Re: Serwer start event
 
But it is calling in case resrat, I'm talking about server start.

YamiKaitou 12-27-2008 03:07

Re: Serwer start event
 
This should work for you, not tested

PHP Code:

#include <amxmodx>

public plugin_init()
{
    
register_cvar("server_startup""1");
}

public 
plugin_precache()
{
    if (!
cvar_exists("server_startup"))
        
// Server just started



|PJ| Shorty 12-27-2008 07:56

Re: Serwer start event
 
Quote:

Originally Posted by GoGoGo (Post 733851)
But it is calling in case resrat, I'm talking about server start.

it works on a server start too. i think there is no difference between start and restart.


All times are GMT -4. The time now is 09:08.

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