View Single Post
Author Message
Gurrth
Junior Member
Join Date: Feb 2020
Old 06-15-2020 , 19:09   MVMVictory HookUserMessage
Reply With Quote #1

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);
	
}

Last edited by Gurrth; 06-15-2020 at 19:12.
Gurrth is offline