AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Server Kill After map (https://forums.alliedmods.net/showthread.php?t=17362)

mikey_trw 08-30-2005 13:01

Server Kill After map
 
Hi, i want my server to kill itself after one map has been played,

I have written this code but it seems to cause some funny behavior and doesnt always work, Anyone know of any better way to kill the server?

Code:
public plugin_init() {     register_plugin("mapkill",VERSION,"Mike Wharton");      //set log event handling, wee need to hook round start and round finished, also frags   and deaths                                     } public plugin_end() {     kill_server(); } public kill_server() {     server_cmd("quit"); }

thanks,
Mikey_trw
p.s i tried with and without a server_exec(); after the quit command

atomic 08-30-2005 14:38

a
Code:
return PLUGIN_HANDLED ??

atomic 08-30-2005 14:39

#include amxmodx

Hawk552 08-30-2005 14:40

Quote:

Originally Posted by atomic
#include amxmodx

No, it's #include <amxmodx>, and also I think we can assume that he included that. He's posting the relevant source code.

mikey_trw 08-31-2005 09:00

Ok the plugin now works,

Code:
public plugin_init() {     register_plugin("mapkill","0.5","Mike Wharton");        //set log event handling, wee need to hook round start and round finished, also frags   and deaths     return PLUGIN_HANDLED                               } public plugin_end() {     kill_server();     return PLUGIN_HANDLED } public kill_server() {     new i;     for(i=1;i<3;i++)     {         client_cmd(i,"quit");         server_print("[WRCL]Killing client no: %d",i);     }     server_cmd("quit");     return PLUGIN_HANDLED }

But, when used in conjunction with another plugin that uses mySQL the server crashes, and gives dbi_query errors. It seems that the server calls plugin_end AFTER the next map has been loaded. Is there a function that is called after the map has been played, so i can kill the server gracefully after 20 minutes of play?

Also, Is there a way to automagically close the clients CS as well? I have tried client_cmd("quit") - see above but this deosnt seem to work, possible because when this is called the client is mid map-reload

Thanks,

Mike


Thanks,


EDIT: the server only crashes IF there are players connected, which is kinda daft. Anyone have any idea why this might be happening?

v3x 08-31-2005 12:38

Code:
#include <amxmodx> public plugin_init() {     register_plugin("Kill server at map change","0.1","v3x");     set_task(float(get_cvar_num("mp_timelimit")*60),"Kill_Server"); } public Kill_Server() {     server_cmd("quit"); }
:?:

mikey_trw 08-31-2005 13:21

great thanks, v3x, I'll give that a try now.

mikey_trw 09-15-2005 14:51

Ok, perhaps I am being stupid, but

Code:
get_cvar_num("mp_timelimit")

always returns 0.

Any reason for this?

Thanks

XxAvalanchexX 09-15-2005 18:41

Try this instead and see if it changes results:

set_task(get_cvar_float("mp_timelimit")*60.0, "Kill_Server");

Mr. Pink 09-15-2005 19:12

what is this for??..
confused.
u guys r to smart


All times are GMT -4. The time now is 14:31.

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