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

[L4D2] Nuke - Timer Issue


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
alasfourom
Senior Member
Join Date: Feb 2022
Location: Saudi Arabia
Old 07-22-2022 , 15:49   [L4D2] Nuke - Timer Issue
Reply With Quote #1

Hello guys

Explaining The plugin:
Nuke/Explode Survivors After A Period Of Time
Currently only slayed

I'm trying to understand some concepts here,

My always issues are with timers, I'm trying to stop timer + repeated timers when round end

The 2nd issue, need to fix the countdown, how to replace the 600 sec with the ConVar

PHP Code:
ExplodingTime g_CountDown-- + 600

Last edited by alasfourom; 07-23-2022 at 00:17.
alasfourom is offline
Marttt
Veteran Member
Join Date: Jan 2019
Location: Brazil
Old 07-22-2022 , 16:54   Re: [L4D2] How to stop timers + countdown issue
Reply With Quote #2

Usually I create a "global" timer variable

PHP Code:
Handle g_tMyTimer
Then on LeftStartArea you could delete the timer:

PHP Code:
delete g_tMyTimer;
g_tMyTimer CreateTimer (1.0Timer_CountDownclientTIMER_REPEAT); 
And on RoundEnd just

PHP Code:
delete g_tMyTimer
Also, you aren't returning "Plugin_Stop" at some point for a repeatable timer.

I recommend you read Dragokas's post about timers.
__________________

Last edited by Marttt; 07-22-2022 at 16:55.
Marttt is offline
alasfourom
Senior Member
Join Date: Feb 2022
Location: Saudi Arabia
Old 07-22-2022 , 17:16   Re: [L4D2] How to stop timers + countdown issue
Reply With Quote #3

Thank you Marttt I will definitely take a look at it, can you also explain to me why this is not working

PHP Code:
 ExplodingTime g_CountDown-- + GetConVarFloat(NukeTimer); 
alasfourom is offline
Marttt
Veteran Member
Join Date: Jan 2019
Location: Brazil
Old 07-22-2022 , 17:28   Re: [L4D2] How to stop timers + countdown issue
Reply With Quote #4

I didn't understand what this variable is for. Seems more of a logic error to me.
If is a countdown usually I set the var in LeftSafeArea to "e.g." 10, then keep decrementing inside the repeat_timer
If the value is <= 0 then you should Stop the timer.
__________________
Marttt is offline
alasfourom
Senior Member
Join Date: Feb 2022
Location: Saudi Arabia
Old 07-22-2022 , 17:39   Re: [L4D2] How to stop timers + countdown issue
Reply With Quote #5

because I want it to countdown the ConVar NukeTimer which can be changed

PHP Code:
 NukeTimer CreateConVar ("l4d2_nuke_time""600.0""Set The Time At Which Players Will Be Nuked" ,FCVAR_NOTIFYtrue1.0true3600.0); 
Since NukeTimer is adjustable and can be changed, so the countdown should also be changed

I hope you got my point

Last edited by alasfourom; 07-22-2022 at 17:40.
alasfourom is offline
Marttt
Veteran Member
Join Date: Jan 2019
Location: Brazil
Old 07-22-2022 , 18:25   Re: [L4D2] How to stop timers + countdown issue
Reply With Quote #6

not much reason to use a float here
btw is just change the "10" example for the one I mentioned

g_CountDown = GetConVarInt(NukeTimer); on round start

and

ExplodingTime = g_CountDown--;
__________________
Marttt is offline
alasfourom
Senior Member
Join Date: Feb 2022
Location: Saudi Arabia
Old 07-22-2022 , 18:47   Re: [L4D2] How to stop timers + countdown issue
Reply With Quote #7

Worked like a charm

Thank you Marttt
alasfourom is offline
alasfourom
Senior Member
Join Date: Feb 2022
Location: Saudi Arabia
Old 07-23-2022 , 00:16   Re: [L4D2] How to stop timers + countdown issue
Reply With Quote #8

I have another issue now

The First Issue, is this error, I have no clue how to fix this > Line 58 I pointed it in the script > delete g_Timer_NukePlayers;

PHP Code:
L 07/23/2022 07:13:13SourceMod error session started
L 07
/23/2022 07:13:13Info (map "c1m1_hotel") (file "C:\Servers\L4D2\TheCrew\left4dead2\addons\sourcemod\logs\errors_20220723.log")
L 07/23/2022 07:13:13: [SMException reportedHandle 69c00789 is invalid (error 3)
L 07/23/2022 07:13:13: [SMBlamingL4D_Nuke.smx
L 07
/23/2022 07:13:13: [SMCall stack trace:
L 07/23/2022 07:13:13: [SM]   [0CloseHandle
L 07
/23/2022 07:13:13: [SM]   [1Line 58C:\Users\Omar Alasfour\Desktop\L4D_Nuke.sp::Event_RoundEnd 
The Second Issue, which is probably the same as first one, delete timer on round end is not working

PHP Code:
#include <sourcemod>
#include <sdktools>

#define PLUGIN_VERSION "1.0"
#define SOUND_NUKE "animation/overpass_jets.wav"

ConVar NukeTimer;
ConVar Announcer;

Handle g_Timer_NukePlayers;
Handle g_Timer_CountDown

int g_CountDown;
int g_Announcer;
int ExplodingTime;

public 
Plugin myinfo 
{
    
name "L4D2 Nuke",
    
author "alasfour",
    
description "Nuke Players With Countdown After Leaving Saferoom",
    
version "1.0",
    
url "https://forums.alliedmods.net/"
};

public 
void OnPluginStart() 
{
    
CreateConVar ("l4d2_nuke_version"PLUGIN_VERSION"L4D2 Nuke" ,FCVAR_SPONLY|FCVAR_NOTIFY|FCVAR_DONTRECORD);
    
NukeTimer CreateConVar ("l4d2_nuke_timer""600.0""Set The Time At Which Players Will Be Nuked [Should Be Higher Than Announcer Time]" ,FCVAR_NOTIFYtrue1.0true3600.0);
    
Announcer CreateConVar ("l4d2_nuke_announcer""90.0""Set The Time At Which Nuke Countdown Will Be Announced To Players [Should Be Lower Than Nuke Time]" ,FCVAR_NOTIFYtrue1.0true3600.0);
    
AutoExecConfig (true"L4D2_Nuke");

    
HookEvent("player_left_start_area"Event_LeftStartArea);
    
HookEvent("round_end"Event_RoundEnd);

    
PrecacheSound(SOUND_NUKE);
}

public 
Action Event_LeftStartArea(Event event, const char[] namebool dontBroadcast)
{
    
int client GetClientOfUserId(GetEventInt(event"userid"));
    {
        
g_CountDown GetConVarInt(NukeTimer);
        
g_Announcer GetConVarInt(Announcer);
        
PrintToChatAll("\x04[Warning] \x01Nuke Countdown Started: \x03%d min %d sec"g_CountDown 60g_CountDown 60);
        
        
g_Timer_CountDown CreateTimer (1.0Timer_CountDownclientTIMER_REPEAT);
    }
    for (
int i 1<= MaxClientsi++)
    {
        
g_Timer_NukePlayers CreateTimer (GetConVarFloat(NukeTimer), Timer_NukePlayersi);
    }
}

public 
Action Event_RoundEnd (Event event, const char[] namebool dontBroadcast)
{
    
delete g_Timer_CountDown;
    
delete g_Timer_NukePlayers;         // Line 58
}

public 
Action Timer_NukePlayers (Handle timerint client)
{
    if (
IsValidClient(client) && IsClientInGame(client) && IsPlayerAlive(client))
    {
        
ForcePlayerSuicide(client);
        
//Exploding Effect
        
if (ExplodingTime <= 1EmitSoundToAll(SOUND_NUKE);
    }
    return 
Plugin_Handled;
}

public 
Action Timer_CountDown (Handle timerint client)
{
    
ExplodingTime g_CountDown-- -1;
    
    if (
ExplodingTime 0) return Plugin_Stop;
    
    if (
ExplodingTime <= g_AnnouncerPrintHintTextToAll("Nuke Time: %d"ExplodingTime);    
    
    return 
Plugin_Continue;
}

stock bool IsValidClient(int client)
{
    return 
client && client <= MaxClients && IsClientInGame (client);


Last edited by alasfourom; 07-23-2022 at 00:20.
alasfourom is offline
Grey83
Veteran Member
Join Date: Dec 2014
Location: Ukraine
Old 07-23-2022 , 03:53   Re: [L4D2] Nuke - Timer Issue
Reply With Quote #9

alasfourom,
PHP Code:
g_CountDown--; 
equals to
PHP Code:
g_CountDown g_CountDown 1
__________________

Last edited by Grey83; 07-23-2022 at 04:03.
Grey83 is offline
Grey83
Veteran Member
Join Date: Dec 2014
Location: Ukraine
Old 07-23-2022 , 03:56   Re: [L4D2] How to stop timers + countdown issue
Reply With Quote #10

Quote:
Originally Posted by alasfourom View Post
The First Issue, is this error, I have no clue how to fix this > Line 58 I pointed it in the script > delete g_Timer_NukePlayers;
PHP Code:
public Action Event_RoundEnd(Event event, const char[] namebool dontBroadcast)
{
    ...
    
delete g_Timer_NukePlayers;         // Line 58
}

public 
Action Timer_NukePlayers(Handle timerint client)
{
    ...
    return 
Plugin_Handled;

==>
PHP Code:
public Action Event_RoundEnd(Event event, const char[] namebool dontBroadcast)
{
    ...
    if(
g_Timer_NukePlayersdelete g_Timer_NukePlayers;         // Line 58
}

public 
Action Timer_NukePlayers(Handle timerint client)
{
    ...
    
g_Timer_NukePlayers null;
    return 
Plugin_Stop;

__________________

Last edited by Grey83; 07-23-2022 at 03:57.
Grey83 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 03:30.


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