You: your credits, level, skill points, the car you're driving, and teleporting it somewhere new.
Thread: game thread only (Game.Tick, Game.Run, or an ANNA entry). CanTeleport can be read from any thread.
Example
Two ANNA menu entries: one gives you 10,000 credits, one takes you to the waypoint you set on the map.
protected override void OnInit()
{
// ANNA entries run on the game's thread.
ANNA.Menu.Add("Get 10,000 CR", () => Player.Credits += 10_000);
ANNA.Menu.Add("Go to waypoint", () =>
{
var target = World.Waypoint;
if (target is not null && Player.CanTeleport)
Player.TeleportTo(target.Value);
});
}
Protected Overrides Sub OnInit()
' ANNA entries run on the game's thread.
ANNA.Menu.Add("Get 10,000 CR", Sub() Player.Credits += 10000)
ANNA.Menu.Add("Go to waypoint",
Sub()
Dim target = World.Waypoint
If target IsNot Nothing AndAlso Player.CanTeleport Then
Player.TeleportTo(target.Value)
End If
End Sub)
End Sub
Members
Properties
| Member | What it does |
|---|---|
Car (property, get, Vehicle?) | The car you're driving this frame, or null (in a menu, on the title screen). |
Credits (property, get/set, int) | Your credits (CR), as the HUD shows them. Values below 0 are set as 0. |
Level (property, get, int) | Your driver level. |
SkillPoints (property, get/set, int) | Skill points to spend in the skill tree. Values below 0 are set as 0. |
CurrentGarageId (property, get, int) | The garage id of your current car (Garage > Change car). Use it with Garage. |
CanTeleport (property, get, bool) | True if TeleportTo can be used on this game build. |
Methods
| Member | What it does |
|---|---|
TeleportTo(Vector3 position) | Puts your car on the road nearest position, facing along it, as the game's fast travel does: on the ground, stopped. Only X and Z need to be right. |
Notes
Player.Caris null when you're not driving. Check for null (Is Nothingin VB) before using it.Player.Caris only valid for the frame you got it in. Get it again each tick; don't keep it.Credits,Level,SkillPointsandCurrentGarageIdread and write the current profile. They throw anInvalidOperationExceptionwhen no profile is loaded yet (the title screen). Changes reach the save the next time the game saves.- After
TeleportTo, the world loads around the car for a moment. The car is held still for about 2.5 seconds, and placed again after about 1.5 seconds. TeleportTothrows anInvalidOperationExceptionifCanTeleportis false, or if the game's fast travel isn't there (for example, when you're not in free roam).- On a game build the SDK doesn't know,
CanTeleportis false andplatform.logsays so ("Player.TeleportTo off"). If the wholeGameclass is off, nothing runs on the game thread at all; see Game. - Using these members off the game thread throws an
InvalidOperationExceptionthat says to useGame.TickorGame.Run.
