OnPickupUse: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
mNo edit summary
m (Edited language change)
 
(12 intermediate revisions by 8 users not shown)
Line 1: Line 1:
__NOTOC__  
__NOTOC__  
This event is triggered when a player stands on a pickup while not in a vehicle.
{{Server event}}
This event is triggered when a [[player]] stands on a [[pickup]] while not in a [[vehicle]].
{{Tip|Pickups use [[colshape]]s, you can get the [[colshape]] of the [[pickup]] with [[getElementColShape]] and use [[colshape]] [[event]]s to it.}}


==Syntax==  
==Parameters==
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
void onPickupUse ( player player )
player playerWhoUsed
</syntaxhighlight>  
</syntaxhighlight>  


==Variables==
*'''playerWhoUsed''': a [[player]] element referring to the player who used the [[pickup]].
* The source of this event refers to the pickup which was used
 
*'''player''': A player element refering to the player who used the pickup
==Source==
The [[event system#Event source|source]] of this event is the [[pickup]] that is getting used by the player.


===Canceling===
===Canceling===
Line 15: Line 18:


==Example==  
==Example==  
This example announces whena  player picks up a pickup
This example outputs a message to the chatbox when a player uses a pickup.
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
addEventHandler ( "onPickupUse", getRootElement(), "pickupUse" )
function pickupUse( thePlayer )
function pickupUse ( thePlayer )
     outputChatBox( getPlayerName( thePlayer ) .. " used a pickup!" )
     outputChatBox ( getClientName ( thePlayer ) .. " picked up a pickup!" )
end
end
addEventHandler( "onPickupUse", root, pickupUse )
</syntaxhighlight>
</syntaxhighlight>


==See Also==
{{See also/Server event|Pickup events}}
{{Event_functions}}
 
[[ru:onPickupUse]]

Latest revision as of 12:13, 8 June 2022

This event is triggered when a player stands on a pickup while not in a vehicle.

[[{{{image}}}|link=|]] Tip: Pickups use colshapes, you can get the colshape of the pickup with getElementColShape and use colshape events to it.

Parameters

player playerWhoUsed
  • playerWhoUsed: a player element referring to the player who used the pickup.

Source

The source of this event is the pickup that is getting used by the player.

Canceling

If this event is canceled, the player will not be given the item they picked up.

Example

This example outputs a message to the chatbox when a player uses a pickup.

function pickupUse( thePlayer )
    outputChatBox( getPlayerName( thePlayer ) .. " used a pickup!" )
end
addEventHandler( "onPickupUse", root, pickupUse )

See Also

Pickup events


Event functions

Shared