Jump to content

one little help :D


Deepu

Recommended Posts

Guys, I always made the animation type window with customized buttons and background. Thats it. But can some one tell me whats the error with this method I used to make a custom edit box for a dx GFX GUI?

code =

function guiCreation () 
   dxDrawRectangle() 
   ... 
   labelA = guiCreateLabel(..... "", false) -- it works though there is no GUI  
end 
addEventHandler("onClientRender", root, guiCreation) 
  
function mainPoop () 
   textA = guiGetText(labelA) 
end 
addEventHandler("onClientRender", root, mainPoop) 
  
function subPoop (button) 
   guiSetText(labelA, textA .. button) 
end 
addEventHandler("onClientKey", root, button) -- Since mta doesnt support lua functions like io.read and io.write... this has to be done... 

Guys, so if you found out my mistake (learning the new custom edit box thing. Love to make one) then please correct me :)

NOTE: Please stay on the topic, don't say "hahaha the pro scripter became a nob and shizzles. I hate that.. Please try to stay on topic. Do not flame in this topic or you can get warned by one of the moderators.

Regards,

Don (Deepu)

Link to comment

You shouldn't create a gui label every frame that causes laggs.

If you're trying to create a editbox you should get the pressed key(onClientKey) and insert it into a table and then just draw it with dxDrawText and using table.concat

Link to comment

well, you guys know Crystal MV? He uses the gui label thing every frame.

And how can I even make a dxDrawText edit box?

Reasons for disapproval:-

1) You got just a boolean saying true or false and you cant use like this:

texts = dxDrawText(""......)

2) dxDrawText's color can't be changed since its not an element and never will be one.

So, I tried that long ago. Doesnt work well.

and the problem with the custom edit box is not a lag KRZO :) its just this:

EDIT: I will be afk for some time so please write the correct fix :D because I wanna learn it quick within a day or so and thats one big thing I wanna learn.

Regards,

Don (Deepu)

output of the above script codes:

when we press a and then b it justs does a and b over it

its just one letter

it doesnt form ab

it just forms a and above it, b.

so can't be done...

So you got some other things to fix it KRZO?

thanks anyway.

Link to comment

There is no other way. And you can change the color of the text ofcourse, otherwise there won't be a color argument lol. And what do you mean with boolean saying true and false? As i suggested tables would be the best for this.

Link to comment
NOTE: Please stay on the topic, don't say "hahaha the pro scripter became a nob and shizzles. I hate that.. Please try to stay on topic. Do not flame in this topic or you can get warned by one of the moderators.

I cannot stand people who think they're top shit when they're obviously not. Sorry dude, but nothing I have seen from you is that impressive. You will get there one day, I wish you luck.

Please refrain from using GUI elements, they are not considered a DX GUI.

local theInput 
local textColor = tocolor(0, 0, 0, 255) 
local editBoxColor = tocolor(255, 255, 255, 255) 
  
addEventHandler("onClientRender", root, 
    function() 
        if theInput then 
            dxDrawRectangle(395, 395, 100, 55, editBoxColor) 
            dxDrawText(theInput, 400, 400, 90, 45, textColor) 
        end 
    end ) 
  
addEventHandler("onClientCharacter", root,  
    function(theChar) 
        theInput = theInput .. theChar 
    end ) 
  
-- handling the backspace key: 
addEventHandler("onClientKey", root, 
    function(theButton, state) 
        if theButton == "backspace" and state == "down" then 
            theInput = theInput:sub(1, theInput:len()-1) 
        end 
    end ) 

I cannot guarantee this will work, its 2am, and didnt want to test it. It's the general method though.

changing the colour is as simple as changing the variable data.

Link to comment

what do you mean with scanf?

How to change color of the text when i move the mouse over a point csmist

You could do smth like this :

function isMouseWithinRangeOf(psx,pssx,psy,pssy) -- Psx = position x , pssx = width , psy = postition y , pssy = height 
  if isCursorShowing() == false then 
    return false 
  end 
  local cx,cy = getCursorPosition() 
  cx,cy = cx*x,cy*y 
  if cx >= psx and cx <= psx+pssx and cy >= psy and cy <= psy+pssy then 
    return true,cx,cy 
  else 
    return false 
  end 
end 
  
addEventHandler("onClientRender",root, 
    function() 
        if isMouseWithinRangeOf(x,180,y,25) then 
            color = tocolor(255,0,0,255) 
        else 
            color = tocolor(255,255,255,255) 
        end 
    end 
) 

Link to comment

Yeah KRZO, I tried that code of yours way before I made the topic.... but thats the reason why I am here... It doesnt work. Since, it has to be derived.

Plus.... I am telling Scanf from the C SLT LIBRARY, because the scanf function as you know it, senses the input of the keyboard+mouse thus deriving the optimum output that the user is wishing.

Telling that for the edit box. Because according to me, using C functions is a lot better than using python, Java, or Lua codes,

And why the **** Doesnt io.read() doesnt work in mta? xD

Please reply guyz, AFK for 3-4 days.. Mom has a surgery and she is crying with pain..

Link to comment

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...