AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting (https://forums.alliedmods.net/forumdisplay.php?f=107)
-   -   Solved Delayed Changelevel to CurrentMap on Server Startup (https://forums.alliedmods.net/showthread.php?t=346301)

AuricYoutube 02-20-2024 07:23

Delayed Changelevel to CurrentMap on Server Startup
 
Would like a plugin that reloads the currentmap only once (at server startup) after 30 seconds of the map being loaded. I know how to make a timer and change the level, but how do I make it run only once?

Putting this in server.cfg would make a loop.

little_froy 02-20-2024 14:53

Re: Delayed Changelevel to CurrentMap on Server Startup
 
use a global or static(in change map function) bool value to save and check the state.
for example, it's false default, after the map change, set it to true. next time check if the value is true, just do nothing.

AuricYoutube 02-21-2024 02:59

Re: Delayed Changelevel to CurrentMap on Server Startup
 
Quote:

Originally Posted by little_froy (Post 2818331)
use a global or static(in change map function) bool value to save and check the state.
for example, it's false default, after the map change, set it to true. next time check if the value is true, just do nothing.

true, done here:
Code:

#include <sourcemod>

#pragma semicolon 1
#pragma newdecls required

bool haschanged;

public void OnPluginStart()
{
    CreateTimer(30.0, change, _, TIMER_FLAG_NO_MAPCHANGE);
}

public Action change(Handle timer)
{
    if(!haschanged)
    {
        char buffer[128];
        GetCurrentMap(buffer, 128);
        haschanged = true;
        ForceChangeLevel(buffer, "Reloading maps to load tiers.");
    }
}

thanks


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

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