Jump to content
RAGE Multiplayer Community

mp.objects.new problem when server starting


Legend
 Share

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
Link to comment
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
 Share

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...