#pragma semicolon 1
#include <sourcemod>
#include <vip>
#include <sdktools>
public Plugin:myinfo =
{
name = "VIP Module (C4 Model)",
author = "1mpulse",
version = "1.0"
};
new const String:g_sItemName[] = "c4_model";
new g_ItemID;
new bool:g_bAccess[MAXPLAYERS + 1];
new bool:g_bEnabled;
new Handle:g_hConVar_C4Model;
new String:g_sConVar_C4Model[PLATFORM_MAX_PATH];
public OnPluginStart()
{
if ((g_ItemID = VIP_RegisterItem(g_sItemName, true, true)) < 1)
SetFailState("VIP_RegisterItem error");
g_hConVar_C4Model = CreateConVar("vip_c4_model", "models/weapons/w_c4_planted.mdl", "Модель бомбы", FCVAR_PLUGIN);
GetConVarString(g_hConVar_C4Model, g_sConVar_C4Model, sizeof(g_sConVar_C4Model));
HookConVarChange(g_hConVar_C4Model, OnConVarChange);
AutoExecConfig(true, "vip_c4_model", "vip/modules");
}
public OnConVarChange(Handle:hConVar, const String:sOldValue[], const String:sNewValue[])
{
GetConVarString(g_hConVar_C4Model, g_sConVar_C4Model, sizeof(g_sConVar_C4Model));
if(PrecacheModel(g_sConVar_C4Model, true) == 0)
{
LoadDefault();
}
}
LoadDefault()
{
strcopy(g_sConVar_C4Model, sizeof(g_sConVar_C4Model), "models/weapons/w_c4_planted.mdl");
PrecacheModel(g_sConVar_C4Model, true);
}
public OnConfigsExecuted()
{
if(PrecacheModel(g_sConVar_C4Model, true) == 0)
{
LoadDefault();
}
}
public OnPluginEnd()
{
VIP_UnRegisterItem(g_sItemName);
}
public OnClientConnected(client)
{
g_bAccess[client] = false;
}
public VIP_OnClientAuthorized(client, const String:steamid[], bool:vip, const String:group[])
{
if (vip) wS_Check(client);
}
public VIP_OnVipItemToggled(client, ItemID, const String:ItemName[], const String:ItemInfo[], bool:enabled)
{
if (ItemID == g_ItemID)
{
g_bAccess[client] = enabled;
VIP_ShowMenu(client);
}
}
public VIP_OnRemoved(client, const String:steamid[], const String:reason[])
{
g_bAccess[client] = false;
}
public VIP_OnGroupChanged(client, const String:steamid[], const String:OldGroup[], const String:NewGroup[])
{
g_bAccess[client] = false;
wS_Check(client);
}
public VIP_OnAdded(client, const String:steamid[], const String:group[], min, const String:admin_steamid[])
{
if (client > 0) wS_Check(client);
}
wS_Check(client)
{
if (!VIP_ItemDisabled(g_sItemName) && VIP_GetItemToggledStatus(client, g_sItemName))
{
decl String:ItemInfo[MAX_ITEMINFO_LENGTH];
if (VIP_GetClientItemInfo(client, g_sItemName, ItemInfo))
g_bAccess[client] = true;
}
}
public Event_BombPlanted(Handle:hEvent, const String:sEvName[], bool:bDontBroadcast)
{
new client = GetClientOfUserId(GetEventInt(hEvent, "userid"));
if (g_bAccess[client])
{
new iEntity = FindEntityByClassname(-1, "planted_c4");
if ( iEntity != -1 && IsValidEntity(iEntity))
{
SetEntityModel(iEntity, g_sConVar_C4Model);
}
}
}
public OnMapStart()
{
g_bEnabled = (FindEntityByClassname(-1, "func_bomb_target") != -1);
if(g_bEnabled)
{
HookEvent("bomb_planted", Event_BombPlanted);
}
}
public OnMapEnd()
{
if(g_bEnabled)
{
HookEvent("bomb_planted", Event_BombPlanted);
}
}