OnClientProjectileCreation: Difference between revisions
Jump to navigation
Jump to search
m (→Example) |
|||
Line 37: | Line 37: | ||
This will disable people from creating flares. ( Dropped by hydra's ) | This will disable people from creating flares. ( Dropped by hydra's ) | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
function disableFlares ( | function disableFlares ( ) | ||
local projType = getProjectileType( source ) -- get the projectile type | local projType = getProjectileType( source ) -- get the projectile type | ||
if projType == 58 then -- if the projectile is a flare | |||
destroyElement(source) -- notice cancelEvent() does not work, so this destroys the projectile element after it was created. | |||
end | |||
end | end | ||
Line 49: | Line 50: | ||
addEventHandler( "onClientProjectileCreation", getRootElement(), disableFlares ) -- when a projectile gets created call disableFlares. | addEventHandler( "onClientProjectileCreation", getRootElement(), disableFlares ) -- when a projectile gets created call disableFlares. | ||
</syntaxhighlight> | </syntaxhighlight> | ||
==See Also== | ==See Also== | ||
===Client projectile events=== | ===Client projectile events=== | ||
{{Client_projectile_events}} | {{Client_projectile_events}} |
Revision as of 22:18, 17 May 2012
This event is triggered when a projectile is created.
Parameters
element creator
Source
The source of this event is the projectile that was created.
Example
This will output a chatbox message when someone creates a projectile.
function projectileCreation() outputChatBox("A projectile was created!") end addEventHandler("onClientProjectileCreation", getRootElement(), projectileCreation)
This will punish a player for throwing a teargas grenade. When he throws it he keeps getting warped to the location where the teargas got created, and also the teargas keeps getting warped to it. This will result in +/-60hp loss for the creator.
function punishSatchelUsersz ( creator ) local zeType = getProjectileType( source ) if zeType == 17 then local zePlayerName = getPlayerName ( creator ) outputChatBox ( zePlayerName.." is a noob teargas user! But he got punished for it don't worry." ) local x, y, z = getElementPosition ( source ) --Getting the position from the projectile creator setTimer ( setElementPosition, 50, 250, source, x, y, z-0.5 ) setTimer ( setElementPosition, 50, 250, creator, x, y, z-0.5 ) end end addEventHandler( "onClientProjectileCreation", getRootElement(), punishSatchelUsersz )
This will disable people from creating flares. ( Dropped by hydra's )
function disableFlares ( ) local projType = getProjectileType( source ) -- get the projectile type if projType == 58 then -- if the projectile is a flare destroyElement(source) -- notice cancelEvent() does not work, so this destroys the projectile element after it was created. end end addEventHandler( "onClientProjectileCreation", getRootElement(), disableFlares ) -- when a projectile gets created call disableFlares.
See Also
Client projectile events