Raised This Month: $ Target: $400
 0% 

[TF2] Run command only on the first round


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Miggy
Member
Join Date: Mar 2015
Old 04-05-2016 , 11:08   [TF2] Run command only on the first round
Reply With Quote #1

Someone told me how to do this previously and for the life of me, I can't remember how to do it.

Essentially I want to display a printtochatall message at the start of the first Tournament Mode round.
Miggy is offline
Chaosxk
Veteran Member
Join Date: Aug 2010
Location: Westeros
Old 04-05-2016 , 13:06   Re: [TF2] Run command only on the first round
Reply With Quote #2

Something like this? You might have to change the event as i don't know what event starts tournament mode round.

Code:
public void OnPluginStart()
{
	HookEvent("teamplay_round_active", teamplay_round_active);
}

public Action teamplay_round_active(Handle event, const char[] name, bool dontBroadcast)
{
	static bool firstRound = true;
	if(firstRound)
	{
		firstRound = false;
		PrintToChatAll("First round only");
	}
}
__________________
Chaosxk is offline
Miggy
Member
Join Date: Mar 2015
Old 04-05-2016 , 15:13   Re: [TF2] Run command only on the first round
Reply With Quote #3

Maybe I'm just reading that completely wrong and I'm a big dumbdumb (Which is very likely)
But, isn't the first round variable set every new round?

I have to make sure this would work in PL, CP, CP A/D, and Koth.

Last edited by Miggy; 04-05-2016 at 15:13.
Miggy is offline
Chaosxk
Veteran Member
Join Date: Aug 2010
Location: Westeros
Old 04-05-2016 , 15:49   Re: [TF2] Run command only on the first round
Reply With Quote #4

Quote:
Originally Posted by Miggy View Post
Maybe I'm just reading that completely wrong and I'm a big dumbdumb (Which is very likely)
But, isn't the first round variable set every new round?

I have to make sure this would work in PL, CP, CP A/D, and Koth.
This is true if i didn't add static. Static variables are essentially global variables but scoped within the function they are declared from.
__________________

Last edited by Chaosxk; 04-05-2016 at 15:49.
Chaosxk is offline
Miggy
Member
Join Date: Mar 2015
Old 04-05-2016 , 18:49   Re: [TF2] Run command only on the first round
Reply With Quote #5

Quote:
Originally Posted by Chaosxk View Post
This is true if i didn't add static. Static variables are essentially global variables but scoped within the function they are declared from.
I see.

So, then I should be doing something like this, no?

PHP Code:
public void OnPluginStart()
{
    
HookEvent("teamplay_round_start"EventRoundStart);
}

public 
Action EventRoundStart(Handle event, const char[] namebool dontBroadcast)
{
    static 
bool firstRound true;
    if(
firstRound)
    {
        
firstRound false;
        
PrintToChatAll("First round only");
    }

Just throwing that event change off the top of my head. I'm not 100% sure it's accurate.

Last edited by Miggy; 04-05-2016 at 19:05.
Miggy is offline
Chaosxk
Veteran Member
Join Date: Aug 2010
Location: Westeros
Old 04-05-2016 , 18:58   Re: [TF2] Run command only on the first round
Reply With Quote #6

These are the list of events for TF2.
https://wiki.alliedmods.net/Team_Fortress_2_Events
__________________
Chaosxk is offline
Miggy
Member
Join Date: Mar 2015
Old 04-05-2016 , 19:12   Re: [TF2] Run command only on the first round
Reply With Quote #7

Quote:
Originally Posted by Chaosxk View Post
These are the list of events for TF2.
https://wiki.alliedmods.net/Team_Fortress_2_Events
Yea I fixed up my mistake
Hurriedly put it together while at work

But, I got it working, and it only shows on the first round!
Thank you, youthebomb.com
Miggy is offline
Chdata
Veteran Member
Join Date: Aug 2012
Location: Computer Chair, Illinois
Old 04-06-2016 , 13:36   Re: [TF2] Run command only on the first round
Reply With Quote #8

Shouldn't you use an actual global variable and reset it OnMapStart?

This plugin shouldn't work if the map changes as it is.
__________________

Last edited by Chdata; 04-06-2016 at 13:36.
Chdata is offline
Chaosxk
Veteran Member
Join Date: Aug 2010
Location: Westeros
Old 04-06-2016 , 15:11   Re: [TF2] Run command only on the first round
Reply With Quote #9

Quote:
Originally Posted by Chdata View Post
Shouldn't you use an actual global variable and reset it OnMapStart?

This plugin shouldn't work if the map changes as it is.
Your right, i forgot about resetting it. So yeah change it to a global variable and reset it.
__________________
Chaosxk is offline
Karibeean
Junior Member
Join Date: May 2013
Old 04-07-2016 , 15:32   Re: [TF2] Run command only on the first round
Reply With Quote #10

PHP Code:
new bool:firstRound true;

public 
void OnPluginStart() 

    
HookEvent("teamplay_round_start"EventRoundStart); 


public 
Action EventRoundStart(Handle event, const char[] namebool dontBroadcast

    if(
firstRound
    { 
        
firstRound false
        
PrintToChatAll("First round only"); 
    } 
}  

public 
void OnMapStart()
{

firstRound true;


Im new on SourceMod but i think will be something like that

Last edited by Karibeean; 04-11-2016 at 15:16.
Karibeean is offline
Reply



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 22:20.


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