Quantcast
Channel: SA-MP Forums
Viewing all articles
Browse latest Browse all 18226

Detect player throwing grenades

$
0
0
Hi,

the title says it all: How do I reliably check for when a player throws a grenade? I've browsed the forums already and found this function here.

Code:

public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
        new weaponid = GetPlayerWeapon(playerid);
        if(newkeys & KEY_FIRE && weaponid == 16)//16 for grenade
        {
          // your codes
        }
        return 1;
}

This is not 100% reliable though. Grenades are thrown with a small delay after pressing the fire key which allows players to switch weapons mid-animation and have the animation play out without actually throwing a grenade. A possible solution would be to run a short but frequently repeating timer for the duration of the animation and check if the currently armed weapon is a grenade. Thoughts?

Viewing all articles
Browse latest Browse all 18226

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>