OnPickupSpawn: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
(Added an example.)
Line 4: Line 4:


==Parameters==
==Parameters==
This event has no arguments
No parameters.


<!-- Add the event's source in the section below -->
==Source==
==Source==
The [[event system#Event source|source]] of this event is the [[pickup]] that just spawned or respawned.
The [[event system#Event source|source]] of this event is the [[pickup]] that just spawned or respawned.

Revision as of 22:06, 2 April 2018

This event is triggered when a pickup is spawned or respawned.

Parameters

No parameters.

Source

The source of this event is the pickup that just spawned or respawned.

Example

This example get's the area and city name when a pickup spawns and outputs it to all the players.

function outputSpawn ()
	local area = getElementZoneName ( source ) -- Get the area name where the pickup spawned.
	local city = getElementZoneName ( source, true ) -- Get the city name where the pickup spawned.
	outputChatBox ( "A pickup has spawned in " .. area .. " ( " .. city .. " )", getRootElement(), 255, 0, 0 ) -- Output the pickup spawn.
end
addEventHandler ( "onPickupSpawn", getRootElement(), outputSpawn ) -- Trigger the function when a pickup spawns.

See Also

Pickup events


Event functions