DeimisT Posted April 29, 2021 Share Posted April 29, 2021 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 comment Share on other sites More sharing options...
hdrtop Posted May 1, 2021 Share Posted May 1, 2021 (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 May 1, 2021 by hdrtop added reason Link to comment Share on other sites More sharing options...
MrPancakers Posted May 2, 2021 Share Posted May 2, 2021 17 hours ago, hdrtop said: SetVariable/GetVariable only works Server-Side (https://wiki.rage.mp/index.php?title=Entity::setVariable). Only setVariable is server-side only, getVariable can be used client-side. 1 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now