Заказать игровой сервер Контакты (заказать плагин/исправить ошибки/другое) Поиск

[ вход ]
[ последние сообщения ]

  • Страница 1 из 1
  • 1
Форум » SourceMod >> CS:Source >> CSGO » Обсуждение » AntiStuck
AntiStuck
Shulgin123233 Дата: Четверг, 13.08.2015, 18:16:00 | Сообщение # 1
Сообщений: 3
Репутация: 0 [ +/- ]
Здравствуйте, хотел бы попросить помощи.
В плагине AntiStuck надо сделать проверку на команду mp_solid_teammates и если она равна 0, то вывести определённый текст вместо действия.

Оригинальный исходник
Код

#include <sourcemod>
#include <sdktools>

#define PLUGIN_VERSION "1.00"
#define PREFIX "\x03[AntiStuck]\x01"

public Plugin:myinfo =
{
  name = "Anti Stuck",
  author = "muso.sk",
  description = "Allows players to push them away from stucked player",
  version = PLUGIN_VERSION,
  url = ""
};

new TimerActive;

#define COLLISION_GROUP_PUSHAWAY            17
#define COLLISION_GROUP_PLAYER              5

public OnPluginStart()
{
  RegConsoleCmd("sm_stuck", Command_Stuck);
}

public Action:Command_Stuck(client, args)
{
  if (IsClientInGame(client) && IsPlayerAlive(client) && TimerActive == 0)
  {
   PrintToChatAll("%s Unstucked all players", PREFIX);  
   TimerActive = 1;
   CreateTimer(1.0, Timer_UnBlockPlayer, client);
    
   for (new i = 1; i <= MaxClients; i++)
   {  
    if (IsClientInGame(i) && IsPlayerAlive(i))
    {
     EnableAntiStuck(i);
    }
   }
  }
  else if (TimerActive == 1)
  {
   PrintToChat(client, "%s Command is already in use", PREFIX);
  }
  else
  {
   PrintToChat(client, "%s You must be alive to use this command", PREFIX);
  }
   
  return Plugin_Handled;
   
}

public Action:Timer_UnBlockPlayer(Handle:timer, any:client)
{
  TimerActive = 0;
   
  for (new i = 1; i <= MaxClients; i++)
  {  
   if (IsClientInGame(i) && IsPlayerAlive(i))
   {
    DisableAntiStuck(i);
   }
  }
   
  return Plugin_Continue;
   
}

DisableAntiStuck(client)
{
  SetEntProp(client, Prop_Data, "m_CollisionGroup", COLLISION_GROUP_PLAYER);
}

EnableAntiStuck(client)
{
  SetEntProp(client, Prop_Data, "m_CollisionGroup", COLLISION_GROUP_PUSHAWAY);
}


Наш исходник, который не работает
Код

#include <sourcemod>
#include <sdktools>

#define PLUGIN_VERSION "1.00"
#define PREFIX "\x03[AntiStuck]\x01"

public Plugin:myinfo =
{
  name = "Anti Stuck",
  author = "muso.sk",
  description = "Allows players to push them away from stucked player",
  version = PLUGIN_VERSION,
  url = ""
};

new TimerActive;
ConVar g_cvNoBlock

#define COLLISION_GROUP_PUSHAWAY            17
#define COLLISION_GROUP_PLAYER              5

public OnPluginStart()
{
  RegConsoleCmd("sm_stuck", Command_Stuck);
}

public Action:Command_Stuck(client, args)
{
     g_cvNoBlock = FindConVar("mp_solid_teammates")
  if (IsClientInGame(client) && IsPlayerAlive(client) && TimerActive == 0 && g_cvNoBlock == 1 )
  {
   PrintToChatAll("%s Unstucked all players", PREFIX);  
   TimerActive = 1;
   CreateTimer(1.0, Timer_UnBlockPlayer, client);
    
   for (new i = 1; i <= MaxClients; i++)
   {  
    if (IsClientInGame(i) && IsPlayerAlive(i))
    {
     EnableAntiStuck(i);
    }
   }
  }
  else if (TimerActive == 1)
  {
   PrintToChat(client, "%s Command is already in use", PREFIX);
  }
  else if (g_cvNoBlock == 0)
  {
   PrintToChat(client, "%s Стоит ноу-блок!", PREFIX);
  }
  else if (IsPlayerDead(client))
  {
   PrintToChat(client, "%s You must be alive to use this command", PREFIX);
  }
   
  return Plugin_Handled;
   
}

public Action:Timer_UnBlockPlayer(Handle:timer, any:client)
{
  TimerActive = 0;
   
  for (new i = 1; i <= MaxClients; i++)
  {  
   if (IsClientInGame(i) && IsPlayerAlive(i))
   {
    DisableAntiStuck(i);
   }
  }
   
  return Plugin_Continue;
   
}

DisableAntiStuck(client)
{
  SetEntProp(client, Prop_Data, "m_CollisionGroup", COLLISION_GROUP_PLAYER);
}

EnableAntiStuck(client)
{
  SetEntProp(client, Prop_Data, "m_CollisionGroup", COLLISION_GROUP_PUSHAWAY);
}
 
Scarface_slv Дата: Пятница, 14.08.2015, 16:08:59 | Сообщение # 2
Сообщений: 737
Репутация: 61 [ +/- ]
Создаешь глобальную переменную рядом с new TimerActive; например new g_iSolid;
В OnPluginStart() хукаешь квар. В общем добавляешь туда это
HookConVarChange(FindConVar("mp_solid_teammates"), ChangeCvarSolid);
Далее добавляешь блок ChangeCvarSolid и при любом изменение квара плагин будет менять переменную g_iSolid
public ChangeCvarSolid(Handle:cvar, const String:oldVal[], const String:newVal[])
{
g_iSolid = GetConVarInt(cvar);
}
Дальше где тебе нужно создаешь проверку
if(g_iSolid == 0) если равен нулю, то PrintToChat(client, "Команда не доступна");
-------------------------------
Объяснил как мог vshapke
 
Shulgin123233 Дата: Воскресенье, 16.08.2015, 12:43:23 | Сообщение # 3
Сообщений: 3
Репутация: 0 [ +/- ]
Код

#include <sourcemod>
#include <sdktools>

#define PLUGIN_VERSION "1.00"
#define PREFIX "\x03[AntiStuck]\x01"

public Plugin:myinfo =
{
  name = "Anti Stuck",
  author = "muso.sk",
  description = "Allows players to push them away from stucked player",
  version = PLUGIN_VERSION,
  url = ""
};

new TimerActive;
new g_iSolid;

#define COLLISION_GROUP_PUSHAWAY            17
#define COLLISION_GROUP_PLAYER              5

public OnPluginStart()
{
  RegConsoleCmd("sm_stuck", Command_Stuck);
  HookConVarChange(FindConVar("mp_solid_teammates"), ChangeCvarSolid);  
}

public ChangeCvarSolid(Handle:cvar, const String:oldVal[], const String:newVal[])  
{  
g_iSolid = GetConVarInt(cvar);  
}  

public Action:Command_Stuck(client, args)
{
  if (IsClientInGame(client) && IsPlayerAlive(client) && TimerActive == 0 && g_iSolid == 1)
  {
   PrintToChatAll("%s Unstucked all players", PREFIX);  
   TimerActive = 1;
   CreateTimer(1.0, Timer_UnBlockPlayer, client);
    
   for (new i = 1; i <= MaxClients; i++)
   {  
    if (IsClientInGame(i) && IsPlayerAlive(i))
    {
     EnableAntiStuck(i);
    }
   }
  }
  else if (TimerActive == 1)
  {
   PrintToChat(client, "%s Command is already in use", PREFIX);
  }
  else if (g_iSolid == 0)
  {
   PrintToChat(client, "%s Включён No-Block", PREFIX);
  }
  else
  {
   PrintToChat(client, "%s You must be alive to use this command", PREFIX);
  }
   
  return Plugin_Handled;
   
}

public Action:Timer_UnBlockPlayer(Handle:timer, any:client)
{
  TimerActive = 0;
   
  for (new i = 1; i <= MaxClients; i++)
  {  
   if (IsClientInGame(i) && IsPlayerAlive(i))
   {
    DisableAntiStuck(i);
   }
  }
   
  return Plugin_Continue;
   
}

DisableAntiStuck(client)
{
  SetEntProp(client, Prop_Data, "m_CollisionGroup", COLLISION_GROUP_PLAYER);
}

EnableAntiStuck(client)
{
  SetEntProp(client, Prop_Data, "m_CollisionGroup", COLLISION_GROUP_PUSHAWAY);
}

Получилось так, но в любом случае " Включён No-Block"
 
Форум » SourceMod >> CS:Source >> CSGO » Обсуждение » AntiStuck
  • Страница 1 из 1
  • 1
Поиск: