Jump to content

Recommended Posts

Posted

/save [name (optional)] command to save your/your vehicle's position and heading/rotation to a file just like in SA-MP.

You can find the saved positions inside savedpos.txt on the server folder.

Code:

const fs = require("fs");
const saveFile = "savedpos.txt";

mp.events.addCommand("save", (player, name = "No name") => {
    let pos = (player.vehicle) ? player.vehicle.position : player.position;
    let rot = (player.vehicle) ? player.vehicle.rotation : player.heading;

    fs.appendFile(saveFile, `Position: ${pos.x}, ${pos.y}, ${pos.z} | ${(player.vehicle) ? `Rotation: ${rot.x}, ${rot.y}, ${rot.z}` : `Heading: ${rot}`} | ${(player.vehicle) ? "InCar" : "OnFoot"} - ${name}\r\n`, (err) => {
        if (err) {
            player.notify(`~r~SavePos Error: ~w~${err.message}`);
        } else {
            player.notify(`~g~Position saved. ~w~(${name})`);
        }
    });
});

What the output looks like:

Position: -422.9187316894531, 1133.0765380859375, 325.8547058105469 | Heading: 344.207763671875 | OnFoot - No name
Position: -411.07977294921875, 1180.73681640625, 325.0368957519531 | Rotation: 1.4606590270996094, 0.7490195631980896, 75.47509765625 | InCar - No name
Position: -1087.9407958984375, 4912.0634765625, 214.6710968017578 | Heading: 222.96522521972656 | OnFoot - Altruist Camp

 

  • Like 17
  • Mask 3
  • 9 months later...
  • 1 month later...
  • 2 years later...
  • 2 months later...

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...