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

[CS:GO] I created this plugin to block weapon buy


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
shadow10
Junior Member
Join Date: Jan 2023
Old 01-30-2023 , 10:06   [CS:GO] I created this plugin to block weapon buy
Reply With Quote #1

I need to know if this works properly without any mistakes !

I'm trying to get the round number and if the round is 1 or 16 it

will block the buy of the specific weapons. The block buy code

works. But when im tryin to get the round number sometimes it

works sometimes not. EDIT : i didnt try this code so i wanna

make sure it works properly.

CODE :

public Action CS_OnBuyCommand(int iClient, const char[] chWeapon)
{

if (GameRules_GetProp("m_totalRoundsPlayed") == 0 || GameRules_GetProp("m_totalRoundsPlayed") == 15)
{
char blocked_weapons[][] = { "ump45", "p90", "mp9", "mp7", "mp5sd", "mac10", "bizon", "ssg08", "sg556", "scar20", "m4a1_silencer", "m4a1", "galilar", "g3sg1", "famas", "awp", "aug", "ak47", "xm1014", "sawedoff", "nova", "negev", "mag7", "m249" };
for (int i = 0; i < sizeof(blocked_weapons); i++)
{
if (StrEqual(chWeapon, blocked_weapons[i]))
{
PrintToChat(iClient, "'You're rich BUT I FORBID YOU TO BUY' - shadowbringer.");
return Plugin_Handled;
}
}
}
return Plugin_Continue; // Continue as normal.
}

im using GameRules_GetProp("m_totalRoundsPlayed") == 0 set to 0 because i think to get the first round it means that totalroundplayed needs to be 0. IF IM WRONG CORRECT ME.

Last edited by shadow10; 01-30-2023 at 10:10.
shadow10 is offline
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 01-30-2023 , 10:51   Re: [CS:GO] I created this plugin to block weapon buy
Reply With Quote #2

Quote:
Originally Posted by shadow10 View Post
I need to know if this works properly without any mistakes !

... i didnt try this code so i wanna

make sure it works properly.
You need test. You need debug.
Making this work for others sound like you are lazy.

*edit
Little tip
Use PrintToChatAll("value %i", GameRules_GetProp("m_totalRoundsPlayed"));
__________________
Do not Private Message @me

Last edited by Bacardi; 01-30-2023 at 10:59.
Bacardi is offline
shadow10
Junior Member
Join Date: Jan 2023
Old 01-30-2023 , 14:20   Re: [CS:GO] I created this plugin to block weapon buy
Reply With Quote #3

Quote:
Originally Posted by Bacardi View Post
You need test. You need debug.
Making this work for others sound like you are lazy.

*edit
Little tip
Use PrintToChatAll("value %i", GameRules_GetProp("m_totalRoundsPlayed"));

I tested it and it worked. I made it but i wasnt sure if it was workin', btw why shall i use 'PrintToChatAll("value %i", GameRules_GetProp("m_totalRoundsPlayed"));' ??
shadow10 is offline
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 01-30-2023 , 15:20   Re: [CS:GO] I created this plugin to block weapon buy
Reply With Quote #4

Quote:
Originally Posted by shadow10 View Post
I tested it and it worked. I made it but i wasnt sure if it was workin', btw why shall i use 'PrintToChatAll("value %i", GameRules_GetProp("m_totalRoundsPlayed"));' ??
Because you are making more questions than actual testing.

If you do not know what will happen in code -> Print output of result.
Bacardi is offline
Grey83
Veteran Member
Join Date: Dec 2014
Location: Ukraine
Old 02-01-2023 , 06:39   Re: [CS:GO] I created this plugin to block weapon buy
Reply With Quote #5

I would do something like this:
PHP Code:
#pragma semicolon 1
#pragma newdecls required

#include <cstrike>
#include <sdktools_gamerules>

static const char WPN[][] = {"ump45""p90""mp9""mp7""mp5sd""mac10""bizon""ssg08""sg556""scar20""m4a1_silencer""m4a1""galilar""g3sg1""famas""awp""aug""ak47""xm1014""sawedoff""nova""negev""mag7""m249"};

bool bBlock;

public 
void OnPluginStart()
{
    
HookEvent("round_start"Event_StartEventHookMode_PostNoCopy);
    
CheckRoundNum();
}

public 
void Event_Start(Event event, const char[] namebool dontBroadcast)
{
    
CheckRoundNum();
}

stock void CheckRoundNum()
{
    
int round GameRules_GetProp("m_totalRoundsPlayed");
    
bBlock round == || round == 15;
    
PrintToChatAll("%s allowed"bBlock "Only pistols" "All guns are");
}

public 
Action CS_OnBuyCommand(int client, const char[] weapon)
{
    if(!
bBlock)
        return 
Plugin_Continue;

    for(
int isizeof(WPN); i++) if(!strcmp(weaponWPN[i]))
    {
        
PrintToChat(client"'You're rich BUT I FORBID YOU TO BUY' - shadowbringer.");
        return 
Plugin_Handled;
    }

    return 
Plugin_Continue;

__________________
Grey83 is offline
Reply


Thread Tools
Display Modes

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 15:22.


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