maky55 Posted March 27, 2015 Author Share Posted March 27, 2015 Still doesn't work, although the output chatbox works now. Ill upload a youtube clip of it now. Link to comment
maky55 Posted March 27, 2015 Author Share Posted March 27, 2015 What is the error now? No error comes up. The same two warnings are there. I created a new account to test it on and gave it admin. Username: admin Password: password. I typed it all in, and clicked the button. The button could be clicked, but it didn't do anything. Normally if the password/username was bad, it would put in the chatbox 'Invalid username or password!' but it didn't. I think the problem is the button. Link to comment
maky55 Posted March 27, 2015 Author Share Posted March 27, 2015 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) 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) 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) Meta: (For the meta, I've tried both gamemode and script. Neither work <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> Link to comment
WhoAmI Posted March 27, 2015 Share Posted March 27, 2015 Server local posX, posY, posZ = 2584.9523925781, -2209.318359375, 1.9927320480347 function loginHandler(username, password) local account = getAccount(username, password) if (account ~= false) then if (logIn(source, 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", source) triggerClientEvent(source, "hideLoginWindow", source) end else outputChatBox("Invalid username or password!",source) end 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) By they way, localPlayer is predefinied variable in MTA, so you don't have to add this in the top of code. Personnaly I would do something like that: local playerName = getPlayerName(localPlayer) function clientSubmitLogin() local username = guiGetText(edtUser) local password = guiGetText(edtPass) if ( username ~= "" and password ~= "" ) then triggerServerEvent("submitLogin", 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, false) 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) destroyElement ( wdwLogin ) showCursor(false) end addEvent("hideLoginWindow", true) addEventHandler("hideLoginWindow", getRootElement(), hideLoginWindow) Link to comment
maky55 Posted March 27, 2015 Author Share Posted March 27, 2015 (edited) ERROR: Loading script failed: [gameplay]\Server\Server.lua:18: '' expected near 'end' ERROR: Loading script failed: [gameplay]\Server\Client.lua:12: '' expected near 'end' Edited March 27, 2015 by Guest Link to comment
WhoAmI Posted March 27, 2015 Share Posted March 27, 2015 Oh, damn. Sorry, my bad local posX, posY, posZ = 2584.9523925781, -2209.318359375, 1.9927320480347 function loginHandler(username, password) local account = getAccount(username, password) if (account ~= false) then if (logIn(source, 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", source) triggerClientEvent(source, "hideLoginWindow", source) end else outputChatBox("Invalid username or password!",source) end end addEvent("submitLogin", true) addEventHandler("submitLogin", getRootElement(), loginHandler) Link to comment
maky55 Posted March 27, 2015 Author Share Posted March 27, 2015 and one more: ERROR: Loading script failed: [gameplay]\Server\Client.lua:12: '' expected near 'end' Link to comment
WhoAmI Posted March 27, 2015 Share Posted March 27, 2015 Sorry again function clientSubmitLogin() local username = guiGetText(edtUser) local password = guiGetText(edtPass) if ( username ~= "" and password ~= "" ) then triggerServerEvent("submitLogin", localPlayer, username, password) else outputChatBox("Please enter a username and password.") end end Link to comment
maky55 Posted March 27, 2015 Author Share Posted March 27, 2015 It still doesn't seem to be working :3. Same problem as before, it doesn't tell my my username and password is wrong, and the button doesn't do anything. Still the same warnings as before . Sorry if this is bothering anyone i'm just a beginner at doing this . Maybe if anyone other then me could test the scripts to see if I'm doing something wrong? Link to comment
maky55 Posted March 27, 2015 Author Share Posted March 27, 2015 Yes of course . Any help is appreciated. Link to comment
WhoAmI Posted March 27, 2015 Share Posted March 27, 2015 Client local posX, posY, posZ = 2584.9523925781, -2209.318359375, 1.9927320480347 function loginHandler(username, password) outputChatBox ( username .. ":" .. password ) local account = getAccount(username, password) if (account ~= false) then local loggin = logIn(source, username, password) if ( loggin ) 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", source) triggerClientEvent(source, "hideLoginWindow", source) end else outputChatBox("Invalid username or password!",source) end end addEvent("submitLogin", true) addEventHandler("submitLogin", getRootElement(), loginHandler) Server local playerName = getPlayerName(localPlayer) local guiElements = { } function clientSubmitLogin() local username = guiGetText(guiElements["edit_user"]) local password = guiGetText(guiElements["edit_pass"]) if ( username ~= "" and password ~= "" ) then triggerServerEvent("submitLogin", localPlayer, username, password) outputChatBox ( username .. ":" .. password ) else outputChatBox("Please enter a username and password.") end end end function createLoginWindow() guiElements["login_window"] = guiCreateWindow(0.375, 0.375, 0.25, 0.25, "Please Log In", true) guiCreateLabel(0.0825, 0.375, 0.25, 0.25, "Username", true, guiElements["login_window"]) guiCreateLabel(0.0825, 0.5, 0.25, 0.25, "Password", true, guiElements["login_window"]) guiElements["edit_user"] = guiCreateEdit(0.415, 0.25, 0.5, 0.15, "", true, guiElements["login_window"]) guiElements["edit_pass"] = guiCreateEdit(0.415, 0.5, 0.5, 0.15, "", true, guiElements["login_window"]) guiEditSetMaxLength(guiElements["edit_user"], 20) guiEditSetMaxLength(guiElements["edit_pass"], 20) guiElements["login_button"] = guiCreateButton(0.415, 0.7, 0.25, 0.20, "Log In", true, guiElements["login_window"]) addEventHandler("onClientGUIClick", guiElements["login_button"], clientSubmitLogin, false) 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) showCursor(false) if ( isElement ( guiElements["login_window"] ) ) then destroyElement ( guiElements["login_window"] ) end end addEvent("hideLoginWindow", true) addEventHandler("hideLoginWindow", getRootElement(), hideLoginWindow) Tell me if in chat it shows "login:password" two times. Link to comment
maky55 Posted March 27, 2015 Author Share Posted March 27, 2015 Yeah it showed: admin:password admin:password Link to comment
WhoAmI Posted March 27, 2015 Share Posted March 27, 2015 So it should work. If it doesn't add this resource in admin group in acl.xml <object name="resource.resource_name" /> Link to comment
maky55 Posted March 27, 2015 Author Share Posted March 27, 2015 (edited) So it should work. If it doesn't add this resource in admin group in acl.xml <object name="resource.resource_name" /> I've already added it. Problem is, it doesn't actually log me in, and the gui doesn't disapeer either. And also, this is a warning about it: WARNING:[gameplay]\server\server.lua:5: Bad argument @ 'logIn' [Expected account at argument 2, got string 'admin'] Edited March 27, 2015 by Guest Link to comment
WhoAmI Posted March 27, 2015 Share Posted March 27, 2015 Server local posX, posY, posZ = 2584.9523925781, -2209.318359375, 1.9927320480347 function loginHandler(username, password) local account = getAccount(username, password) outputChatBox ( "1" ) if ( account ) then local loggin = logIn(source, username, password) outputChatBox ( "2" ) if ( loggin ) then outputChatBox ( "3" ) spawnPlayer(source, posX, posY, posZ) fadeCamera(source, true) setCameraTarget(source, source) setPedArmor(source, 100) setElementModel(source, 287) outputChatBox("Wow, you actually made it on", source) triggerClientEvent(source, "hideLoginWindow", source) end else outputChatBox("Invalid username or password!",source) end end addEvent("submitLogin", true) addEventHandler("submitLogin", getRootElement(), loginHandler) Client local playerName = getPlayerName(localPlayer) local guiElements = { } function clientSubmitLogin() local username = guiGetText(guiElements["edit_user"]) local password = guiGetText(guiElements["edit_pass"]) if ( username ~= "" and password ~= "" ) then triggerServerEvent("submitLogin", localPlayer, username, password) outputChatBox ( username .. ":" .. password ) else outputChatBox("Please enter a username and password.") end end function createLoginWindow() guiElements["login_window"] = guiCreateWindow(0.375, 0.375, 0.25, 0.25, "Please Log In", true) guiCreateLabel(0.0825, 0.375, 0.25, 0.25, "Username", true, guiElements["login_window"]) guiCreateLabel(0.0825, 0.5, 0.25, 0.25, "Password", true, guiElements["login_window"]) guiElements["edit_user"] = guiCreateEdit(0.415, 0.25, 0.5, 0.15, "", true, guiElements["login_window"]) guiElements["edit_pass"] = guiCreateEdit(0.415, 0.5, 0.5, 0.15, "", true, guiElements["login_window"]) guiEditSetMaxLength(guiElements["edit_user"], 20) guiEditSetMaxLength(guiElements["edit_pass"], 20) guiElements["login_button"] = guiCreateButton(0.415, 0.7, 0.25, 0.20, "Log In", true, guiElements["login_window"]) addEventHandler("onClientGUIClick", guiElements["login_button"], clientSubmitLogin, false) end addEventHandler("onClientResourceStart", resourceRoot, function () createLoginWindow() outputChatBox("Welcome to My MTA:SA Server, please log in.") showCursor(true) guiSetInputEnabled(true) end ) function hideLoginWindow() guiSetInputEnabled(false) showCursor(false) if ( isElement ( guiElements["login_window"] ) ) then destroyElement ( guiElements["login_window"] ) end end addEvent("hideLoginWindow", true) addEventHandler("hideLoginWindow", getRootElement(), hideLoginWindow) Tell me how many number it will show in chatbox. Link to comment
maky55 Posted March 27, 2015 Author Share Posted March 27, 2015 And also, this is a warning about it: WARNING:[gameplay]\server\server.lua:5: Bad argument @ 'logIn' [Expected account at argument 2, got string 'admin'] Ill check it now Link to comment
WhoAmI Posted March 27, 2015 Share Posted March 27, 2015 WOW. DIDNT SEE THAT! Mate replace it with local loggin = logIn(source, account, password) Has to work now. Link to comment
maky55 Posted March 27, 2015 Author Share Posted March 27, 2015 It shows: admin:password 1 2 Link to comment
WhoAmI Posted March 27, 2015 Share Posted March 27, 2015 After changing this line too? local loggin = logIn(source, username, password) change it to local loggin = logIn(source, account, password) Link to comment
maky55 Posted March 27, 2015 Author Share Posted March 27, 2015 IT WORKKSSSSSSSSSSS!!!!!!!!!!!!!!!!!!!!!!!!!!! Omg dude thank you so much! You just saved me trying to write a new script. Link to comment
WhoAmI Posted March 27, 2015 Share Posted March 27, 2015 Didn't see at all in beginning. Good that you showed me this error. Have fun with scritpting! 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