maky55 Posted March 26, 2015 Share Posted March 26, 2015 Hello men! Well as you know, i'm an lua newb. I was following the wiki on a basic login screen, and i've to the point where you can click login, and it knows you click it, but does nothing . I don't know what the problem is, but heres the script I tried to put together: client function clientSubmitLogin(button,state) if button == "left" and state == "up" then local username = guiGetText(edtUser) local password = guiGetText(edtPass) if username and password then triggerServerEvent("submitLogin", getRootElement(), username, password) guiSetInputEnabled(false) guiSetVisible(wdwLogin, false) showCursor(false) else outputChatBox("Please enter a username and password.") end end end function createLoginWindow() local X = 0.375 local Y = 0.375 local Width = 0.25 local Height = 0.25 wdwLogin = guiCreateWindow(X, Y, Width, Height, "Please Log In", true) addEventHandler("onClientGUIClick", btnLogin, clientSubmitLogin, false) X = 0.0825 Y = 0.25 Width = 0.25 Height = 0.25 guiCreateLabel(X, Y, Width, Height, "Username", true, wdwLogin) Y = 0.5 guiCreateLabel(X, Y, Width, Height, "Password", true, wdwLogin) addEventHandler("onClientGUIClick", btnLogin, clientSubmitLogin, false) X = 0.415 Y = 0.25 Width = 0.5 Height = 0.15 edtUser = guiCreateEdit(X, Y, Width, Height, "", true, wdwLogin) Y = 0.5 edtPass = guiCreateEdit(X, Y, Width, Height, "", true, wdwLogin) guiEditSetMaxLength(edtUser, 20) guiEditSetMaxLength(edtpass, 20) addEventHandler("onClientGUIClick", btnLogin, clientSubmitLogin, false) X = 0.415 Y = 0.7 Width = 0.25 Height = 0.20 bntLogin = guiCreateButton(X, Y, Width, Height, "Log In", true, wdwLogin) guiSetVisible(wdwLogin, false) addEventHandler("onClientGUIClick", btnLogin, clientSubmitLogin, false) end addEventHandler("onClientResourceStart", getResourceRootElement(), function () createLoginWindow() outputChatBox("Welcome to My MTA:SA Server, please log in.") if (wdwLogin ~= nil) then guiSetVisible(wdwLogin, true) else outputChatBox("An unexpected error has occurred and the log in GUI has not been created.") end showCursor(true) guiSetInputEnabled(true) end ) Server local spawnX, spawnY, spawnZ = 2584.9523925781, -2209.318359375, 1.9927320480347 function loginHandler(username, password) if username =="" and password == "" then if (client) then spawnPlayer(client, spawnX, spawnY, spawnZ) fadeCamera(client, true) setCameraTarget(client, cient) setElementModel(source, 287) setPedArmor (source, 100) outputChatBox("Welcome to the test server!", client) end else outputChatBox("Invalid username or password", client) end end It looks really simple, but I don't know whats wrong. It's all from the wiki, but the wiki doesn't show you what the finished serverside and clientside should look like so I'm lost. Also, what do I put in this bit for username and password?: function loginHandler(username, password) if username =="" and password == "" then if (client) then Please help with this Link to comment
Dimos7 Posted March 26, 2015 Share Posted March 26, 2015 So you want help make you the server side? Link to comment
maky55 Posted March 26, 2015 Author Share Posted March 26, 2015 So you want help make you the server side? Really, all I want is to know what's wrong with this. It's just so I can log onto a local server for fun without having to type /login all the time. The login window shows up, you can type things in and you can click the buttons, but the buttons don't do anything. Link to comment
Dimos7 Posted March 26, 2015 Share Posted March 26, 2015 Client Side: local localPlayer = getLocalPlayer() local playerName = getPlayerName(localPlayer) function clientSubmitLogin(button,state) if button == "left" and state == "up" then local username = guiGetText(edtUser) local password = guiGetText(edtPass) if username and password then triggerServerEvent("submitLogin", getRootElement(), localPlayer, username, password) else outputChatBox("Please enter a username and password.") end end end function createLoginWindow() local X = 0.375 local Y = 0.375 local Width = 0.25 local Height = 0.25 wdwLogin = guiCreateWindow(X, Y, Width, Height, "Please Log In", true) addEventHandler("onClientGUIClick", btnLogin, clientSubmitLogin, false) X = 0.0825 Y = 0.25 Width = 0.25 Height = 0.25 guiCreateLabel(X, Y, Width, Height, "Username", true, wdwLogin) Y = 0.5 guiCreateLabel(X, Y, Width, Height, "Password", true, wdwLogin) addEventHandler("onClientGUIClick", btnLogin, clientSubmitLogin, false) X = 0.415 Y = 0.25 Width = 0.5 Height = 0.15 edtUser = guiCreateEdit(X, Y, Width, Height, "", true, wdwLogin) Y = 0.5 edtPass = guiCreateEdit(X, Y, Width, Height, "", true, wdwLogin) guiEditSetMaxLength(edtUser, 20) guiEditSetMaxLength(edtpass, 20) addEventHandler("onClientGUIClick", btnLogin, clientSubmitLogin, false) X = 0.415 Y = 0.7 Width = 0.25 Height = 0.20 bntLogin = guiCreateButton(X, Y, Width, Height, "Log In", true, wdwLogin) guiSetVisible(wdwLogin, false) addEventHandler("onClientGUIClick", btnLogin, clientSubmitLogin, false) end addEventHandler("onClientResourceStart", getResourceRootElement(), function () createLoginWindow() outputChatBox("Welcome to My MTA:SA Server, please log in.") if (wdwLogin ~= nil) then guiSetVisible(wdwLogin, true) else outputChatBox("An unexpected error has occurred and the log in GUI has not been created.") end showCursor(true) guiSetInputEnabled(true) end ) function hideLoginWindow() guiSetInputEnabled(false) guiSetVisible(wdwLogin, false) showCursor(false) end addEvent("hideLoginWindow", true) addEventHandler("hideLoginWindow", getRootElement(), hideLoginWindow) Server Side: local spawnX, spawnY, spawnZ = 2584.9523925781, -2209.318359375, 1.9927320480347 function loginHandler(player, username, password) local account = getAccount(username, password) if (account ~= false) then if (logIn(player, username, password) == true) then spawnPlayer(source, spawnX, spawnY, spawnZ) fadeCamera(source, true) setCameraTarget(source, source) setPedArmor(source, 100) outputChatBox("Welcome to the test server!", player) triggerClientEvent(player, "hideLoginWindow", getRootElement()) end else outputChatBox("Invaild username or password", player) end end addEvent("submitLogin", true) addEventHandler("submitLogin", getRootElement(), LoginHandler) Link to comment
maky55 Posted March 26, 2015 Author Share Posted March 26, 2015 Client Side: local localPlayer = getLocalPlayer() local playerName = getPlayerName(localPlayer) function clientSubmitLogin(button,state) if button == "left" and state == "up" then local username = guiGetText(edtUser) local password = guiGetText(edtPass) if username and password then triggerServerEvent("submitLogin", getRootElement(), localPlayer, username, password) else outputChatBox("Please enter a username and password.") end end end function createLoginWindow() local X = 0.375 local Y = 0.375 local Width = 0.25 local Height = 0.25 wdwLogin = guiCreateWindow(X, Y, Width, Height, "Please Log In", true) addEventHandler("onClientGUIClick", btnLogin, clientSubmitLogin, false) X = 0.0825 Y = 0.25 Width = 0.25 Height = 0.25 guiCreateLabel(X, Y, Width, Height, "Username", true, wdwLogin) Y = 0.5 guiCreateLabel(X, Y, Width, Height, "Password", true, wdwLogin) addEventHandler("onClientGUIClick", btnLogin, clientSubmitLogin, false) X = 0.415 Y = 0.25 Width = 0.5 Height = 0.15 edtUser = guiCreateEdit(X, Y, Width, Height, "", true, wdwLogin) Y = 0.5 edtPass = guiCreateEdit(X, Y, Width, Height, "", true, wdwLogin) guiEditSetMaxLength(edtUser, 20) guiEditSetMaxLength(edtpass, 20) addEventHandler("onClientGUIClick", btnLogin, clientSubmitLogin, false) X = 0.415 Y = 0.7 Width = 0.25 Height = 0.20 bntLogin = guiCreateButton(X, Y, Width, Height, "Log In", true, wdwLogin) guiSetVisible(wdwLogin, false) addEventHandler("onClientGUIClick", btnLogin, clientSubmitLogin, false) end addEventHandler("onClientResourceStart", getResourceRootElement(), function () createLoginWindow() outputChatBox("Welcome to My MTA:SA Server, please log in.") if (wdwLogin ~= nil) then guiSetVisible(wdwLogin, true) else outputChatBox("An unexpected error has occurred and the log in GUI has not been created.") end showCursor(true) guiSetInputEnabled(true) end ) function hideLoginWindow() guiSetInputEnabled(false) guiSetVisible(wdwLogin, false) showCursor(false) end addEvent("hideLoginWindow", true) addEventHandler("hideLoginWindow", getRootElement(), hideLoginWindow) Server Side: local spawnX, spawnY, spawnZ = 2584.9523925781, -2209.318359375, 1.9927320480347 function loginHandler(player, username, password) local account = getAccount(username, password) if (account ~= false) then if (logIn(player, username, password) == true) then spawnPlayer(source, spawnX, spawnY, spawnZ) fadeCamera(source, true) setCameraTarget(source, source) setPedArmor(source, 100) outputChatBox("Welcome to the test server!", player) triggerClientEvent(player, "hideLoginWindow", getRootElement()) end else outputChatBox("Invaild username or password", player) end end addEvent("submitLogin", true) addEventHandler("submitLogin", getRootElement(), LoginHandler) Hi, thanks for the reply. Sadly this didn't work and it still had the same problem. You also made an error in the script: addEventHandler("submitLogin", getRootElement(), LoginHandler) It should be loginHandler, with lowercase l. I changed it but it still doesnt work. This is the video of it: https://www.youtube.com/watch?v=YEU5lz7Gj6g&feature=youtu.be Link to comment
maky55 Posted March 26, 2015 Author Share Posted March 26, 2015 I will check it Thank you . Link to comment
Dimos7 Posted March 26, 2015 Share Posted March 26, 2015 local localPlayer = getLocalPlayer() local playerName = getPlayerName(localPlayer) function clientSubmitLogin(button,state) if button == "left" and state == "up" then local username = guiGetText(edtUser) local password = guiGetText(edtPass) if username and password then triggerServerEvent("submitLogin", getRootElement(), localPlayer, username, password) else outputChatBox("Please enter a username and password.") end end end function createLoginWindow() local X = 0.375 local Y = 0.375 local Width = 0.25 local Height = 0.25 wdwLogin = guiCreateWindow(X, Y, Width, Height, "Please Log In", true) addEventHandler("onClientGUIClick", btnLogin, clientSubmitLogin, false) X = 0.0825 Y = 0.25 Width = 0.25 Height = 0.25 guiCreateLabel(X, Y, Width, Height, "Username", true, wdwLogin) Y = 0.5 guiCreateLabel(X, Y, Width, Height, "Password", true, wdwLogin) addEventHandler("onClientGUIClick", btnLogin, clientSubmitLogin, false) X = 0.415 Y = 0.25 Width = 0.5 Height = 0.15 edtUser = guiCreateEdit(X, Y, Width, Height, "", true, wdwLogin) Y = 0.5 edtPass = guiCreateEdit(X, Y, Width, Height, "", true, wdwLogin) guiEditSetMaxLength(edtUser, 20) guiEditSetMaxLength(edtpass, 20) addEventHandler("onClientGUIClick", btnLogin, clientSubmitLogin) X = 0.415 Y = 0.7 Width = 0.25 Height = 0.20 bntLogin = guiCreateButton(X, Y, Width, Height, "Log In", true, wdwLogin) guiSetVisible(wdwLogin, false) end addEventHandler("onClientResourceStart", getResourceRootElement(), function () createLoginWindow() outputChatBox("Welcome to My MTA:SA Server, please log in.") if (wdwLogin ~= nil) then guiSetVisible(wdwLogin, true) else outputChatBox("An unexpected error has occurred and the log in GUI has not been created.") end showCursor(true) guiSetInputEnabled(true) end ) function hideLoginWindow() guiSetInputEnabled(false) guiSetVisible(wdwLogin, false) showCursor(false) end addEvent("hideLoginWindow", true) addEventHandler("hideLoginWindow", getRootElement(), hideLoginWindow) if you want your password not showed as number or text do that guiEditSetMasked(edtPass, true) Link to comment
maky55 Posted March 26, 2015 Author Share Posted March 26, 2015 local localPlayer = getLocalPlayer() local playerName = getPlayerName(localPlayer) function clientSubmitLogin(button,state) if button == "left" and state == "up" then local username = guiGetText(edtUser) local password = guiGetText(edtPass) if username and password then triggerServerEvent("submitLogin", getRootElement(), localPlayer, username, password) else outputChatBox("Please enter a username and password.") end end end function createLoginWindow() local X = 0.375 local Y = 0.375 local Width = 0.25 local Height = 0.25 wdwLogin = guiCreateWindow(X, Y, Width, Height, "Please Log In", true) addEventHandler("onClientGUIClick", btnLogin, clientSubmitLogin, false) X = 0.0825 Y = 0.25 Width = 0.25 Height = 0.25 guiCreateLabel(X, Y, Width, Height, "Username", true, wdwLogin) Y = 0.5 guiCreateLabel(X, Y, Width, Height, "Password", true, wdwLogin) addEventHandler("onClientGUIClick", btnLogin, clientSubmitLogin, false) X = 0.415 Y = 0.25 Width = 0.5 Height = 0.15 edtUser = guiCreateEdit(X, Y, Width, Height, "", true, wdwLogin) Y = 0.5 edtPass = guiCreateEdit(X, Y, Width, Height, "", true, wdwLogin) guiEditSetMaxLength(edtUser, 20) guiEditSetMaxLength(edtpass, 20) addEventHandler("onClientGUIClick", btnLogin, clientSubmitLogin) X = 0.415 Y = 0.7 Width = 0.25 Height = 0.20 bntLogin = guiCreateButton(X, Y, Width, Height, "Log In", true, wdwLogin) guiSetVisible(wdwLogin, false) end addEventHandler("onClientResourceStart", getResourceRootElement(), function () createLoginWindow() outputChatBox("Welcome to My MTA:SA Server, please log in.") if (wdwLogin ~= nil) then guiSetVisible(wdwLogin, true) else outputChatBox("An unexpected error has occurred and the log in GUI has not been created.") end showCursor(true) guiSetInputEnabled(true) end ) function hideLoginWindow() guiSetInputEnabled(false) guiSetVisible(wdwLogin, false) showCursor(false) end addEvent("hideLoginWindow", true) addEventHandler("hideLoginWindow", getRootElement(), hideLoginWindow) if you want your password not showed as number or text do that guiEditSetMasked(edtPass, true) Thanks, but it now says: ERROR: Client (asdf) triggered serverside event requestLODsClient, but event is not added serverside. Link to comment
Addlibs Posted March 26, 2015 Share Posted March 26, 2015 That debug error is not related to this issue. That's from scripting extensions from map editor. Link to comment
maky55 Posted March 27, 2015 Author Share Posted March 27, 2015 Sorted that bit, the error it's giving now is: ERROR: [gameplay]\Server\Client.lua:1: attempt to call global 'getLocalPlayer' (A nill value) Link to comment
maky55 Posted March 27, 2015 Author Share Posted March 27, 2015 Meta: <meta> <info author="Tiger" version="1.0" type="gamemode" name="Server" description="a simple spawn script" /> <script src="Server.lua" /> <script src="Client.lua" /> </meta> Client: local localPlayer = getLocalPlayer() local playerName = getPlayerName(localPlayer) function clientSubmitLogin(button,state) if button == "left" and state == "up" then local username = guiGetText(edtUser) local password = guiGetText(edtPass) if username and password then triggerServerEvent("submitLogin", getRootElement(), localPlayer, username, password) else outputChatBox("Please enter a username and password.") end end end function createLoginWindow() local X = 0.375 local Y = 0.375 local Width = 0.25 local Height = 0.25 wdwLogin = guiCreateWindow(X, Y, Width, Height, "Please Log In", true) addEventHandler("onClientGUIClick", btnLogin, clientSubmitLogin, false) X = 0.0825 Y = 0.25 Width = 0.25 Height = 0.25 guiCreateLabel(X, Y, Width, Height, "Username", true, wdwLogin) Y = 0.5 guiCreateLabel(X, Y, Width, Height, "Password", true, wdwLogin) addEventHandler("onClientGUIClick", btnLogin, clientSubmitLogin, false) X = 0.415 Y = 0.25 Width = 0.5 Height = 0.15 edtUser = guiCreateEdit(X, Y, Width, Height, "", true, wdwLogin) Y = 0.5 edtPass = guiCreateEdit(X, Y, Width, Height, "", true, wdwLogin) guiEditSetMaxLength(edtUser, 20) guiEditSetMaxLength(edtpass, 20) addEventHandler("onClientGUIClick", btnLogin, clientSubmitLogin) X = 0.415 Y = 0.7 Width = 0.25 Height = 0.20 bntLogin = guiCreateButton(X, Y, Width, Height, "Log In", true, wdwLogin) guiSetVisible(wdwLogin, false) end addEventHandler("onClientResourceStart", getResourceRootElement(), function () createLoginWindow() outputChatBox("Welcome to My MTA:SA Server, please log in.") if (wdwLogin ~= nil) then guiSetVisible(wdwLogin, true) else outputChatBox("An unexpected error has occurred and the log in GUI has not been created.") end showCursor(true) guiSetInputEnabled(true) end ) function hideLoginWindow() guiSetInputEnabled(false) guiSetVisible(wdwLogin, false) showCursor(false) end addEvent("hideLoginWindow", true) addEventHandler("hideLoginWindow", getRootElement(), hideLoginWindow) Server: local posX, posY, posZ = 2584.9523925781, -2209.318359375, 1.9927320480347 function loginHandler(player, username, password) local account = getAccount(username, password) if (account ~= false) then if (logIn(player, username, password) == true) then spawnPlayer(source, posX, posY, posZ) fadeCamera(source, true) setCameraTarget(source, source) setPedArmor(source, 100) setElementModel(source, 287) outputChatBox("Wow, you actually made it on", player) triggerClientEvent(player, "hideLoginWindow", getRootElement()) end else outputChatBox("Invalid username or password!",player) end end addEvent("submitLogin", true) addEventHandler("submitLogin", getRootElement(), loginHandler) function dieInServer() spawnPlayer(source, posX, posY, posZ) fadeCamera(source, true) setCameraTarget(source, source) setPedArmor(source, 100) setElementModel(source, 287) outputChatBox("And.... BAM! You're back!", source) end addEventHandler("onPlayerWasted",getRootElement(),dieInServer) Link to comment
roaddog Posted March 27, 2015 Share Posted March 27, 2015 <meta> <info author="Tiger" version="1.0" type="gamemode" name="Server" description="a simple spawn script" /> <script src="Server.lua" /> <script src="Client.lua" type="client" /> </meta> You have to put the client type, if you dont put the type it will load as server side script. therefore, you got the error. Link to comment
maky55 Posted March 27, 2015 Author Share Posted March 27, 2015 Crap.. I know that I forgot something so simple. Link to comment
maky55 Posted March 27, 2015 Author Share Posted March 27, 2015 Hello again . I've only just had time to test it, and this time the login panel shows, but the same problem as before, when you click the button, it doesn't do anything. When I activate debugscript 3, I get no errors, only 4 warnings: -- WARNING: Server\Client.lua:26: Bad argument @ 'addEventHandler' [expected element at argument 2, got nil] -- WARNING: Server\Client.lua:35: Bad argument @ 'addEventHandler' [expected element at argument 2, got nil] -- WARNING: Server\Client.lua:45: Bad argument @ guiEditSetMaxLength' [expected gui-element at argument 1, got nil] -- WARNING: Server\Client.lua:46: Bad argument @ 'addEventHandler' [expected element at argument 2, got nil] these are the lines it's got problems with: addEventHandler("onClientGUIClick", btnLogin, clientSubmitLogin, false) -- For 3 of them guiEditSetMaxLength(edtUser, 20) -- For 1 of them. here is the full client code: local localPlayer = getLocalPlayer() local playerName = getPlayerName(localPlayer) function clientSubmitLogin(button,state) if button == "left" and state == "up" then local username = guiGetText(edtUser) local password = guiGetText(edtPass) if username and password then triggerServerEvent("submitLogin", getRootElement(), localPlayer, username, password) else outputChatBox("Please enter a username and password.") end end end function createLoginWindow() local X = 0.375 local Y = 0.375 local Width = 0.25 local Height = 0.25 wdwLogin = guiCreateWindow(X, Y, Width, Height, "Please Log In", true) addEventHandler("onClientGUIClick", btnLogin, clientSubmitLogin, false) X = 0.0825 Y = 0.25 Width = 0.25 Height = 0.25 guiCreateLabel(X, Y, Width, Height, "Username", true, wdwLogin) Y = 0.5 guiCreateLabel(X, Y, Width, Height, "Password", true, wdwLogin) addEventHandler("onClientGUIClick", btnLogin, clientSubmitLogin, false) X = 0.415 Y = 0.25 Width = 0.5 Height = 0.15 edtUser = guiCreateEdit(X, Y, Width, Height, "", true, wdwLogin) Y = 0.5 edtPass = guiCreateEdit(X, Y, Width, Height, "", true, wdwLogin) guiEditSetMaxLength(edtUser, 20) guiEditSetMaxLength(edtpass, 20) addEventHandler("onClientGUIClick", btnLogin, clientSubmitLogin) X = 0.415 Y = 0.7 Width = 0.25 Height = 0.20 bntLogin = guiCreateButton(X, Y, Width, Height, "Log In", true, wdwLogin) guiSetVisible(wdwLogin, false) end addEventHandler("onClientResourceStart", getResourceRootElement(), function () createLoginWindow() outputChatBox("Welcome to My MTA:SA Server, please log in.") if (wdwLogin ~= nil) then guiSetVisible(wdwLogin, true) else outputChatBox("An unexpected error has occurred and the log in GUI has not been created.") end showCursor(true) guiSetInputEnabled(true) end ) function hideLoginWindow() guiSetInputEnabled(false) guiSetVisible(wdwLogin, false) showCursor(false) end addEvent("hideLoginWindow", true) addEventHandler("hideLoginWindow", getRootElement(), hideLoginWindow) Link to comment
roaddog Posted March 27, 2015 Share Posted March 27, 2015 Try this, not tested but It could work. local localPlayer = getLocalPlayer() local playerName = getPlayerName(localPlayer) function clientSubmitLogin(button,state) if button == "left" and state == "up" then local username = guiGetText(edtUser) local password = guiGetText(edtPass) if username and password then triggerServerEvent("submitLogin", getRootElement(), localPlayer, username, password) else outputChatBox("Please enter a username and password.") end end end function createLoginWindow() local X = 0.375 local Y = 0.375 local Width = 0.25 local Height = 0.25 wdwLogin = guiCreateWindow(X, Y, Width, Height, "Please Log In", true) X = 0.0825 Width = 0.25 Height = 0.25 guiCreateLabel(X, Y, Width, Height, "Username", true, wdwLogin) Y = 0.5 guiCreateLabel(X, Y, Width, Height, "Password", true, wdwLogin) X = 0.415 Y = 0.25 Width = 0.5 Height = 0.15 edtUser = guiCreateEdit(X, Y, Width, Height, "", true, wdwLogin) Y = 0.5 edtPass = guiCreateEdit(X, Y, Width, Height, "", true, wdwLogin) guiEditSetMaxLength(edtUser, 20) guiEditSetMaxLength(edtpass, 20) X = 0.415 Y = 0.7 Width = 0.25 Height = 0.20 bntLogin = guiCreateButton(X, Y, Width, Height, "Log In", true, wdwLogin) guiSetVisible(wdwLogin, false) addEventHandler("onClientGUIClick", btnLogin, clientSubmitLogin) end addEventHandler("onClientResourceStart", getResourceRootElement(), function () createLoginWindow() outputChatBox("Welcome to My MTA:SA Server, please log in.") if not guiGetVisible(wdwLogin) then guiSetVisible(wdwLogin, true) else outputChatBox("An unexpected error has occurred and the log in GUI has not been created.") end showCursor(true) guiSetInputEnabled(true) end ) function hideLoginWindow() guiSetInputEnabled(false) guiSetVisible(wdwLogin, false) showCursor(false) end addEvent("hideLoginWindow", true) addEventHandler("hideLoginWindow", getRootElement(), hideLoginWindow) Link to comment
maky55 Posted March 27, 2015 Author Share Posted March 27, 2015 No sadly it still isn't working :\. Maybe it's a problem with the server side script? local posX, posY, posZ = 2584.9523925781, -2209.318359375, 1.9927320480347 function loginHandler(player, username, password) local account = getAccount(username, password) if (account ~= false) then if (logIn(player, username, password) == true) then spawnPlayer(source, posX, posY, posZ) fadeCamera(source, true) setCameraTarget(source, source) setPedArmor(source, 100) setElementModel(source, 287) outputChatBox("Wow, you actually made it on", player) triggerClientEvent(player, "hideLoginWindow", getRootElement()) end else outputChatBox("Invalid username or password!",player) end end addEvent("submitLogin", true) addEventHandler("submitLogin", getRootElement(), loginHandler) function dieInServer() spawnPlayer(source, posX, posY, posZ) fadeCamera(source, true) setCameraTarget(source, source) setPedArmor(source, 100) setElementModel(source, 287) outputChatBox("And.... BAM! You're back!", source) end addEventHandler("onPlayerWasted",getRootElement(),dieInServer) Link to comment
roaddog Posted March 27, 2015 Share Posted March 27, 2015 I doubt it is. Check debugscript please? but the same problem as before, when you click the button, it doesn't do anything. give this resource admin priveleges. Link to comment
maky55 Posted March 27, 2015 Author Share Posted March 27, 2015 (edited) Whats the command to give it admin privalages? or do I have to put it in the ACL? Edited March 27, 2015 by Guest Link to comment
Dimos7 Posted March 27, 2015 Share Posted March 27, 2015 put that resource on acl admin group Link to comment
maky55 Posted March 27, 2015 Author Share Posted March 27, 2015 Also debugscript gives me two warnings: http://imgur.com/ddLk9YU Which would be these two lines: addEventHandler("onClientGUIClick", btnLogin, clientSubmitLogin) guiEditSetMaxLength(edtpass, 20) And putting it in admin didn't change a thing. Link to comment
roaddog Posted March 27, 2015 Share Posted March 27, 2015 How about tbis? local localPlayer = getLocalPlayer() local playerName = getPlayerName(localPlayer) function clientSubmitLogin(button,state) if button == "left" and state == "up" then local username = guiGetText(edtUser) local password = guiGetText(edtPass) if username and password then triggerServerEvent("submitLogin", getRootElement(), localPlayer, username, password) else outputChatBox("Please enter a username and password.") end end end addEventHandler("onClientGUIClick", btnLogin, clientSubmitLogin) function createLoginWindow() local X = 0.375 local Y = 0.375 local Width = 0.25 local Height = 0.25 wdwLogin = guiCreateWindow(X, Y, Width, Height, "Please Log In", true) X = 0.0825 Width = 0.25 Height = 0.25 guiCreateLabel(X, Y, Width, Height, "Username", true, wdwLogin) Y = 0.5 guiCreateLabel(X, Y, Width, Height, "Password", true, wdwLogin) X = 0.415 Y = 0.25 Width = 0.5 Height = 0.15 edtUser = guiCreateEdit(X, Y, Width, Height, "", true, wdwLogin) Y = 0.5 edtPass = guiCreateEdit(X, Y, Width, Height, "", true, wdwLogin) guiEditSetMaxLength(edtUser, 20) guiEditSetMaxLength(edtpass, 20) X = 0.415 Y = 0.7 Width = 0.25 Height = 0.20 bntLogin = guiCreateButton(X, Y, Width, Height, "Log In", true, wdwLogin) end addEventHandler("onClientResourceStart", getResourceRootElement(), function () createLoginWindow() outputChatBox("Welcome to My MTA:SA Server, please log in.") showCursor(true) guiSetInputEnabled(true) end ) function hideLoginWindow() guiSetInputEnabled(false) guiSetVisible(wdwLogin, false) showCursor(false) end addEvent("hideLoginWindow", true) addEventHandler("hideLoginWindow", getRootElement(), hideLoginWindow) Link to comment
maky55 Posted March 27, 2015 Author Share Posted March 27, 2015 Still didn't work The WARNINGS are the same as last time I've noticed another thing, it doesn't output this to chatbox: Welcome to My MTA:SA Server, please log in. Link to comment
WhoAmI Posted March 27, 2015 Share Posted March 27, 2015 local localPlayer = getLocalPlayer() local playerName = getPlayerName(localPlayer) function clientSubmitLogin(button,state) if button == "left" and state == "up" then local username = guiGetText(edtUser) local password = guiGetText(edtPass) if username and password then triggerServerEvent("submitLogin", getRootElement(), localPlayer, username, password) else outputChatBox("Please enter a username and password.") end end end function createLoginWindow() local X = 0.375 local Y = 0.375 local Width = 0.25 local Height = 0.25 wdwLogin = guiCreateWindow(X, Y, Width, Height, "Please Log In", true) X = 0.0825 Width = 0.25 Height = 0.25 guiCreateLabel(X, Y, Width, Height, "Username", true, wdwLogin) Y = 0.5 guiCreateLabel(X, Y, Width, Height, "Password", true, wdwLogin) X = 0.415 Y = 0.25 Width = 0.5 Height = 0.15 edtUser = guiCreateEdit(X, Y, Width, Height, "", true, wdwLogin) Y = 0.5 edtPass = guiCreateEdit(X, Y, Width, Height, "", true, wdwLogin) guiEditSetMaxLength(edtUser, 20) guiEditSetMaxLength(edtpass, 20) X = 0.415 Y = 0.7 Width = 0.25 Height = 0.20 bntLogin = guiCreateButton(X, Y, Width, Height, "Log In", true, wdwLogin) addEventHandler("onClientGUIClick", btnLogin, clientSubmitLogin) end addEventHandler("onClientResourceStart", getResourceRootElement(), function () createLoginWindow() outputChatBox("Welcome to My MTA:SA Server, please log in.") showCursor(true) guiSetInputEnabled(true) end ) function hideLoginWindow() guiSetInputEnabled(false) guiSetVisible(wdwLogin, false) showCursor(false) end addEvent("hideLoginWindow", true) addEventHandler("hideLoginWindow", getRootElement(), hideLoginWindow) 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