View Single Post
Author Message
LordHotPocketHomicide
Member
Join Date: Aug 2016
Location: This Realm of Existence
Old 03-14-2020 , 00:33   Plugin won't load, doesn't appear in sm plugins.
Reply With Quote #1

Hello! I've (very) recently gotten into writing plugins, largely thanks to a friend of mine who generously agreed to teach me some of the basics, and even showed me to some incredibly useful resources such as the API reference. My end goal is to be able to write FF2 sub-plugins, though that's a story for another time.

The problem I'm currently having is as such: for some odd reason, this plugin, and this plugin alone, won't load on my test server, and it doesn't appear in the sm plugins menu. Just to make sure it wasn't an issue on the server's end, I wrote up a quick test program, which worked perfectly fine, so I wound up concluding that the issue is somewhere in my code. I've tried sm plugins load, I've restarted my server several times, and I've re-written my code in various ways, all to no avail, so I eventually wound up coming here for support. If somebody could point out what I did wrong, I would greatly appreciate it! Thanks in advance.

Code:
#include <sourcemod>
#include <tf2.inc>
#include <tf2_stocks.inc>
#include <tf2attributes.inc>
#include <sdkhooks.inc>
#include <clients.inc>

public Plugin myinfo =
{
	name		=	"TF2 Chaos Mod",
	description	=	"Applies a random perk to players when they call for medic. Future plans include applying a random perk whenever a player inputs anything, with no cooldown whatsoever.",
	author		=	"Lord ''Spookmaster'' Homicide",
	version		=	"0.5",
};
public OnPluginStart()
{
	HookEvent("teamplay_round_start", Event_InitiateChaos);
}
public Action Event_InitiateChaos(Event chaos, const char[] sEvName, bool bDontBroadcast)
{
	AddCommandListener(playerCalledForMedic, "voicemenu 0 0");
	return Plugin_Continue;
}

bool cooldownCheck = false; //Global variable. From what I know, these should typically be avoided, but my limited SourcePawn knowledge makes it hard to find a work-around for the time being.

public Action playerCalledForMedic(int client, const char[] voicemenu, int argc)
{
	if (!cooldownCheck)
	{
		if (!IsClientConnected(client) || !IsPlayerAlive(client))
		{
			return Plugin_Handled;
		}
		int perkSelector = GetRandomInt(0, 128);
		TF2_AddCondition(client, perkSelector, 5.0, 0);
		PrintToChatAll("%N just got a perk!", GetClientOfUserId(client));
		cooldownCheck = true;
		CreateTimer(5.0, cooldownReset);
	}
	else
	{
		PrintToChat(client, "Oops! You've gained a perk too recently. Try again in a few seconds.");
	}
	return Plugin_Continue;
}
public Action cooldownReset(Handle timer)
{
	cooldownCheck = false;
	return Plugin_Changed;
}

Last edited by LordHotPocketHomicide; 03-14-2020 at 13:47.
LordHotPocketHomicide is offline