OnVehicleRespawn: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 14: Line 14:


==Example==  
==Example==  
<!-- Explain what the example is in a single sentance -->
This example shows a message in the chatbox, if it is respawned.
This example does...
<!-- Add the code below, an emphasis should be on making it clear, not optimized. You could provide two versions if you wish, one clear and well commented, the other optimized -->
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
--This line does...
function onVehicleRespawn ( exploded )
blah()
  -- Add this variable. It contains the vehicle name of the respawned vehicle
--This line does this...
  local vehicleName = getVehicleName ( source )
mooo
 
  -- If it is exploded, echo a custom message
  if ( exploded == true ) then
    outputChatBox("A " .. vehiclename .. " has been respawned, after an explosion")
 
  -- else echo a normal message
  else
    outputChatBox("A " .. vehiclename .. " has been respawned")
  end
end
 
-- Add the Event Handler
addEventHandler ( "OnVehicleRespawn", getRootElement(), onVehicleRespawn )
</syntaxhighlight>
</syntaxhighlight>


==See Also==
==See Also==
{{Event_functions}}
{{Event_functions}}
[[Category:Needs Example]]

Revision as of 11:58, 5 January 2008

This event is triggered when a vehicle is respawned due. See toggleVehicleRespawn.

Parameters

bool exploded
  • exploded: true if this vehicle respawned because it exploded, false if it respawned due to being deserted.

Source

The source of this event is the vehicle that respawned.

Example

This example shows a message in the chatbox, if it is respawned.

function onVehicleRespawn ( exploded )
  -- Add this variable. It contains the vehicle name of the respawned vehicle
  local vehicleName = getVehicleName ( source )
  
  -- If it is exploded, echo a custom message
  if ( exploded == true ) then 
    outputChatBox("A " .. vehiclename .. " has been respawned, after an explosion")
  
  -- else echo a normal message
  else 
    outputChatBox("A " .. vehiclename .. " has been respawned")
  end
end

-- Add the Event Handler
addEventHandler ( "OnVehicleRespawn", getRootElement(), onVehicleRespawn )

See Also