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

[L4D2] Nuke - Timer Issue


Post New Thread Reply   
 
Thread Tools Display Modes
Grey83
Veteran Member
Join Date: Dec 2014
Location: Ukraine
Old 07-23-2022 , 04:36   Re: [L4D2] How to stop timers + countdown issue
Reply With Quote #11

Quote:
Originally Posted by alasfourom View Post
The Second Issue, which is probably the same as first one, delete timer on round end is not working
This will work
Attached Files
File Type: sp Get Plugin or Get Source (l4d2_nuke 1.1.0.sp - 41 views - 2.7 KB)
__________________

Last edited by Grey83; 07-23-2022 at 11:48. Reason: updated source file: fixed countdown timer
Grey83 is offline
alasfourom
Senior Member
Join Date: Feb 2022
Location: Saudi Arabia
Old 07-23-2022 , 10:01   Re: [L4D2] How to stop timers + countdown issue
Reply With Quote #12

Quote:
Originally Posted by Grey83 View Post
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;



Awwwww Your Awesome

That fixed my issue now thank you very much > 0 Errors and it reset when round ends

Quote:
Originally Posted by Grey83 View Post
This will work
I tested it, countdown was not working and doesn't slay you after time passes
Shouldn't be TIMER_REPEAT > To make countdown work???
alasfourom is offline
Grey83
Veteran Member
Join Date: Dec 2014
Location: Ukraine
Old 07-23-2022 , 11:45   Re: [L4D2] How to stop timers + countdown issue
Reply With Quote #13

Quote:
Originally Posted by alasfourom View Post
Shouldn't be TIMER_REPEAT > To make countdown work???
yes
PHP Code:
public Action Timer_StartCountDown(Handle timer)
{
    
g_Timer CreateTimer(1.0Timer_CountDown);
    return 
Plugin_Stop;

==>
PHP Code:
public Action Timer_StartCountDown(Handle timer)
{
    
g_Timer CreateTimer(1.0Timer_CountDown_TIMER_REPEAT);
    return 
Plugin_Stop;

__________________
Grey83 is offline
alasfourom
Senior Member
Join Date: Feb 2022
Location: Saudi Arabia
Old 07-23-2022 , 12:22   Re: [L4D2] How to stop timers + countdown issue
Reply With Quote #14

Quote:
Originally Posted by Grey83 View Post
yes
PHP Code:
public Action Timer_StartCountDown(Handle timer)
{
    
g_Timer CreateTimer(1.0Timer_CountDown);
    return 
Plugin_Stop;

==>
PHP Code:
public Action Timer_StartCountDown(Handle timer)
{
    
g_Timer CreateTimer(1.0Timer_CountDown_TIMER_REPEAT);
    return 
Plugin_Stop;

Excellent, thanks
alasfourom is offline
alasfourom
Senior Member
Join Date: Feb 2022
Location: Saudi Arabia
Old 07-23-2022 , 23:28   Re: [L4D2] Nuke - Timer Issue
Reply With Quote #15

Script is working, I added the following:
- ConVar Warning Message > StartWarning = CreateConVar ("l4d2_nuke_warning"
- !Nuke > RegConsoleCmd("sm_nuke", Command_Nuke, "Print Nuke Countdown To Players");
- Explosion > Taken From l4d2_custom_commands


but I had these errors, any ideas?


PHP Code:
L 07/24/2022 06:26:45: [SMException reportedInvalid Handle 0 (error 4)
L 07/24/2022 06:26:45: [SMBlamingL4D2_Nuke.smx
L 07
/24/2022 06:26:45: [SMCall stack trace:
L 07/24/2022 06:26:45: [SM]   [0SDKCall
L 07
/24/2022 06:26:45: [SM]   [1Line 279C:\Users\Omar Alasfour\Desktop\Nuke.sp::FlingPlayer
L 07
/24/2022 06:26:45: [SM]   [2Line 257C:\Users\Omar Alasfour\Desktop\Nuke.sp::CreateExplosion
L 07
/24/2022 06:26:45: [SM]   [3Line 171C:\Users\Omar Alasfour\Desktop\Nuke.sp::timerStrike 
PHP Code:
#pragma newdecls required
#pragma semicolon 1
#include <sourcemod>
#include <sdktools>

#define NUKE_SOUND "animation/overpass_jets.wav"
#define EXPLOSION_SOUND "ambient/explosions/explode_1.wav"
#define EXPLOSION_DEBRIS "animation/plantation_exlposion.wav"

#define FIRE_PARTICLE "gas_explosion_ground_fire"
#define EXPLOSION_PARTICLE "FluidExplosion_fps"

#define PLUGIN_VERSION "1.1.0"

ConVar StartWarning;
Handle g_Timer;
float fNukefAnnouncefEndg_fSeconds;    

bool g_bLeftStartArea;
bool g_bStrike;
Handle sdkCallPushPlayer;

public 
Plugin myinfo =
{
    
name "L4D2 Nuke",
    
version PLUGIN_VERSION,
    
description "Nuke Players With Countdown After Leaving Saferoom",
    
author "alasfourom, Grey83",
    
url "https://forums.alliedmods.net/"
}

public 
void OnPluginStart()
{
    
CreateConVar("l4d2_nuke_version"PLUGIN_VERSION"L4D2 Nuke" ,FCVAR_SPONLY|FCVAR_NOTIFY|FCVAR_DONTRECORD);

    
ConVar cvar;
    
cvar CreateConVar("l4d2_nuke_timer""600.0""Set The Time At Which Players Will Be Nuked [ Should Be Higher Than Announcer Time ]"_true1.0true3600.0);
    
cvar.AddChangeHook(CVarChange_Nuke);
    
fNuke cvar.FloatValue;

    
cvar CreateConVar("l4d2_nuke_announcer""90.0""Set The Time At Which Nuke Countdown Hint Will Be Announced To Players [ Should Be Lower Than Nuke Time, Disable = 0 ]"_true1.0true3600.0);
    
cvar.AddChangeHook(CVarChange_Announce);
    
fAnnounce cvar.FloatValue;
    
    
StartWarning CreateConVar ("l4d2_nuke_warning""1""Display Nuke Warning Text When Players Leave Saferoom [ 0 = Disable - 1 = Enable ]"_true0.0true1.0);

    
AutoExecConfig(true"L4D2_Nuke");

    
RegConsoleCmd("sm_nuke"Command_Nuke"Print Nuke Countdown To Players");

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

    
PrecacheSound(NUKE_SOUND);
    
PrecacheSound(EXPLOSION_SOUND);
    
PrecacheSound(EXPLOSION_DEBRIS);
}

public 
void CVarChange_Nuke(ConVar cvar, const char[] oldValue, const char[] newValue)
{
    
fNuke cvar.FloatValue;
}

public 
void CVarChange_Announce(ConVar cvar, const char[] oldValue, const char[] newValue)
{
    
fAnnounce cvar.FloatValue;
}

public 
void OnMapStart()
{
    
g_bLeftStartArea false;
    if(
g_Timerdelete g_Timer;
}

public 
void OnMapEnd()
{
    
OnMapStart();
}

public 
void Event_RoundEnd(Event event, const char[] namebool dontBroadcast)
{
    
OnMapStart();
}

public 
void Event_LeftStartArea(Event event, const char[] namebool dontBroadcast)
{
    
g_fSeconds GetEngineTime();
    
    if (!
g_bLeftStartAreag_bLeftStartArea true;
    
    if(
g_Timer) return;

    
int client GetClientOfUserId(GetEventInt(event"userid"));
    if(!
client) return;

    
fEnd GetEngineTime() + fNuke;
    
int time RoundToNearest(fNuke);
    
PrintToChatAll("\x04[Warning] \x01Nuke Timeleft: \x03%d min %d sec"time 60time 60);

    
g_Timer CreateTimer(fAnnounceTimer_StartCountDown);
}

public 
Action Command_Nuke(int clientint args)
{
    
int timestart RoundToNearest(fNuke);
    
int timeleft RoundToNearest(fNuke) - RoundToFloor(GetEngineTime() - g_fSeconds);
    
    if (!
g_bLeftStartArea && GetConVarBool(StartWarning)) PrintToChatAll("\x04[Warning] \x01Nuke Timeleft: \x03%d min %d sec"timestart 60timestart 60);
    if (
g_bLeftStartArea && timeleft 0PrintToChatAll("\x04[Warning] \x01Nuke Timeleft: \x03%d min %d sec"timeleft 60timeleft 60);
    if (
g_bLeftStartArea && timeleft <= 0PrintToChatAll("\x04[Warning] \x01You Have Been \x03Nuked");
    return 
Plugin_Handled;
}

public 
Action Timer_StartCountDown(Handle timer)
{
    
g_Timer CreateTimer(1.0Timer_CountDown_TIMER_REPEAT);
    
TriggerTimer(g_Timer);
    return 
Plugin_Stop;
}

public 
Action Timer_CountDown(Handle timer)
{
    
float time fEnd GetEngineTime();
    if(
time >= 0.0)
    {
        
PrintHintTextToAll("Nuke Time: %d"RoundToNearest(time));
        return 
Plugin_Continue;
    }
    
    
EmitSoundToAll(NUKE_SOUND);
    
    for(
int i 1<= MaxClientsi++)
    if(
IsClientInGame(i) && IsPlayerAlive(i) && IsClientSurvivor(i))
    {
        
g_bStrike true;
        
CreateTimer(2.0timerKillPlayersi);
        
CreateTimer(6.0timerStrikeTimeoutiTIMER_FLAG_NO_MAPCHANGE);
        
CreateTimer(1.0timerStrikeiTIMER_REPEAT TIMER_FLAG_NO_MAPCHANGE);
    }

    
g_Timer null;
    return 
Plugin_Stop;
}

// Slaying Clients After 2 Seconds Of The Explosion For More Realastic Effect
public Action timerKillPlayers(Handle timerany client)
{
    
ForcePlayerSuicide(client);
    return 
Plugin_Handled;
}

/*===========================================================================
//                From Here Taken From l4d2_custom_commands                   //
===========================================================================*/

public Action timerStrikeTimeout(Handle timer)
{
    
g_bStrike false;
    return 
Plugin_Continue;
}

public 
Action timerStrike(Handle timerany client)
{
    if (!
g_bStrike) return Plugin_Stop;

    
float pos[3];
    
GetClientAbsOrigin(clientpos);
    
float radius 1.0;
    
pos[0] += GetRandomFloat(radius*-1radius);
    
pos[1] += GetRandomFloat(radius*-1radius);
    
CreateExplosion(pos);
    return 
Plugin_Continue;
}

void CreateExplosion(float carPos[3])
{
    static 
char sRadius[1];
    static 
char sPower[1];
    
float flMxDistance 1.0;
    
float power 1.0;
    
IntToString(1sRadiussizeof(sRadius));
    
IntToString(1sPowersizeof(sPower));
    
int exTrace CreateEntityByName("info_particle_system");
    
int exPhys CreateEntityByName("env_physexplosion");
    
int exParticle CreateEntityByName("info_particle_system");
    
int exEntity CreateEntityByName("env_explosion");
    
    
DispatchKeyValue(exParticle"effect_name"EXPLOSION_PARTICLE);
    
DispatchSpawn(exParticle);
    
ActivateEntity(exParticle);
    
TeleportEntity(exParticlecarPosNULL_VECTORNULL_VECTOR);

    
DispatchKeyValue(exTrace"effect_name"FIRE_PARTICLE);
    
DispatchSpawn(exTrace);
    
ActivateEntity(exTrace);
    
TeleportEntity(exTracecarPosNULL_VECTORNULL_VECTOR);

    
DispatchKeyValue(exEntity"fireballsprite""sprites/muzzleflash4.vmt");
    
DispatchKeyValue(exEntity"iMagnitude"sPower);
    
DispatchKeyValue(exEntity"iRadiusOverride"sRadius);
    
DispatchKeyValue(exEntity"spawnflags""828");
    
DispatchSpawn(exEntity);
    
TeleportEntity(exEntitycarPosNULL_VECTORNULL_VECTOR);

    
DispatchKeyValue(exPhys"radius"sRadius);
    
DispatchKeyValue(exPhys"magnitude"sPower);
    
DispatchSpawn(exPhys);
    
TeleportEntity(exPhyscarPosNULL_VECTORNULL_VECTOR);
    
    
EmitAmbientGenericSound(carPosEXPLOSION_SOUND);
    
EmitAmbientGenericSound(carPosEXPLOSION_DEBRIS);
    
    
AcceptEntityInput(exParticle"Start");
    
AcceptEntityInput(exTrace"Start");
    
AcceptEntityInput(exEntity"Explode");
    
AcceptEntityInput(exPhys"Explode");
    
    
float duration 6.0;
    static 
char temp_str[64];
    
Format(temp_strsizeof(temp_str), "OnUser1 !self:Kill::%f:1"duration+1.5);
    
    
SetVariantString(temp_str);
    
AcceptEntityInput(exParticle"AddOutput");
    
AcceptEntityInput(exParticle"FireUser1");
    
SetVariantString(temp_str);
    
AcceptEntityInput(exEntity"AddOutput");
    
AcceptEntityInput(exEntity"FireUser1");
    
SetVariantString(temp_str);
    
AcceptEntityInput(exPhys"AddOutput");
    
AcceptEntityInput(exPhys"FireUser1");
    
    
Format(temp_strsizeof(temp_str), "OnUser1 !self:Stop::%f:1"duration);
    
SetVariantString(temp_str);
    
AcceptEntityInput(exTrace"AddOutput");
    
AcceptEntityInput(exTrace"FireUser1");
    
    
float survivorPos[3], traceVec[3], resultingFling[3], currentVelVec[3];
    for (
int i 1<= MaxClientsi++)
    {
        if (!
IsClientInGame(i) || !IsPlayerAlive(i)) continue;

        
GetEntPropVector(iProp_Data"m_vecOrigin"survivorPos);
        
        if (
GetVectorDistance(carPossurvivorPos) <= flMxDistance)
        {
            
MakeVectorFromPoints(carPossurvivorPostraceVec);
            
GetVectorAngles(traceVecresultingFling);
            
            
resultingFling[0] = Cosine(DegToRad(resultingFling[1])) * power;
            
resultingFling[1] = Sine(DegToRad(resultingFling[1])) * power;
            
resultingFling[2] = power;
            
            
GetEntPropVector(iProp_Data"m_vecVelocity"currentVelVec);
            
resultingFling[0] += currentVelVec[0];
            
resultingFling[1] += currentVelVec[1];
            
            
FlingPlayer(iresultingFlingi);
        }
    }
}

void EmitAmbientGenericSound(float pos[3], const char[] snd_str)
{
    
int snd_ent CreateEntityByName("ambient_generic");
    
    
TeleportEntity(snd_entposNULL_VECTORNULL_VECTOR);
    
DispatchKeyValue(snd_ent"message"snd_str);
    
DispatchKeyValue(snd_ent"health""10");
    
DispatchKeyValue(snd_ent"spawnflags""48");
    
DispatchSpawn(snd_ent);
    
ActivateEntity(snd_ent);
    
    
AcceptEntityInput(snd_ent"PlaySound");
    
AcceptEntityInput(snd_ent"Kill");
}

void FlingPlayer(int clientfloat vector[3], int attackerfloat stunTime 3.0)
{
    
SDKCall(sdkCallPushPlayerclientvector16attackerstunTime);
}

stock bool IsClientSurvivor (int client)
{
    return (
GetClientTeam(client) == 2);


Last edited by alasfourom; 07-23-2022 at 23:39.
alasfourom is offline
alasfourom
Senior Member
Join Date: Feb 2022
Location: Saudi Arabia
Old 07-24-2022 , 12:55   Re: [L4D2] Nuke - Timer Issue
Reply With Quote #16

After testing couple of times, the explosion is not starting but only sound effects + slaying

and these errors

PHP Code:
L 07/24/2022 19:49:33: [SMException reportedClient index 0 is invalid
L 07
/24/2022 19:49:33: [SMBlamingl4d2_nuke 1.1.1.smx
L 07
/24/2022 19:49:33: [SMCall stack trace:
L 07/24/2022 19:49:33: [SM]   [0GetClientAbsOrigin
L 07
/24/2022 19:49:33: [SM]   [1Line 171, /home/forums/content/files/2/5/6/7/1/3/195924.attach::Timer_Strike 
I will try to work it out later at night, thank you Grey83

Last edited by alasfourom; 07-24-2022 at 14:49.
alasfourom is offline
Grey83
Veteran Member
Join Date: Dec 2014
Location: Ukraine
Old 07-24-2022 , 16:36   Re: [L4D2] Nuke - Timer Issue
Reply With Quote #17

Quote:
Originally Posted by alasfourom View Post
PHP Code:
L 07/24/2022 19:49:33: [SMException reportedClient index 0 is invalid 
PHP Code:
public Action Timer_Strike(Handle timerany client)
{
    
float radius 1.0pos[3];
    for(
int i 1<= MaxClientsi++) if(IsClientSurvivor(ifalse))
    {
        
GetClientAbsOrigin(clientpos);
        
pos[0] += GetRandomFloat(radius*-1radius);
        
pos[1] += GetRandomFloat(radius*-1radius);
        
CreateExplosion(pos);
    }
    return 
Plugin_Continue;

==>
PHP Code:
public Action Timer_Strike(Handle timer)
{
    
float radius 1.0pos[3];
    for(
int i 1<= MaxClientsi++) if(IsClientSurvivor(ifalse))
    {
        
GetClientAbsOrigin(ipos);
        
pos[0] += GetRandomFloat(radius*-1radius);
        
pos[1] += GetRandomFloat(radius*-1radius);
        
CreateExplosion(pos);
    }
    return 
Plugin_Continue;

Attached Files
File Type: sp Get Plugin or Get Source (l4d2_nuke 1.1.1.sp - 62 views - 8.3 KB)
__________________

Last edited by Grey83; 07-24-2022 at 16:37.
Grey83 is offline
alasfourom
Senior Member
Join Date: Feb 2022
Location: Saudi Arabia
Old 07-24-2022 , 18:36   Re: [L4D2] Nuke - Timer Issue
Reply With Quote #18

Awww it was simple issue

Excellent Grey83, its now working 101%
alasfourom 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 15:50.


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