Raised This Month: $299 Target: $400
 74% 

Delaying an Event


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Maliwolf
Member
Join Date: Jul 2015
Old 04-02-2017 , 07:19   Delaying an Event
Reply With Quote #1

I'm trying to delay the Event message popup for when the HHH boss spawns. I need to block the original message and make a new one around 3 seconds later. The below code loops into itself by blocking the event and then creates a new event that loops back into being blocked. How could I write this to achieve what I want?
Code:
HookEvent("pumpkin_lord_summoned", Event_HHH_Spawned, EventHookMode_Pre);

public Action Event_HHH_Spawned(Event event, const char[] name, bool dontBroadcast)
{
    CreateTimer(3.0, Timer_HHH_Delay_Message);
    return Plugin_Handled;
}
public Action Timer_HHH_Delay_Message(Handle timer) {

    Handle event = CreateEvent("pumpkin_lord_summoned");
    FireEvent(event);
}

Last edited by Maliwolf; 04-02-2017 at 07:29.
Maliwolf is offline
Fyren
FyrenFyrenFyrenFyrenFyren FyrenFyrenFyrenFyrenFyren FyrenFyrenFyrenFyrenFyren FyrenFyrenFyrenFyrenFyren
Join Date: Feb 2106
Old 04-02-2017 , 09:13   Re: Delaying an Event
Reply With Quote #2

One way would be to use a global boolean to set whether to allow the next event to fire. Set it to false at your plugin's start, set it to true before firing the event, and set it back false after firing. In your event handler, only block the event if it's false.
Fyren is offline
Maliwolf
Member
Join Date: Jul 2015
Old 04-02-2017 , 20:00   Re: Delaying an Event
Reply With Quote #3

This seems to work, thanks!
Maliwolf is offline
Reply


Thread Tools
Display Modes

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 23:41.


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