Jump to content

How to detect empty text?


Cronoss

Recommended Posts

I made a button for a GUI, when the player presses it, the button triggers another GUI Panel, but I want to make sure the player complete all the comboBox items, how I could do it?

		A1 = guiComboBoxGetSelected(blabla)
        A2 = guiComboBoxGeItemText(A1)
		B1 = guiComboBoxGetSelected(blabla2)
        B2 = guiComboBoxGeItemText(B1)
            if (A2=="") or (B2=="") then --This doesn't work correctly, it only makes nothing happens after pressing the GUI button
                outputChatBox("You must... blablabla", 255, 0, 0, source)
            else
                triggerServerEvent("AwesomeFunction", getLocalPlayer(), A2, B2)
            end
		end, false)

This is client side

Link to comment
1 hour ago, Cronoss said:

I made a button for a GUI, when the player presses it, the button triggers another GUI Panel, but I want to make sure the player complete all the comboBox items, how I could do it?

		A1 = guiComboBoxGetSelected(blabla)
        A2 = guiComboBoxGeItemText(A1)
		B1 = guiComboBoxGetSelected(blabla2)
        B2 = guiComboBoxGeItemText(B1)
            if (A2=="") or (B2=="") then --This doesn't work correctly, it only makes nothing happens after pressing the GUI button
                outputChatBox("You must... blablabla", 255, 0, 0, source)
            else
                triggerServerEvent("AwesomeFunction", getLocalPlayer(), A2, B2)
            end
		end, false)

This is client side

try using string.len and string.gsub

local text = "" -- empty text 
text = string.gsub(text, "%s+", "")  -- delete all spaces

if(string.len(text) > 0) then --if text is greater than 0 characters
   -- codes here
end

 

  • Like 1
Link to comment
14 minutes ago, Cronoss said:

But how I could add it to the guiComboBoxGeItemText thing? ?

 

There is no reason for you to do this check for the combo box, if you want to check it with the player's input, it may work, but I'll give an example anyway.

A2 = string.gsub(A2, "%s+", "")  -- delete all spaces for A2

if(string.len(A2) > 0) then --if A2 is greater than 0 characters
   -- codes here
end

you can only use this in variables where you use guiComboBoxGeItemText function

Edited by Burak5312
Link to comment
Quote

There is no reason for you to do this check for the combo box

I asked because I put the code, obviusly I tried to figure out how to make the "text" detect the combobox, but I didn't realize how. The code itself works, but I don't get how to make the "text" part get the player combobox item selected, because the "text" variable keeps with empty text :/ 

Edited by Cronoss
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...