|
Veteran Member
Join Date: Jun 2013
Location: IsValidClient()
|
05-05-2021
, 10:13
Re: [TF2] How to disable player picks up weapons?
|
#15
|
Quote:
Originally Posted by MasterMind420
This will prevent any item pickup you choose in onentitycreated...
Code:
public void OnEntityCreated(int entity, const char[] classname)
{
if (StrEqual(classname, "item classname you don't want to pickup here"))
{
SDKHook(entity, SDKHook_SpawnPost, SpawnPost);
}
}
public void SpawnPost(int entity)
{
SDKHook(entity, SDKHook_Use, OnPlayerUse);
}
public Action OnPlayerUse(int entity, int activator, int caller, UseType type, float value)
{
int client = activator;
if (IsEntityValid(entity) && IsClientValid(client))
{
return Plugin_Handled;
}
return Plugin_Continue;
}
stock bool IsClientValid(int client)
{
return (client > 0 && client <= MaxClients);
}
stock bool IsEntityValid(int entity)
{
return (entity > 0 && IsValidEntity(entity));
}
|
In the OnPlayerUse callback, why did you define a new variable for client instead of just changing activator to client?
|
|
|
|