Raised This Month: $32 Target: $400
 8% 

[L4D2]Why this cause tank instant spawn when rount start?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
gilmon
Senior Member
Join Date: Feb 2011
Location: China
Old 06-26-2019 , 08:29   [L4D2]Why this cause tank instant spawn when rount start?
Reply With Quote #1

PHP Code:
new bool:tankSI false;

public 
OnPluginStart()
{
    
HookEvent("round_start"round_start);
    
HookEvent("round_end"round_end);
    
HookEvent("finale_start"final_start);
    
HookEvent("finale_escape_start"final_start);
}

public 
Action:round_end(Handle:event, const String:name[], bool:dontBroadcast)
{
    if(
TankTimer != INVALID_HANDLE)
    {
        
// Stop it and clear handle
        
KillTimer(TankTimer);
        
TankTimer INVALID_HANDLE;
        
tankSI false;
    }
}

public 
Action:round_start(Handle:event, const String:name[], bool:dontBroadcast)
{
    
tankSI true;
    if(
TankTimer != INVALID_HANDLE)
    {
        
TankTimer INVALID_HANDLE;
    }
    else
    {
        
TankTimer CreateTimer(GetRandomFloat(450.0750.0), SpawnRandomTank_TIMER_REPEAT);
    }    
}

public 
Action:final_start(Handle:event, const String:name[], bool:dontBroadcast)
{
    
tankSI false;
}

public 
Action:SpawnRandomTank(Handle:timer)
{
    if(
tankSI)
    {
        
//tank spawn code here..
        
tankSI false;
    }

Any help about this? everytime round start the tank will instant spawn i dont know why, also there's anther one question i want know, if I remove the "tankSI" condition, tank spawn will be more and more faster at last will spawn only between about 10-30 seconds, any fix to it too?

Last edited by gilmon; 06-26-2019 at 08:30. Reason: remove useless code inside
gilmon is offline
Send a message via MSN to gilmon
Marttt
Veteran Member
Join Date: Jan 2019
Location: Brazil
Old 06-26-2019 , 12:25   Re: [L4D2]Why this cause tank instant spawn when rount start?
Reply With Quote #2

Did you got this bug on every round? or only after the first map?
Looks like your timer only spawns the tank after 7.5 ~ 12.5 minutes after round_start;
Usually repeater timers are followed by the "TIMER_FLAG_NO_MAPCHANGE" flag, so they aren't carried to the next map/round

You can get some reference here
__________________
Marttt is offline
gilmon
Senior Member
Join Date: Feb 2011
Location: China
Old 06-27-2019 , 04:27   Re: [L4D2]Why this cause tank instant spawn when rount start?
Reply With Quote #3

It always happen everyround, I will check out that later, thanks.
gilmon is offline
Send a message via MSN to gilmon
impossible_cc
Senior Member
Join Date: Sep 2018
Location: Ukraine
Old 06-29-2019 , 16:20   Re: [L4D2]Why this cause tank instant spawn when rount start?
Reply With Quote #4

Also don't use TIMER_FLAG_NO_MAPCHANGE if you have a variable (Handle) which tracks timer condition, because if timer gets killed on map end, variable doesnt become equal to INVALID_HANDLE or null, but timer doesnt exist anymore.


PHP Code:
// new bool:tankSI = false;

public OnPluginStart()
{
    
HookEvent("round_start"round_start);
    
HookEvent("round_end"round_end);
    
// HookEvent("finale_start", final_start);
    // HookEvent("finale_escape_start", final_start);
}

public 
Action:round_end(Handle:event, const String:name[], bool:dontBroadcast)
{
    if(
TankTimer != INVALID_HANDLE)
    {
        
// Stop it and clear handle
        
KillTimer(TankTimer);
        
TankTimer INVALID_HANDLE;
    }
}

public 
Action:round_start(Handle:event, const String:name[], bool:dontBroadcast)
{
    if(
TankTimer != INVALID_HANDLE)
    {
        
KillTimer(TankTimer);
    }
    
    
TankTimer CreateTimer(GetRandomFloat(450.0750.0), SpawnRandomTankTIMER_REPEAT);  
}

// public Action:final_start(Handle:event, const String:name[], bool:dontBroadcast)
// {
    // tankSI = false;
// }

public Action:SpawnRandomTank(Handle:timer)
{
    
// if(tankSI)
    // {
        // 
        // tankSI = false;
    // }
    
    
    //tank spawn code here..

__________________
impossible_cc 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 03:07.


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