-
Posts
24 -
Joined
-
Last visited
Everything posted by Abbas_gamer100
-
It didn't work either. I don't know what's wrong.
-
function createLoginGui () wdwLogin = guiCreateWindow(529, 206, 488, "Login Panel", false) guiWindowSetMovable (wdwLogin, false) guiWindowSetSizable (wdwLogin, false) guiSetAlpha (wdwLogin, 1.00) guiSetProperty (wdwLogin, "CaptionColour", "FFFEFEFE") lblMainLogin = guiCreateLabel (7, 14, 293, 48, "Testing server", true, wdwLogin) guiSetFont (lblMainLogin, "clear-normal") guiLabelSetColor(lblMainLogin, "center", true) guiLabelSetHorizontalAlign (lblMainLogin, "center", true) guiLabelSetVerticalAlign (lblMainLogin, "center", true) guiLabelSetVerticalAlign (lblMainLogin, "center") lblUsernameLogin = guiCreateLabel (11, 77, 124, 24, "Username", true, wdwLogin) edtUsernameLogin = guiCreateEdit (11, 106, 279, 34, "", true, wdwLogin) lblPasswordLogin = guiCreateLabel (16, 147, 128, 24, "Password", true, wdwLogin) edtPasswordLogin = guicreateEdit (11, 171, 279, 34, "", true, wdwLogin) btnLogin = guiCreateButton (10, 308, 114, 34, "Register", true, wdwLogin) guiSetVisible (wdwLogin, false) end addEventHandler ("onClientResourceStart", getRootElement(), function () createLoginGui () outputChatbox ("Welcome to the testing server") if (wdwLogin == nil) then guiSetVisible (wdwLogin, true) else outputChatbox ("Failed to create login panel") end showCursor (true) guiSetInputEnabled (true) end ) I need help concerning my login panel. I scripted it right and according to the MTA website tutorial. But when I join the server it the login panel doesn't show up, and I am left with black screen. The code is up there, something wrong with it? Here's how it's defined in meta.xml: <meta> <info author="Someguy" type="gamemode" name="Testing server" description="A server for testing scripts" /> <script src="client/login_gui.lua" type="client" /> </meta>
-
I placed the code in a clientside file. And identified it as client in meta.xml. But I still get the error message. Error: attempt to call local getAccount (a nil value)
-
Проблема заключается в том: Я начинающий. Так, я следую за учебники на вики.
-
How to make it Client side?
-
Error message: Error: attempt to call getAccount(a nil value)
-
It shows up my password and my account name. I will try the method you posted about logIn
-
It worked. But the GUI isn't logging me on still. It shows the error message I've set when the GUI couldn't log me in(the original problem). What is the solution for this? Or should I use logIn? If yes tell me how and how to connect it to the GUI.
-
I think we are almost there. After placing the code you've given me. I had this error message: Error: attempt to concatenate local 'password' (a nil value)
-
Alright. Everyting is okay now. I know where exactly the error is. Exactly this time. It's in loginHandler. The GUI runs okay. But it is having a problem loggin me in. The original problem I posted this thread to solve. This is where the script has the error (where the debug strings showed me that it didn't work): loginHandler: function loginHandler(player, username, password) outputDebugString("loginHandler has been called")--This string showed if username == "user" and password == "apple" then outputDebugString("Checking username and password is being executed!")--But this didn't if (isElement(player)) then spawnPlayer(client, 1959.55, -1714.46, 10) fadeCamera(client, true) setCameraTarget(client, client) outputChatBox("Welcome to My Server", client) outputDebugString("Player spawned after logging in!")--And this didn't also. end else outputChatBox("An unexpected error has occured!")--This showed in the server's chat box outputDebugString("Player didn't spawn after he logged in!")--And this showed up. Meaning the GUI runs just fine. But it has a problem logging me in!! end end addEvent("submitLogin", true) addEventHandler("submitLogin", resourceRoot, loginHandler)
-
Done. I detected the problem. The GUI panel is working. But it's button functions are not. And they said after executing the working debug strings: attempt to call outputDebugString < a nil value> Here's the code: function clientSubmitLogin(button, state) outputDebugString("The clientSubmitLogin function has been called!") if button == "left" and state == "up" then outputDebugString("Player has called the button function!") local username = guiGetText(Edit1) local password = guiGetText(Edit2) if username and password then --All previous debug strings has been called. And the following debug strings didn't outputDebugscript("Player has logged in!") triggerServerEvent("submitLogin", getRootElement(), username, password) guiSetInputEnabled(false) guiSetVisible(LoginPanel, false) showCursor(false) else outputChatBox("Please enter a valid username and password.") outputDebugString("The function ran through an error while executing!") end end end loginHandler script : --The following debu strings didn't show up too. function loginHandler(player, username, password) outputDebugString("loginHandler has been called") if username == "user" and password == "apple" then outputDebugString("Checking username and password is being executed!") if (isElement(player)) then spawnPlayer(client, 1959.55, -1714.46, 10) fadeCamera(client, true) setCameraTarget(client, client) outputChatBox("Welcome to My Server", client) outputDebugString("Player spawned after logging in!") end else outputChatBox("An unexpected error has occured!") outputDebugString("Player didn't spawn after he logged in!") end end addEvent("submitLogin", true) addEventHandler("submitLogin", resourceRoot, loginHandler)
-
Alright I will try. And I will report in.
-
Update: I kept trying, and I noticed the Console says username and password do not match. But my account exists and the proof is that I used my admin account to restart the script.
-
I didn't understand fully. The thing is. I am a beginner. And I try to make scripts following the MTA tutorials.. And I end up with many bugs and problems. Especially with GUIs I used your modified script. Now the error message doesn't show up but it doesn't log me in either.
-
Sure. Here it is: addEventHandler("onClientResourceStart", getResourceRootElement(), function() LoginPanel = guiCreateWindow(299, 101, 362, 521, "Login Panel", false) guiWindowSetMovable(LoginPanel, false) guiWindowSetSizable(LoginPanel, false) Image = guiCreateStaticImage(13, 37, 339, 130, ":admin/client/images/flags/ru.png", false, LoginPanel) Label1 = guiCreateLabel(20, 233, 67, 39, "Username", false, LoginPanel) Edit1 = guiCreateEdit(77, 228, 200, 24, "", false, LoginPanel) Edit2 = guiCreateEdit(77, 267, 200, 24, "", false, LoginPanel) Label2 = guiCreateLabel(20, 267, 67, 39, "Password", false, LoginPanel) Button1 = guiCreateButton(20, 334, 104, 40, "Login", false, LoginPanel) addEventHandler("onClientGUIClick", Button1, clientSubmitLogin, false) outputChatBox("Welcome to my Server!") if (LoginPanel ~= nil) then guiSetVisible(LoginPanel, true) else outputChatBox("An unexpected error has occured! Please re-connect and try again.") end showCursor(true) guiSetInputEnabled(true) end ) function clientSubmitLogin(button, state) if button == "left" and state == "up" then local username = guiGetText(Edit1) local password = guiGetText(Edit2) if username and password then triggerServerEvent("submitLogin", resourceRoot, player, username, password) guiSetInputEnabled(false) guiSetVisible(LoginPanel, false) showCursor(false) else outputChatBox("Please enter a valid username and password.") end end end loginHandler: function loginHandler(player, username, password) outputDebugString("loginHandler has been called") if username == "user" and password == "apple" then outputDebugString("Username and password do not match.") if (not client and isElement(player)) or client == player then spawnPlayer(client, 1959.55, -1714.46, 10) fadeCamera(client, true) setCameraTarget(client, client) outputChatBox("Welcome to My Server", client) outputDebugString("I am an idiot!") end else outputChatBox("An unexpected error has occured!") end end addEvent("submitLogin", true) addEventHandler("submitLogin", resourceRoot, loginHandler)
-
The debugger only says joinHandler has been called. And one more problem occured now. Before when I don't type anything or when I use an account that isn't registered it says please type a valid username and password as I have set it. But now even if I don't write anything it acts as if I written an account and closes the panel and shows the error message.
-
I've made a Login GUI. The GUI works properly. But it doesn't detect my account. And it says unexpected error has occured which is the message I have set to show when the panel couldn't log me in. The code: addEventHandler("onClientResourceStart", getResourceRootElement(), function() LoginPanel = guiCreateWindow(299, 101, 362, 521, "Login Panel", false) guiWindowSetMovable(LoginPanel, false) guiWindowSetSizable(LoginPanel, false) Image = guiCreateStaticImage(13, 37, 339, 130, ":admin/client/images/flags/ru.png", false, LoginPanel) Label1 = guiCreateLabel(20, 233, 67, 39, "Username", false, LoginPanel) Edit1 = guiCreateEdit(77, 228, 200, 24, "", false, LoginPanel) Edit2 = guiCreateEdit(77, 267, 200, 24, "", false, LoginPanel) Label2 = guiCreateLabel(20, 267, 67, 39, "Password", false, LoginPanel) Button1 = guiCreateButton(20, 334, 104, 40, "Login", false, LoginPanel) addEventHandler("onClientGUIClick", Button1, clientSubmitLogin, false) outputChatBox("Welcome to my Server!") if (LoginPanel ~= nil) then guiSetVisible(LoginPanel, true) else outputChatBox("An unexpected error has occured! Please re-connect and try again.") end showCursor(true) guiSetInputEnabled(true) end ) function clientSubmitLogin(button, state) if button == "left" and state == "up" then local username = guiGetText(Edit1) local password = guiGetText(Edit2) if username and password then triggerServerEvent("submitLogin", getRootElement(), username, password) guiSetInputEnabled(false) guiSetVisible(LoginPanel, false) showCursor(false) else outputChatBox("Please enter a valid username and password.") end end end Server Client's file code : function loginHandler(username, password) if username == "user" and password == "apple" then if (client) then spawnPlayer(client, 1959.55, -1714.46, 10) fadeCamera(client, true) setCameraTarget(client, client) outputChatBox("Welcome to My Server", client) outputDebugString("I am an idiot!") end else outputChatBox("An unexpected error has occured!") end end addEvent("submitLogin", true) addEventHandler("submitLogin", root, loginHandler)
-
So what is the bug currently. And how to solve it?
-
It says attempt to call guiSetVisible <a nil value>... I think I made some changed to the script and they are the reason. Here is the script: function createSpawningPanel() SpawnWindow = guiCreateWindow(319, 196, 408, 277, "Base Spawning Panel", false) guiWindowSetMovable(SpawnWindow, false) guiWindowSetSizable(SpawnWindow, false) guiSetVisible(SpawnWindow,false) Button[1] = guiCreateButton(17, 38, 376, 73, "Go to the base", false, SpawnWindow) addEventHandler("onClientGUIClick", Button[1], teleportPlayer, false) Button[2] = guiCreateButton(14, 161, 379, 71, "Kill yourself", false, SpawnWindow) addEventHandler("onClientGUIClick", Button[2], teleportPlayer, false) outputDebugString( "CreateSpawningPanel called and completed!" ) end addEventHandler("onClientResourceStart", resourceRoot, function () createSpawningPanel() end ) function openSpawnWindow() guiSetVisible( SpawnWindow, true ) showCursor( true, true ) outputDebugString( "opened window! [i feel useless]" ) end addCommandHandler( "teleportme", openSpawnWindow ) function teleportPlayer(button,state) if button == "left" and state == "up" then outputDebugString( "Executing teleportPlayer" ) if source == Button[1] then triggerServerEvent( "movePlayerToPosition", localPlayer, 1479.6,-1612.8,14.0,0 ) outputDebugString( "Button 1 pressed" ) elseif source == Button[2] then killPed(sourcePlayer,sourcePlayer) outputDebugString( "Button 2 pressed" ) end guiSetVisible(SpawnWindow,false) showCursor(false) outputDebugString( "teleportPlayer executed!" ) end end
-
YES FINALLY THANK YOU A LOT!! The GUI has showed up. But it is bugged a lot. It only shows the "Go to the base button". And it doesn't work(not teleporting on pressing the button).
-
It still doesn't work. And when I type the command it doesn't show/say anything... I don't know what's the problem And debugscript 3 doesn't work at all. It says incorrect client type in the Console.
-
I am pretty certain for some reason that the problem is in my meta.xml file. Here is my meta.xml file. Maybe I didn't define the script correctly?? The script file's name is Spawn_Panel.lua <meta> <info author="YourName" type="gamemode" name="My Server" description="My first MTA server" /> <script src="script.lua" type="server"/> <scipt src="Spawn_Panel.lua" type="server"/> </meta>
-
It didn't work. My problem in full description is. I type the command but the GUI never shows up(in the server). I watch out for the command's spelling, nothing! I try and type it in the Console and other places, still not working. The GUI doesn't show up when I call the command in the server.
-
I have created a GUI. It is supposed to either spawn you at a base (a base that I created and mapped) and/or kills you. It is supposed to be activated by a command. But it didn't work. Can you look at my script and tell me what have I done wrong? And if you know how to bind the GUI to a specific button please tell me how because I tried all methods. function createSpawningPanel() SpawnWindow = guiCreateWindow(319, 196, 408, 277, "Base Spawning Panel", false) guiWindowSetMovable(SpawnWindow, false) guiWindowSetSizable(SpawnWindow, false) Button[1] = guiCreateButton(17, 38, 376, 73, "Go to the base", false, SpawnWindow) Button[2] = guiCreateButton(14, 161, 379, 71, "Kill yourself", false, SpawnWindow) guiSetVisible(SpawnWindow,false) end addEventHandler("onClientGUIClick", Button[1], teleportPlayer, false) addEventHandler("onClientGUIClick", Button[2], teleportPlayer, false) addEventHandler("onClientResourceStart", getResourceRootElement(getThisResource()), function () createSpawningPanel() end ) function openSpawnWindow() guiSetVisible(SpawnWindow,true) showCursor(true,true) end addCommandHandler("teleportme",openSpawnWindow) function teleportPlayer(button,state) if button == "left" and state == "up" then if source == Button[1] then triggerServerEvent("movePlayerToPosition",getLocalPlayer(),1479.6,-1612.8,14.0,0) elseif source == Button[2] then killPed(sourcePlayer,sourcePlayer) end guiSetVisible(SpawnWindow,false) showCursor(false) end end
