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

I'm trying to make a AWP restriction.. help


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
kratoss1812
Senior Member
Join Date: May 2018
Location: Romānia
Old 11-12-2019 , 11:35   I'm trying to make a AWP restriction.. help
Reply With Quote #1

PHP Code:
#pragma semicolon 1

#include <sourcemod>
#include <cstrike>
#include <sdktools>

#pragma newdecls required

int iAWPBroughThisRoundCTiAWPBroughThisRoundT;


public 
void OnPluginStart()
{    
    
HookEvent("round_start"OnRoundStart);    
}

public 
Action OnRoundStart(Handle pHndl, const char[] Namebool bNoBCast)
{        
    
iAWPBroughThisRoundCT 0;
    
iAWPBroughThisRoundT 0;
}

public 
Action CS_OnBuyCommand(int Client, const char[] sWpnName)
{
    if(
StrEqual(sWpnName"awp"true))
    {
        if(
GetClientTeam(Client) == CS_TEAM_CT)
        {
            
float AlowedAWPs float(((33 100) * GetTeamClientCount(CS_TEAM_CT)));
            
PrintToChat(Client"debug AWPS = %f"AlowedAWPs);
            if (
iAWPBroughThisRoundCT AlowedAWPs)
                return 
Plugin_Stop;
                
            
iAWPBroughThisRoundCT++;
        }
            
        if(
GetClientTeam(Client) == CS_TEAM_T)
        {
            
float AlowedAWPs float(((33 100) * GetTeamClientCount(CS_TEAM_T)));
            
PrintToChat(Client"debug AWPS = %f"AlowedAWPs);
            if (
iAWPBroughThisRoundT AlowedAWPs)
                return 
Plugin_Stop;
                
            
iAWPBroughThisRoundT++;
        }
        return 
Plugin_Continue;
    }

    
/*if (strcmp(sWpnName, "weapon_negev") == 0)return Plugin_Stop;
    if (strcmp(sWpnName, "weapon_m249") == 0)return Plugin_Stop;
    if (strcmp(sWpnName, "weapon_scar20") == 0)return Plugin_Stop;
    if (strcmp(sWpnName, "weapon_g3sg1") == 0)return Plugin_Stop;*/
    
    
if(StrEqual(sWpnName"m249"true) || StrEqual(sWpnName"negev"true) || StrEqual(sWpnName"scar20"true) || StrEqual(sWpnName"g3sg1"true))
    {
        
PrintToChat(Client"\x01 \x02VIP★ Info\x01 :: \x09 You Can Not buy This Weapon");
        return 
Plugin_Stop;
    }    
    
    return 
Plugin_Continue;

here's my code.
what i'm trying to do is make a restriction that works like this: there are alowed only 33% of the players to have AWP.. so the number of the purchaseable AWPs is (33/100) * PlayersCount where PlayersCount = players only from CT or T
__________________
kratoss1812 is offline
Ilusion9
Veteran Member
Join Date: Jun 2018
Location: Romania
Old 11-12-2019 , 13:40   Re: I'm trying to make a AWP restriction.. help
Reply With Quote #2

PHP Code:

#include <sourcemod>
#include <sdktools>
#include <cstrike>

#pragma newdecls required

int g_AWPsOnT;
int g_AWPsOnCTs;

public 
void OnPluginStart()
{    
    
HookEvent("round_start"OnRoundStart);    
}

public 
void OnRoundStart(Event event, const char[] namebool dontBroadcast)
{        
    
g_AWPsOnT 0;
    
g_AWPsOnCTs 0;
}

public 
Action CS_OnBuyCommand(int client, const char[] weapon)
{
    if (
StrEqual(weapon"awp"false))
    {
        if (
GetClientTeam(client) == CS_TEAM_CT)
        {
            if (
g_AWPsOnCTs GetTeamClientCount(CS_TEAM_CT) / 3)
                return 
Plugin_Handled;
            
            
g_AWPsOnCTs++;
        }
            
        else
        {
            if (
g_AWPsOnT GetTeamClientCount(CS_TEAM_T) / 3)
                return 
Plugin_Handled;
            
            
g_AWPsOnT++;
        }
        
        return 
Plugin_Continue;
    }
    
    if (
StrEqual(weapon"m249"false) || StrEqual(weapon"negev"false) || StrEqual(weapon"scar20"false) || StrEqual(weapon"g3sg1"false))
    {
        
PrintToChat(client" \x02VIP★ Info\x01 :: \x09 You cannot buy this weapon!");
        return 
Plugin_Handled;
    }    
    
    return 
Plugin_Continue;

__________________
Ilusion9 is offline
xSaG
Junior Member
Join Date: Sep 2018
Location: Romānia
Old 11-12-2019 , 14:18   Re: I'm trying to make a AWP restriction.. help
Reply With Quote #3

Not tested
PHP Code:
#define PLUGIN_NAME           "Restricție AWP"
#define PLUGIN_AUTHOR         "xSaG.exe"
#define PLUGIN_DESCRIPTION    "Restricție la awp īn funcție de jucători."
#define PLUGIN_VERSION        "1.0"
#define PLUGIN_URL            "https://steamcommunity.com/id/xsag69"

#include <sourcemod>
#include <sdktools>

int iAWP;

public 
Plugin:myinfo =
{
    
name PLUGIN_NAME,
    
author PLUGIN_AUTHOR,
    
description PLUGIN_DESCRIPTION,
    
version PLUGIN_VERSION,
    
url PLUGIN_URL
};

public 
OnPluginStart()
{
    
HookEvent("player_spawn"Event_PlayerSpawn);
}

public 
Action Event_PlayerSpawn(Event event, const char[] namebool dontBroadcast)
{
    
iAWP 0;
}

public 
Action CS_OnBuyCommand(int client, const char[] weapon)
{
    
int CheckTeam GetClientTeam(client);
    if(
strcmp(weapon,"awp"false) == && (CheckTeam == || CheckTeam == 3))
    {
        
float RatieAwpT float((33 100) * GetTeamClientCount(2));
        
float RatieAwpCT float((33 100) * GetTeamClientCount(3));
        if(
RatieAwpT iAWP || RatieAwpCT iAWP)
        {
            
PrintToChat(client"Echipa ta are prea multe awp-uri!");
            return 
Plugin_Handled;
        }
        
iAWP++;
    }
    return 
Plugin_Continue;

Best Regard!

Last edited by xSaG; 11-12-2019 at 14:28.
xSaG is offline
kratoss1812
Senior Member
Join Date: May 2018
Location: Romānia
Old 11-13-2019 , 07:37   Re: I'm trying to make a AWP restriction.. help
Reply With Quote #4

Ilusion's works well. Thanks!
Thank you too xSaG for your effort
__________________
kratoss1812 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 22:38.


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