Jump to content

Script simplify


Recommended Posts

addEventHandler ("onClientGUIClick", getRootElement(), 
    function (state) 
        if state == "left" then 
            if source == regbut then 
            local p1 = guiGetText (pwf1) 
            local p2 = guiGetText (pwf2) 
            local day = guiGetText (T) 
            local month = guiGetText (M) 
            local year = guiGetText (J) 
            local mailt = guiGetText (email) 
            local laenge = #p1 
            local tlaenge = #day 
            local mlaenge = #month 
            local jlaenge = #year 
            local maillaenge = #mailt 
            if (p1 ~= p2) then 
            outputChatBox ("Bitte gib zwei gleiche Passwörter ein!", 255,0,0) 
            end 
            if (p1 == p2) and (laenge < -- s8) --> or (laenge > 19) then 
            outputChatBox ("Dein Passwort muss zwischen 8 und 20 Zeichen lang sein!", 255,255,0) 
            end 
            if (p1 == p2) and (laenge > 7) and (p1 == "12345678") and (laenge < 21) then 
            outputChatBox ("Wähle ein anderes Passwort!", 255,255,0) 
end 
if (ifbdisvalid (tlaenge, mlaenge, jlaenge, day, month, year ) == false) and (ifmailisvalid (maillaenge, mailt ) == false ) and (p1 == p2) and (laenge > 7) and (p1 ~= "12345678") and (laenge < 21) then 
            outputChatBox (" ") 
            outputChatBox (" ") 
            outputChatBox (" ") 
            outputChatBox (" ") 
            outputChatBox (" ") 
            outputChatBox (" ") 
            outputChatBox (" ") 
            outputChatBox (" ") 
            outputChatBox (" ") 
            outputChatBox (" ") 
            outputChatBox ("Herzlich willkommmen auf "..ServerName..", wir wünschen dir viel Spaß!", 0,255,0) 
            m = guiRadioButtonGetSelected(selectm) 
            w = guiRadioButtonGetSelected(selectw) 
            local pname = getPlayerName (localPlayer) 
            if (m == true) then 
            rgeschlecht = "Mann" 
            else 
            rgeschlecht = "Frau" 
            end 
            triggerServerEvent ("onRegisterButtonClick", localPlayer, localPlayer, p1, mailt, day, month, year, rgeschlecht ) 
            guiSetVisible (Fenster, false) 
            showCursor (false) 
            guiSetInputEnabled (false) 
            elseif (ifbdisvalid (tlaenge, mlaenge, jlaenge, day, month, year ) == false) and (ifmailisvalid (maillaenge, mailt ) == true ) and (p1 == p2) and (laenge > 7) and (p1 ~= "12345678") and (laenge < 21) then 
            outputChatBox ("Bitte gib eine ordentliche E-Mail Adresse ein!", 255,0,0) 
            elseif (ifbdisvalid (tlaenge, mlaenge, jlaenge, day, month, year ) == true) and (ifmailisvalid (maillaenge, mailt ) == true ) and (p1 == p2) and (laenge > 7) and (p1 ~= "12345678") and (laenge < 21) then 
            outputChatBox ("Bitte gib eine ordentliche E-Mail Adresse ein!", 255,0,0) 
            elseif (ifbdisvalid (tlaenge, mlaenge, jlaenge, day, month, year ) == true) and (ifmailisvalid (maillaenge, mailt ) == false ) and (p1 == p2) and (laenge > 7) and (p1 ~= "12345678") and (laenge < 21) then 
            outputChatBox ("Bitte gib ein ordentliches Geburtsdatum ein!", 255,0,0) 
            end 
        end 
    end 
end) 

How i can make this script easier (shorter)?

Link to comment

try this:

addEventHandler ("onClientGUIClick",guiRoot,function (state) 
    if state ~= "left" then return end 
    if source ~= regbut then return end 
    local p1,p2,day,month,year,mailt = guiGetText (pwf1,guiGetText (pwf2),guiGetText (T),guiGetText(M),guiGetText (J),guiGetText (email) 
    local laenge,tlaenge,mlaenge,jlaenge,maillaenge = #p1,#day,#month,#year,#mailt 
    if (p1 ~= p2) then 
        outputChatBox ("Bitte gib zwei gleiche Passwörter ein!", 255,0,0) 
    elseif (p1 == p2) and (laenge < -- s8) --> or (laenge > 19) then 
        outputChatBox ("Dein Passwort muss zwischen 8 und 20 Zeichen lang sein!", 255,255,0) 
    elseif (p1 == p2) and (laenge > 7) and (p1 == "12345678") and (laenge < 21) then 
        outputChatBox ("Wähle ein anderes Passwort!", 255,255,0) 
    end 
    if (ifbdisvalid (tlaenge, mlaenge, jlaenge, day, month, year ) == false) and (ifmailisvalid (maillaenge, mailt ) == false ) and (p1 == p2) and (laenge > 7) and (p1 ~= "12345678") and (laenge < 21) then 
        for i=0,11 do 
            outputChatBox (" ") 
        end 
        outputChatBox ("Herzlich willkommmen auf "..ServerName..", wir wünschen dir viel Spaß!", 0,255,0) 
        local m,w,pname = guiRadioButtonGetSelected(selectm),guiRadioButtonGetSelected(selectw),getPlayerName (localPlayer) 
        if (m == true) then 
            rgeschlecht = "Mann" 
        else 
            rgeschlecht = "Frau" 
        end 
        triggerServerEvent ("onRegisterButtonClick", localPlayer, localPlayer, p1, mailt, day, month, year, rgeschlecht ) 
        guiSetVisible (Fenster, false) 
        showCursor (false) 
        guiSetInputEnabled (false) 
    elseif (ifbdisvalid (tlaenge, mlaenge, jlaenge, day, month, year ) == false) and (ifmailisvalid (maillaenge, mailt ) == true ) and (p1 == p2) and (laenge > 7) and (p1 ~= "12345678") and (laenge < 21) then 
        outputChatBox ("Bitte gib eine ordentliche E-Mail Adresse ein!", 255,0,0) 
    elseif (ifbdisvalid (tlaenge, mlaenge, jlaenge, day, month, year ) == true) and (ifmailisvalid (maillaenge, mailt ) == true ) and (p1 == p2) and (laenge > 7) and (p1 ~= "12345678") and (laenge < 21) then 
        outputChatBox ("Bitte gib eine ordentliche E-Mail Adresse ein!", 255,0,0) 
    elseif (ifbdisvalid (tlaenge, mlaenge, jlaenge, day, month, year ) == true) and (ifmailisvalid (maillaenge, mailt ) == false ) and (p1 == p2) and (laenge > 7) and (p1 ~= "12345678") and (laenge < 21) then 
        outputChatBox ("Bitte gib ein ordentliches Geburtsdatum ein!", 255,0,0) 
    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...