OnPlayerProjectileCreation: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
 
Line 23: Line 23:
The [[event system#Event source|source]] of this event is the [[player]] who created the projectile.
The [[event system#Event source|source]] of this event is the [[player]] who created the projectile.


===Canceling===
==Canceling==
If this event is [[Event system #Canceling|canceled]], the projectile will not be created for other players on the server.
If this event is [[Event system #Canceling|canceled]], the projectile will not be created for other players on the server.



Latest revision as of 06:51, 8 June 2024

BETA: NEW FEATURE (BUILD: 1.6.0 r22293)
This event is triggered every time a projectile is created by a player - either through a weapon, a vehicle weapon or createProjectile.

Parameters

int weaponType, float x, float y, float z, float force, element target, float rotX, float rotY, float rotZ, float velX, float velY, float velZ
  • weaponType: ID, see below
ID Name/Description
16 Grenade
17 Tear Gas Grenade
18 Molotov
19 Rocket (simple)
20 Rocket (heat seeking)
21 Air Bomb
39 Satchel Charge
58 Hydra flare
  • x: X coordinate of where the projectile was created
  • y: Y coordinate of where the projectile was created
  • z: Z coordinate of where the projectile was created
  • force: force of thrown projectile. Valid for ID 16, 17, 18, 39.
  • target: element the projectile is targeting. Valid for ID 19, 20.
  • rotX: X rotation. Valid for ID 19, 20.
  • rotY: Y rotation. Valid for ID 19, 20.
  • rotZ: Z rotation. Valid for ID 19, 20.
  • velX: X axis velocity. Valid for ID 16, 17, 18, 19, 20, 39.
  • velY: Y axis velocity. Valid for ID 16, 17, 18, 19, 20, 39.
  • velZ: Z axis velocity. Valid for ID 16, 17, 18, 19, 20, 39.

Source

The source of this event is the player who created the projectile.

Canceling

If this event is canceled, the projectile will not be created for other players on the server.

Example

local projectileNames = {
    [16]='Grenade',
    [17]='Tear Gas Grenade',
    [18]='Molotov',
    [19]='Rocket (simple)',
    [20]='Rocket (heat seeking)',
    [21]='Air Bomb',
    [39]='Satchel Charge',
    [58]='Hydra flare'
}

addEventHandler('onPlayerProjectileCreation', root,
    function(weaponType)
        cancelEvent()
        
        local weaponName = projectileNames[weaponType] or 'Unknown'
        outputServerLog('* '..getPlayerName(source)..' created projectile ('..weaponName..')! most likely he is cheater, event canceled')
    end
)

See Also

Player events


Event functions