Serius Posted April 25, 2021 Share Posted April 25, 2021 How can I get the camera position of the player I want I tried getCameraMartix but it just takes my camera Link to comment
Discord Moderators Zango Posted April 26, 2021 Discord Moderators Share Posted April 26, 2021 (edited) You need to sync the camera matrix between the player and the other players manually triggerServerEvent -- Send the camera matrix from the player to the server triggerClientEvent -- Send the camera matrix to the other players from the server Edited April 26, 2021 by Zango Link to comment
WASSIm. Posted April 27, 2021 Share Posted April 27, 2021 setElementData getElementData Link to comment
RomanDev Posted April 27, 2021 Share Posted April 27, 2021 Did you know that getCameraMatrix is shared? So you could do it on the server side... function getPlayerFromID(id) v = false for i, player in ipairs (getElementsByType("player")) do if getElementData(player, "ID") == id then v = player break end end return v end addCommandHandler("getcam", function(player, _, id) if (tonumber(id)) then local playerID = getPlayerFromID(id) if (playerID) then local cameraMatrix = {getCameraMatrix(playerID)} outputChatBox("The player's camera matrix is: [1] x = "..(cameraMatrix[1])..", y = "..(cameraMatrix[2])..", z = "..(cameraMatrix[3]).." [2] x = "..(cameraMatrix[4])..", y = "..(cameraMatrix[5])..", z = "..(cameraMatrix[6]).." [3] x = "..(cameraMatrix[7])..", y = "..(cameraMatrix[8]), player) else outputChatBox("The player is not online", player) end else outputChatBox("You did not enter the id", player) end end ) I think it's something like this! I hope this helps. Link to comment
Discord Moderators Zango Posted April 28, 2021 Discord Moderators Share Posted April 28, 2021 19 hours ago, RomanDev said: Did you know that getCameraMatrix is shared? So you could do it on the server side... getCameraMatrix only works serverside if the camera is fixed with setCameraMatrix, it doesn't return GTA camera values. Instead of element data, I recommend using triggerServerEvent to send the values to server, and triggerClientEvent to send to relevant (nearby) players. 1 Link to comment
RomanDev Posted April 28, 2021 Share Posted April 28, 2021 (edited) 34 minutes ago, Zango said: getCameraMatrix só funciona no lado do servidor se a câmera for fixada com setCameraMatrix, não retorna os valores da câmera GTA. Em vez de dados de elemento, eu recomendo usar triggerServerEvent para enviar os valores para o servidor e triggerClientEvent para enviar para jogadores relevantes (próximos). Okay, sorry! New code: -- Server-Side addEvent("dataClient:CameraMatrix", true) addEventHandler("dataClient:CameraMatrix", root, function(data) outputChatBox("The player camera matrix is: [1] x = "..(data[1])..", y = "..(data[2])..", z = "..(data[3]).." [2] x = "..(data[4])..", y = "..(data[5])..", z = "..(data[6]).." [3] x = "..(data[7])..", y = "..(data[8]), source) end ) -- Client-Side function getPlayerFromID(id) v = false for i, player in ipairs (getElementsByType("player")) do if getElementData(player, "ID") == id then v = player break end end return v end addCommandHandler("getcam", function(_, id) if (tonumber(id)) then local playerID = getPlayerFromID(id) if (playerID) then local cameraMatrix = {getCameraMatrix(playerID)} triggerServerEvent("dataClient:CameraMatrix", localPlayer, cameraMatrix) else outputChatBox("The player is not online", localPlayer) end else outputChatBox("You did not enter the id", localPlayer) end end ) Edited April 28, 2021 by RomanDev 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