Jump to content

cant see the problem


Stylez

Recommended Posts

Posted

Hi, again. So i have this login, register, guest, Gui window which should work properly but, i cant see the problem why window doesnt shows up. And there is no errors in debugscript 3 heres the code C

function loginas() 
  
    local sWidth, sHeight = guiGetScreenSize() 
    local width, height = 400, 400 
     
    local x = (sWidth/2) - (width/2) 
    local y = (sHeight/2) - (height/2) 
     
mainWin = guiCreateWindow (x,y, width, height, "Hello, Please Log-In", false) 
guiWindowSetMovable(mainWin, false) 
guiWindowSetSizable(mainWin, false) 
  
user_Label = guiCreateLabel (175, 100, 100, 50, "Username:", false, mainWin) 
pass_Label = guiCreateLabel (175, 150, 100, 50, "Password:", false, mainWin) 
guiEditSetMasked(pass_Label, true) 
  
editUser = guiCreateEdit (175, 125, 150, 25, false, mainWin) 
editPass = guiCreateEdit (175, 175, 150, 25, false, mainWin) 
  
loginBtn = guiCreateButton (175, 200, 150, 50, false, mainWin) 
regBtn = guiCreateButton (175, 225, 150, 50, false, mainWin) 
guestBtn = guiCreateButton (175, 250, 150, 50, false, mainWin) 
  
showCursor(true) 
guiSetInputEnabled(mainWin, true) 
  
end 
addEventHandler("onClientGUIClick",getRootElement(), 
function() 
    local user = guiGetText(editUser) 
    local pass = guiGetText(editPass) 
        if source == guestBtn then 
            guiSetVisible(loginas, false) 
            showCursor(false) 
            guiSetInputEnabled(false) 
        elseif source == loginBtn then 
            triggerServerEvent("login", getLocalPlayer(), user, pass) 
        elseif source == regBtn then 
            triggerServerEvent("inUse", getLocalPlayer(), user, pass) 
        end 
    end 
) 
  
addEvent("setcol",true) 
addEventHandler("setcol",getRootElement(), 
    function() 
        guiSetVisible(loginas,false) 
        showCursor(false) 
        guiSetInputEnabled(false) 
    end 
) 

S

addEvent("login", true) 
addEventHandler("login", getRootElement(), 
    function(user, pass) 
        local account = getAccount(user, pass) 
        if account then 
            logIn(source, account, pass) 
            triggerClientEvent(source,"setcol", source) 
        else 
            outputChatBox("#FFAE00Warning: Wrong username or password.", source) 
        end 
    end 
) 
addEvent("inUse", true) 
addEventHandler("inUse", getRootElement(), 
    function(user, pass) 
        local account = getAccount(user, pass) 
        if account then 
            outputChatBox("#FFAE00Warning: This account is already in use.", source) 
        elseif account then 
            addAccount(user, pass) 
            outputChatBox("#00A627Succes. #FFFFFFNote: Remmember your Username: "..user.." And Password: "..pass, source,0,0,0, true) 
        end 
    end  
) 

Posted (edited)

ehm,

      
   local account = getAccount(user, pass) 
        if account then 
        elseif account then 
            addAccount(user, pass) 
     

that's the same

and I don't see the event's of triggering the event; 'login'

you should recode the server side code.

Edited by Guest

Sometimes I dream about cheese

Posted
function loginas() 
  
    local sWidth, sHeight = guiGetScreenSize() 
    local width, height = 400, 400 
    
    local x = (sWidth/2) - (width/2) 
    local y = (sHeight/2) - (height/2) 
    
mainWin = guiCreateWindow (x,y, width, height, "Hello, Please Log-In", false) 
guiWindowSetMovable(mainWin, false) 
guiWindowSetSizable(mainWin, false) 
  
user_Label = guiCreateLabel (175, 100, 100, 50, "Username:", false, mainWin) 
pass_Label = guiCreateLabel (175, 150, 100, 50, "Password:", false, mainWin) 
guiEditSetMasked(pass_Label, true) 
  
editUser = guiCreateEdit (175, 125, 150, 25, false, mainWin) 
editPass = guiCreateEdit (175, 175, 150, 25, false, mainWin) 
  
loginBtn = guiCreateButton (175, 200, 150, 50, false, mainWin) 
regBtn = guiCreateButton (175, 225, 150, 50, false, mainWin) 
guestBtn = guiCreateButton (175, 250, 150, 50, false, mainWin) 
  
showCursor(true) 
guiSetInputEnabled(mainWin, true)  
end 
addEventHandler ( "onClientResourceStart", resourceRoot, loginas ) 
  
addEventHandler("onClientGUIClick",getRootElement(), 
function() 
    local user = guiGetText(editUser) 
    local pass = guiGetText(editPass) 
        if source == guestBtn then 
            guiSetVisible(mainWin, false) 
            showCursor(false) 
            guiSetInputEnabled(false) 
        elseif source == loginBtn then 
            triggerServerEvent("login", getLocalPlayer(), user, pass) 
        elseif source == regBtn then 
            triggerServerEvent("inUse", getLocalPlayer(), user, pass) 
        end 
    end 
) 
  
addEvent("setcol",true) 
addEventHandler("setcol",getRootElement(), 
    function() 
        guiSetVisible(mainWin,false) 
        showCursor(false) 
        guiSetInputEnabled(false) 
    end 
) 

The problem was that you never executed "loginas" function, and in the guiSetVisible you put the function instead of the GUI-window.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

You forgot to fill the text argument:

editUser = guiCreateEdit (175, 125, 150, 25, "", false, mainWin) 
editPass = guiCreateEdit (175, 175, 150, 25, "", false, mainWin) 
  
loginBtn = guiCreateButton (175, 200, 150, 50, "Login", false, mainWin) 
regBtn = guiCreateButton (175, 225, 150, 50, "Register", false, mainWin) 
guestBtn = guiCreateButton (175, 250, 150, 50, "Guest", false, mainWin) 

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

Yes, you can go to the server log file.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

You're welcome.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted
ehm,
      
   local account = getAccount(user, pass) 
        if account then 
        elseif account then 
            addAccount(user, pass) 
     

that's the same

and I don't see the event's of triggering the event; 'login'

you should recode the server side code.

hmm.. i edited serverside code. And now it works just like it should

Here's my full code, can u look if there is any problems/fails in it?

C

function loginas() 
  
    local sWidth, sHeight = guiGetScreenSize() 
    local width, height = 400, 400 
    
    local x = (sWidth/2) - (width/2) 
    local y = (sHeight/2) - (height/2) 
    
mainWin = guiCreateWindow (x,y, width, height, "Hello, Please Log-In", false) 
guiWindowSetMovable(mainWin, false) 
guiWindowSetSizable(mainWin, false) 
  
user_Label = guiCreateLabel (150, 100, 100, 50, "Username:", false, mainWin) 
pass_Label = guiCreateLabel (150, 150, 100, 50, "Password:", false, mainWin) 
  
editUser = guiCreateEdit (150, 120, 150, 25, "", false, mainWin) 
editPass = guiCreateEdit (150, 170, 150, 25, "", false, mainWin) 
guiEditSetMasked(editPass, true)  
  
loginBtn = guiCreateButton (150, 215, 100, 30, "Login", false, mainWin) 
regBtn = guiCreateButton (150, 270, 100, 30, "Register", false, mainWin) 
guestBtn = guiCreateButton (150, 305, 100, 30, "Guest", false, mainWin) 
  
showCursor(true) 
guiSetInputEnabled(true)  
end 
addEventHandler ( "onClientResourceStart", resourceRoot, loginas ) 
  
addEventHandler("onClientGUIClick",getRootElement(), 
function() 
    local user = guiGetText(editUser) 
    local pass = guiGetText(editPass) 
        if source == guestBtn then 
            triggerServerEvent("guest", getLocalPlayer(), user, pass) 
        elseif source == loginBtn then 
            triggerServerEvent("login", getLocalPlayer(), user, pass) 
        elseif source == regBtn then 
            triggerServerEvent("inUse", getLocalPlayer(), user, pass) 
        end 
    end 
) 
  
addEvent("setcol",true) 
addEventHandler("setcol",getRootElement(), 
    function() 
        guiSetVisible(mainWin,false) 
        showCursor(false) 
        guiSetInputEnabled(false) 
    end 
) 

S

addEvent("login", true) 
addEventHandler("login", getRootElement(), 
    function(user, pass) 
        local account = getAccount(user, pass) 
        if account then 
            logIn(source, account, pass) 
            triggerClientEvent(source,"setcol", source) 
            spawnPlayer(source, 2496.97, -1659.15, 15.30) 
            fadeCamera(source, false, 1.0, 0, 0, 0) -- 
            setTimer( fadeCamera, 500, 1, source, true, 0.5 )  
            setCameraTarget(source)-- 
            outputChatBox("Welocme To Cops & Robbers Server.", source, 55,150,0) 
        else 
            outputChatBox("#FFAE00Warning: Wrong username or password.", source) 
        end 
    end 
) 
addEvent("inUse", true) 
addEventHandler("inUse", getRootElement(), 
    function(user, pass) 
        local isUsedAccount = getAccount(user, pass) 
        if isUsedAccount then 
            outputChatBox("#FFA600 Warning: This account is already in use.", source) 
        elseif not isUsedAccount then 
            addAccount(user, pass) 
            outputChatBox("#00A627 Succes. #FFFFFF Note: Remmember your Username: "..user.." And Password: "..pass, source,0,0,0, true) 
        end 
    end  
) 
  
function spawnG() 
    triggerClientEvent(source,"setcol", source) 
    spawnPlayer(source, 2496.97, -1659.15, 15.30) 
    fadeCamera(source, false, 1.0, 0, 0, 0) -- 
    setTimer( fadeCamera, 500, 1, source, true, 0.5 )  
    setCameraTarget(source)-- 
    outputChatBox("Welocme To Cops & Robbers Server. Remember You are guest", source,55,150,0) 
end 
addEvent("guest", true) 
addEventHandler("guest", getRootElement(), spawnG) 

Posted

Why don't you test it and tell us what's wrong?

Do you require a paid scripter? Contact me! (Unavailable) Currently I am experienced in Lua, PHP, HTML, CSS, SQL and JS.

Developer and owner of

https://projectbea.st - Project Beast

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