View Single Post
11530
Veteran Member
Join Date: Sep 2011
Location: Underworld
Old 09-05-2011 , 12:11   Re: [TF2]TF2items.com MOTD backpack(With player menu)
Reply With Quote #35

Quote:
Originally Posted by CoolJosh3k View Post
I just noticed an issue with the adverts too. You made a mistake in the code.

You forgot to tell the plugin to read the state of the cvar controlling the advert state.

Code:
//Timer for adverts
public Action:Adverttimer(Handle:timer)
{
	PrintToChatAll("\x03 Aim at someone and type !bp or !backpack [playername]");
	return Plugin_Continue;
}
should be:

Code:
//Timer for adverts
public Action:Adverttimer(Handle:timer)
{
	if (adsOn == 1)
	{
		PrintToChatAll("\x03 Aim at someone and type !bp or !backpack [playername]");
	}
	return Plugin_Continue;
}
I could be very wrong though, as I don't know how to write plugins yet.
You're pretty much there CoolJosh, but it's best to wrap the evaluation around StartTimer() in the OnPluginStart() function, so the timer never starts until it's needed:

Code:
	if (GetConVarBool(g_Adverts))
		StartTimer();
Also I added a line to remove the handle from a stopped timer in OnAdtimeChange() purely for cleanup:

Code:
		if (g_Adtimer != INVALID_HANDLE)
		{
			KillTimer(g_Adtimer);
			g_Adtimer = INVALID_HANDLE;
		}
Also changed default time between adverts to 300 seconds.


Edit: See Post #46 for the latest edits.

Last edited by 11530; 03-06-2012 at 05:06.
11530 is offline