Category | Scripting |
Created | 02.12.2024 11:05 |
Tobias Brekerbohm (z3r091) | 02.12.2024 11:05 |
---|---|
I try to get along with the coordinates. When i run local x, y, z = player:getPosition() i get positions, which are different to the shown coordinate position on the minimap. For teleporting i need the correct coordinates from the minimap, not the ones from player:getPosition() ... How can i transform them? |
DeMavis | 28.03.2025 15:53 |
---|---|
Hello, maybe your problem is already solved, but maybe someone else will find something for themselves here. I suggest playing with a simple script I wrote to make friends with coordinates on the map. <lua_code> -- For better orientation in the code, all proper names such as names of variables, functions, etc. start with the phrase "DeMv_" lub "deMv_". deMv_playerPos = { x = nil, -- X-axis (horizontal) y = nil, -- Y-axis (vertical, i.e. height) z = nil -- Z-axis (vertical) } addModEventListener(deMv_playerPos); function deMv_playerPos:update(dt) local deMv_player = nil; if g_currentMission.player ~= nil then deMv_player = g_currentMission.player.rootNode; -- player is outside the vehicle (on foot) end; if g_currentMission.controlledVehicle ~= nil then deMv_player = g_currentMission.controlledVehicle.rootNode; -- the player is in a vehicle end; if deMv_player ~= nil then local bX, bY, bZ = getWorldTranslation(deMv_player); self.x = math.ceil(bX); self.y = math.ceil(bY); self.z = math.ceil(bZ); end; end function deMv_playerPos:draw() g_currentMission:addExtraPrintText("Player position on the Map: "..self.x.." "..self.y.." "..self.z); end </lua_code> Of course we don't paste these two lines from "lua_code" ;) Best regards :) |
Note: Log in to post. Create a new account here.