Jump to content
RAGE Multiplayer Community

Script dont get x,y,z from database


HarrySchnotter
 Share

Recommended Posts

For some reason the script cant get x, y, z from my database, if im using normal cordinates instead of x,yz its working fine.

mp.events.add("server:KeyE", (player) => {
gm.databaseManager.getConnection().query("SELECT * FROM garagen WHERE 1=1",[],function(err,res) {
console.log("Geht"); 
    if (err) console.log("Error in Garagen: "+err);    
    for(let i = 0; i < res.length; i++) {
        let GaragenCol = mp.colshapes.newSphere(parseInt(res[0].X),parseInt(res[0].Y),parseInt(res[0].Z), 3, 0);
        if(GaragenCol.isPointWithin(player.position)) {
            mp.events.call("server:garagemenu",player,res[i].id);
        }
    }
});
});

Can anyone help me with that?

Link to comment
Share on other sites

It'd be much quicker if you simply console.log the results of res to make sure you're actually getting the correct values

If res[0].X is returning null/nothing I'd do res[0]['X'], it's hard to understand if your asking why res[0].X returns nothing or if they do have values but you can't get the colShape to be created.

Link to comment
Share on other sites

is res[0].X, res[0].Y and res[0].Z definitely giving you the coordinates you want to load?

mp.colshapes.newSphere(x, y, z, range); is definitely all you need.

 

Wait why do you have (x, y, z, int, int)? it only takes 4 parameters not 5, what's the last 0 for?

let GaragenCol = mp.colshapes.newSphere(parseInt(res[0].X),parseInt(res[0].Y),parseInt(res[0].Z), 3, 0);

should be

 

let GaragenCol = mp.colshapes.newSphere(parseInt(res[0].X),parseInt(res[0].Y),parseInt(res[0].Z), 3);
Edited by MrPancakers
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...