This function is used to create a vehicle at a 3D position.
createVehicle(int model, float x, float y, float z, float rx, float ry, float rz)
- int model: The model ID of the vehicle you would like to create
- float x: The X position to create the vehicle at
- float y: The Y position to create the vehicle at
- float z: The Z position to create the vehicle at
- float rx: The RX (rotation) position to create the vehicle at
- float ry: The RY (rotation) position to create the vehicle at
- float rz: The RZ (rotation) position to create the vehicle at
- int - vehicleid which was created
//SERVER
addCommandHandler( "run",
function( playerid )
{
local myPos = getPlayerPosition(playerid)
local vehicleid = createVehicle( 0, myPos[0], myPos[1], myPos[2], 0.0, 0.0, 0.0 );
});
This function is used to destroy (remove) a created vehicle.
destroyVehicle(int vehicleid)
- int vehicleid: The vehicleid to destroy
Returns 'true' if successful, 'false' otherwise.
//SERVER
addCommandHandler( "run",
function( playerid )
{
local myPos = getPlayerPosition(playerid)
local vehicleid = createVehicle( 0, myPos[0], myPos[1], myPos[2], 0.0, 0.0, 0.0 );
destroyVehicle( vehicleid );
});
This function is used to trigger a client event
triggerClientEvent(int playerid, string event, ...)
- int playerid: The ID of the player
- string event: The name of the event to trigger
- ...: (Optional) Arguments to sent to the events function
Returns 'true' if successful, 'false' otherwise.
//SERVER
function playerSpawn( playerid )
{
triggerClientEvent( playerid, "myEvent", "My String" );
}
addEventHandler( "onPlayerSpawn", playerSpawn );
//CLIENT
addEventHandler("myEvent",
function( str )
{
log( "Output: " + str );
});