Raised This Month: $ Target: $400
 0% 

Infinite HE/Decoy grenades issue


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
PersianMG
Member
Join Date: Dec 2014
Old 02-22-2015 , 05:54   Infinite HE/Decoy grenades issue
Reply With Quote #1

So as a part of a plugin I have some code that gives you infinite HE grenades or infinite decoy grenades for 1 round. The nade is the only 'weapon' you have to use for the entire round (you can't pick up other guns or use knife).

The way i've done it is a nade is given to you 1.75 seconds after you throw one (you are initially spawned with 1 grenade). However, the issue is that sometimes (i'm not sure what causes it), a player will no longer be able to throw their nade, the nade will appear on their hud and when they try to drop it they get the 'You cant drop your HE grenade' message but their viewmodel of them holding the grenade is not there and they cannot throw the grenade. This ruins the gamemode obviously for the rest of the round for this person.

Any idea what might be causing this?
Code is below.

Thanks in advance

Code:
//The following line is in OnPluginStart()
HookEvent("weapon_fire", Event_GrenadeThrow);

/*
* Give client a grenade after they throw it, used in some events
*/
public Action:Event_GrenadeThrow(Handle:event, const String:name[], bool:dontBroadcast)
{
  if (!isEnabled) 
    return Plugin_Continue;
  
  //Return if not grenade round
  if (eventDay != EVENT_HEONLY && eventDay != EVENT_1HPDECOY)
    return Plugin_Continue;
  
  new String:weapon[32]; 
  GetEventString(event, "weapon", weapon, sizeof(weapon));

  if(StrEqual(weapon, "hegrenade", false) || StrEqual(weapon, "decoy", false)) 
  { 
    new client = GetClientOfUserId(GetEventInt(event, "userid"));
    CreateTimer(1.75, Timer_GiveGrenade, client);
    return Plugin_Handled;
  }
  
  return Plugin_Handled;
}

/*
* Timer - Give client a grenade based on event day
*/
public Action:Timer_GiveGrenade(Handle:timer, any:client)
{
  if (eventDay == EVENT_HEONLY)
    GivePlayerItem(client, "weapon_hegrenade");
  else if (eventDay == EVENT_1HPDECOY)
    GivePlayerItem(client, "weapon_decoy");
}

Last edited by PersianMG; 02-22-2015 at 05:54.
PersianMG 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 11:11.


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