| 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(hConfig, SDKConf_Signature, "CTFPlayer::RemoveObject"); PrepSDKCall_AddParameter(SDKType_CBaseEntity, SDKPass_Pointer); //CBaseObject if ((g_hSDKRemoveObject = EndPrepSDKCall()) == INVALID_HANDLE) SetFailState("Failed To create SDKCall for CTFPlayer::RemoveObject signature"); delete hConfig; RegAdminCmd("sm_ownaimbuilding", Command_OwnAim, ADMFLAG_ROOT); }
public Action Command_OwnAim(int client, int args) { int obj = GetClientAimTarget(client, false); if(IsValidEntity(obj)) { SetBuilder(obj, client); PrintToChat(client, "Building (%i) is now yours %N", obj, client); }
return Plugin_Handled; }
stock void SetBuilder(int obj, int client) { int iBuilder = GetEntPropEnt(obj, Prop_Send, "m_hBuilder"); bool bMiniBuilding = GetEntProp(obj, Prop_Send, "m_bMiniBuilding") || GetEntProp(obj, Prop_Send, "m_bDisposableBuilding");
if(iBuilder > 0 && iBuilder <= MaxClients && IsClientInGame(iBuilder)) SDKCall(g_hSDKRemoveObject, iBuilder, obj); SetEntPropEnt(obj, Prop_Send, "m_hBuilder", -1); AcceptEntityInput(obj, "SetBuilder", client); SetEntPropEnt(obj, Prop_Send, "m_hBuilder", client); SetVariantInt(GetClientTeam(client)); AcceptEntityInput(obj, "SetTeam"); SetEntProp(obj, Prop_Send, "m_nSkin", bMiniBuilding ? GetClientTeam(client) : GetClientTeam(client) - 2); }
tf2.setbuilder.txt
|