Hi all, I'd like to use the User Message MVMVictory, and hook it with HookUserMessage.
Basically, I'd like sm_resetpopfile to be sent once it's been hooked with MVMVictory after a mann vs machine match was completed.
I've tried it with this code, I don't exactly know what type of public action to use for it.
Code:
#include <sourcemod>
#include <sdktools>
#include <tf2>
#include <sdkhooks>
#include <events>
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()
{
PrintToServer("[SM] Rest Pop Files is Loaded!");
RegConsoleCmd("sm_resetpopfile", command_resetpopfile, "resets popfile");
HookUserMessage(GetUserMessageId("MVMVictory" ), mvm_complete, true);
}
// What sm_resetpopfile does
public Action:command_resetpopfile(client, args)
{
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);
}