Sign in to follow this  
Legend

mp.objects.new problem when server starting

Recommended Posts

Hi.

When server started then running my script (and print good value(example: Retrieved 1 trashes)) but I connecting my server and object isn't seen. It's good if then execute my script when running the server.

var cachedTrashes = [];

function loadTrashes() {
    global.db.query("SELECT * FROM `trashes`", function(error, results, fields) {
        if(error) { 
            console.log("error while retrieving trashes from mysql database! (" + error + ")");
        } else {
            results.forEach(function(currElement) {
                let obj = mp.objects.new(mp.joaat("prop_bin_delpiero"), new mp.Vector3(parseFloat(currElement.x), parseFloat(currElement.y), parseFloat(currElement.z)),
                {
                    rotation: 0.0,
                    alpha: 255,
                    dimension: parseInt(currElement.dim)
                });
                obj.setVariable("inv:trash", true);
                cachedTrashes[parseInt(currElement.id)] = obj;
            });
            console.log("Retrieved " + results.length + " trashes");
        }
    });
}
loadTrashes();

Please help me. :D

Edit: 

If reconnected then I don't see again my server sided objects when I ran my script after server start.

Edited by Legend

Share this post


Link to post
Share on other sites

coul be issue that some objects seem to be broken in meaning they don't shop up. I have some objects spawned which now are gone since last gta update. 

Share this post


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
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.