Stylez Posted October 15, 2012 Share Posted October 15, 2012 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 ) Link to comment
denny199 Posted October 15, 2012 Share Posted October 15, 2012 (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 October 15, 2012 by Guest Link to comment
Castillo Posted October 15, 2012 Share Posted October 15, 2012 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. Link to comment
Stylez Posted October 15, 2012 Author Share Posted October 15, 2012 oh thanks. but now, i dont understand why it doesnt creates buttons and edit fields.. everything is seems to be okey. Link to comment
denny199 Posted October 15, 2012 Share Posted October 15, 2012 Typ /debugscript 3 now. Link to comment
Castillo Posted October 15, 2012 Share Posted October 15, 2012 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) Link to comment
Stylez Posted October 15, 2012 Author Share Posted October 15, 2012 there is few errors, in debugscript. Is there any way to copy the errors? Link to comment
Castillo Posted October 15, 2012 Share Posted October 15, 2012 Yes, you can go to the server log file. Link to comment
Stylez Posted October 15, 2012 Author Share Posted October 15, 2012 Oh now it works.. made a stupid mistake . btw. it dosent outputs debugscript errors into server log file Link to comment
Stylez Posted October 15, 2012 Author Share Posted October 15, 2012 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) Link to comment
GTX Posted October 15, 2012 Share Posted October 15, 2012 Why don't you test it and tell us what's wrong? Link to comment
Stylez Posted October 15, 2012 Author Share Posted October 15, 2012 no need anymore, i just tested everything. and it works now im gonna try to make it with SQL Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now