KirillWd Posted August 3, 2012 Share Posted August 3, 2012 Hey, Everyone! My question is how can I record the camera's position? Why doesn't it work? [b]function[/b] trace(player) [b]local [/b]x, y, z = getCameraMatrix(player) [b]outputChatBox[/b]("x: "..tostring(x).."; y: "..tostring(y).."; z: "..tostring(z), player) [b]end[/b] ----- [b]addCommandHandler[/b]("t", trace) It always prints: x: false; y: nil; z: nil I don't understand why x is false, y and z are undefined. Please, help! Link to comment
HunT Posted August 3, 2012 Share Posted August 3, 2012 Why tostring? Maybe tonumber is better Link to comment
TAPL Posted August 3, 2012 Share Posted August 3, 2012 are you sure you have put it as server side in meta? Link to comment
Jaysds1 Posted August 3, 2012 Share Posted August 3, 2012 (edited) actually, the values could go in with out using "tostring" or "tonumber". anyways, make sure this is server-sided. if it still doesn't work, try this: function trace(source) local x, y, z = getCameraMatrix(source) if x and y and z then outputChatBox("Your Camera Positions are x: "..(x).."; y: "..(y).."; z: "..(z),source) else outputChatBox("Test!!!",source) local x1,y1,z1 = getElementPosition(source) setCameraMatrix(source,x1,y1,z1+3,x1,y1,z1) -- this would set the camera looking down at you x, y, z = getCameraMatrix(source) --replace the current vars outputChatBox("Your Camera Positions are x: "..(x).."; y: "..(y).."; z: "..(z),source) setTimer(setCameraTarget,7000,1,source,source) setTimer(setCameraTarget,7000,1,source,source) end end addCommandHandler("t",trace) Edited August 4, 2012 by Guest Link to comment
KirillWd Posted August 4, 2012 Author Share Posted August 4, 2012 yep, this file is on server-side. Jaysds1, that isn't i want. yeah, this work, but everytime camera's x (either y) are the same of player's x (and y). I needn't know the player's position, but camera's. If change the position after the first time, there is the test again. Why does it happen? Link to comment
Jaysds1 Posted August 4, 2012 Share Posted August 4, 2012 well, it seems like you could only get the camera matrix if it's set first. Link to comment
KirillWd Posted August 4, 2012 Author Share Posted August 4, 2012 Do you want a joke? This script works on client-side and doesn't on server-side. so -- <script src="script.lua" type="client" /> [b]function[/b] trace() local x, y, z = getCameraMatrix() outputChatBox("x: "..math.ceil(x).."; y: "..math.ceil(y)) [b]end[/b] addCommandHandler("t", trace) -- works! Nevermind, I've understood I don't need server to know camera's position of all players. Well, the task is completed. Anyway, thx to everyone who has tried to help! Link to comment
50p Posted August 5, 2012 Share Posted August 5, 2012 For your information, server-side getCameraMatrix will return the values you previously set with setCameraMatrix, you will not get position of player's camera unless you set it first. That's because server doesn't need to update this information every tick, this would lag the server and eventually freeze it. Link to comment
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