Raised This Month: $ Target: $400
 0% 

Plugin won't work on the first round after map change, but does on the second.


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
VeMi
Member
Join Date: Feb 2011
Location: Sweden
Old 11-09-2013 , 13:26   Plugin won't work on the first round after map change, but does on the second.
Reply With Quote #1

The plugin works by creating a timer with a certain command that disables another plugin after x amount of seconds. The issue is that when a map changes, it doesnt work on that first round, but after the first round it works as it should.. Any fix to this? This code was written by TnTSCS

Here is the code:
Code:
#pragma semicolon 1
#include <sourcemod>

new Handle:autorespawn = INVALID_HANDLE;
new Handle:respawntime = INVALID_HANDLE;
new Handle:AR_Timer = INVALID_HANDLE;
new Handle:b_displayMessage = INVALID_HANDLE;
new Handle:s_message = INVALID_HANDLE;
new String:AR_Message[192];

public OnPluginStart()
{
	autorespawn = FindConVar("sm_autorespawn_enabled");
	
	if (autorespawn == INVALID_HANDLE)
	{
		SetFailState("Unable to find \"sm_autorespawn_enabled\"");
	}
	
	respawntime = CreateConVar("sm_ar_time", "20.0", "Number of seconds to allow sm_autorespawn to remain enabled");
	b_displayMessage = CreateConVar("sm_ar_msg", "1", "Display a message when autorespawn is disabled?", _, true, 0.0, true, 1.0);
	s_message = CreateConVar("sm_ar_message", "Autorespawn is now disabled", "Message to display to users when autorespawn is disabled");
	GetConVarString(s_message, AR_Message, sizeof(AR_Message));
	
	HookEvent("round_start", Event_RoundStart);
}

public OnMapStart()
{
	ClearTimer(AR_Timer);
}

public OnMapEnd()
{
	ClearTimer(AR_Timer);
}

public Action:Event_RoundStart(Handle:event, const String:name[], bool:dontBroadcast)
{
	ClearTimer(AR_Timer);
	
	SetConVarInt(autorespawn, 1);
	
	AR_Timer = CreateTimer(GetConVarFloat(respawntime), Timer_DisableAR);
}

public Action:Timer_DisableAR(Handle:timer)
{
	AR_Timer = INVALID_HANDLE;
	
	SetConVarInt(autorespawn, 0);
	
	if (GetConVarBool(b_displayMessage))
	{
		PrintToChatAll("%s", AR_Message);
	}
}

ClearTimer(&Handle:timer)
{
	if (timer != INVALID_HANDLE)
	{
		KillTimer(timer);
		timer = INVALID_HANDLE;
	}     
}
__________________

Last edited by VeMi; 11-09-2013 at 13:30.
VeMi is offline
GsiX
gee, six eggs
Join Date: Aug 2012
Location: Land Below The Wind
Old 11-09-2013 , 13:48   Re: Plugin won't work on the first round after map change, but does on the second.
Reply With Quote #2

you cant kill non repeat timer.

PHP Code:
#pragma semicolon 1
#include <sourcemod>

new Handle:autorespawn INVALID_HANDLE;
new 
Handle:respawntime INVALID_HANDLE;
new 
Handle:b_displayMessage INVALID_HANDLE;
new 
Handle:s_message INVALID_HANDLE;
new 
String:AR_Message[192];
new 
respawnT;
new 
bool:g_RoundEnd;

public 
OnPluginStart()
{
    
respawntime CreateConVar("sm_ar_time""20.0""Number of seconds to allow sm_autorespawn to remain enabled");
    
b_displayMessage CreateConVar("sm_ar_msg""1""Display a message when autorespawn is disabled?"_true0.0true1.0);
    
s_message CreateConVar("sm_ar_message""Autorespawn is now disabled""Message to display to users when autorespawn is disabled");
    
GetConVarString(s_messageAR_Messagesizeof(AR_Message));
    
    
HookEvent("round_start"Event_RoundStart);
    
HookEvent("round_end"Event_RoundEnd);
}

public 
OnMapStart()
{
    
autorespawn FindConVar("sm_autorespawn_enabled");

    if (
autorespawn == INVALID_HANDLE)
    {
        
SetFailState("Unable to find \"sm_autorespawn_enabled\"");
    }
}

public 
Action:Event_RoundStart(Handle:event, const String:name[], bool:dontBroadcast)
{
    if(
autorespawn != INVALID_HANDLE)
    {
        
g_RoundEnd false;
        
SetConVarInt(autorespawn1);
        
respawnT GetConVarIntrespawntime );
        
CreateTimer1.0Timer_DisableAR_TIMER_REPEAT|TIMER_FLAG_NO_MAPCHANGE );
    }
    else
    {
        
PrintToServer"[autorespawn]: Fail to load \"sm_autorespawn_enabled\"" );
    }
}

public 
Action:Event_RoundEnd(Handle:event, const String:name[], bool:dontBroadcast)
{
    
g_RoundEnd true;
}

public 
Action:Timer_DisableAR(Handle:timer)
{
    
respawnT--;
    if( 
respawnT && !g_RoundEnd )
    {
        return 
Plugin_Continue;
    }
    
    
SetConVarInt(autorespawn0);
    if (
GetConVarBool(b_displayMessage))
    {
        
PrintToChatAll("%s"AR_Message);
    }

    return 
Plugin_Stop;

__________________
If i happen to insulted you unintentionally,
it was me and Google Translate who did it.

Last edited by GsiX; 11-09-2013 at 14:19.
GsiX is offline
VeMi
Member
Join Date: Feb 2011
Location: Sweden
Old 11-10-2013 , 10:22   Re: Plugin won't work on the first round after map change, but does on the second.
Reply With Quote #3

I dont understand, did you fix the code? Because it's still the same issue. I am not really good at writing codes so I wouldn't know if you fixed it or just pointed out the issue.
__________________

Last edited by VeMi; 11-10-2013 at 10:41.
VeMi is offline
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 11-10-2013 , 11:34   Re: Plugin won't work on the first round after map change, but does on the second.
Reply With Quote #4

@GsiX, nonsense.

@VeMi (and others), it help a lot if you are telling in first post, what the game is about.
Because SourceMod support many HL2-Source-games and each game have own things more or less.

So, big guess. You have cs:go and first round (warmup?) not work because round_start event not yet appear.
So, change
PHP Code:
"round_start"
to
"round_freeze_end" 
Bacardi is offline
GsiX
gee, six eggs
Join Date: Aug 2012
Location: Land Below The Wind
Old 11-10-2013 , 11:51   Re: Plugin won't work on the first round after map change, but does on the second.
Reply With Quote #5

my bad, i have no clue of cs:go, yet i didnt google it..
__________________
If i happen to insulted you unintentionally,
it was me and Google Translate who did it.
GsiX is offline
VeMi
Member
Join Date: Feb 2011
Location: Sweden
Old 11-10-2013 , 12:04   Re: Plugin won't work on the first round after map change, but does on the second.
Reply With Quote #6

Yeah it's CS:GO and no there is no warmup at all
__________________
VeMi is offline
VeMi
Member
Join Date: Feb 2011
Location: Sweden
Old 11-10-2013 , 12:18   Re: Plugin won't work on the first round after map change, but does on the second.
Reply With Quote #7

Quote:
Originally Posted by Bacardi View Post
@GsiX, nonsense.

@VeMi (and others), it help a lot if you are telling in first post, what the game is about.
Because SourceMod support many HL2-Source-games and each game have own things more or less.

So, big guess. You have cs:go and first round (warmup?) not work because round_start event not yet appear.
So, change
PHP Code:
"round_start"
to
"round_freeze_end" 
Nevermind seems fixed! Had to change in the server.cfg the mp_freezetime 1
Thank you very much!
__________________

Last edited by VeMi; 11-10-2013 at 12:51. Reason: Solved
VeMi is offline
TnTSCS
AlliedModders Donor
Join Date: Oct 2010
Location: Undisclosed...
Old 11-11-2013 , 11:30   Re: Plugin won't work on the first round after map change, but does on the second.
Reply With Quote #8

so this is working now?
__________________
View my Plugins | Donate
TnTSCS 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 01:40.


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