onTrainArrive

From Liberty Unleashed Wiki
Revision as of 23:53, 12 September 2011 by Juppi (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search
Home   |   Squirrel Scripting   |   Server Functions   |   Server Events   |   Client Functions   |   Client Events
LU This function works in Liberty Unleashed only.

This is called when a train arrives at a train station.

Syntax

  1. function onTrainArrive( int train, int station )

Arguments

  • train - The ID of the train in question
  • station - The station the train arrived at. See a list of constants here.

Returns

This event does not handle return values.

Example

This example will message the player when their train arrives at a station.

  1.  
  2. function onTrainArrive( train, station )
  3. {
  4. if ( train == FindLocalPlayer().Train )
  5. {
  6. Message( "You arrived at " + GetTrainStationName( station ) + " Station" );
  7. }
  8. return 1;
  9. }
  10.  
  11. function GetTrainStationName( station )
  12. {
  13. switch ( station )
  14. {
  15. // L-train
  16. case STATION_STMARKS:
  17. return "Baillie";
  18. case STATION_HEPBURN:
  19. return "Rothwell";
  20. case STATION_CHINATOWN:
  21. return "Kurowski";
  22.  
  23. // Subway
  24. case STATION_PORTLAND:
  25. return "Portland";
  26. case STATION_ROCKFORD:
  27. return "Rockford";
  28. case STATION_TERMINAL:
  29. return "Shoreside Terminal";
  30. case STATION_STAUNTON:
  31. return "Staunton South";
  32. }
  33.  
  34. return "Train";
  35. }
  36.  

Notes

The functions Message, FindLocalPlayer and Player.Train were used in this example. More info about them can be found in the corresponding pages.

Related Events

Personal tools
Namespaces

Variants
Actions
Navigation
scripting
Toolbox