AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Snippets and Tutorials (https://forums.alliedmods.net/forumdisplay.php?f=112)
-   -   [TF2] Changing building ownership (https://forums.alliedmods.net/showthread.php?t=282078)

Pelipoika 04-28-2016 08:15

[TF2] Changing building ownership
 
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

luki1412 05-27-2016 12:35

Re: [TF2] Changing building ownership
 
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");

?

Pelipoika 05-27-2016 12:50

Re: [TF2] Changing building ownership
 
Quote:

Originally Posted by luki1412 (Post 2422500)
so
Code:

AcceptEntityInput(obj, "SetBuilder", client);
and
Code:

SetEntPropEnt(obj, Prop_Send, "m_hBuilder", client);
are both needed?
?

Yes

Quote:

Originally Posted by luki1412 (Post 2422500)
Also, where is
Code:

SetEntProp(obj, Prop_Send, "m_iTeamNum", team);
and
Code:

SetVariantInt(team);
AcceptEntityInput(obj, "TeamNum");

?

What?

luki1412 05-27-2016 12:53

Re: [TF2] Changing building ownership
 
Quote:

Originally Posted by Pelipoika (Post 2422511)
What?

The second part should be for setting the team or is it not needed?

Pelipoika 05-27-2016 13:19

Re: [TF2] Changing building ownership
 
Quote:

Originally Posted by luki1412 (Post 2422513)
The second part should be for setting the team or is it not needed?

The stock has already been tested and it works


All times are GMT -4. The time now is 18:53.

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