Raised This Month: $51 Target: $400
 12% 

I need Help With one Plugin please


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
MasterWindowS
BANNED
Join Date: May 2020
Location: Chile
Old 08-16-2020 , 20:04   I need Help With one Plugin please
Reply With Quote #1

Hi, I need help with this plugin. Everything works fine, but I want the "sm_buyshield" command to work only for CT equipment. Please help

SP:

#include <sourcemod>
#include <sdktools>

public Plugin:myinfo =
{
name = "BuyShield",
author = "backwards",
description = "Allows players to buy shields by typing !buyshield.",
version = SOURCEMOD_VERSION,
url = none
}

new ShieldCost = 5000
new bool:RequireBuyZone = true;
Handle BuyStartRoundTimer;

public OnPluginStart()
{
RegConsoleCmd("sm_buyshield", BuyShieldCMD);
HookEvent("round_prestart", Event_RoundPreStart);
}

public Action BuyShieldCMD(int client, int args)
{
if(RequireBuyZone)
{
new bool:InBuyZone = view_as<bool>(GetEntProp(client, Prop_Send, "m_bInBuyZone"));
if(!InBuyZone)
{
PrintToChat(client, "Sorry You're Not In a Buy Zone.");
return Plugin_Handled;
}
if (BuyStartRoundTimer == null)
{
PrintToChat(client, "The Buy Time Has Expired For This Round.")
return Plugin_Handled;
}
}

new account = GetEntProp(client, Prop_Send, "m_iAccount");
if(account < ShieldCost)
{
PrintToChat(client, "Sorry you don't have $5000 to buy the shield.");
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, "You are already carrying a shield.");
return Plugin_Handled;
}
}
}

SetEntProp(client, Prop_Send, "m_iAccount", account - ShieldCost);
GivePlayerItem(client, "weapon_shield");
PrintToChat(client, "You've bought a shield.");

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;
}
Attached Files
File Type: sp Get Plugin or Get Source (buyshield_v1.2 (1).sp - 111 views - 2.2 KB)
MasterWindowS is offline
8guawong
AlliedModders Donor
Join Date: Dec 2013
Location: BlackMarke7
Old 08-17-2020 , 02:49   Re: I need Help With one Plugin please
Reply With Quote #2

now only CT can buy
Attached Files
File Type: sp Get Plugin or Get Source (buyshield_v1.2.sp - 110 views - 2.3 KB)
__________________

Last edited by 8guawong; 08-17-2020 at 02:49.
8guawong is offline
MasterWindowS
BANNED
Join Date: May 2020
Location: Chile
Old 08-17-2020 , 04:00   Re: I need Help With one Plugin please
Reply With Quote #3

I already tried it and it doesn't work
MasterWindowS is offline
8guawong
AlliedModders Donor
Join Date: Dec 2013
Location: BlackMarke7
Old 08-17-2020 , 14:37   Re: I need Help With one Plugin please
Reply With Quote #4

Quote:
Originally Posted by MasterWindowS View Post
I already tried it and it doesn't work
if you will only say "it doesn't work" then no one can help you
__________________

Last edited by 8guawong; 08-17-2020 at 14:38.
8guawong is offline
MasterWindowS
BANNED
Join Date: May 2020
Location: Chile
Old 08-17-2020 , 14:49   Re: I need Help With one Plugin please
Reply With Quote #5

Quote:
Originally Posted by 8guawong View Post
if you will only say "it doesn't work" then no one can help you
sorry, I had the wrong plugin. I had put the bad version that I did. Today I tried again to compile yours and it worked. Thank you very much, sorry for the confusion
MasterWindowS is offline
Reply



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 19:12.


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