DEFCON1 Posted December 19, 2009 Share Posted December 19, 2009 Hello MTA community, first let me introduce myself a bit! I'm new to MTA, and I want to get into scripting cool things, because i'm really bored of SA:MP Ok now for my question! Before I start making my script and my images, i would like to know few things because I'm unsure: - I want to use DxDrawRectangle and DxDrawImage (in a client side script). - The image which will be displayed have some places with transparency. - The rectangle will be displayed behind my image. - I want my rectangle to fill the transparent places of the image. So my first question is, will I see the rectangle's color where the image is transparent? My second question: my script will draw a new image every frame, can I draw the rectangle only once (as it will not change often) and display/hiding differents images on top of it without any display problems ? Also in DxDrawImage I see a parameter 'color', and I'm wondering if I need to set it to 0 so my image's transparency work? Thanks for your time, i hope this is possible Link to comment
50p Posted December 19, 2009 Share Posted December 19, 2009 1. Yes, .png files work with transparency and so does dxDrawImage. 2. No, every DirectX drawing function needs to be used every frame. Alternatively, you can create background rectangle with GUI function (guiCreateStaticImage) which will be displayed until guiSetVisible is called to hide it. 3. You should set it to 0 unless you want to get some effects like this: https://community.multitheftauto.com/index.php?p= ... ils&id=427 I change gauge colour based on time. Link to comment
DEFCON1 Posted December 23, 2009 Author Share Posted December 23, 2009 Sorry for bump, everything goes well in my script but I don't understand something: tocolor(0, 0, 255, 255) is true blue color, but why 0xFF0000FF give black color (at least in DxDrawRectangle) ? Isn't it the same blue color? I think that is a bug, but I'm not sure, can anyone tell me what is wrong with this 0xFF0000FF ? Link to comment
Dark Dragon Posted December 23, 2009 Share Posted December 23, 2009 https://wiki.multitheftauto.com/wiki/Tocolor doesn't really give an example what it actually returns. i guess that the syntax is just not correct that way. Link to comment
DEFCON1 Posted December 25, 2009 Author Share Posted December 25, 2009 I really think the hex color codes are bugged, well that's not a real problem actually,I will ask something else now In fact i am doing a speedometer, which uses only images, and I am wondering what is more efficient (please do not answer if you don't really know!) : - Drawing differents images every frames with the dxDrawImage function in onClientRender, or - Drawing static images with guiCreateStaticImage and change them with guiStaticImageLoadImage inside a 50ms timer ? Note that i still need onClientRender for rendering the background rectangle with dxDrawRectangle. The speed is calculated inside the 50ms timer, so isn't called every frame which is better, I THINK! I'm just hesiting on what method from above I should use. Both methods works perfectly fine and are working very similarly, and I don't see any fps lose with either methods (playing on local server, which should not have any effect since it is a client side script, and on my laptop which isn't really a gaming computer). I really think the second method require less cpu usage but I'm unsure, since gui functions are probably not as efficient as the directx functions. I just care a lot about efficiency of scripts, hope someone will give me advices on what method is better for what i want to achieve Thanks! Link to comment
subenji99 Posted December 25, 2009 Share Posted December 25, 2009 dxDrawImage onClientRender every frame, only 1 needle image that you rotate (assuming this speedo is analog) is the most efficient. There is a resource that already does this in the resource center though; you may just want to change the images on that. Link to comment
DEFCON1 Posted December 26, 2009 Author Share Posted December 26, 2009 Damn, I forgot to say, it's not a analog speedometer . It's using digits so it doesn't need to be updated as often as a needle. Here is the current, not finished look: I've got few nice comments about it so I release it when finished. It is kind of skinnable.. 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