cangncan
Участник
- Сообщения
- 69
- Реакции
- 4
Есть два плагина c4_for_all и buyc4.
Необходимо добавить в плагин "c4_for_all" проверку на карты (DE). Такая проверка присутствует в плагине "buyc4".
Помогите сделать задуманное:)
Вот сам исходный код плагинов:
c4_for_all:
buyc4:
Необходимо добавить в плагин "c4_for_all" проверку на карты (DE). Такая проверка присутствует в плагине "buyc4".
Помогите сделать задуманное:)
Вот сам исходный код плагинов:
c4_for_all:
PHP:
#pragma semicolon 1
#include <sourcemod>
#include <sdktools_functions>
public Plugin:myinfo =
{
name = "c4_for_all",
author = "wS / Schmidt",
description = "Бомба для каждого террориста",
version = "1.1",
url = "http://♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥"
};
new Handle:cfa_clear_c4,
Handle:cfa_give_c4_timer,
Handle:sv_cheats,
Handle:TIMER;
new bool:c4_planted;
public OnPluginStart()
{
cfa_clear_c4 = CreateConVar("cfa_clear_c4", "1.0", "1 = если бомба установлена, удалить все другие, 0 = нет", FCVAR_NOTIFY, true, 0.0, true, 1.0);
cfa_give_c4_timer = CreateConVar("cfa_give_c4_timer", "10.0", "Дать всем террористам бомбу через 'x' сек после начала раунда", FCVAR_NOTIFY, true, 1.0);
CreateConVar("c4_for_all", "1.1", "c4_for_all version [ Plugin by wS ]", FCVAR_NOTIFY);
HookEvent("bomb_planted", bomb_planted, EventHookMode_PostNoCopy);
HookEvent("round_start", round_start, EventHookMode_PostNoCopy);
sv_cheats = FindConVar("sv_cheats");
SetConVarFlags(sv_cheats, GetConVarFlags(sv_cheats) & ~FCVAR_NOTIFY);
}
public bomb_planted(Handle:event, const String:name[], bool:dontBroadcast)
{
c4_planted = true;
if (GetConVarBool(cfa_clear_c4))
{
new bool:value = GetConVarBool(sv_cheats);
ServerCommand(value ? "ent_remove_all weapon_c4" : "sv_cheats 1;ent_remove_all weapon_c4;sv_cheats 0");
}
}
public round_start(Handle:event, const String:name[], bool:dontBroadcast)
{
c4_planted = false;
if (TIMER != INVALID_HANDLE) KillTimer(TIMER);
TIMER = CreateTimer(GetConVarFloat(cfa_give_c4_timer), TryGiveC4);
}
public Action:TryGiveC4(Handle:timer)
{
TIMER = INVALID_HANDLE;
if (c4_planted) return;
for (new i = 1; i <= MaxClients; i++)
{
if (IsClientInGame(i) && IsPlayerAlive(i) && GetClientTeam(i) == 2 && GetPlayerWeaponSlot(i, 4) < 1)
{
GivePlayerItem(i, "weapon_c4");
}
}
}
PHP:
#include <sourcemod>
#include <sdktools>
#include <morecolors>
#define PLUGIN_VERSION "0.5"
new Handle:buyc4_enabled = INVALID_HANDLE;
new Handle:buyc4_cost = INVALID_HANDLE;
new Handle:buyc4_chatannounce = INVALID_HANDLE;
new Handle:buyc4_onlybombmaps = INVALID_HANDLE;
new Handle:buyc4_limit = INVALID_HANDLE;
new Handle:mp_buytime = INVALID_HANDLE;
new Float:buytime;
new Float:roundfreezeend;
new bool:enable;
new count;
public Plugin:myinfo =
{
name = "[CSS] Buy C4",
author = "Bacardi",
description = "Terrorist can buy C4 bomb",
version = PLUGIN_VERSION,
url = "www.sourcemod.net"
}
public OnPluginStart()
{
LoadTranslations("buyc4.phrases");
RegAdminCmd("sm_buyc4", Cmd_BuyC4, ADMFLAG_SLAY, "Terrorist can buy C4 from buy zone"); // Create command
RegAdminCmd("sm_bum", Cmd_BuyC4, ADMFLAG_SLAY, "Terrorist can buy C4 from buy zone [2]"); // Create command
buyc4_enabled = CreateConVar("buyc4_enabled", "1", "When enabled, TERRORIST can buy C4 bomb", _, true, 0.0, true, 1.0); // Create cvar
buyc4_cost = CreateConVar("buyc4_cost", "13000", "Set price to weapon C4 bomb", _, true, 0.0, true, 16000.0); // Create cvar
buyc4_chatannounce = CreateConVar("buyc4_chatannounce", "1", "Print in chat announce to terrorist when round start", _, true, 0.0, true, 1.0); // Create cvar
buyc4_onlybombmaps = CreateConVar("buyc4_onlybombmaps", "1", "Works only maps where bomb site", _, true, 0.0, true, 1.0); // Create cvar
buyc4_limit = CreateConVar("buyc4_limit", "0", "Limit the number of bombs, 0 = unlimited", _, true, 0.0); // Create cvar
mp_buytime = FindConVar("mp_buytime"); // To Hook cvar from srcds
buytime = GetConVarFloat(FindConVar("mp_buytime"))*60; // Convert minutes to seconds
HookEvent("round_start", Event_RoundStart, EventHookMode_PostNoCopy);
HookEvent("round_freeze_end", Event_RoundFreezeEnd, EventHookMode_PostNoCopy);
HookConVarChange(mp_buytime, buytimechanged); // Check cvar change
}
public OnMapStart()
{
if(GetConVarBool(buyc4_onlybombmaps) && FindEntityByClassname(-1, "func_bomb_target") == -1) // cvar 'buyc4_onlybombmaps' enabled and current map have not bomb plant site
{
enable = false;
}
else // cvar 'buyc4_onlybombmaps' disabled (or cvar 'buyc4_onlybombmaps' enabled and bomb plant site exist)
{
enable = true;
}
}
public Event_RoundStart(Handle:event, const String:name[], bool:dontBroadcast)
{
if(enable && GetConVarBool(buyc4_enabled))
{
roundfreezeend = GetGameTime(); // Get current map time
count = 0; // Reset counter
if(GetConVarBool(buyc4_chatannounce))
{
for (new i = 1; i <= MaxClients; i++)
{
if (IsClientInGame(i) && GetClientTeam(i) == 2 && CheckCommandAccess(i, "sm_buyc4", ADMFLAG_SLAY))
{
new price = GetConVarInt(buyc4_cost);
if(price > 0)
{
CPrintToChat(i, "[SM] %t", "C4_Cost", price);
}
else
{
CPrintToChat(i, "[SM] %t", "C4_Cost_Free");
}
}
}
}
}
}
public Event_RoundFreezeEnd(Handle:event, const String:name[], bool:dontBroadcast)
{
if(enable && GetConVarBool(buyc4_enabled))
{
roundfreezeend = GetGameTime(); // Get current map time
}
}
public Action:Cmd_BuyC4(client, arg)
{
if(enable)
{
if(client == 0) // Prevent command usage from server input and via RCON
{
PrintToConsole(client, "Can't use this command from server input");
return Plugin_Handled;
}
if(!GetConVarBool(buyc4_enabled))
{
PrintToConsole(client, "[SM] Buy C4 is disabled");
return Plugin_Handled;
}
if(GetClientTeam(client) == 2 && GetEntProp(client, Prop_Send, "m_bInBuyZone") == 1) // Client is TERRORIST and inside buy zone
{
new Float:buytimeleft = (roundfreezeend + buytime) - GetGameTime(); // Get buy time left
if(buytimeleft > 0)
{
if(GetPlayerWeaponSlot(client, 4) != -1) // Player have bomb already
{
PrintCenterText(client, "[SM] %t", "C4_Cant_Carry");
return Plugin_Handled;
}
new limit = GetConVarInt(buyc4_limit); // Get bomb limit from cvar
if(limit > 0) // limit have been set greater than 0
{
new ent = -1;
count = 0; // Reset counter
while ((ent = FindEntityByClassname(ent, "weapon_c4")) != -1) // Find all C4 bombs
{
count++; // Count bombs
}
if(count >= limit) // Bomb limit reached
{
PrintCenterText(client, "[SM] %t", "C4_Limit", count);
return Plugin_Handled;
}
}
new cash = GetEntProp(client, Prop_Send, "m_iAccount"); // Check player cash
new cost = GetConVarInt(buyc4_cost); // Check C4 price
if(cash < cost) // Player not have enough money
{
PrintCenterText(client, "[SM] %t", "C4_Need_Money", cost);
EmitSoundToClient(client, "weapons/clipempty_rifle.wav");
}
else
{
new cashback = cash - cost;
SetEntProp(client, Prop_Send, "m_iAccount", cashback);
GivePlayerItem(client, "weapon_c4");
PrintCenterText(client, "[SM] %t", "C4_Successful_Buying");
}
}
else
{
PrintCenterText(client, "[SM] %t", "C4_Timeout", buytime);
}
}
else if(IsPlayerAlive(client) && GetClientTeam(client) == 2 && GetEntProp(client, Prop_Send, "m_bInBuyZone") == 0) // Client is TERRORIST and outside buy zone
{
PrintCenterText(client, "[SM] %t", "C4_Wrong_Place");
}
}
return Plugin_Handled; // This prevent print "Unknow command" in client console
}
public buytimechanged(Handle:convar, const String:oldValue[], const String:newValue[])
{
buytime = StringToFloat(newValue)*60; // Update buy time and in seconds when mp_buytime change
}