Deepu Posted May 15, 2014 Share Posted May 15, 2014 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
Karuzo Posted May 15, 2014 Share Posted May 15, 2014 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
Deepu Posted May 15, 2014 Author Share Posted May 15, 2014 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 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
Karuzo Posted May 15, 2014 Share Posted May 15, 2014 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
.:HyPeX:. Posted May 15, 2014 Share Posted May 15, 2014 You get a boolean becouse thats what dxDrawText returns from it. You can change the colours from the dxDrawText by using variables. Also, if he does create the labels every frame, he should be deleting them too. Link to comment
Deepu Posted May 16, 2014 Author Share Posted May 16, 2014 Just fix the main problem. Reread the posts. Not the lag Link to comment
codeluaeveryday Posted May 16, 2014 Share Posted May 16, 2014 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
Deepu Posted May 17, 2014 Author Share Posted May 17, 2014 Thanks csmit. Now i can make a better gui Link to comment
Karuzo Posted May 17, 2014 Share Posted May 17, 2014 That was exactly what i'm trying to say. Link to comment
Deepu Posted May 17, 2014 Author Share Posted May 17, 2014 How to change color of the text when i move the mouse over a point csmist Link to comment
Karuzo Posted May 17, 2014 Share Posted May 17, 2014 https://wiki.multitheftauto.com/wiki/OnClientCursorMove Use this function. You just need some checks. Link to comment
Deepu Posted May 17, 2014 Author Share Posted May 17, 2014 Lol the code isnt working like i said. And krzo what you said is wrong. How can i use scanf function in lua? Link to comment
Karuzo Posted May 17, 2014 Share Posted May 17, 2014 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
Deepu Posted May 22, 2014 Author Share Posted May 22, 2014 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? Please reply guyz, AFK for 3-4 days.. Mom has a surgery and she is crying with pain.. Link to comment
Karuzo Posted May 22, 2014 Share Posted May 22, 2014 What do you mean with derived? My code works to 100%.Honestly idk C, so i can't help you with the "scanf" func. Link to comment
.:HyPeX:. Posted May 22, 2014 Share Posted May 22, 2014 It might be disabled aswell as os functions library, maybe for security reasons. Link to comment
Deepu Posted May 23, 2014 Author Share Posted May 23, 2014 what about using C functions in lua? Is that possible? any function in lua like this: c.ExportFunction(function) ?? Link to comment
.:HyPeX:. Posted May 23, 2014 Share Posted May 23, 2014 .. Really? They're 2 different languages, Lua and C! Yeah right, we now got visual basic functions in lua. They're just similar in coding. 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