Raised This Month: $89 Target: $400
 22% 

Timer problems


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
uurbyrkdr
Senior Member
Join Date: Apr 2015
Old 06-15-2015 , 17:39   Timer problems
Reply With Quote #1

PHP Code:
public Action:Event_Round_Start(Handle:event, const String:name[], bool:dontBroadcast
{
    
iTime GetTime();
    
CreateTimer(60.0GodOff);
    for(new 
1i<=MaxClients;i++)
    {
        if(
IsClientInGame(i) && IsPlayerAlive(i))
            
SetEntProp(iProp_Data"m_takedamage"01);
    }
}

public 
Action:GodOff(Handle:timer)
{
    
int iRoundTime GetTime() - iTime;
    if(
iRoundTime == 60// Checking again time for bugs
    
{
        for(new 
1i<=MaxClients;i++)
        {
            
SetEntProp(iProp_Data"m_takedamage"21);
        }
        
CreateTimer(90.0GiveBeacon);
    }
}

public 
Action:GiveBeacon(Handle:timer)
{
    
int iRoundTime GetTime() - iTime;
    if(
iRoundTime == 150)
    {
        
ServerCommand("sm_beacon @all");
        
CreateTimer(90.0blabla...);
    }
}

... 
How can I optimize this code?
I know, i'm really a poor coder
uurbyrkdr is offline
uurbyrkdr
Senior Member
Join Date: Apr 2015
Old 06-15-2015 , 19:14   Re: Timer problems
Reply With Quote #2

i used OnGameFrame, with this i got better stability.
Now works correctly..
uurbyrkdr is offline
Drixevel
AlliedModders Donor
Join Date: Sep 2009
Location: Somewhere headbangin'
Old 06-16-2015 , 07:37   Re: Timer problems
Reply With Quote #3

Code:
public Action:Event_Round_Start(Handle:event, const String:name[], bool:dontBroadcast)
{
	for (new i = 1; i <= MaxClients; i++)
	{
		if(IsClientInGame(i) && IsPlayerAlive(i))
		{
			SetEntProp(i, Prop_Data, "m_takedamage", 0, 1);
		}
	}
	
	CreateTimer(60.0, GodOff);
}

public Action:GodOff(Handle:timer)
{
	for(new i = 1; i <= MaxClients; i++)
	{
		SetEntProp(i, Prop_Data, "m_takedamage", 2, 1);
	}
	
	CreateTimer(90.0, GiveBeacon);
}

public Action:GiveBeacon(Handle:timer)
{
	ServerCommand("sm_beacon @all");
	
	CreateTimer(90.0, blabla...);
}
Not sure what you're trying to do but that's what I see.
__________________
Not Taking Commissions | My [Dev] Website
Drixevel is offline
TnTSCS
AlliedModders Donor
Join Date: Oct 2010
Location: Undisclosed...
Old 06-16-2015 , 09:14   Re: Timer problems
Reply With Quote #4

Here's another example of working with timers you want to execute only if certain conditions apply... like resetting every round_start event

code
__________________
View my Plugins | Donate
TnTSCS is offline
Reply


Thread Tools
Display Modes

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 00:50.


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