Raised This Month: $13 Target: $400
 3% 

Solved Timer for HookEvent


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Gurrth
Junior Member
Join Date: Feb 2020
Old 05-22-2020 , 20:08   Timer for HookEvent
Reply With Quote #1

Hello all, need help regarding creating a Timer for a HookEvent.

I would like to make it so that at the end of a mvm mission victory, the server waits 15 seconds
to then use the command sm_resetpopfile.

Can't figure out the timer part, but resetpopfile does reset the round and not make it change maps after a victory.

Any help would be greatly appreciated.


Code:
#include <sourcemod>
#include <sdktools>
#include <tf2>
#include <tf2_objects>
#include <sdkhooks>


public Plugin:myinfo = 
{
	name = "[TF2]Reset Popfile",
	author = "Gurrth",
	description = "Resets current Popfile after a MVM Mission Completes, no map change",
	version = "1.0",
	url = ""
}

public OnPluginStart()
{
	
	HookEvent("mvm_mission_complete", Event_MissionComplete);
	
	
	PrintToServer("[SM] Rest Pop Files is Loaded!")
	
	
	RegConsoleCmd("sm_resetpopfile", command_resetpopfile, "resets popfile");
	
	
	
}


// What sm_resetpopfile does
public Action:command_resetpopfile(client, args)
{
	
	// Test Text
	PrintToServer("This is a Test");
	
	
	char responseBuffer[4096];
	int ObjectiveEntity = FindEntityByClassname(-1, "tf_objective_resource");
	
	
	// Get Popfile Name
	GetEntPropString(ObjectiveEntity, Prop_Send, "m_iszMvMPopfileName", responseBuffer, sizeof(responseBuffer));
	
	// Tell server to change popfile 
	ServerCommand("tf_mvm_popfile %s", ObjectiveEntity);
	
}

public Action:Event_MissionComplete(Handle:event, const String:mission[], bool:dontBroadcast)
{
	// Tell server to use command
	ServerCommand("sm_resetpopfile");
		
}

Last edited by Gurrth; 05-25-2020 at 15:19.
Gurrth is offline
Tilex
Junior Member
Join Date: May 2020
Old 05-24-2020 , 08:11   Re: Timer for HookEvent
Reply With Quote #2

pretty basic one-shot timer:
(see: https://wiki.alliedmods.net/Timers_(...Mod_Scripting) )
PHP Code:

public Action:Event_MissionComplete(Handle:event, const String:mission[], bool:dontBroadcast)
{
    
//execute fireReset after 15 seconds
    
CreateTimer(15.0fireReset);
}
 
public 
Action:fireReset(Handle timer)
{
    
// Tell server to use command
    
ServerCommand("sm_resetpopfile");

Tilex 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 05:06.


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