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

[CS:GO] Help with Timer and CSay


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Certified_GSD
New Member
Join Date: Aug 2015
Location: Minnesota
Old 01-23-2021 , 00:40   [CS:GO] Help with Timer and CSay
Reply With Quote #1

Hello Folks,


I'm trying to get a simple plugin together that just runs a timer on round_start and as soon as the timer passes, it will push a center message to all players similar to the !csay function of SourceMod. Specifically because it's very visible, and because CS:GO broadcasts this with a big red "ALERT!" as this message will specifically be marking a time for players that rules are changing mid-round.

I'm kind of stumped though. I've been Google'ing how SourceMod interacts with the game and trying to read through the source code of other programs that utilize the center text box but I can't quite figure out how to do that here. This center message also goes away after a set amount of time, is there a way I can have it stay up in the player's HUD until the end of the round?


I'm also not sure how to tell the plugin to look for round_end but to stick around and keep listening for the next round_start and do it all over again. Thanks! I appreciate the help!


Code:
#include <sourcemod>

public Plugin myinfo =
{
	name = "Overtime Alert",
	author = "reDrocket",
	description = "Sets Overtime Alert in CS:GO",
	version = "1.0",
	url = "x"
};

public OnPluginStart()
{
    HookEvent("round_start", OnRoundStart, EventHookMode_PostNoCopy);
}

public OnRoundStart(Handle:event, const String:name[], bool:dontBroadcast)
{
    CreateTimer(210.0, otalert);
} 

public Action otalert(Handle timer)
{
	DisplayCenterTextToAll(
Certified_GSD is offline
FroGeX
Senior Member
Join Date: Aug 2020
Old 01-23-2021 , 01:57   Re: [CS:GO] Help with Timer and CSay
Reply With Quote #2

https://sourcemod.dev/#/halflife/fun...tHintTextToAll
FroGeX is offline
Certified_GSD
New Member
Join Date: Aug 2015
Location: Minnesota
Old 01-23-2021 , 20:07   Re: [CS:GO] Help with Timer and CSay
Reply With Quote #3

Quote:
Originally Posted by FroGeX View Post

Thanks, that's a good resource to use.


I did get the code to work using this:
PHP Code:
#include <sourcemod>

public Plugin myinfo =
{
    
name "Overtime Alert",
    
author "reDrocket",
    
description "Sets Overtime Alert in CSGO",
    
version "1.0",
    
url "http://foxholegaming.net/"
};

public 
OnPluginStart()
{
    
HookEvent("round_start"OnRoundStartEventHookMode_PostNoCopy);
}

public 
OnRoundStart(Handle:event, const String:name[], bool:dontBroadcast)
{
    
CreateTimer(240.0otalert);


public 
Action otalert(Handle timer)
{
for (new 
1<= MaxClientsi++)
    {
        if(
IsClientInGame(i) && !IsFakeClient(i))
        
PrintCenterText(i"%s""OVERTIME! Live Check and Kill on Sus Allowed!");
    } 



However, it only shows the message once and quickly disappears. I'm using the SourceMod Timers wiki entry to try and figure out how to get a second timer to run after the first and continue to ping the command for a lot longer but while no error shows in SourceMod, no command is pushed out.

What exactly am I doing wrong here?

PHP Code:

#include <sourcemod>

public Plugin myinfo =
{
    
name "Overtime Alert",
    
author "reDrocket",
    
description "Sets Overtime Alert in CSGO",
    
version "1.0",
    
url "http://foxholegaming.net/"
};

public 
OnPluginStart()
{
    
HookEvent("round_start"OnRoundStartEventHookMode_PostNoCopy);
}

public 
OnRoundStart(Handle:event, const String:name[], bool:dontBroadcast)
{
    
CreateTimer(50alert);
}

public 
Action alert(Handle timer)
{
    
CreateTimer(3.0repeater_TIMER_REPEAT);


public 
Action repeater(Handle timer)
{
   
// Create a global variable visible only in the local scope (this function).
    
static int numPrinted 0;
 
    if (
numPrinted >= 15
    {
        
numPrinted 0;
        return 
Plugin_Stop;
    }

    for (new 
1<= MaxClientsi++)
    {
        if(
IsClientInGame(i) && !IsFakeClient(i))
        
PrintCenterText(i"%s""OVERTIME! Live Check and Kill on Sus Allowed!");
        
numPrinted++;
    } 
 
    return 
Plugin_Continue;

Certified_GSD 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:09.


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