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

Please help me to complete it.


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Rain_Effect
New Member
Join Date: Mar 2019
Location: China(GuangDong GuangZho
Old 03-10-2019 , 14:01   Please help me to complete it.
Reply With Quote #1

I am learning the plugin, but my plugin is not working properly at the time of production.

This plugins will be use in my "DangerZone Mode Server", Please help.

Code:
#include <sourcemod>
#include <cstrike>
#include <clientprefs>

#define LoopClients(%1) for(int %1 = 1;%1 <= MaxClients;%1++) if(IsValidClient(%1))

new Handle:PluginEnabled = INVALID_HANDLE;
new Handle:WarmupTime = INVALID_HANDLE;
new Handle:PlayerCountStart = INVALID_HANDLE;
new Handle:WarmupBack = INVALID_HANDLE;
new bool:IsWarmup;
new bool:ToWarmup;
int ToWarmupTime = 0;

public Plugin:myinfo =
{
 name = "[CS:GO] Warmup Lobby",
 author = "Rain_Effect",
 description = "Keeps game in warmup untill specified number of players to start.",
 version = "1.0",
 url = "http://mc-rain.cn/"
};

public OnPluginStart()
{
 PluginEnabled = CreateConVar("sm_warmup_lobby_enabled", "1", "Whether the plugin is enabled");
 WarmupTime = CreateConVar("sm_warmup_lobby_time", "140", "Warmup time after players have connected");
 PlayerCountStart = CreateConVar("sm_warmup_lobby_players_start", "2", "Number of players to end warmup");
 WarmupBack = CreateConVar("sm_warmup_lobby_end_back", "10", "How long to back warmup when a round end");
 AutoExecConfig(true, "warmup_lobby");
 IsWarmup = false;
 CreateTimer(1.0, Timer_GlobalTimer, _, TIMER_REPEAT|TIMER_FLAG_NO_MAPCHANGE);
}

public Action Timer_GlobalTimer(Handle timer)
{
 if(IsWarmup)
 {
  LoopClients(i)
  {
   PrintHintText(i, "[WarmUp Lobby]<br>Need ",GetConVarInt(PlayerCountStart), player(s) to"<br>start the game!");
  }
 }
 if(ToWarmup)
 {
  if(ToWarmupTime<0)
  {
   LoopClients(i)
   {
    PrintHintText(i, "[WarmUp Lobby]<br>Game will be reset<br>in ",ToWarmupTime," seconds!");
   }
   ToWarmupTime=ToWarmupTime-1;
  }
  else
  {
   ServerCommand("mp_warmup_start;");
   ToWarmup = false;
  }
 }
 return Plugin_Continue;
}

public OnClientPutInServer(client)
{
 CheckCount();
}

public OnClientDisconnect_Post()
{
 CheckCount();
}

public CheckCount()
{
 if(GetConVarBool(PluginEnabled))
 {
  SetConVarInt(FindConVar("mp_warmuptime"), GetConVarInt(WarmupTime));
  SetConVarInt(FindConVar("mp_do_warmup_period"), 1);
  if(GetClientCount(true) < GetConVarInt(PlayerCountStart))
  {
   if(!IsWarmup)
   {
    ServerCommand("mp_warmup_start;");
    IsWarmup = true;
   }
   ServerCommand("mp_warmup_pausetimer 1");
  }
  else
  {
   ServerCommand("mp_warmup_pausetimer 0");
  }
 }
}

public round_start()
{
 if(IsWarmup)
 IsWarmup = false;
}

public round_end()
{
 ToWarmupTime = GetConVarInt(WarmupBack);
 ToWarmup = true;
}

stock bool IsValidClient(int client, bool alive = false)
{
 if(0 < client && client <= MaxClients && IsClientInGame(client) && IsFakeClient(client) == false && (alive == false || IsPlayerAlive(client))) return true;
 return false;
}
Rain_Effect is offline
impossible_cc
Senior Member
Join Date: Sep 2018
Location: Ukraine
Old 03-11-2019 , 16:18   Re: Please help me to complete it.
Reply With Quote #2

PHP Code:
CreateTimer(1.0Timer_GlobalTimer_TIMER_REPEAT/*|TIMER_FLAG_NO_MAPCHANGE*/); 
You create timer OnPluginStart, instead of OnMapStart, so you don't need to destroy at map end.

Last edited by impossible_cc; 03-11-2019 at 16:19.
impossible_cc is offline
Dragokas
Veteran Member
Join Date: Nov 2017
Location: Ukraine on fire
Old 03-13-2019 , 09:49   Re: Please help me to complete it.
Reply With Quote #3

When server is going to freeze timers will be killed. So, your repeatable timer created in OnMapStart forward will not work.
__________________
Expert of CMD/VBS/VB6. Malware analyst. L4D fun (Bloody Witch & FreeZone)
[My plugins] [My tools] [GitHub] [Articles] [HiJackThis+] [Donate]
Dragokas 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 20:13.


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