Raised This Month: $51 Target: $400
 12% 

[TF2] Grappling hook only for vips?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
ElleVen
AlliedModders Donor
Join Date: May 2016
Location: Italy, Milan
Old 06-06-2016 , 15:51   [TF2] Grappling hook only for vips?
Reply With Quote #1

Hi reddits.
any way to restrict the grappling hook (tf_grapplinghook_enable 1) only to a flag? THANK YOU ALL!
__________________

Last edited by ElleVen; 06-06-2016 at 15:52. Reason: mistyped bacon .-.
ElleVen is offline
ElleVen
AlliedModders Donor
Join Date: May 2016
Location: Italy, Milan
Old 06-06-2016 , 18:28   Re: [TF2] Grappling hook only for vips?
Reply With Quote #2

Quote:
Originally Posted by abrandnewday View Post
1. This isn't Reddit.
2. You can't restrict a global convar that is changed by the server to a flag. You'll need that convar set to 1, and then you'll need a plugin that hooks the post_inventory_application event (spawning in or touching a resupply locker). In that event hook, check the client's flags. If the flags don't match VIP, do something to the grapple hook like clearing their slot so they no longer have access to it.
1. i was joking...
2. O.O i dont even understand what you're saying... i dont even have tf2 installed im just making a server for my community... can you explain what you sayed it to a newbie?
__________________

Last edited by ElleVen; 06-06-2016 at 19:11.
ElleVen is offline
ZAGOR
AlliedModders Donor
Join Date: Sep 2015
Old 06-07-2016 , 18:23   Re: [TF2] Grappling hook only for vips?
Reply With Quote #3

Yes, im looking too..
__________________

ZAGOR is offline
ElleVen
AlliedModders Donor
Join Date: May 2016
Location: Italy, Milan
Old 06-08-2016 , 11:29   Re: [TF2] Grappling hook only for vips?
Reply With Quote #4


__________________
ElleVen is offline
Chaosxk
Veteran Member
Join Date: Aug 2010
Location: Westeros
Old 06-08-2016 , 14:16   Re: [TF2] Grappling hook only for vips?
Reply With Quote #5

Think he's missing the gamedata file.

Here is mines, i used SDKHook_WeaponCanUse instead.
The default flag Generic but can be overrided with "sm_vipgrappler_override" or you can edit it in the code yourself.

Also the plugin only enables if tf_grapplinghook_enable is also enabled.

Code:
#pragma semicolon 1

#define PLUGIN_AUTHOR "Tak (Chaosxk)"
#define PLUGIN_VERSION "0.01"
#define GRAPPLER 1152

#include <sourcemod>
#include <sdktools>
#include <sdkhooks>

#pragma newdecls required

ConVar cEnabled;
bool bEnabled;

public Plugin myinfo = 
{
	name = "[TF2] Grappling Hook for VIPS",
	author = PLUGIN_AUTHOR,
	description = "Allow grappling hook for vips only.",
	version = PLUGIN_VERSION,
	url = "https://forums.alliedmods.net/showthread.php?t=283607"
};

public void OnPluginStart()
{
	CreateConVar("sm_vipgrappler_version", "Version for vip grappler.", PLUGIN_VERSION, FCVAR_PLUGIN|FCVAR_SPONLY|FCVAR_DONTRECORD|FCVAR_NOTIFY);
	
	cEnabled = FindConVar("tf_grapplinghook_enable");
	
	cEnabled.AddChangeHook(OnConvarChanged);
	
	ExecuteLateLoad();
}

public void OnConfigsExecuted()
{
	bEnabled = cEnabled.BoolValue;
	//Removes grappler is plugin is late-loaded/refreshed during gameplay
	RemoveGrappler();
}

public void OnConvarChanged(Handle convar, char[] oldValue, char[] newValue) 
{
	if (StrEqual(oldValue, newValue, true))
		return;
		
	int iNewValue = !!StringToInt(newValue);
	
	if(convar == cEnabled)
	{
		bEnabled = view_as<bool>(iNewValue);
		RemoveGrappler();
	}
}

public void OnClientPutInServer(int client)
{
	SDKHook(client, SDKHook_WeaponCanUse, OnWeaponCanUse);
}

public Action OnWeaponCanUse(int client, int weapon)
{
	if(!bEnabled)
		return Plugin_Continue;
	int index = GetEntProp(weapon, Prop_Send, "m_iItemDefinitionIndex");
	
	if(index == GRAPPLER && !CheckCommandAccess(client, "sm_vipgrappler_override", ADMFLAG_GENERIC, false))
		return Plugin_Handled;
		
	return Plugin_Continue;
}

void ExecuteLateLoad()
{
	for (int i = 1; i <= MaxClients; i++)
	{
		if(!IsClientInGame(i))
			continue;
		SDKHook(i, SDKHook_WeaponCanUse, OnWeaponCanUse);
	}
}

void RemoveGrappler()
{
	if(!bEnabled)
		return;
		
	//Can i get the grappling hook with GetClientWeaponSlot? Doesn't seem to work.
	int entity;
	while((entity = FindEntityByClassname(entity, "tf_weapon_grapplinghook")) != -1)
	{
		int owner = GetEntPropEnt(entity, Prop_Send, "m_hOwnerEntity");
		if(!CheckCommandAccess(owner, "sm_vipgrappler_override", ADMFLAG_GENERIC, false))
		{
			SDKHooks_DropWeapon(owner, entity, NULL_VECTOR, NULL_VECTOR);
			AcceptEntityInput(entity, "kill");
		}
	}
}
Attached Files
File Type: sp Get Plugin or Get Source (vipgrappler.sp - 335 views - 2.3 KB)
__________________
Chaosxk is offline
ElleVen
AlliedModders Donor
Join Date: May 2016
Location: Italy, Milan
Old 06-08-2016 , 15:41   Re: [TF2] Grappling hook only for vips?
Reply With Quote #6

Quote:
Originally Posted by abrandnewday View Post
Oh take off, eh. I was giving you a starting point, I wasn't giving you a fully working plugin especially after the salt shaker emotes. Have fun trying to fix it.
Opss somebody fixed it for me
__________________
ElleVen 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 04:05.


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