addToWorld

From GTA Connected
Jump to navigation Jump to search

Function Server and Client All Games Online and Offline

Server 1.0.0, Client 1.0.0

void addToWorld(Element element)

Description

The addToWorld function is used to add the element to the game.
Currently, this function only needs to be called for elements created server-side, not for elements created client-side.

Parameters

Type Name Presence Default Value Description
Element
element
required n/a The element to add to the game.

Returns

Success Returns

Type Description
void
This function doesn't return any values on success.

Failure Returns

Type Value
void
n/a

Notes

Examples

Example 1 - JavaScript - Server-Side:

addCommandHandler('vehicle', function(command, parameters, client)
{
    if(client.player && parameters.trim() != '') // ensure player is spawned and input text isn't blank
    {
        var model = parseInt(parameters);
        var vehicle = createVehicle(model, client.player.position);
        addToWorld(vehicle); // currently, if the element is created client-side, this line of code isn'
t needed.
    }
});

Compatibility

  • This function was previously named game.addToWorld in version 1.0.71.

Related

Server Related

addToWorld
gta.ssvBridgeEnabled


Client Related

addToWorld
gta.findGroundZForCoord
gta.setPlanesEnabled
gta.setTrainsEnabled
removeFromWorld