Raised This Month: $47 Target: $400
 11% 

[REQ] Set Flag


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
ApoziX
Member
Join Date: Sep 2018
Old 11-27-2018 , 13:29   [REQ] Set Flag
Reply With Quote #1

Hello Someone can help me
I want Only Flag T To use that plugin

Thanks for helpers +rep

PHP Code:
#include <sourcemod>
#include <sdktools>
#include <tf2>
#include <tf2_stocks>
#include <clients>
#include <sdkhooks>

int OwnerOffset;
ConVar sm_dispenser_limit;
ConVar sm_sentry_limit;
ConVar sm_instant_upgrade;

public 
Plugin myinfo ={
    
name "Multiple buildings",
    
author "shewowkees",
    
description "self explanatory",
    
version "1.1",
    
url "noSiteYet"
};

public 
void OnPluginStart(){

    
sm_dispenser_limit CreateConVar("sm_dispenser_limit""5""Self explanatory");
    
sm_sentry_limit CreateConVar("sm_sentry_limit""5""Self explanatory");
    
sm_instant_upgrade CreateConVar("sm_instant_upgrade","0","Self explanatory");

    
HookEvent("player_builtobject",Evt_BuiltObject,EventHookMode_Pre);

    
RegConsoleCmd("sm_destroy_dispensers"Command_destroy_dispensers);
    
RegConsoleCmd("sm_destroy_sentries"Command_destroy_sentries);

    
OwnerOffset FindSendPropInfo("CBaseObject""m_hBuilder");

    for(
int client=1;client<MaxClients;client++){
        if(!
IsValidEntity(client)){
            continue;
        }
        if(!
IsClientConnected(client)){
            continue;
        }

        
SDKUnhook(clientSDKHook_WeaponSwitchWeaponSwitch);
        
SDKHookEx(clientSDKHook_WeaponSwitchWeaponSwitch);
    }
}



public 
void OnClientPostAdminCheck(client){
    
SDKHookEx(clientSDKHook_WeaponSwitchWeaponSwitch);
}
public 
Action Evt_BuiltObject(Event event, const char[] namebool dontBroadcast){
    
int ObjIndex event .GetInt("index");

    if(
GetConVarInt(sm_instant_upgrade)>0){

        
SetEntProp(ObjIndexProp_Send"m_iUpgradeMetal"600);
        
SetEntProp(ObjIndex,Prop_Send,"m_iUpgradeMetalRequired",0);

    }



    return 
Plugin_Continue;
}


public 
Action WeaponSwitch(clientweapon){
    
//Safety Checks
    
if(!IsClientInGame(client)){
        return 
Plugin_Continue;
    }
    if(
TF2_GetPlayerClass(client)!=TFClass_Engineer){
        return 
Plugin_Continue;
    }
    if(!
IsValidEntity(GetPlayerWeaponSlot(client,1))){
        return 
Plugin_Continue;
    }
    if(!
IsValidEntity(GetPlayerWeaponSlot(client,3))){
        return 
Plugin_Continue;
    }
    if(!
IsValidEntity(GetPlayerWeaponSlot(client,4))){
        return 
Plugin_Continue;
    }
    if(!
IsValidEntity(weapon)){
        return 
Plugin_Continue;
    }

    
//if the building pda is opened
    //Switches some buildings to sappers so the game doesn't count them as engie buildings
    
if(GetPlayerWeaponSlot(client,3)==weapon){
        
function_AllowBuilding(client);
        return 
Plugin_Continue;
    }
//else if the client is not holding the building tool
    
else if(GetEntProp(weapon,Prop_Send,"m_iItemDefinitionIndex")!=28){
        
function_AllowDestroying(client);
        return 
Plugin_Continue;
    }
    return 
Plugin_Continue;

}






public 
Action Command_destroy_dispensers(int clientint args){

    for(
int i=1;i<2048;i++){

        if(!
IsValidEntity(i)){
            continue;
        }

        
decl String:netclass[32];
        
GetEntityNetClass(inetclasssizeof(netclass));

        if ( !
strcmp(netclass"CObjectDispenser") == 0){
            continue;
        }

        if(
GetEntDataEnt2(iOwnerOffset)!=client){
            continue;
        }
        
SetVariantInt(9999);
        
AcceptEntityInput(i,"RemoveHealth");
    }

    return 
Plugin_Handled;


}

public 
Action Command_destroy_sentries(int clientint args){

    for(
int i=1;i<2048;i++){

        if(!
IsValidEntity(i)){
            continue;
        }

        
decl String:netclass[32];
        
GetEntityNetClass(inetclasssizeof(netclass));

        if ( !(
strcmp(netclass"CObjectSentrygun") == 0) ){
            continue;
        }

        if(
GetEntDataEnt2(iOwnerOffset)!=client){
            continue;
        }
        
SetVariantInt(9999);
        
AcceptEntityInput(i,"RemoveHealth");
    }

    return 
Plugin_Handled;

}

public 
void function_AllowBuilding(int client){

    
int DispenserLimit GetConVarInt(sm_dispenser_limit);
    
int SentryLimit GetConVarInt(sm_sentry_limit);

    
int DispenserCount 0;
    
int SentryCount 0;

    for(
int i=0;i<2048;i++){

        if(!
IsValidEntity(i)){
            continue;
        }

        
decl String:netclass[32];
        
GetEntityNetClass(inetclasssizeof(netclass));
        if ( !(
strcmp(netclass"CObjectSentrygun") == || strcmp(netclass"CObjectDispenser") == 0) ){
            continue;
        }

        if(
GetEntDataEnt2(iOwnerOffset)!=client){
            continue;
        }


        
int type=view_as<int>(function_GetBuildingType(i));

        
//Switching the dispenser to a sapper type
        
if(type==view_as<int>(TFObject_Dispenser)){
            
DispenserCount=DispenserCount+1;
            
SetEntProp(iProp_Send"m_iObjectType"TFObject_Sapper);
            if(
DispenserCount>=DispenserLimit){
                
//if the limit is reached, disallow building
                
SetEntProp(iProp_Send"m_iObjectType"type);

            }

        
//not a dispenser,
        
}else if(type==view_as<int>(TFObject_Sentry)){
            
SentryCount++;
            
SetEntProp(iProp_Send"m_iObjectType"TFObject_Sapper);
            if(
SentryCount>=SentryLimit){
                
//if the limit is reached, disallow building
                
SetEntProp(iProp_Send"m_iObjectType"type);
            }
        }
    
//every building is in the desired state


    
}
}
public 
void function_AllowDestroying(int client){
    for(
int i=1;i<2048;i++){

        if(!
IsValidEntity(i)){
            continue;
        }

        
decl String:netclass[32];
        
GetEntityNetClass(inetclasssizeof(netclass));

        if ( !(
strcmp(netclass"CObjectSentrygun") == || strcmp(netclass"CObjectDispenser") == 0) ){
            continue;
        }

        if(
GetEntDataEnt2(iOwnerOffset)!=client){
            continue;
        }

        
SetEntProp(iProp_Send"m_iObjectType"function_GetBuildingType(i));
    }

}

public 
TFObjectType function_GetBuildingType(int entIndex){
    
//This function relies on Netclass rather than building type since building type
    //gets changed
    
decl String:netclass[32];
    
GetEntityNetClass(entIndexnetclasssizeof(netclass));

    if(
strcmp(netclass"CObjectSentrygun") == 0){
        return 
TFObject_Sentry;
    }
    if(
strcmp(netclass"CObjectDispenser") == 0){
        return 
TFObject_Dispenser;
    }

    return 
TFObject_Sapper;



__________________
Looking To Start A TF2 Community
My Discord | My Steam

Last edited by ApoziX; 11-28-2018 at 13:02.
ApoziX is offline
bakusiovskyyyy
Junior Member
Join Date: Nov 2017
Location: Poland
Old 11-30-2018 , 01:46   Re: [REQ] Set Flag
Reply With Quote #2

Not sure but I think you should change
Quote:
RegConsoleCmd("sm_destroy_dispensers", Command_destroy_dispensers);
to:
Quote:
RegAdminCmd("sm_destroy_dispensers", Command_destroy_dispensers, ADMFLAG_CUSTOM5);
Try it
__________________
bakusiovskyyyy is offline
8guawong
AlliedModders Donor
Join Date: Dec 2013
Location: BlackMarke7
Old 11-30-2018 , 02:55   Re: [REQ] Set Flag
Reply With Quote #3

just use command overrides

https://wiki.alliedmods.net/Overridi...ess_(SourceMod)
__________________
8guawong is offline
ApoziX
Member
Join Date: Sep 2018
Old 11-30-2018 , 19:50   Re: [REQ] Set Flag
Reply With Quote #4

No

I want If you Have Flag T The Multiple buildings Would run on you and if you dont got T flag so plugin would not run on you
__________________
Looking To Start A TF2 Community
My Discord | My Steam
ApoziX is offline
CliptonHeist
Senior Member
Join Date: Feb 2016
Old 11-30-2018 , 22:25   Re: [REQ] Set Flag
Reply With Quote #5

Try this:
Attached Files
File Type: sp Get Plugin or Get Source (plugin.sp - 62 views - 6.6 KB)

Last edited by CliptonHeist; 11-30-2018 at 22:27.
CliptonHeist is offline
ApoziX
Member
Join Date: Sep 2018
Old 12-01-2018 , 06:59   Re: [REQ] Set Flag
Reply With Quote #6

Quote:
Originally Posted by CliptonHeist View Post
Try this:
Thanks mate +rep
__________________
Looking To Start A TF2 Community
My Discord | My Steam
ApoziX 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 19:56.


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