Dear Scripters,
I'm having some problems don't realy understand i've build an GUI Login Screen and created the code to make it login on the click.
The only thing is that i get this error when loggin in:
WARNING: DGC-SS\dgcss_server.lua:16: Bad argument @ 'logIn'
WARNING: DGC-SS\dgcss_server.lua:18: Bad argument @ 'triggerClientEvent'
So the error seems to be in the server-sided script but i myself can't find it i think i'm looking over something but i'm just an beginner in LUA Scripting so thats why i'm asking it here
Here are the servers/client scripts:
Client-Side:
-- Begin: DGC Login GUI Handlers
function resourceStartOpenLoginWindow()
createLoginWindow()
if ( guiGetVisible ( DGCAccountLogin_Window ) == false ) then
guiSetVisible( DGCAccountLogin_Window, true )
showCursor(true)
guiSetInputEnabled(true)
else
outputChatBox("[GUI]: An error has occurred!")
end
end
function clientSubmitLogin(button, state)
local username = guiGetText(DGCAccount_UserEdit)
local password = guiGetText(DGCAccount_PassEdit)
if username and password then
triggerServerEvent("submitLogin", getRootElement(), thePlayer, username, password)
else
outputChatBox("[LOGIN]: Enter username and password!")
end
end
function clientSubmitRegister(button, state)
if button == "left" and state == "up" then
local username = guiGetText(DGCAccount_UserEdit)
local password = guiGetText(DGCAccount_PassEdit)
if username and password then
triggerServerEvent("submitRegister", getRootElement(), localPlayer, username, password)
else
outputChatBox("[REGISTER]: Enter username and password.")
end
end
end
function hideLoginWindow()
guiSetInputEnabled(false)
guiSetVisible(DGCAccountLogin_Window, false)
showCursor(false)
end
-- End: DGC Login GUI Handlers
-- Begin: DGC Login GUI Errors
function unknownError()
outputChatBox("[ERROR]: An unknown error occured!")
end
function loginWrong()
outputChatbox("[LOGIN]: Wrong username and/or password!")
end
function registerTaken()
outputChatBox("[REGISTER]: This username is allready taken!")
end
-- End: DGC Login GUI Errors
-- Begin: Event Handlers DGC Login GUI
addEvent("hideLoginWindow", true)
addEvent("unknownError", true)
addEvent("loginWrong", true)
addEvent("registerTaken", true)
addEventHandler("hideLoginWindow", getRootElement(), hideLoginWindow)
addEventHandler("unknownError", getRootElement(), unknownError)
addEventHandler("loginWrong", getRootElement(), loginWrong)
addEventHandler("registerTaken", getRootElement(), registerTaken)
addEventHandler("onClientResourceStart", getResourceRootElement( getThisResource( ) ), resourceStartOpenLoginWindow)
-- End: Event Handlers DGC Login GUI
-- Begin: DGC Login GUI
GUIEditor_Label = {}
DGCAccountLogin_Window = guiCreateWindow(0.3549,0.3344,0.3111,0.29,"DGC Account Services - [LOGIN]",true)
guiWindowSetMovable(DGCAccountLogin_Window,false)
guiWindowSetSizable(DGCAccountLogin_Window,false)
guiSetProperty(DGCAccountLogin_Window,"Visible","true")
DGCAccount_LoginButton = guiCreateButton(224,218,104,32,"Login",false,DGCAccountLogin_Window)
guiSetFont(DGCAccount_LoginButton,"default-bold-small")
guiSetProperty(DGCAccount_LoginButton,"Visible","true")
DGCAccount_RegisterButton = guiCreateButton(333,218,104,32,"Register",false,DGCAccountLogin_Window)
guiSetFont(DGCAccount_RegisterButton,"default-bold-small")
guiSetProperty(DGCAccount_RegisterButton,"Visible","true")
DGCAccount_UserEdit = guiCreateEdit(56,34,156,24,"",false,DGCAccountLogin_Window)
guiSetProperty(DGCAccount_UserEdit,"Visible","true")
DGCAccount_PassEdit = guiCreateEdit(56,61,156,24,"",false,DGCAccountLogin_Window)
guiSetProperty(DGCAccount_PassEdit,"Visible","true")
GUIEditor_Label[1] = guiCreateLabel(10,36,51,25,"User:",false,DGCAccountLogin_Window)
guiLabelSetColor(GUIEditor_Label[1],255,255,255)
guiLabelSetVerticalAlign(GUIEditor_Label[1],"top")
guiLabelSetHorizontalAlign(GUIEditor_Label[1],"left",false)
guiSetProperty(GUIEditor_Label[1],"Visible","true")
GUIEditor_Label[2] = guiCreateLabel(11,63,52,30,"Pass:",false,DGCAccountLogin_Window)
guiLabelSetColor(GUIEditor_Label[2],255,255,255)
guiLabelSetVerticalAlign(GUIEditor_Label[2],"top")
guiLabelSetHorizontalAlign(GUIEditor_Label[2],"left",false)
guiSetProperty(GUIEditor_Label[2],"Visible","true")
GUIEditor_Label[3] = guiCreateLabel(12,238,213,23,"Copyright 2010 @ -DGC-FrankNL",false,DGCAccountLogin_Window)
guiLabelSetColor(GUIEditor_Label[3],255,255,255)
guiLabelSetVerticalAlign(GUIEditor_Label[3],"top")
guiLabelSetHorizontalAlign(GUIEditor_Label[3],"left",false)
guiSetFont(GUIEditor_Label[3],"default-small")
guiSetProperty(GUIEditor_Label[3],"Visible","true")
DGCAccount_AutoLoginBox = guiCreateCheckBox(13,86,208,23,"Auto-Login By Serial (Not Supported Yet!)",false,false,DGCAccountLogin_Window)
guiSetFont(DGCAccount_AutoLoginBox,"default-small")
guiSetProperty(DGCAccount_AutoLoginBox,"Visible","true")
GUIEditor_Label[4] = guiCreateLabel(0.7646,0.0011,0.2104,0.0478,"www.dgc-mta.nl",true)
guiLabelSetColor(GUIEditor_Label[4],255,255,255)
guiLabelSetVerticalAlign(GUIEditor_Label[4],"top")
guiLabelSetHorizontalAlign(GUIEditor_Label[4],"left",false)
guiSetFont(GUIEditor_Label[4],"sa-header")
guiSetVisible( DGCAccountLogin_Window, true )
showCursor(true)
addEventHandler("onClientGUIClick", DGCAccount_LoginButton, clientSubmitLogin, false)
addEventHandler("onClientGUIClick", DGCAccount_RegisterButton, clientSubmitRegister, false)
-- End: DGC Login GUI
Server-side:
-- Begin: DGC Join Handler
function joinHandlerDGC ( )
local joinedPlayerName = getPlayerName ( source )
local serverName = getServerName( )
outputChatBox ( "Welcome " .. joinedPlayerName .. " to DGC Gaming, Please Login!" , source, 255, 255, 0 )
end
addEventHandler ( "onPlayerJoin", getRootElement(), joinHandlerDGC )
-- End: DGC Join Handler
-- Begin: DGC Account Services, Login/Register Handler
function loginHandler(player, username, password)
local account = getAccount( username, password )
if (account ~= false) then
if (logIn ( thePlayer, account, password ) ~= true) then
outputChatBox("[DGC]: You are now Logged In, Have Fun!", player)
triggerClientEvent (player, "hideLoginWindow", getRootElement())
else
triggerClientEvent (player, "unknownError", getRootElement())
end
else
triggerClientEvent (player, "loginWrong", getRootElement())
end
end
function registerHandler(player, username, password)
local account = getAccount(username, password)
if (account ~= false) then
triggerClientEvent(player, "registerTaken", getRootElement())
else
account = addAccount(username, password)
if (logIn(player, account, password) == true) then
outputChatBox("[DGC]: You have registered your account and are now logged in!", player)
triggerClientEvent(player, "hideLoginWindow", getRootElement())
else
triggerClientEvent(player, "unknownError", getRootElement())
end
end
end
addEvent("submitLogin", true)
addEvent("submitRegister", true)
addEventHandler("submitLogin", root, loginHandler)
addEventHandler("submitRegister", root, registerHandler)
-- End: DGC Account Services, Login/Register Handler
Could someone help me and explain what i've done wrong always nice to learn
Thanks!
Greatings FrankNL