Raised This Month: $ Target: $400
 0% 

[TF2] Changing building ownership


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
Pelipoika
Veteran Member
Join Date: May 2012
Location: Inside
Old 04-28-2016 , 08:15   [TF2] Changing building ownership
Reply With Quote #1

Heres a thing for properly changing a buildings ownership:

PHP Code:
#include <sdktools>

#pragma newdecls required

Handle g_hSDKRemoveObject;

public 
Plugin myinfo 
{
    
name "[TF2] Building Ownage",
    
author "Pelipoika",
    
description "",
    
version "1.0",
    
url "http://www.sourcemod.net/plugins.php?author=Pelipoika&search=1"
};

public 
void OnPluginStart()
{
    
Handle hConfig LoadGameConfigFile("tf2.setbuilder");

    
StartPrepSDKCall(SDKCall_Player);
    
PrepSDKCall_SetFromConf(hConfigSDKConf_Signature"CTFPlayer::RemoveObject");
    
PrepSDKCall_AddParameter(SDKType_CBaseEntitySDKPass_Pointer);    //CBaseObject
    
if ((g_hSDKRemoveObject EndPrepSDKCall()) == INVALID_HANDLESetFailState("Failed To create SDKCall for CTFPlayer::RemoveObject signature");
    
    
delete hConfig;
    
    
RegAdminCmd("sm_ownaimbuilding"Command_OwnAimADMFLAG_ROOT);
}

public 
Action Command_OwnAim(int clientint args)
{
    
int obj GetClientAimTarget(clientfalse);
    if(
IsValidEntity(obj))
    {
        
SetBuilder(objclient);
        
PrintToChat(client"Building (%i) is now yours %N"objclient);
    }

    return 
Plugin_Handled;
}

stock void SetBuilder(int objint client)
{
    
int iBuilder GetEntPropEnt(objProp_Send"m_hBuilder");
    
bool bMiniBuilding GetEntProp(objProp_Send"m_bMiniBuilding") || GetEntProp(objProp_Send"m_bDisposableBuilding");

    if(
iBuilder && iBuilder <= MaxClients && IsClientInGame(iBuilder))
        
SDKCall(g_hSDKRemoveObjectiBuilderobj);
    
    
SetEntPropEnt(objProp_Send"m_hBuilder", -1);
    
AcceptEntityInput(obj"SetBuilder"client);
    
SetEntPropEnt(objProp_Send"m_hBuilder"client);
    
    
SetVariantInt(GetClientTeam(client));
    
AcceptEntityInput(obj"SetTeam");
    
    
SetEntProp(objProp_Send"m_nSkin"bMiniBuilding GetClientTeam(client) : GetClientTeam(client) - 2);

tf2.setbuilder.txt
__________________

Last edited by Pelipoika; 01-24-2018 at 09:05.
Pelipoika is offline
 



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 18:53.


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