Im working on a login / register screen for my first gamemod ever in MTA, but im having some weird problems with it. Perhaps some experienced user can help me
I have two problems.
The first is that when i connect to my localhost server for first time the client script don't work, i must disconnect and connect again and then it loads ok.
I think is some kind of bug with the download manager?.
The second one is a problem calling the client event that shows the login screen, it only works the first time i call it.
Thats my code:
Server side:
function playerJoinHandler()
outputChatBox("Player connecting...",source)
triggerClientEvent("ShowLoginGUIEvent",source) --trigger the client event of the player
end
addEventHandler("onPlayerJoin", getRootElement(), playerJoinHandler)
function SubmitLoginHandler(user,pass)
outputChatBox("slh",source)
local acc = getAccount(user)
if (not acc) then
outputChatBox("This name is not registered.",source)
triggerClientEvent("ShowLoginGUIEvent",source) --trigger the client event of the player
else
if (logIn(source,acc,pass)) then
outputChatBox("Login correct.",source)
else
outputChatBox("Login incorrect.",source)
triggerClientEvent("ShowLoginGUIEvent",source) --trigger the client event of the player
end
end
end
addEvent("SubmitLoginEvent",true)
addEventHandler("SubmitLoginEvent",getRootElement(),SubmitLoginHandler);
Client side:
function guiShowLogin()
outputChatBox("Login.", getLocalPlayer())
CreateLoginWindow()
addEventHandler("onClientGUIClick", btnLogin, clientSubmitLogin, false)
if (wdwLogin ~= nil) then
guiSetVisible(wdwLogin, true)
end
showCursor(true)
guiSetInputEnabled(true)
end
addEventHandler("ShowLoginGUIEvent", getLocalPlayer(),guiShowLogin,false)