Events

Client

There are 3 client events intended to be used by external scripts, these are stungrenade:flashed, stungrenade:flashFading and stungrenade:fadedOut. stungrenade:flashed is triggered when a stungrenade flashes the player, it has 4 parameters, strength (0.0-1.0), duration (ms), position (vector3) and distance (meters). A few things to notice are that the strength is the strength added by this flash, not the total and that the duration is the time this flash will last (any new or older flashes might make it longer).

stungrenade:flashFading is triggered when the flash starts to fade out, this is when the weapon wheel is accessible again and when the minimap appears (if those configs are enabled). It has 2 parameters, strength (0.0-1.0) and duration (ms), these are the same as the parameters for stungrenade:flashed.

stungrenade:fadedOut is triggered when the flash has completely faded out, it has no parameters.

Examples

AddEventHandler('stungrenade:flashed', function(strength, duration, position, distance)
    print(string.format("Local player was flashed by a stungrenade at %s, at a distance of %s meters for %s milliseconds with strength %s", position, string.format("%.2f", distance), string.format("%.0f", duration), string.format("%.1f", strength)))
end)

AddEventHandler('stungrenade:flashFading', function(strength, duration)
    print(string.format("Local player flash is starting to fade, the player was flashed at strength %s for %s milliseconds", string.format("%.1f", strength), string.format("%.0f", duration)))
end)

AddEventHandler('stungrenade:fadedOut', function()
    print("Local player flash has completely faded out")
end)

Server

There is also 1 internal server event named stungrenade:explosion, it has one parameter coords, it is triggered by the client. For more information on its usage see Measures Against Cheaters.

Examples

RegisterServerEvent('stungrenade:explosion', function(coords)
    print(string.format("A stungrenade explosion was fired at %s by player with server id %s", coords, source))
end)

Last updated