Jump to content

[HELP] dxEdit


N3xT

Recommended Posts

Posted

Hello guys,

I am trying to do a " dxEdit ", I try that but it doesn't work.

local text = {} 
  
addEventHandler("onClientCharacter", root, 
    function (c) 
        table.insert(text,c) 
    end ) 
  
addEventHandler("onClientRender", root, 
    function () 
        dxDrawText(#text, 654, 354, 778, 377, tocolor(255, 255, 255, 255), 1, f2, "left", "top", true, true, true, true, true) 
    end ) 

when I press anything I got a " numbers " in the dxText,

example, when I type hello, I got a number 5.

so How to fix it ?

Posted
    local text = "" 
      
    addEventHandler("onClientCharacter", root, 
        function (c) 
            text = text..c 
        end ) 
      
    addEventHandler("onClientRender", root, 
        function () 
            dxDrawText(text, 654, 354, 778, 377, tocolor(255, 255, 255, 255), 1, f2, "left", "top", true, true, true, true, true) 
        end ) 

Posted

or you can use this:

addEventHandler ("onClientRender", root, 
     function () 
          dxDrawText(table.maxn (text), 654, 354, 778, 377, tocolor(255, 255, 255, 255), 1, f2, "left", "top", true, true, true, true, true) 
     end 
) 

Posted
    local text = "" 
      
    addEventHandler("onClientCharacter", root, 
        function (c) 
            text = text..c 
        end ) 
      
    addEventHandler("onClientRender", root, 
        function () 
            dxDrawText(text, 654, 354, 778, 377, tocolor(255, 255, 255, 255), 1, f2, "left", "top", true, true, true, true, true) 
        end ) 

It's working, but how I can delete the last value?

bindKey("backspace", "down", function () 
  text = "" 
end) 

or I just can delete all the values ?

Posted
        
  
  
  
       local text = {} 
          
        addEventHandler("onClientCharacter", root, 
            function (c) 
                text[#text+1] = c 
            end ) 
             
        bindKey("backspace", "down", function () 
         text[#text] = nil 
        end) 
             
  
        function getText() 
        local Text = "" 
        for i,v in pairs(text) do 
        local Text = Text..v 
        end 
        return Text 
        end 
         
        addEventHandler("onClientRender", root, 
            function () 
                dxDrawText(getText(), 654, 354, 778, 377, tocolor(255, 255, 255, 255), 1, f2, "left", "top", true, true, true, true, true) 
            end ) 

Posted
        
  
  
  
       local text = {} 
          
        addEventHandler("onClientCharacter", root, 
            function (c) 
                text[#text+1] = c 
            end ) 
             
        bindKey("backspace", "down", function () 
         text[#text] = nil 
        end) 
             
  
        function getText() 
        local Text = "" 
        for i,v in pairs(text) do 
        local Text = Text..v 
        end 
        return Text 
        end 
         
        addEventHandler("onClientRender", root, 
            function () 
                dxDrawText(getText(), 654, 354, 778, 377, tocolor(255, 255, 255, 255), 1, f2, "left", "top", true, true, true, true, true) 
            end ) 

line 19 : bad argument #1 to'pairs' (table expected got string)

Posted

Oh sorry try this.

           
      
      
      
           local text = {} 
              
            addEventHandler("onClientCharacter", root, 
                function (c) 
                    text[#text+1] = c 
                end ) 
                
            bindKey("backspace", "down", function () 
             text[#text] = nil 
            end) 
                
      
            function getText() 
            local TText = "" 
            for i,v in pairs(text) do 
            local TText = TText..v 
            end 
            return TText 
            end 
            
            addEventHandler("onClientRender", root, 
                function () 
                    dxDrawText(getText(), 654, 354, 778, 377, tocolor(255, 255, 255, 255), 1, f2, "left", "top", true, true, true, true, true) 
                end ) 

Posted
Oh sorry try this.
           
      
      
      
           local text = {} 
              
            addEventHandler("onClientCharacter", root, 
                function (c) 
                    text[#text+1] = c 
                end ) 
                
            bindKey("backspace", "down", function () 
             text[#text] = nil 
            end) 
                
      
            function getText() 
            local TText = "" 
            for i,v in pairs(text) do 
            local TText = TText..v 
            end 
            return TText 
            end 
            
            addEventHandler("onClientRender", root, 
                function () 
                    dxDrawText(getText(), 654, 354, 778, 377, tocolor(255, 255, 255, 255), 1, f2, "left", "top", true, true, true, true, true) 
                end ) 

same error.

Posted

CodyL your code will not work o.O

pairs? local in this for block?

local text = "" 
  
bindKey ( "backspace", "down", function ()  
    if text ~= "" then 
        string.sub ( text, 1, #text - 1 ) 
    end 
end ) 
  
addEventHandler ( "onClientCharacter", root, function ( key ) 
    text = text .. key 
end ) 
  
addEventHandler ( "onClientRender", root, function ()  
    dxDrawText ( text, ... ) 
end ) 

Posted
CodyL your code will not work o.O

pairs? local in this for block?

local text = "" 
  
bindKey ( "backspace", "down", function ()  
    if text ~= "" then 
        string.sub ( text, 1, #text - 1 ) 
    end 
end ) 
  
addEventHandler ( "onClientCharacter", root, function ( key ) 
    text = text .. key 
end ) 
  
addEventHandler ( "onClientRender", root, function ()  
    dxDrawText ( text, ... ) 
end ) 

It's only writing, nothing in debug

Posted

I'm sorry I wasn't thinking about that at the time, try this

     
    local text = "" 
      
    bindKey ( "backspace", "down", function () 
        if text ~= "" then 
            string.sub ( text, 1, #text - 1 ) 
        end 
    end ) 
      
    addEventHandler ( "onClientCharacter", root, function ( key ) 
    if not key == "backspace" then 
        text = text .. key 
    end 
    end ) 
      
    addEventHandler ( "onClientRender", root, function () 
        dxDrawText ( text, 654, 354, 778, 377, tocolor(255, 255, 255, 255), 1, f2, "left", "top", true, true, true, true, true) 
    end ) 

-- Updated version of other guys code.

Posted
I'm sorry I wasn't thinking about that at the time, try this
     
    local text = "" 
      
    bindKey ( "backspace", "down", function () 
        if text ~= "" then 
            string.sub ( text, 1, #text - 1 ) 
        end 
    end ) 
      
    addEventHandler ( "onClientCharacter", root, function ( key ) 
    if not key == "backspace" then 
        text = text .. key 
    end 
    end ) 
      
    addEventHandler ( "onClientRender", root, function () 
        dxDrawText ( text, 654, 354, 778, 377, tocolor(255, 255, 255, 255), 1, f2, "left", "top", true, true, true, true, true) 
    end ) 

-- Updated version of other guys code.

Now I can't write :(

Posted
local text = "" 
  
bindKey ( "backspace", "down", function () 
    if text ~= "" then 
        string.sub ( text, 1, #text - 1 ) 
    end 
end ) 
  
addEventHandler ( "onClientCharacter", root, function ( key ) 
    text = text .. key 
end ) 
  
addEventHandler ( "onClientRender", root, function () 
     dxDrawText ( text, 654, 354, 778, 377, tocolor(255, 255, 255, 255), 1, f2, "left", "top", true, true, true, true, true) 
end ) 

I expected you to fill the dxDrawText :D

Was on mobile phone

Posted
local text = "" 
  
bindKey ( "backspace", "down", function () 
    if text ~= "" then 
        string.sub ( text, 1, #text - 1 ) 
    end 
end ) 
  
addEventHandler ( "onClientCharacter", root, function ( key ) 
    text = text .. key 
end ) 
  
addEventHandler ( "onClientRender", root, function () 
     dxDrawText ( text, 654, 354, 778, 377, tocolor(255, 255, 255, 255), 1, f2, "left", "top", true, true, true, true, true) 
end ) 

I expected you to fill the dxDrawText :D

Was on mobile phone

Ok, now it's writing but can't delete the text

Posted

Hmm ... normally I don't use bindKey there, I use onClientKey.

Test this:

local text = "" 
  
addEventHandler ( "onClientKey", root, function ( button, press ) 
    if press then 
        if button == "tab" then 
            text = text .. "\n" 
        elseif button == "backspace" then 
            if #text > 0 then 
                string.sub ( text, 1, #text - 1 ) 
            end 
        end 
    end 
end ) 
  
addEventHandler ( "onClientCharacter", root, function ( key ) 
    text = text .. key 
end ) 
  
addEventHandler ( "onClientRender", root, function () 
     dxDrawText ( text, 654, 354, 778, 377, tocolor(255, 255, 255, 255), 1, f2, "left", "top", true, true, true, true, true) 
end ) 

Posted

Lets try this

addEventHandler ( "onClientKey", root, function ( button, press )  
    if press and button == "backspace" then 
        outputChatBox ( "Test" ) 
    end 
end ) 

Put this in and try to delete like you normally do.

Do you get an output in the chat?

Posted
Yes, I got "Test"

I've done some research, found out some of you guys's biggest mistake

Replace: string.sub ( text, 1, #text - 1 )

with

  
text = string.sub ( text, 1, #text - 1 ) 
  

should work perfectly. :)

Posted

Haha don't worry, it's the smallest mistakes that you cant see even when they're right infront of your eyes, it's what used to happen to me when I was an amateur in coding :P

Good-luck on your code N3xT, was happy to help.

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