Scripting Moderators ds1-e Posted May 15, 2019 Scripting Moderators Share Posted May 15, 2019 Hello. I have decided to write some kind of GPS/radar script by myself. As always, there is some problems which i don't know can i solve. I have also other script which i'm using, but i prefer to rewrite it, because when local player is moving, the radar isn't moving smooth. - How can i get correct offsets for radar, depends from player position, and background map with resolution 3000x3000. - Why this code isn't that much effective as this one? And somehow when minimalizing a game, it uses less or more CPU. -- takes up to 8, 10% of CPU local gpsRender = dxCreateRenderTarget(290, 175) local mapWidth, mapHeight = 3000, 3000 if gpsRender and playerTable.settings.user[2] then -- used within onClientRender <- render events by IIYAMA, i've tested, and default events gives nearly same results. dxSetRenderTarget(gpsRender, true) local x, y, z = getElementPosition(getLocalPlayer()) local rotX, rotY, rotZ = getElementRotation(getCamera()) dxDrawImage(-10, -10, mapWidth, mapHeight, "map.png", rotZ, x/mapWidth, -y/mapHeight, tocolor(255, 255, 255, 255)) dxSetRenderTarget() dxDrawImage(20, 100, 365, 235, gpsRender, 0, 0, 0, tocolor(255, 255, 255, 255)) end -- before that code it's just a dxDrawText and nothing more. -- takes up to 1-4% of CPU, and 20% when starting. local worldW, worldH = 3072, 3072 local rt = dxCreateRenderTarget(290, 175) local mW, mH = dxGetMaterialSize(rt) -- used within onClientRender. dxSetRenderTarget(rt, true) local x, y = getElementPosition(localPlayer) local X, Y = mW/2 -(x/(6000/worldW)), mH/2 +(y/(6000/worldH)) local camX,camY,camZ = getElementRotation(getCamera()) dxDrawImage(X - worldW/2, mH/5 + (Y - worldH/2), worldW, worldH, "img/radar_map.jpg", camZ, (x/(6000/worldW)), -(y/(6000/worldH)), tocolor(255, 255, 255, 255)) dxSetRenderTarget() -- later is some other code, and also ipairs loop. 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