Jump to content

1 Screenshot

About This File

Draw-zone script

Description: Drawing zones on map by using (tab, space, del) buttons and save it as polygon (call remote event drawZone.save)

Controls:

Tab - Place user mark on map (can be moved to draw lines)

Space - Save dot on mark place

Del - delete previous dot

Commands:

/zstart - Start drawing zones on map

/zstop - Stop drawing zones

/zreset - Reset drawing

/zsave - Saving coords (Calling remote event drawZone.save)

/zlist - list of commands

Video snippet: https://imgur.com/a/liLwZo5

Repository: https://github.com/READYTOMASSACRE/ragemp-draw-zone

Edited by cacao

  • Like 3

User Feedback

Create an account or sign in to leave a review

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

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

Eager

   1 of 2 members found this review helpful 1 / 2 members

How can I use these Vector3 in a blip or colshape ?

Response from the author:

You can do it like that (server-side code):

btw, readSync/writeSync bad practice, use async methods for i/o

// savecoords.js
// It saves coords in same directory in file "drawzones.json" by default
// Saved data will look like [ [[x0, y0], [x1, y1], ..., [xN, yN]], ... (other polygons will have same structure) ]
(() => {
    try {
        const path = require('path');
        const fs = require('fs');
        
        const save = ({ asFile = false, file = 'drawzones.json', coords }) => {
          if (!asFile) return console.log(coords) // you can just output logs

          const filepath = path.resolve(__dirname, '.', file);
          const exists = fs.existsSync(filepath);
        
          let payload = [coords];
        
          if (exists) {
            payload = [
              ...JSON.parse(fs.readFileSync(filepath).toString()),
              ...payload,
            ];
          }
        
          fs.writeFileSync(filepath, JSON.stringify(payload));
        }
        
        mp.events.add('drawZone.save', coords => {
          try {
            save({ asFile: true, coords: JSON.parse(coords) });
          } catch (err) {
            console.error(err);
          }
        });
    } catch (err) {
        console.error(err);
    }
})();

If you have questions, you can ask me in discord: RAGEКАКАО#0980

  • Like 1
Kopra

  

Very cool, great one!

  • Like 1
×
×
  • Create New...