Raised This Month: $32 Target: $400
 8% 

[TF2] Changing building ownership


Post New Thread Reply   
 
Thread Tools Display Modes
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
luki1412
Veteran Member
Join Date: Oct 2008
Location: OnPluginStart()
Old 05-27-2016 , 12:35   Re: [TF2] Changing building ownership
Reply With Quote #2

so
Code:
AcceptEntityInput(obj, "SetBuilder", client);
and
Code:
SetEntPropEnt(obj, Prop_Send, "m_hBuilder", client);
are both needed?

Also, where is
Code:
SetEntProp(obj, Prop_Send, "m_iTeamNum", team);
and
Code:
SetVariantInt(team);
AcceptEntityInput(obj, "TeamNum");
?
__________________
luki1412 is offline
Pelipoika
Veteran Member
Join Date: May 2012
Location: Inside
Old 05-27-2016 , 12:50   Re: [TF2] Changing building ownership
Reply With Quote #3

Quote:
Originally Posted by luki1412 View Post
so
Code:
AcceptEntityInput(obj, "SetBuilder", client);
and
Code:
SetEntPropEnt(obj, Prop_Send, "m_hBuilder", client);
are both needed?
?
Yes

Quote:
Originally Posted by luki1412 View Post
Also, where is
Code:
SetEntProp(obj, Prop_Send, "m_iTeamNum", team);
and
Code:
SetVariantInt(team);
AcceptEntityInput(obj, "TeamNum");
?
What?
__________________
Pelipoika is offline
luki1412
Veteran Member
Join Date: Oct 2008
Location: OnPluginStart()
Old 05-27-2016 , 12:53   Re: [TF2] Changing building ownership
Reply With Quote #4

Quote:
Originally Posted by Pelipoika View Post
What?
The second part should be for setting the team or is it not needed?
__________________
luki1412 is offline
Pelipoika
Veteran Member
Join Date: May 2012
Location: Inside
Old 05-27-2016 , 13:19   Re: [TF2] Changing building ownership
Reply With Quote #5

Quote:
Originally Posted by luki1412 View Post
The second part should be for setting the team or is it not needed?
The stock has already been tested and it works
__________________
Pelipoika is offline
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 14:08.


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