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

[CSGO] Need help with a plugin


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
ItsExTacY
Member
Join Date: Jul 2017
Location: Israel
Old 12-20-2018 , 12:51   [CSGO] Need help with a plugin
Reply With Quote #1

Hello guys, I tried to created a plugin that check:
If there is less then 2 players start and pause warmup
And if there is more then 2 players the round will continue normaly.
At the start the plugin worked fine but then we figure out that if there is 2 players and one of them log off it doesnt start warmup.
Thanks if someone can help me fix the code
I have to mention that we have warmup on round start.

PHP Code:
public void OnPluginStart() {
    
HookEvent("player_spawn"Event_PlayerSpawn);
}
   
public 
Action Event_PlayerSpawn(Event event, const char[] namebool dontBroadcost) {
    if(
GetClientCount() < 2){
        
ServerCommand("mp_warmup_pausetimer 1");
    }
    else {
        
ServerCommand("mp_warmup_pausetimer 0");
    }

ItsExTacY is offline
Drixevel
AlliedModders Donor
Join Date: Sep 2009
Location: Somewhere headbangin'
Old 12-20-2018 , 13:51   Re: [CSGO] Need help with a plugin
Reply With Quote #2

Code:
public void OnClientPutInServer(int client)
{
	ServerCommand("mp_warmup_pausetimer %i", GetClientCount() < 2 ? "1" : "0");
}

public void OnClientDisconnect(int client)
{
	ServerCommand("mp_warmup_pausetimer %i", GetClientCount() < 2 ? "1" : "0");
}
Not 100% sure this would work but this makes more sense to me.
Drixevel is offline
ItsExTacY
Member
Join Date: Jul 2017
Location: Israel
Old 12-20-2018 , 13:56   Re: [CSGO] Need help with a plugin
Reply With Quote #3

Quote:
Originally Posted by Drixevel View Post
Code:
public void OnClientPutInServer(int client)
{
	ServerCommand("mp_warmup_pausetimer %i", GetClientCount() < 2 ? "1" : "0");
}

public void OnClientDisconnect(int client)
{
	ServerCommand("mp_warmup_pausetimer %i", GetClientCount() < 2 ? "1" : "0");
}
Not 100% sure this would work but this makes more sense to me.
Thanks, but i need it to also start somewhere the warmup not only pause it. but whenever i tried it it just spammed the console and crashed the server
ItsExTacY is offline
eyal282
Veteran Member
Join Date: Aug 2011
Old 12-22-2018 , 11:14   Re: [CSGO] Need help with a plugin
Reply With Quote #4

This code starts a warmup to end after 2 minutes ( I think )
Code:
public void OnPluginStart()
{
	HookEvent("round_start", Event_RoundStart, EventHookMode_PostNoCopy);
}
public Action Event_RoundStart(Handle hEvent, const char[] Name, bool dontBroadcast)
{
	float WarmupDuration = 120.0; // Warmup duration in seconds.
	float GameTime = GetGameTime();
	GameRules_SetProp("m_bWarmupPeriod", 1);
	GameRules_SetProp("m_fWarmupPeriodStart ", GameTime);
	GameRules_SetProp("m_fWarmupPeriodEnd ", GameTime + WarmupDuration);
}

I did not compile this, might not even compile.
__________________
I am available to make plugins for pay.

Discord: Eyal282#1334

Last edited by eyal282; 12-22-2018 at 11:14.
eyal282 is offline
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 12-24-2018 , 13:14   Re: [CSGO] Need help with a plugin
Reply With Quote #5

I'm not sure I follow OP post correctly...
- When there is 2 players, warmup should continue and match start.
- When there is 1 player, warmup pause and also start warmup.
right ?

*edit
Ok, you need these cvars set in gamemode config
Code:
mp_warmuptime 7 // min. 7sec or warmup ends immediatelly, longer time is better
mp_warmup_pausetimer 1 // pause warmup after map change
PHP Code:
/*
Server event "switch_team", Tick 37719:
- "numPlayers" = "0"
- "numSpectators" = "1"
- "avg_rank" = "0"
- "numTSlotsFree" = "10"
- "numCTSlotsFree" = "10"
*/
#include <sdktools>
public void OnPluginStart()
{
    
HookEvent("switch_team"switch_team);
}

public 
void switch_team(Event event, const char[]name bool dontBroadcast)
{
    
// This event (switch_team) not count bots

    
static int numPlayers_previous;
    
int m_bWarmupPeriod GameRules_GetProp("m_bWarmupPeriod");

    if(
m_bWarmupPeriodPrintToChatAll(" \x02[SM] Warmup: Need 2 or more players to start match.");


    
int numPlayers event.GetInt("numPlayers");
    
//int numSpectators = event.GetInt("numSpectators");
    //int numTSlotsFree = event.GetInt("numTSlotsFree");
    //int numCTSlotsFree = event.GetInt("numCTSlotsFree");

    
if(!m_bWarmupPeriod && numPlayers <= && numPlayers_previous numPlayers)
    {
        
PrintToChatAll(" \x02[SM] Warmup: Need 2 or more players to start match.");
        
ServerCommand("mp_warmup_pausetimer 1");
        
ServerCommand("mp_warmup_start");
    }

    if(
m_bWarmupPeriod && numPlayers >= && numPlayers_previous numPlayers)
    {
        
ServerCommand("mp_warmup_pausetimer 0");
    }

    
numPlayers_previous numPlayers;

__________________
Do not Private Message @me

Last edited by Bacardi; 12-24-2018 at 13:58. Reason: misread player count
Bacardi 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 02:10.


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