Raised This Month: $114 Target: $400
 28% 

[TF2] How to disable player picks up weapons?


Post New Thread Reply   
 
Thread Tools Display Modes
Chdata
Veteran Member
Join Date: Aug 2012
Location: Computer Chair, Illinois
Old 07-05-2015 , 11:38   Re: [TF2] How to disable player picks up weapons?
Reply With Quote #11

good idea, though i've never tried using settransmit before in any of my modding
__________________
Chdata is offline
Ronas963
Junior Member
Join Date: Jun 2016
Old 05-03-2021 , 14:57   Re: [TF2] How to disable player picks up weapons?
Reply With Quote #12

if I put server.cfg tf_dropped_weapon_lifetime 0 but it is not worked

they can pick it up. but something idea?
Ronas963 is offline
MasterMind420
Veteran Member
Join Date: Nov 2010
Old 05-04-2021 , 15:33   Re: [TF2] How to disable player picks up weapons?
Reply With Quote #13

Quote:
Originally Posted by Ronas963 View Post
if I put server.cfg tf_dropped_weapon_lifetime 0 but it is not worked

they can pick it up. but something idea?
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));
}

Last edited by MasterMind420; 05-04-2021 at 15:58.
MasterMind420 is offline
Ronas963
Junior Member
Join Date: Jun 2016
Old 05-05-2021 , 10:07   Re: [TF2] How to disable player picks up weapons?
Reply With Quote #14

Thanks it worked

Last edited by Ronas963; 05-05-2021 at 10:09. Reason: it is worked
Ronas963 is offline
ThatKidWhoGames
Veteran Member
Join Date: Jun 2013
Location: IsValidClient()
Old 05-05-2021 , 10:13   Re: [TF2] How to disable player picks up weapons?
Reply With Quote #15

Quote:
Originally Posted by MasterMind420 View Post
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?
ThatKidWhoGames is offline
MasterMind420
Veteran Member
Join Date: Nov 2010
Old 05-05-2021 , 10:45   Re: [TF2] How to disable player picks up weapons?
Reply With Quote #16

Quote:
Originally Posted by ThatKidWhoGames View Post
In the OnPlayerUse callback, why did you define a new variable for client instead of just changing activator to client?
Readability, why change the original functions labeling? The client is the activator of the use input.

Last edited by MasterMind420; 05-05-2021 at 10:46.
MasterMind420 is offline
Reply


Thread Tools
Display Modes

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 12:29.


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