DRW Posted July 17, 2015 Posted July 17, 2015 Hello, I've created a dxDrawImage on the 3D world but somehow nothing appears, what can I do? addEventHandler ("onClientResourceStart",getResourceRootElement(getThisResource()),function() setElementDimension (minepedt1, 200) setPedFrozen (minepedt1,true) addEventHandler( 'onClientRender', root, function() local scX, scY = guiGetScreenSize(); local l_w = 64; local l_h = 64; local l_ratio = l_w / l_h; local lscale_w = 1920 / scX; l_w = l_w / lscale_w; l_h = l_w / l_ratio; local px, py = getScreenFromWorldPosition(238.48828125, 555.599609375, 86.254005432129, 0.06 ) dxDrawImage( px-l_w/2, py - scY/17, l_w, l_h, 'sonido/moon.png', 0, 0, 0, tocolor( 255,255,255, 255 ) ); end) end) Proud owner and developer of ZNEXT: Aftermath. Enter a post-apocalyptic San Andreas and fight over 30 types of enemies and bosses with varying difficulties and skills, improve and customize your character by leveling up, completing challenges and a solid lootbox system with no Pay-to-Win mechanics that will break your experience. Meet new characters, creatures and weapon metas, experience an innovative combo-based melee system, or join our solid PvP modes to show other survivors who’s boss. Español, Pусский, Türk, عربى, Polski, Português IP: mtasa://104.36.110.227:22003 - Discord: https://discord.gg/CxMxjvC5pB
GTX Posted July 17, 2015 Posted July 17, 2015 Use: dxDrawMaterialLine3D Do you require a paid scripter? Contact me! (Unavailable) Currently I am experienced in Lua, PHP, HTML, CSS, SQL and JS. Developer and owner of https://projectbea.st - Project Beast
DRW Posted July 17, 2015 Author Posted July 17, 2015 Use: dxDrawMaterialLine3D addEventHandler( 'onClientRender', root, function() local img1 = dxCreateTexture ("sonido/moon.png","png",2000,2000) dxDrawMaterialLine3D (-1410.13671875, 1362.8200683594, 109.26251983643,-1410.13671875, 1362.8203125, 119.46251678467,img1,80) end) Tried this, not working, nothing in debugscript. Proud owner and developer of ZNEXT: Aftermath. Enter a post-apocalyptic San Andreas and fight over 30 types of enemies and bosses with varying difficulties and skills, improve and customize your character by leveling up, completing challenges and a solid lootbox system with no Pay-to-Win mechanics that will break your experience. Meet new characters, creatures and weapon metas, experience an innovative combo-based melee system, or join our solid PvP modes to show other survivors who’s boss. Español, Pусский, Türk, عربى, Polski, Português IP: mtasa://104.36.110.227:22003 - Discord: https://discord.gg/CxMxjvC5pB
GTX Posted July 17, 2015 Posted July 17, 2015 Better check dxCreateTexture syntax again. dxCreateTexture("sonido/moon.png") Do you require a paid scripter? Contact me! (Unavailable) Currently I am experienced in Lua, PHP, HTML, CSS, SQL and JS. Developer and owner of https://projectbea.st - Project Beast
DRW Posted July 18, 2015 Author Posted July 18, 2015 Better check dxCreateTexture syntax again. dxCreateTexture("sonido/moon.png") It works! Thanks, but I have too much lag, FPS drop from 40-50 to 4.8. Isn't there any alternative or something to make it work good? I mean, it's just an image, that FPS drop is not very normal. Proud owner and developer of ZNEXT: Aftermath. Enter a post-apocalyptic San Andreas and fight over 30 types of enemies and bosses with varying difficulties and skills, improve and customize your character by leveling up, completing challenges and a solid lootbox system with no Pay-to-Win mechanics that will break your experience. Meet new characters, creatures and weapon metas, experience an innovative combo-based melee system, or join our solid PvP modes to show other survivors who’s boss. Español, Pусский, Türk, عربى, Polski, Português IP: mtasa://104.36.110.227:22003 - Discord: https://discord.gg/CxMxjvC5pB
Buffalo Posted July 18, 2015 Posted July 18, 2015 dx draw functions are very resource consuming, nothing you can do to avoid fps drop, except using smaller resolution and not using it to draw too much. thats limitations of current mta version. Powered by Kimsufi© ☢ ZHP on Facebook ☢ ZHP on Youtube ☢ Support us ☢
DRW Posted July 18, 2015 Author Posted July 18, 2015 dx draw functions are very resource consuming, nothing you can do to avoid fps drop, except using smaller resolution and not using it to draw too much. thats limitations of current mta version. local white = tocolor(255,255,255,255) function dxDrawImage3D(x,y,z,w,h,m,c,r,...) local lx, ly, lz = x+w, y+h, (z+tonumber(r or 0)) or z return dxDrawMaterialLine3D(x,y,z, lx, ly, lz, m, h, c or white, ...) end local pnet = dxCreateTexture("planet.png") addEventHandler("onClientRender", root, function() dxDrawImage3D(0,0, 20, 20, 800, pnet, tocolor(255,255,255,255)) end ) I've used this, it consumes almost nothing, the only problem is that I want the image to look always at me, and this one only looks at me when I'm over or below the image, but hey, the dxDrawMaterialLine3D looks at me if I'm at the right or left side of the image, so it's almost the same problem. Look at this: viewtopic.php?f=91&t=89832, Proud owner and developer of ZNEXT: Aftermath. Enter a post-apocalyptic San Andreas and fight over 30 types of enemies and bosses with varying difficulties and skills, improve and customize your character by leveling up, completing challenges and a solid lootbox system with no Pay-to-Win mechanics that will break your experience. Meet new characters, creatures and weapon metas, experience an innovative combo-based melee system, or join our solid PvP modes to show other survivors who’s boss. Español, Pусский, Türk, عربى, Polski, Português IP: mtasa://104.36.110.227:22003 - Discord: https://discord.gg/CxMxjvC5pB
GTX Posted July 18, 2015 Posted July 18, 2015 Try: local white = tocolor(255,255,255,255) function dxDrawImage3D(x,y,z,w,h,m,c,r) local lx, ly, lz = x+w, y+h, (z+tonumber(r or 0)) or z return dxDrawMaterialLine3D(x,y,z, lx, ly, lz, m, h, c or white) end local pnet = dxCreateTexture("planet.png") addEventHandler("onClientRender", root, function() dxDrawImage3D(0,0, 20, 20, 800, pnet, tocolor(255,255,255,255)) end ) Do you require a paid scripter? Contact me! (Unavailable) Currently I am experienced in Lua, PHP, HTML, CSS, SQL and JS. Developer and owner of https://projectbea.st - Project Beast
Dealman Posted July 18, 2015 Posted July 18, 2015 You were creating the texture 30-60 times per second. Anything run inside onClientRender will be done with every frame. addEventHandler( 'onClientRender', root, function() local img1 = dxCreateTexture ("sonido/moon.png","png",2000,2000) -- This is run with every frame, you only need to do it once. dxDrawMaterialLine3D (-1410.13671875, 1362.8200683594, 109.26251983643,-1410.13671875, 1362.8203125, 119.46251678467,img1,80) end) If I help you in a thread and you need further assistance, please don't PM me - use the thread you created instead. This way everyone on the forum can take advantage of it.
DRW Posted July 18, 2015 Author Posted July 18, 2015 Try: local white = tocolor(255,255,255,255) function dxDrawImage3D(x,y,z,w,h,m,c,r) local lx, ly, lz = x+w, y+h, (z+tonumber(r or 0)) or z return dxDrawMaterialLine3D(x,y,z, lx, ly, lz, m, h, c or white) end local pnet = dxCreateTexture("planet.png") addEventHandler("onClientRender", root, function() dxDrawImage3D(0,0, 20, 20, 800, pnet, tocolor(255,255,255,255)) end ) Same as before Proud owner and developer of ZNEXT: Aftermath. Enter a post-apocalyptic San Andreas and fight over 30 types of enemies and bosses with varying difficulties and skills, improve and customize your character by leveling up, completing challenges and a solid lootbox system with no Pay-to-Win mechanics that will break your experience. Meet new characters, creatures and weapon metas, experience an innovative combo-based melee system, or join our solid PvP modes to show other survivors who’s boss. Español, Pусский, Türk, عربى, Polski, Português IP: mtasa://104.36.110.227:22003 - Discord: https://discord.gg/CxMxjvC5pB
Dealman Posted July 18, 2015 Posted July 18, 2015 dxDrawMaterialLine3D has a parameter whether or not to face a certain position or always face the camera. Try using this instead? Other than that I'm rather confused as to what the actual problem is. Is it still lagging? Is it not facing you? If I help you in a thread and you need further assistance, please don't PM me - use the thread you created instead. This way everyone on the forum can take advantage of it.
DRW Posted July 18, 2015 Author Posted July 18, 2015 dxDrawMaterialLine3D has a parameter whether or not to face a certain position or always face the camera. Try using this instead?Other than that I'm rather confused as to what the actual problem is. Is it still lagging? Is it not facing you? Well, I'll explain you: This one works pretty well, it prints the image to the 3D world and the lag is 0, so it's kinda good, but it's not facing me when i'm moving at left or right of the image, only if I'm moving up and down, so yeah, it faces me, but not on all directions. local white = tocolor(255,255,255,255) function dxDrawImage3D(x,y,z,w,h,m,c,r,...) local lx, ly, lz = x+w, y+h, (z+tonumber(r or 0)) or z return dxDrawMaterialLine3D(x,y,z, lx, ly, lz, m, h, c or white, ...) end local pnet = dxCreateTexture("planet.png") addEventHandler("onClientRender", root, function() local x,y,z = getElementPosition(localPlayer) dxDrawImage3D(0,0, 20, 20, 800, pnet, tocolor(255,255,255,255),0,x,y,z) end ) Now, this is exactly the opposite of the other one, it lags a lot and it only follows me if I move at the right or at the left side of the image, so by far I'd select the first, but both of them are useless to me since they can't follow the player properly until I do something, and I'm not very familiarized with the dxDraw functions, so no idea about how to solve it. addEventHandler( 'onClientRender', root, function() local img1 = dxCreateTexture ("sonido/moon.png","png",2000,2000) dxDrawMaterialLine3D (-1410.13671875, 1362.8200683594, 109.26251983643,-1410.13671875, 1362.8203125, 119.46251678467,img1,80) Proud owner and developer of ZNEXT: Aftermath. Enter a post-apocalyptic San Andreas and fight over 30 types of enemies and bosses with varying difficulties and skills, improve and customize your character by leveling up, completing challenges and a solid lootbox system with no Pay-to-Win mechanics that will break your experience. Meet new characters, creatures and weapon metas, experience an innovative combo-based melee system, or join our solid PvP modes to show other survivors who’s boss. Español, Pусский, Türk, عربى, Polski, Português IP: mtasa://104.36.110.227:22003 - Discord: https://discord.gg/CxMxjvC5pB
Dealman Posted July 18, 2015 Posted July 18, 2015 As I already said; the second one lags because you're creating a new texture with every frame. So of course it's gonna lag. Simply move this line local img1 = dxCreateTexture ("sonido/moon.png","png",2000,2000) To the top of the script. onClientRender is triggered with every drawn frame, and since MTA is drawn between 30 to 60 times per second. It's rather obvious why it would lag. As for it facing you when you move left and right but not up and down is rather odd, I recall using this function a while ago and I believe it worked like you want it to. I might check it out later tonight. If I help you in a thread and you need further assistance, please don't PM me - use the thread you created instead. This way everyone on the forum can take advantage of it.
DRW Posted July 18, 2015 Author Posted July 18, 2015 As I already said; the second one lags because you're creating a new texture with every frame. So of course it's gonna lag.Simply move this line local img1 = dxCreateTexture ("sonido/moon.png","png",2000,2000) To the top of the script. onClientRender is triggered with every drawn frame, and since MTA is drawn between 30 to 60 times per second. It's rather obvious why it would lag. As for it facing you when you move left and right but not up and down is rather odd, I recall using this function a while ago and I believe it worked like you want it to. I might check it out later tonight. Dammit, sorry, I didn't read that part and didn't notice that, it makes so much sense, thank you both for helping me Proud owner and developer of ZNEXT: Aftermath. Enter a post-apocalyptic San Andreas and fight over 30 types of enemies and bosses with varying difficulties and skills, improve and customize your character by leveling up, completing challenges and a solid lootbox system with no Pay-to-Win mechanics that will break your experience. Meet new characters, creatures and weapon metas, experience an innovative combo-based melee system, or join our solid PvP modes to show other survivors who’s boss. Español, Pусский, Türk, عربى, Polski, Português IP: mtasa://104.36.110.227:22003 - Discord: https://discord.gg/CxMxjvC5pB
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