Hello good, I need help with a plugin please. Could someone help me by making the shield unbreakable please? I'd be really grateful.
Code:
#include <sourcemod>
#include <sdktools>
public Plugin:myinfo =
{
name = "BuyShield",
author = "backwards",
description = "Allows players to buy shields by typing !buyshield.",
version = SOURCEMOD_VERSION,
url = "http://www.steamcommunity.com/id/mypassword"
}
new ShieldCost = 15300
new bool:RequireBuyZone = false;
Handle BuyStartRoundTimer;
public OnPluginStart()
{
RegConsoleCmd("sm_escudo", BuyShieldCMD);
HookEvent("round_prestart", Event_RoundPreStart);
}
public Action BuyShieldCMD(int client, int args)
{
if(GetClientTeam(client) != 3)
{
PrintToChat(client, "Solo el CT puede tener escudo.")
return Plugin_Handled;
}
if(RequireBuyZone)
{
new bool:InBuyZone = view_as<bool>(GetEntProp(client, Prop_Send, "m_bInBuyZone"));
if(!InBuyZone)
{
PrintToChat(client, "Lo siento no estas en zona de compra.");
return Plugin_Handled;
}
if (BuyStartRoundTimer == null)
{
PrintToChat(client, "El tiempo de compra ha expirado.")
return Plugin_Handled;
}
}
new account = GetEntProp(client, Prop_Send, "m_iAccount");
if(account < ShieldCost)
{
PrintToChat(client, "Lo siento no tienes 15300 para comprarte otro");
return Plugin_Handled;
}
new weaponIdx = GetPlayerWeaponSlot(client, 11);
if(weaponIdx != -1)
{
if(IsValidEdict(weaponIdx) && IsValidEntity(weaponIdx))
{
decl String:className[128];
GetEntityClassname(weaponIdx, className, sizeof(className));
if(StrEqual("weapon_shield", className))
{
PrintToChat(client, "Aqui tienes un escudo.");
return Plugin_Handled;
}
}
}
SetEntProp(client, Prop_Send, "m_iAccount", account - ShieldCost);
GivePlayerItem(client, "weapon_shield");
PrintToChat(client, "Aqui tienes un escudo.");
return Plugin_Handled;
}
public Event_RoundPreStart(Handle:event, const String:name[], bool:dontBroadcast)
{
new Float:BuyTime = 45.0;
ConVar cvarBuyTime = FindConVar("mp_buytime");
if(cvarBuyTime != null)
BuyTime = float(cvarBuyTime.IntValue);
if (BuyStartRoundTimer != null)
{
KillTimer(BuyStartRoundTimer);
BuyStartRoundTimer = null;
}
BuyStartRoundTimer = CreateTimer(BuyTime, StopBuying);
}
public Action StopBuying(Handle timer, any client)
{
BuyStartRoundTimer = null;
return Plugin_Stop;
}