AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Plugin not working after restart (https://forums.alliedmods.net/showthread.php?t=60133)

mordi 08-27-2007 15:15

Plugin not working after restart
 
Code:
#include <amxmodx> #include <amxmisc> #include <fun> #define MAX_PLAYERS 32 new bool:g_restart_attempt[MAX_PLAYERS + 1] public plugin_init() {         register_plugin("test", "0.1", "test")     register_cvar("amx_test", "1")     register_event("ResetHUD", "event_hud_reset", "be")     register_clcmd("fullupdate", "clcmd_fullupdate")     register_event("TextMsg", "event_restart_attempt", "a", "2=#Game_will_restart_in")     } public clcmd_fullupdate() {     return PLUGIN_HANDLED_MAIN } public event_restart_attempt() {     new players[32], num     get_players(players, num, "a")     for (new i; i < num; ++i)         g_restart_attempt[players[i]] = true } public event_hud_reset(id) {     if (g_restart_attempt[id]) {         g_restart_attempt[id] = false         return             }         event_player_spawn(id) } public event_player_spawn(id) {     if(is_user_alive(id) && get_cvar_num("amx_test") > 0) {     set_task(0.1, "test", id)     }     } public test (id) {     strip_user_weapons(id)     give_item(id, "weapon_hegrenade") }

Compiles and works great, but if I restart the round it stops working. Why? And how do I cause amx_test 0 to restart?

X-Script 08-28-2007 08:15

Re: Plugin not working after restart
 
It doesn't work because your registering it as a CVAR and if you want amx_text to restart you shouldn't use it as a CVAR.

Try this:
PHP Code:

#include <amxmodx>
#include <amxmisc>
 
#define PLUGIN "Restart"
#define VERSION "1.0"
#define AUTHOR "Blah"
 
public plugin_init()
{  
        
register_plugin(PLUGINVERSIONAUTHOR);
       
register_concmd("amx_restartserver""cmdrestart")
       
register_logevent("logevent_round_start"2"1=Round_Start");
    
}
public 
Round_Start()
{
        
set_task(2.5"auto_restart")
}
public 
auto_restart()
{
        
server_cmd("sv_restart 1");
}
public 
cmdrestart(id)
{
    
set_task(2.5"auto_restart")
    return 
PLUGIN_HANDLED


To restart just type in the console:
amx_restartserver

mordi 08-28-2007 08:27

Re: Plugin not working after restart
 
I don't want it to auto-restart. I want to be able to turn a plugin on or off, on with 1 and off with 0. When someone type amx_test 1 it will turn on and restart and if someone type amx_test 0 it will turn off and restart.

X-Script 08-28-2007 16:08

Re: Plugin not working after restart
 
Use your amxmodx menu.
Console:
amxmodmenu | Number Nine | Number Six.

mordi 08-28-2007 17:07

Re: Plugin not working after restart
 
you still dont get the point.

X-Script 08-28-2007 23:40

Re: Plugin not working after restart
 
then explain it more wtf...

you can't use a CVAR when trying this.

edit:
What the hell is this:
PHP Code:

public test (id) {
    
strip_user_weapons(id)
    
give_item(id"weapon_hegrenade")


How does that have anything related to what your doing..


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

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