so i am using mta wiki to learn scripting , recently i tried to script login window from the "Introduction to Scripting the GUI" tutorial but it is not working idk why
gui.Lua
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
Y = 0.2
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.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, "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.")
end
showCursor(true)
guiSetInputEnabled(true)
end
)
function createLoginWindow()
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("Please enter a username and password.")
end
end
end
function loginHandler(username,password)
if username =="user" and password =="apple" then
if (client) then
spawnPlayer(client, 1959.55, -1714.46 , 16)
fadeCamera(client, true)
setCameraTarget(client, client)
outputChatBox("Welcome to My Server.", client)
end
else
outputChatBox("invalid username and password. Please re-connect and try again.",client)
end
end
addEvent("submitLogin",true)
addEventHandler("submitLogin",root,loginHandler)
meta.xml
<meta>
<info author="Ghost_447" version="1.0.0" name="LoginPanel" />
<script src="client/gui.Lua" type="client" />
</meta>
can someone help me and tell me what is the problem with it
thanks