Hi reddits.
any way to restrict the grappling hook (tf_grapplinghook_enable 1) only to a flag? THANK YOU ALL!
:bacon!: :bacon!: :bacon!: :bacon!: :bacon!:
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... :salty: :salty: :salty:
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?
https://i.gyazo.com/078c40c326367e9629f40596410d5128.png
http://replygif.net/i/88.gif
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.
#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|FC VAR_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");
}
}
}
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 :D
8)8)8)8)8)
vBulletin® v3.8.7, Copyright ©2000-2024, vBulletin Solutions, Inc.