Jump to content
RAGE Multiplayer Community

Checkpoint in client side not working


Recommended Posts

let BusCP = null;

mp.events.add("CreateCheckpointCustom", (posX,posY,posZ) => {
    BusCP.setVariable("BusCP","BusCP") = mp.checkpoints.new(47, new mp.Vector3(posX,posY,posZ), 1,
    {
        color: [ 255, 255, 255, 255 ],
        visible: true,
        dimension: 0
    });

});

mp.events.add("playerEnterCheckpoint", (checkpoint) => {
    if(checkpoint.getVariable("BusCP") == "BusCP") {
        //entered
    } else {
        //no
    }
});

I get an error cannot read property getVariable,  how to fix it?

Link to post
Share on other sites
Posted (edited)

Replace your code with:

var BusCP = null;

mp.events.add("CreateCheckpointCustom", (posX,posY,posZ) => {
    BusCP = mp.checkpoints.new(47, new mp.Vector3(posX,posY,posZ), 1,
    {
        color: [ 255, 255, 255, 255 ],
        visible: true,
        dimension: 0
    });

});

mp.events.add("playerEnterCheckpoint", (checkpoint) => {
    if(checkpoint == "BusCP") {
        //entered
    } else {
        //no
    }
});

SetVariable/GetVariable only works Server-Side (https://wiki.rage.mp/index.php?title=Entity::setVariable).

Just add to the created variable the checkpoint itself. If you want to create variables for this checkpoint you can do
 

// BusCP.variable - EXAMPLE:
BusCP.name = "Bus Ckecpoint";

 

Edited by hdrtop
added reason
Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...