PDA

View Full Version : Autoexecute a Command on Map Start


ConstructionBoy
03-16-2016, 01:36
Hi everyone, I'm trying/tried to make a plugin that executes a command everytime the server changes maps, this is as far as I got:

public OnMapStart()
{

Btw the command is "sm reload plugins TF2Jail" its kind of an unusual command because it doesn't have any underscores so I'm concerned that it might just read that everything after "sm" as an argument.

P.S. I do not know C++, I just read other codes and take notes on the basics

ddhoward
03-16-2016, 01:55
What makes you think that those aren't arguments?

https://sm.alliedmods.net/new-api/console/ServerCommand

Phil25
03-16-2016, 02:22
Having to reload a plugin means there must be something wrong with it. Do you have the source of TF2Jail and have you tried figuring out what's wrong with it?

ConstructionBoy
03-16-2016, 12:51
You're right Phil, the reason I have to reload it on every map change is because the Freeday Teleporting feature breaks after every map change. The reason it does this is because I had to fiddle with the source code to get this feature to work (seeing as it is broken right out of the box) and I'm not a coder. It works on the first map after starting the server but after I change the map, it breaks itself. Reloading the plugin seems to do the trick every time.

I think it would be easier to just reload the plugin with a command than fix the source code, and its a super long code so I couldn't post it here.

headline
03-16-2016, 22:59
You're right Phil, the reason I have to reload it on every map change is because the Freeday Teleporting feature breaks after every map change. The reason it does this is because I had to fiddle with the source code to get this feature to work (seeing as it is broken right out of the box) and I'm not a coder. It works on the first map after starting the server but after I change the map, it breaks itself. Reloading the plugin seems to do the trick every time.

I think it would be easier to just reload the plugin with a command than fix the source code, and its a super long code so I couldn't post it here.

You should always fix the broken plugin, however if you need to use this as a hotfix: so be it.

#include <sourcemod>

#pragma semicolon 1

public OnMapStart()
{
ServerCommand("sm plugins reload TF2Jail");
}

ConstructionBoy
03-16-2016, 23:27
Thanks man, I feel so dumb looking at the source code you posted :oops:

Phil25
03-17-2016, 01:14
Due to the plugin's name I gotta ask if it's map-specific. Because if it is it means it might grab some entities and there could be problems with doing that in the very frame of the OnMapStart. If putting the reload in that function doesn't work, try putting it in TF2_OnWaitingForPlayersStart instead, where the map and its entities should be fully initialized.