User Tools

Site Tools


scripting:introduction_to_events

Event Scripting Overview

Events are triggered on your world server when various things happen - for instance, a 'UseItem' event is triggered when a player uses an item - and you add script for each event - for instance, adding a particle effect and changing a score whenever a particular item is used. You control events on your world server by script through the file Data/Script/ServerScript.mit.

Event Script Example

Here's an example of an event script file..

	Event( "NewBuilding", "3" ) 
	{ 
		*say %PLAYER% built building 3 
		*grantcash %PLAYER% 400 
	} 

	Event( "UseItem", "Bread" ) 
	{ 
		*say %PLAYER% used the kudos item 
		*grantkudos %PLAYER% 1 
		*resetpos %PLAYER%
	} 

This file defines 2 events. In the example above, whenever a player ('Bob' for instance) builds building type 3, the commands within { } braces are executed. i.e.

	*say Bob built building 3 
	*grantcash Bob 400 

would be entered - the say message will appear in red for all players and 'Bob' will get an extra 40s. Similar procedure for the other event should someone use the 'Bread'.

As well as triggering server commands from script, you can add logic, store persistent (per-player and global) values that can be accessed from other script events, call functions and set timers for events to occur later.

For a full list of events, check the event reference

For a full list of all the '*' commands like say and grantcash, check the command reference.

Next section

scripting/introduction_to_events.txt · Last modified: 2020/01/28 17:50 by 127.0.0.1

Except where otherwise noted, content on this wiki is licensed under the following license: Public Domain
Public Domain Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki