OnPickupHit: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 21: Line 21:
end
end
end
end
addEventHandler ( "onPickupHit", root, pickedUpWeaponCheck )
addEventHandler ( "onPickupHit", getRootElement(), pickedUpWeaponCheck )
</syntaxhighlight>
</syntaxhighlight>

Revision as of 22:27, 29 September 2007

This event is triggered when a player hits a pickup. A pickup is health, armor, or a weapon.

Syntax

void onPickupHit ( player player ) 

Parameters

  • The source of this event refers to the pickup which was hit by the player.
  • thePlayer: a player element referring to the player who moved over the pickup.

Example

This example creates a pickup and outputs a message to the chat box when the player walks over it

createPickup ( 10.0, 10.0, 10.0, 2, 31, 3000, 50 ) --Create an M4 weapon pickup when script starts

function pickedUpWeaponCheck ( player, matchingDimension )
	if source == myPickup then --If the pickup I grabbed was myPickup
	    outputChatBox ( "You have picked up your pickup weapon" ) --Display this message in the chat box
	end
end
addEventHandler ( "onPickupHit", getRootElement(), pickedUpWeaponCheck )