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

no need for this


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
AlexFlaviu
Junior Member
Join Date: Aug 2018
Old 08-28-2023 , 03:04   no need for this
Reply With Quote #1

no need for this

Last edited by AlexFlaviu; 09-12-2023 at 01:27. Reason: no need for this
AlexFlaviu is offline
fat0nix
Junior Member
Join Date: Dec 2022
Location: Kosovo
Old 08-29-2023 , 05:30   Re: New Request
Reply With Quote #2

#include <sourcemod>

bool blockPlanting = false; // Flag to block bomb planting
float roundEndTime = 0.0; // Time when the round ended
float delayTime = 10.0; // Time in seconds to block planting after round end

public void OnPluginStart()
{
HookEvent("round_end", Event_RoundEnd);
HookEvent("bomb_plant", Event_BombPlant);
}

public Action Event_RoundEnd(Event event, const char[] name, bool dontBroadcast)
{
blockPlanting = true;
roundEndTime = GetGameTime();
CreateTimer(delayTime, Timer_ResetBlockPlanting);
return Plugin_Continue;
}

public Action Event_BombPlant(Event event, const char[] name, bool dontBroadcast)
{
if (blockPlanting && (GetGameTime() - roundEndTime) < delayTime)
{
int client = GetClientOfUserId(event.GetInt("userid"));
PrintToChat(client, "You cannot plant the bomb right now.");
return Plugin_Handled;
}
return Plugin_Continue;
}

public Action Timer_ResetBlockPlanting(Handle timer, any data)
{
blockPlanting = false;
return Plugin_Stop;
}
fat0nix is offline
Teamkiller324
Senior Member
Join Date: Feb 2014
Location: Earth
Old 08-29-2023 , 16:16   Re: New Request
Reply With Quote #3

Quote:
Originally Posted by AlexFlaviu View Post
thank you sooo much, is working!!!!
One thing. could you please do that when there is 0 cts alive, the bomb still can not be planted?like to only be able to plant ONLY when they are still at least 1 ct ALIVE
THANK YOU!!!!
This should do the work

Code:
#pragma semicolon 1
#pragma newdecls required
#define Version "1.0.1"
#include <sdktools>

public Plugin myinfo =
{
	name = "Prevent bomb plant on round end.",
	author = "fat0nix, Teamkiller324",
	description = "Prevents bomb being planted on round end if CTs are alive.",
	version = Version,
	url = "https://forums.alliedmods.net/showthread.php?t=343763"
}

bool bPreventPlant = false; // Flag to block bomb planting
float bPreventPlantTime = 0.0; // Time when the round ended
float bPreventPlantDelay = 10.0; // Time in seconds to block planting after round end

public void OnMapStart()
{
	bPreventPlant = false;
	bPreventPlantTime = 0.0;
}

public void OnPluginStart()
{
	HookEvent("round_end", Event_RoundEnd);
	HookEvent("bomb_plant", Event_BombPlant, EventHookMode_Pre);
}

public Action Event_RoundEnd(Event event, const char[] event_name, bool dontBroadcast)
{
	bPreventPlant = true;
	bPreventPlantTime = GetGameTime();
	CreateTimer(bPreventPlantDelay, Timer_ResetBlockPlanting);
	return Plugin_Continue;
}

Action Event_BombPlant(Event event, const char[] event_name, bool dontBroadcast)
{
	if(!bPreventPlant)
	{
		return Plugin_Continue;
	}
	
	int userid = event.GetInt("userid");
	if(userid < 1)
	{
		return Plugin_Continue;
	}
	
	int CTsAlive;
	if((CTsAlive = GetAliveCTPlayers()) < 1)
	{
		return Plugin_Continue;
	}
	
	if((GetGameTime() - bPreventPlantTime) < bPreventPlantDelay)
	{
		int client;
		if(IsValidClient((client = GetClientOfUserId(userid))))
		{
			PrintToChat(client, "You may not plant the bomb right now, there are %i CTs alive.", CTsAlive);
			return Plugin_Handled;
		}
	}
	
	return Plugin_Continue;
}

Action Timer_ResetBlockPlanting(Handle timer)
{
	bPreventPlant = false;
	return Plugin_Stop;
}

bool IsValidClient(int client)
{
	if(client < 1 || client > MAXPLAYERS)
	{
		return false;
	}
	
	if(!IsClientConnected(client))
	{
		return false;
	}
	
	if(!IsClientInGame(client))
	{
		return false;
	}
	
	if(IsClientSourceTV(client))
	{
		return false;
	}
	
	if(IsClientReplay(client))
	{
		return false;
	}
	
	return true;
}

int GetAliveCTPlayers()
{
	int count;
	int player;
	
	while((player = FindEntityByClassname(player, "player")) != -1)
	{
		if(IsValidClient(player))
		{
			if(GetEntProp(player, Prop_Send, "m_iTeamNum") == 3)
			{
				if(IsPlayerAlive(player))
				{
					count++;
				}
			}
		}
	}
	
	return count;
}
Attached Files
File Type: sp Get Plugin or Get Source (cs_plant_block.sp - 38 views - 2.4 KB)
__________________

Last edited by Teamkiller324; 08-29-2023 at 16:17.
Teamkiller324 is offline
Grey83
Veteran Member
Join Date: Dec 2014
Location: Ukraine
Old 08-30-2023 , 09:26   Re: New Request
Reply With Quote #4

Quote:
Originally Posted by AlexFlaviu View Post
Exception reported: Game event "bomb_plant" does not
exist
The event is called "bomb_planted":
https://wiki.alliedmods.net/Counter-...s#bomb_planted
__________________
Grey83 is offline
Grey83
Veteran Member
Join Date: Dec 2014
Location: Ukraine
Old 09-01-2023 , 07:33   Re: New Request
Reply With Quote #5

AlexFlaviu, try this
Attached Files
File Type: sp Get Plugin or Get Source (sm_bomb_plant_control 1.0.0_01.09.2023.sp - 31 views - 1.9 KB)
__________________
Grey83 is offline
Grey83
Veteran Member
Join Date: Dec 2014
Location: Ukraine
Old 09-01-2023 , 11:14   Re: New Request
Reply With Quote #6

AlexFlaviu, you can try remove all functions after timer Timer_Reset: OnEntityCreated() and C4_Spawn()
PHP Code:
#pragma semicolon 1
#pragma newdecls required

#include <sdktools_entinput>
#include <sdktools_functions>
#include <sdktools_gamerules>

bool bCheck;

public 
Plugin myinfo =
{
    
name        "Bomb plant control",
    
version        "1.0.1_01.09.2023",
    
description    "Prevents the bomb from being planted after the round ends",
    
author        "Grey83",
    
url            "https://steamcommunity.com/groups/grey83ds"
}

public 
void OnMapStart()
{
    static 
bool check;
    if(
check == !!GameRules_GetProp("m_bMapHasBombTarget"))
        return;

    if((
check ^= true))
    {
        
HookEvent("round_start"Event_ToggleEventHookMode_PostNoCopy);
        
HookEvent("round_end"Event_ToggleEventHookMode_PostNoCopy);
        
HookEvent("bomb_planted"Event_ToggleEventHookMode_PostNoCopy);
    }
    else
    {
        
UnhookEvent("round_start"Event_ToggleEventHookMode_PostNoCopy);
        
UnhookEvent("round_end"Event_ToggleEventHookMode_PostNoCopy);
        
UnhookEvent("bomb_planted"Event_ToggleEventHookMode_PostNoCopy);
    }
}

public 
void Event_Toggle(Event event, const char[] namebool dontBroadcast)
{
    if(
name[6] != 's')
        return;

    
int i MaxClients+1;
    while((
FindEntityByClassname(i"weapon_c4")) != -1AcceptEntityInput(i"Kill");

__________________

Last edited by Grey83; 09-01-2023 at 11:17.
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 16:02.


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