Raised This Month: $ Target: $400
 0% 

OnWeaponUse Issue


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
ShadowRanger
Junior Member
Join Date: Aug 2017
Old 10-29-2017 , 23:54   OnWeaponUse Issue
Reply With Quote #1

I'm having an issue with the OnWeaponUse event which I'm trying to use to prevent weapons from being picked up but also not removing the player's current weapon which happens if I don't add the GivePlayerItem at the end and also removing the weapon that gets dropped. The issue is that whenever I try and pick up a weapon, a few seconds after the client/server crashes. I'm not sure what I'm doing wrong.

Code:
public Action OnWeaponCanUse(int client, int weapon)
{
	// Exit if a fun round is not in progress
	if (!g_startedFunRound) return Plugin_Continue;

	// Run some other checks
	if (!IsClientInGame(client)) return Plugin_Continue;
	if (!IsPlayerAlive(client)) return Plugin_Stop;

	// Prevent the weapon from being picked up
	if (IsValidEntity(weapon))
	{
		AcceptEntityInput(weapon, "Kill");
	}

	if (!StrEqual(g_curRoundWeapon, "weapon_knife"))
	{
		GivePlayerItem(client, g_curRoundWeapon);
	}

	return Plugin_Handled;
}
ShadowRanger is offline
 



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 23:11.


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