Raised This Month: $51 Target: $400
 12% 

After X Rounds


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Inject
Junior Member
Join Date: Sep 2013
Old 09-21-2013 , 17:21   After X Rounds
Reply With Quote #1

I want to execute ServerCommand() after X Rounds, I did it like this(On this situation after 49 rounds):
Code:
public OnPluginStart()
{
    HookEvent("round_start", round_start, EventHookMode_PostNoCopy);
}

new Rounds = 0;

public OnMapStart()
{
Rounds = 0;
}

public round_start(Handle:event, const String:name[], bool:dontBroadcast)
{
    if (++Rounds >= 50)
        ServerCommand("sm_command");
}
But after 49 rounds it's executing the command for every round how I can cancel it?
Inject is offline
Bimbo1
Senior Member
Join Date: Jan 2010
Location: brazil
Old 09-21-2013 , 17:49   Re: After X Rounds
Reply With Quote #2

Code:
public OnPluginStart()
{
    HookEvent("round_start", round_start, EventHookMode_PostNoCopy);
}

new Rounds = 0;

public OnMapStart()
{
Rounds = 0;
}

public round_start(Handle:event, const String:name[], bool:dontBroadcast)
{
    if (++Rounds >= 50)
        ServerCommand("sm_command");
        Rounds = 0;
}
you gotta set it to zero so it can start counting again.
__________________
sie sind das essen und wir sind die jäger!
Bimbo1 is offline
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 09-21-2013 , 20:41   Re: After X Rounds
Reply With Quote #3

Quote:
Originally Posted by Bimbo1 View Post
Code:
public OnPluginStart()
{
    HookEvent("round_start", round_start, EventHookMode_PostNoCopy);
}

new Rounds = 0;

public OnMapStart()
{
Rounds = 0;
}

public round_start(Handle:event, const String:name[], bool:dontBroadcast)
{
    if (++Rounds >= 50)
        ServerCommand("sm_command");
        Rounds = 0;
}
you gotta set it to zero so it can start counting again.
Forgetting some brackets?
Code:
    if (++Rounds >= 50)
    {
        ServerCommand("sm_command");
        Rounds = 0;
    }
__________________
Not currently working on SourceMod plugin development.
Powerlord is offline
Bimbo1
Senior Member
Join Date: Jan 2010
Location: brazil
Old 09-21-2013 , 21:08   Re: After X Rounds
Reply With Quote #4

yep, xp, i'm so careless. it's python's fault, even though it would still be missing ":". but, actually, it's my school's fault, who decided to teach us python. urgh, if they were wanting to teach us a high level language, why not ruby?
__________________
sie sind das essen und wir sind die jäger!
Bimbo1 is offline
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 09-21-2013 , 22:36   Re: After X Rounds
Reply With Quote #5

Quote:
Originally Posted by Bimbo1 View Post
yep, xp, i'm so careless. it's python's fault, even though it would still be missing ":". but, actually, it's my school's fault, who decided to teach us python. urgh, if they were wanting to teach us a high level language, why not ruby?
Slightly related to the missing brackets: One of the reasons I tend to use brackets even on single statement ifs is to avoid the problem where I forget to add them in if I change it to multiple statements.
__________________
Not currently working on SourceMod plugin development.
Powerlord 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 02:53.


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