Raised This Month: $2 Target: $400

MVMVictory HookUserMessage

Post New Thread Reply   
Thread Tools Display Modes
Author Message
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.

#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
PC Gamer
Senior Member
Join Date: Mar 2014
Old 06-16-2020 , 20:01   Re: MVMVictory HookUserMessage
Reply With Quote #2

I haven't used HookUserMessage before. But... after reading these:


I would probably do something like this:

PHP Code:
#include <sourcemod>
#include <sdktools>

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 ""

RegConsoleCmd("sm_resetpopfile"command_resetpopfile"resets popfile");
HookUserMessage(GetUserMessageId("MVMVictory" ), mvm_completetrue); 

Action:mvm_complete(UserMsg:msg_idHandle:bf, const players[], playersNumbool:reliablebool:init
char responseBuffer[4096];
int ObjectiveEntity FindEntityByClassname(-1"tf_objective_resource");

// Get Popfile Name
// Tell server to change popfile 
ServerCommand("tf_mvm_popfile %s"ObjectiveEntity);

char responseBuffer[4096];
int ObjectiveEntity FindEntityByClassname(-1"tf_objective_resource");
// Get Popfile Name
// Tell server to change popfile 
ServerCommand("tf_mvm_popfile %s"ObjectiveEntity);

Note: Not tested since I gave up on running MvM long ago after it kept kicking all players every mapchange. I never did receive a solution to that problem. Anyway, I hope this works for you.
PC Gamer is offline

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 10:07.

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