cacao Posted November 27, 2016 Posted November 27, 2016 (edited) Hi everyone! have here server-side script local col = createColCircle(170, -377, 15) local object = createObject(737, 175, -377, 6) print(isElementWithinColShape(object, col)) -- print false Can anyone tell me, why i got false, when object IN colshape? Object and colshape have same coordinates. Edited November 27, 2016 by cacao
Rose Posted November 27, 2016 Posted November 27, 2016 Wiki: a colshape created on the client does not collide with elements already existing at that location until they first move.
cacao Posted November 27, 2016 Author Posted November 27, 2016 (edited) But i'm create colshape on the server and first i'm created the colshape before the object Edited November 27, 2016 by cacao
Dzsozi (h03) Posted November 27, 2016 Posted November 27, 2016 local col = createColCircle(170, -377, 15) local object = createObject(737, 175, -377, 6) moveObject ( object, 100, 175, -378, 6 ) setTimer(function() print(isElementWithinColShape(object, col)) end, 500, 1, object) I don't know if I did right, but try something like this, try using timers, since you have to move the element if they are at the same position when being created. So MTA can recognize when did the element hit the collision shape, so it can assign the isElementWithinColShape function to it, I guess. Try using something like I posted.
cacao Posted November 27, 2016 Author Posted November 27, 2016 (edited) 8 minutes ago, Dzsozi said: local col = createColCircle(170, -377, 15) local object = createObject(737, 175, -377, 6) moveObject ( object, 100, 175, -378, 6 ) setTimer(function() print(isElementWithinColShape(object, col)) end, 500, 1, object) I don't know if I did right, but try something like this, try using timers, since you have to move the element if they are at the same position when being created. So MTA can recognize when did the element hit the collision shape, so it can assign the isElementWithinColShape function to it, I guess. Try using something like I posted. I tried it, but still false. Edited November 27, 2016 by cacao
cacao Posted November 27, 2016 Author Posted November 27, 2016 (edited) 5 minutes ago, Dzsozi said: Did the object move? Yes.Look: Before After Result Edited November 27, 2016 by cacao
Dzsozi (h03) Posted November 27, 2016 Posted November 27, 2016 Maybe try creating the object outside of the colshape and then move it inside the colshape using moveobject and use a timer to print the text, see if it works.
cacao Posted November 27, 2016 Author Posted November 27, 2016 (edited) It works, but it strange. Look, i switch createObject and colCircle and it's true, but it is strange.. I need to create in colshape objects and later check them counts.. Edited November 27, 2016 by cacao 1
Tails Posted November 27, 2016 Posted November 27, 2016 (edited) You can move the colshape before you check the object though: local col = createColCircle(2306.687, -1658.936, 14.386) local object = createObject(737, 2306.687, -1658.936, 14.386) addCommandHandler("c", function() local x,y,z = getElementPosition(col) setElementPosition(col,x,y,z+1) setElementPosition(col,x,y,z) print(isElementWithinColShape(object, col)) end ) I don't really know why it doesn't work normally, MTA is weird. Edited November 27, 2016 by Tails
ViRuZGamiing Posted November 27, 2016 Posted November 27, 2016 1 hour ago, cacao said: It works, but it strange. Look, i switch createObject and colCircle and it's true, but it is strange.. I need to create in colshape objects and later check them counts.. May I ask which Editor you use? I like the linter better than my N++, is this Sublime Text perhaps?
cacao Posted November 27, 2016 Author Posted November 27, 2016 (edited) 34 minutes ago, ViRuZGamiing said: May I ask which Editor you use? I like the linter better than my N++, is this Sublime Text perhaps? Atom (https://atom.io) UI Theme: Atom Material Theme: Apathy Packages: linter, linter-lua, language-lua Edited November 27, 2016 by cacao 1
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