Razo Posted May 5, 2017 Share Posted May 5, 2017 (edited) Hi. I've just started learning scripting, and most of the time, I used the Wiki's introduction topics. I tried to create a simple login panel, following the tutorial, but it doesn't appear. I tried to change a few things, maybe I just made it worse, I don't know. Please don't be rude, I'm not used to this lang. I played and scripted SAMP before, for like, 5 years, so it's still a bit confusing to me. I don't know how the things work perfectly, but I followed the tutorial, and it's still not okay. If anyone has a solution, please help. Here are all the codes: meta.xml: <meta> <info author="Razo" type="script" name="LoginSys" version="1.0" /> <script src="gui.lua" type="client" /> <script src="sside.lua" type="server" /> </meta> gui.lua: function createLoginGUI() local X = 0.3 local Y = 0.3 local Width = 0.25 local Height = 0.25 wdwLogin = guiCreateWindow(X, Y, Width, Height, "Bejelentkezés", true) X = 0.0825 Y = 0.2 Width = 0.25 Height = 0.25 guiCreateLabel(X,Y,Width,Height,"Felhasználó",true,wdwLogin) Y = 0.5 guiCreateLabel(X,Y,Width,Height,"Jelszó",true,wdwLogin) X = 0.415 Y = 0.2 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, 50) guiEditSetMaxLength(edtPass, 50) X = 0.415 Y = 0.7 Width = 0.25 Height = 0.2 btnLogin = guiCreateButton(X, Y, Width, Height, "Bejelentkezés", true, wdwLogin) guiSetVisible(wdwLogin, true) addEventHandler("onClientGUIClick",btnLogin,clientSubmitLogin,false) end 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("Írj be egy felhasználónevet és egy jelszót...") end end end function startRes() createLoginGUI() if(wdwLogin ~= nil) then guiSetVisible(wdwLogin,true) else outputChatBox("Hiba történt, a GUI-t nem sikerült megjeleníteni.") end showCursor(true) guiSetInputEnabled(true) end addEventHandler("onClientResourceStart",getRootElement(),startRes) sside.lua: local spawnX, spawnY, spawnZ = 1959.55, -1714.46, 20 function loginHandler(username,password) if username == "asd" and password == "asd" then if(client) then spawnPlayer(client,spawnX,spawnY,spawnZ) fadeCamera(client,true) setCameraTarget(client,client) --outputChatBox("Previon, Landstalker, Uranus, Alpha",client) --the list of the modded vehicles, just for fun else outputChatBox("Hibás felh. és/vagy jelszó.",client) --basically an error msg end end end addEvent("submitLogin",true) addEventHandler("submitLogin",root,loginHandler) Edited May 5, 2017 by Razo Link to comment
pa3ck Posted May 5, 2017 Share Posted May 5, 2017 The best way to debug your code is to make yourself admin on your server and use "/debugscript 3", that most of the times tell you what's wrong. Try it yourself and see if that helps you. If you don't know how to make yourself admin, just search for an "acl admin" tutorial. Link to comment
Razo Posted May 5, 2017 Author Share Posted May 5, 2017 Thanks man I've figured out the problem right after debugging. In the gui.lua, line 34 and 35, I unintentionally used == instead of =. I probably didn't pay enough attention. Link to comment
pa3ck Posted May 5, 2017 Share Posted May 5, 2017 No worries, it's always better if you spot small mistakes like that yourself using the built-in debug tools, but if you really can't, you can always come to the forums. 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