Timer for HookEvent
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");
}
|