Raised This Month: $51 Target: $400
 12% 

Solved Delayed Changelevel to CurrentMap on Server Startup


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
AuricYoutube
Senior Member
Join Date: Aug 2016
Location: Here
Old 02-20-2024 , 07:23   Delayed Changelevel to CurrentMap on Server Startup
Reply With Quote #1

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.

Last edited by AuricYoutube; 02-21-2024 at 03:00.
AuricYoutube is offline
little_froy
Senior Member
Join Date: May 2021
Old 02-20-2024 , 14:53   Re: Delayed Changelevel to CurrentMap on Server Startup
Reply With Quote #2

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.
little_froy is offline
AuricYoutube
Senior Member
Join Date: Aug 2016
Location: Here
Old 02-21-2024 , 02:59   Re: Delayed Changelevel to CurrentMap on Server Startup
Reply With Quote #3

Quote:
Originally Posted by little_froy View Post
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
AuricYoutube is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 12:24.


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