Raised This Month: $ Target: $400
 0% 

Please help me to complete it.


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
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
 



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:30.


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