The ClientAPI (custom content)
Last updated
Last updated
THIS PAGE IS A WORK IN PROGRESS.
Since sending dll's mod to clients would represent a security risk we've made a small client api that allows you to interact with the clients and load custom content. It is pretty basic but it can already allow for a TON of stuff. Only your imagination is your limit. The ClientAPI works by using paths from the hierarchy for non-networked objects. It is not 100% safe as if a client hierarchy get out of sync it could stop working. However things like buildings, map, ATM's etc.. that are static should not be impacted by this if you follow the general rules.
The ClientAPI offers mostly extension methods to GameObjects ending by Clientside. Most of the methods sends a network message to the client to tell him to move an object, rotate it, disable it, call a method on it etc. For most things it is saved for new players such as position, rotation, destroying, disabling etc. Which means that if when your plugin starts you remove the police office, new players will get that removal action when they connect.
Warning, the only 2 methods not saved upon reconnect are InvokeMethodClientside
and SetVariableClientside
. So if you use them for changing something permanently you might want to listen when a new player joins and call it again for this player.
The ClientAPI also works with NetworkObjects (Players, Vehicles etc) And is more stable than the hierarchy path approach (It'll internally detect when its a NetworkObject or child of one).
This sets the position of the object you pass.
There is also SetLocalPositionClientside
for changing the position relative to the gameobject parent.
This sets the rotation of the object you pass.
There is also SetLocalRotationClientside
for changing the rotation relative to the gameobject parent.
This allows you to disable objects, simple call it with either true or false to set the object as active (true) or inactive (false).
This allows you to set a gameobject parent.
This allows you to create a copy of a gameobject. (Not working with network objects)
It returns the cloned object so you can then use for example SetPositionClientside
on it.
Allows you enable or disable specific components. You can use it to disable game scripts, renderers or parts of an object.
This is probably one of the most powerful methods of the API yet. It allows to invoke any method on any object with any parameters.
This is also one of the most powerful methods as it allows you to set any variables on any game object.
This allows you to destroy objects on the client.
I would personally not recommend using the DestroyClientside method but instead use SetActiveClientside unless you know what you are doing. Deleting map objects could cause the game to have errors, lag and eventually get the hierarchy out of sync and all other methods would stop working.
This will disable the rendering of the current vehicle body (Police shitbox for testing).
This will enable the police lights and sirens on the current vehicle if any.
I think a screenshot will be enough for the explanation.