Jump to content

move dx position


Wisin

Recommended Posts

Posted

hi again, i want to know how i can do like i got a DX rectangle in top of screen and i wanna slowly move it up, how would i do that?

Posted

set a global variables with position, like:

  
posx = 10 
posy = 10 
function drawing() 
  posx=posx+1 
  posy=posy+1 
  -- draw here, using posx, posy as position arguments 
end 
  

Multi theft auto tools - replace cars and peds, move your map or compile your Lua files online!

programista php rzeszów

Need free webhosting for your small site? PM me. Need help with portforwarding? PM me. Do not PM me asking for help with scripting.

Having problems with port forwarding? Send me pm, I can do whole thing for you using TeamViewer (already helped about 20 people, no worries)!

Posted

varez, your code would move the rectangle in a diagonal direction (down and right), not up or down.

local y = 0; 
local height = 20; 
function drawRect( ) 
    y = y - 1; 
    dxDrawRectangle( ..., y, .., height, .... ); 
    if y < -height then 
        -- remove handler 
    end 
end 

Don't forget to remove handler for this animation once the rectangle is off screen because it'll keep going up but there is no point if you can't even see it.

Posted

whops, i didnt read carefully

Multi theft auto tools - replace cars and peds, move your map or compile your Lua files online!

programista php rzeszów

Need free webhosting for your small site? PM me. Need help with portforwarding? PM me. Do not PM me asking for help with scripting.

Having problems with port forwarding? Send me pm, I can do whole thing for you using TeamViewer (already helped about 20 people, no worries)!

Posted

uhm, it dosn't works the rectangle dosn't even appears in screen

  
local y = 0; 
local height = 20; 
function createDX( ) 
    y = y - 1; 
    dxDrawRectangle( 0.0, y, 1023.0, height, 19.0,tocolor(0,0,0,200),false ); 
    if y < -height then 
        removeEventHandler("onClientRender",root,createDX) 
    end 
end 

any idea?

Posted

do you have onClientRender event handler? or you have no idea about dx drawing? (if no idea -> https://wiki.multitheftauto.com/wiki/DxDrawText or any dx function on wiki)

Multi theft auto tools - replace cars and peds, move your map or compile your Lua files online!

programista php rzeszów

Need free webhosting for your small site? PM me. Need help with portforwarding? PM me. Do not PM me asking for help with scripting.

Having problems with port forwarding? Send me pm, I can do whole thing for you using TeamViewer (already helped about 20 people, no worries)!

Posted

yes i have idea about DXdrawing and GUI

addEventHandler("onClientRender",root,createDX)

i got the event it works with normal rectangle but not with the one that should move.

Posted

hmm, tell me what is that 19.0 ? it should be color variable.. arguments are invalid

Multi theft auto tools - replace cars and peds, move your map or compile your Lua files online!

programista php rzeszów

Need free webhosting for your small site? PM me. Need help with portforwarding? PM me. Do not PM me asking for help with scripting.

Having problems with port forwarding? Send me pm, I can do whole thing for you using TeamViewer (already helped about 20 people, no worries)!

Posted

you are right i was doing wrong arguments now it appears but it removes like before, here is my code,

local y2 = 0; 
local height = 20; 
function createDX( ) 
    y = y2 - 1; 
    dxDrawRectangle( 0.0, y2, 1023.0, height, tocolor(0,0,0,200),false ); 
    if y2 < -height then 
        removeEventHandler("onClientRender",root,createDX) 
    end 
end 
  
function removeNews() 
removeEventHandler("onClientRender",root,createDX) 
end 

Posted

why you ahve changed y to y2? and on like 4 you have y = ...

Multi theft auto tools - replace cars and peds, move your map or compile your Lua files online!

programista php rzeszów

Need free webhosting for your small site? PM me. Need help with portforwarding? PM me. Do not PM me asking for help with scripting.

Having problems with port forwarding? Send me pm, I can do whole thing for you using TeamViewer (already helped about 20 people, no worries)!

Posted

and if you change like 4 to y2 = y2 - 1? anyway - it will be removed when y hits -20, which should be done under a sec.

do it like that so you can see what is going on, THEN mess up with variables:

  
local y2 = 300 -- initial y value 
local height = 50 -- height of rectangle 
local width = 400 -- width ... 
local x2 = 300 -- initial x value 
function createDX() 
  y2=y2-1 -- on every frame y will be lowered - causing rectangle to move 
  dxDrawRectangle( x2, y2, width, height, tocolor(0,0,0,200),false ); 
  if y2 < 0 then -- if y will hit the top of screen 
    removeEventHandler("onClientRender",root,createDX) -- remove event 
  end 
end 
  

Multi theft auto tools - replace cars and peds, move your map or compile your Lua files online!

programista php rzeszów

Need free webhosting for your small site? PM me. Need help with portforwarding? PM me. Do not PM me asking for help with scripting.

Having problems with port forwarding? Send me pm, I can do whole thing for you using TeamViewer (already helped about 20 people, no worries)!

Posted

you can mess with the variables now - code is commented so you have to find out what is what

Multi theft auto tools - replace cars and peds, move your map or compile your Lua files online!

programista php rzeszów

Need free webhosting for your small site? PM me. Need help with portforwarding? PM me. Do not PM me asking for help with scripting.

Having problems with port forwarding? Send me pm, I can do whole thing for you using TeamViewer (already helped about 20 people, no worries)!

Posted

yeah i edited it but i got a question, how i can move the text with the timer i made?

edit: also this dosn't works for all resolutions O_o

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...