Jump to content

[Help] server password


Stranger

Recommended Posts

hello guys

i have a little problem in tihs code

addEventHandler( "onClientGUIClick", root, 
function() 
    if (source == set ) then 
           if not tonumber ( guiGetText ( pass ) ) then 
               guiSetText(pass, "Only Numbers") 
                  return end 
                    triggerServerEvent( "setpassword", getLocalPlayer(), pass ) 
                       outputChatBox("Password has been set to " ..guiGetText ( pass ).. " ", 0, 255, 0) 
                        guiSetVisible ( GUIEditor.window[1],not guiGetVisible ( GUIEditor.window[1] ) ) 
                        showCursor ( guiGetVisible ( GUIEditor.window[1] ) ) 
                        else 
                      outputChatBox( "There is no password ", 255, 0, 0 ) 
                    end 
            end 
) 

it's should be working but no, i think the problem in the trigger ?

this is the trigger :

addEvent("setpassword", true) 
addEventHandler("setpassword", root, 
function (pass) 
setServerPassword( pass) 
end 
) 

Link to comment
addEventHandler("onClientGUIClick", root, 
function() 
    if (source == set) then 
        if (tonumber(guiGetText(pass)) == nil) then 
            guiSetText(pass, "Only Numbers") 
            return 
        end 
        triggerServerEvent("setpassword", getLocalPlayer(), pass) 
        outputChatBox("Password has been set to " .. guiGetText(pass) .. " ", 0, 255, 0) 
        guiSetVisible(GUIEditor.window[1], not guiGetVisible(GUIEditor.window[1])) 
        showCursor(guiGetVisible(GUIEditor.window[1])) 
    end 
end) 

Edited by Guest
Link to comment

do you mean like this ?

addEventHandler("onClientGUIClick", root, 
function() 
    if (source == set) then 
        if not tonumber ( guiGetText ( pass ) ) then 
            guiSetText(pass, "Only Numbers") 
            return 
           end 
          triggerServerEvent("setpassword", getLocalPlayer(), guiGetText ( pass )) 
         outputChatBox("Password has been set to " ..guiGetText(pass).. " ", 0, 255, 0) 
        guiSetVisible(GUIEditor.window[1], false) 
       showCursor(false) 
    end 
end 
) 

Link to comment
pass is a GUI Element.... you should use guiGetText(pass) in order to know the password. you are triggering the GUI element iself

Oh, I see it now, he is right. Try copy:

addEventHandler("onClientGUIClick", root, 
function() 
    -- Check if "set" and "pass" is GUI elements, you can remove two lines: 
    outputChatBox("(set) Is GUI-Button?: " .. (isElement(set) and getElementType(set) == "gui-button") and "true" or "false")) 
    outputChatBox("(pass) Is GUI-Edit?: " .. (isElement(pass) and getElementType(pass) == "gui-edit") and "true" or "false")) 
    if (source == set) then 
        local password = tonumber(guiGetText(pass)) 
        if (password == nil) then 
            guiSetText(pass, "Only Numbers") 
            return 
        end 
        triggerServerEvent("setpassword", getLocalPlayer(), password) 
        outputChatBox("Password has been set to " .. password, 0, 255, 0) 
        guiSetVisible(GUIEditor.window[1], not guiGetVisible(GUIEditor.window[1])) 
        showCursor(guiGetVisible(GUIEditor.window[1])) 
    end 
end) 

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