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

I tried search object in client sided but don't working. Object is not synchronization if then I created object when I not online.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.