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

buy shield for ct


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
MasterWindowS
BANNED
Join Date: May 2020
Location: Chile
Old 09-29-2021 , 16:22   buy shield for ct
Reply With Quote #1

Code:
#include <sourcemod>
#include <sdktools>
#include <cstrike>

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 = 5000
new bool:RequireBuyZone = false;

public OnPluginStart()
{
	RegConsoleCmd("sm_shield", BuyShieldCMD);
	RegConsoleCmd("sm_escudo", BuyShieldCMD);
}

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;
		}
	}
	
	new account = GetEntProp(client, Prop_Send, "m_iAccount");
	if(account < ShieldCost)
	{
		PrintToChat(client, "No tienes los creditos suficientes para comprar uno.");
		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))
			{
				PrintCenterText(client, "Ya tienes un escudo actualmente.");
				return Plugin_Handled;
			}
		}
	}
	
	SetEntProp(client, Prop_Send, "m_iAccount", account - ShieldCost);
	GivePlayerItem(client, "weapon_shield");
	PrintCenterText(client, "Ya tienes un escudo actualmente.");
	
	
	return Plugin_Handled;
}
could someone help me by setting it so that only cts can use the command please

Last edited by MasterWindowS; 09-29-2021 at 16:22.
MasterWindowS is offline
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 09-29-2021 , 19:01   Re: buy shield for ct
Reply With Quote #2

Code:
#include <sourcemod>
#include <sdktools>
#include <cstrike>

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 = 5000
new bool:RequireBuyZone = false;

public OnPluginStart()
{
	RegConsoleCmd("sm_shield", BuyShieldCMD);
	RegConsoleCmd("sm_escudo", BuyShieldCMD);
}

public Action BuyShieldCMD(int client, int args) 
{

	if(!client || !IsClientInGame(client) || !IsPlayerAlive(client) || GetClientTeam(client) != CS_TEAM_CT)
		return Plugin_Handled;

	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;
		}
	}
	
	new account = GetEntProp(client, Prop_Send, "m_iAccount");
	if(account < ShieldCost)
	{
		PrintToChat(client, "No tienes los creditos suficientes para comprar uno.");
		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))
			{
				PrintCenterText(client, "Ya tienes un escudo actualmente.");
				return Plugin_Handled;
			}
		}
	}
	
	SetEntProp(client, Prop_Send, "m_iAccount", account - ShieldCost);
	GivePlayerItem(client, "weapon_shield");
	PrintCenterText(client, "Ya tienes un escudo actualmente.");
	
	
	return Plugin_Handled;
}
__________________
Do not Private Message @me
Bacardi is offline
namleww
Junior Member
Join Date: Mar 2022
Old 03-07-2022 , 02:57   Re: buy shield for ct
Reply With Quote #3

Quote:
Originally Posted by Bacardi View Post
Code:
#include <sourcemod>
#include <sdktools>
#include <cstrike>

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 = 5000
new bool:RequireBuyZone = false;

public OnPluginStart()
{
	RegConsoleCmd("sm_shield", BuyShieldCMD);
	RegConsoleCmd("sm_escudo", BuyShieldCMD);
}

public Action BuyShieldCMD(int client, int args) 
{

	if(!client || !IsClientInGame(client) || !IsPlayerAlive(client) || GetClientTeam(client) != CS_TEAM_CT)
		return Plugin_Handled;

	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;
		}
	}
	
	new account = GetEntProp(client, Prop_Send, "m_iAccount");
	if(account < ShieldCost)
	{
		PrintToChat(client, "No tienes los creditos suficientes para comprar uno.");
		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))
			{
				PrintCenterText(client, "Ya tienes un escudo actualmente.");
				return Plugin_Handled;
			}
		}
	}
	
	SetEntProp(client, Prop_Send, "m_iAccount", account - ShieldCost);
	GivePlayerItem(client, "weapon_shield");
	PrintCenterText(client, "Ya tienes un escudo actualmente.");
	
	
	return Plugin_Handled;
}
hi i tried this code but cts can't pick the shield up in de map. any solution? thanks
namleww is offline
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 03-07-2022 , 09:07   Re: buy shield for ct
Reply With Quote #4

game_type 4 (cooperative)
game_type 6 (freeforall)

In these modes, player is able to pickup shield.

I have no clue what these modes change on player or on game rules.

*deja vu came when Franc1sco post solution.
__________________
Do not Private Message @me

Last edited by Bacardi; 03-07-2022 at 11:01.
Bacardi is offline
Franc1sco
Veteran Member
Join Date: Oct 2010
Location: Spain (Madrid)
Old 03-07-2022 , 09:16   Re: buy shield for ct
Reply With Quote #5

Quote:
Originally Posted by namleww View Post
hi i tried this code but cts can't pick the shield up in de map. any solution? thanks
This works well.
Attached Files
File Type: sp Get Plugin or Get Source (allow_shields.sp - 123 views - 204 Bytes)
__________________
Veteran Coder -> Activity channel
Coding on CS2 and taking paid and free jobs.

Contact: Steam, Telegram or discord ( franug ).

You like my work? +Rep in my steam profile comments or donate.

Franc1sco is offline
Send a message via MSN to Franc1sco
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 11:23.


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