HarrySchnotter Posted October 16, 2019 Posted October 16, 2019 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?
trolovecro Posted October 16, 2019 Posted October 16, 2019 try - res[0].x .... and not res[0].X ... try parse.float...
MrPancakers Posted October 16, 2019 Posted October 16, 2019 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.
HarrySchnotter Posted October 16, 2019 Author Posted October 16, 2019 @MrPancakers i checked it with console log, thats working fine now im wondering. if im using normal cords instead of the calls the colshapes getting created where could be the problem *.*
MrPancakers Posted October 16, 2019 Posted October 16, 2019 mp.colshapes.newSphere(new mp.Vector3(res[0].X, res[0].Y, res[0].Z));
HarrySchnotter Posted October 16, 2019 Author Posted October 16, 2019 (edited) not working either @MrPancakers Edited October 16, 2019 by HarrySchnotter
MrPancakers Posted October 17, 2019 Posted October 17, 2019 (edited) 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 October 17, 2019 by MrPancakers
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now