Hallo Ich habe ein Register/Login Panel Gescriptet. Das Gui wird erstellt, aber wenn ich den Button zum Login Drück will funktioniert es nicht es passiert einfach nichts. In der Console komemn auch keine Errors vor.
Client:
Lua
addEventHandler("onClientResourceStart",resourceRoot,
function()
GUIEditor_Window = {}
GUIEditor_TabPanel = {}
GUIEditor_Tab = {}
GUIEditor_Button = {}
GUIEditor_Label = {}
GUIEditor_Edit = {}
GUIEditor_Image = {}
GUIEditor_Window1 = guiCreateWindow(552,345,249,326,"Login Panel by Denny",false)
GUIEditor_Image1 = guiCreateStaticImage(17,29,219,105,"data/header.PNG",false,GUIEditor_Window1)
GUIEditor_TabPanel1 = guiCreateTabPanel(18,153,216,127,false,GUIEditor_Window1)
GUIEditor_Tab1 = guiCreateTab("Login",GUIEditor_TabPanel1)
GUIEditor_Label1 = guiCreateLabel(15,63,90,21,"Passwort:",false,GUIEditor_Tab1)
GUIEditor_Label2 = guiCreateLabel(14,9,78,22,"Benutzer:",false,GUIEditor_Tab1)
GUIEditor_Edit1 = guiCreateEdit(71,8,137,25,"",false,GUIEditor_Tab1)
GUIEditor_Edit2 = guiCreateEdit(71,58,136,25,"",false,GUIEditor_Tab1)
GUIEditor_Tab2 = guiCreateTab("Register",GUIEditor_TabPanel1)
GUIEditor_Label3 = guiCreateLabel(12,10,72,18,"Benutzer:",false,GUIEditor_Tab2)
GUIEditor_Label4 = guiCreateLabel(8,38,79,20," Passwort:",false,GUIEditor_Tab2)
GUIEditor_Label5 = guiCreateLabel(12,65,80,21,"Werber:",false,GUIEditor_Tab2)
GUIEditor_Edit3 = guiCreateEdit(67,7,142,25,"",false,GUIEditor_Tab2)
GUIEditor_Edit4 = guiCreateEdit(66,37,144,25,"",false,GUIEditor_Tab2)
GUIEditor_Edit5 = guiCreateEdit(65,67,146,24,"",false,GUIEditor_Tab2)
GUIEditor_Button1 = guiCreateButton(18,288,217,29,"Enter",false,GUIEditor_Window1)
GUIEditor_Button2 = guiCreateButton(18,288,217,29,"Enter",false,GUIEditor_Window1)
end
)
guiSetVisible ( GUIEditor_Window1, false )
local localPlayer = getLocalPlayer ( )
function windowHandler( )
local playername = getPlayerName(localPlayer)
guiSetText(GUIEditor_Edit2, "")
guiSetText(GUIEditor_Edit1, "")
guiSetText(GUIEditor_Edit2, playername)
guiSetText(GUIEditor_Edit1, playername)
guiSetVisible (GUIEditor_Window1, true )
guiSetInputEnabled(true)
showCursor ( true )
end
function onClickBtn ( button, state )
if (source == GUIEditor_Button1) then
triggerServerEvent ( "onLogin", getRootElement(), localPlayer, guiGetText(GUIEditor_Edit2), guiGetText(GUIEditor_Edit1) )
end
end
function onClickBtn2 ( button, state )
if (source == GUIEditor_Button2) then
triggerServerEvent ( "onRegister", getRootElement(), localPlayer, guiGetText(GUIEditor_Edit3), guiGetText(GUIEditor_Edit4))
end
end
function hideLoginWindow()
guiSetInputEnabled(false)
guiSetVisible (GUIEditor_Window1, false )
showCursor ( false )
end
addEvent( "hideLoginWindow", true )
addEventHandler( "hideLoginWindow", getRootElement(), hideLoginWindow )
addEventHandler("onClientResourceStart", getResourceRootElement(getThisResource()), windowHandler )
addEventHandler ( "onClientGUIClick", GUIEditor_Button1, onClickBtn, false )
addEventHandler ( "onClientGUIClick", GUIEditor_Button2, onClickBtn2, false )
Alles anzeigen
Server:
Lua
function onLogin ( player, user, pass )
local account = getAccount ( user, pass )
if ( account ~= false ) then
if (logIn ( player, account, pass ) == true) then
triggerClientEvent ( "hideLoginWindow", getRootElement())
else
outputChatBox ( "Login error!", player, 255, 255, 0 ) -- Output they got the details wrong.
end
else
outputChatBox ( "Falscher Username oder Passwort!", player, 255, 255, 0 ) -- Output they got the details wrong.
end
end
addEvent( "onLogin", true )
addEventHandler( "onLogin", getRootElement(), onLogin )
function onRegister ( player, user, pass )
local account = getAccount ( user, pass )
if ( account ~= false ) then
if (logIn ( player, account, pass ) == true) then
triggerClientEvent ( "hideLoginWindow", getRootElement())
else
outputChatBox ( "Login error!", player, 255, 255, 0 ) -- Output they got the details wrong.
end
else
account = addAccount ( user, pass )
if (logIn ( player, account, pass ) == true) then
triggerClientEvent ( "hideLoginWindow", getRootElement())
else
outputChatBox ( "Register/Login error!", player, 255, 255, 0 ) -- Output they got the details wrong.
end
end
end
addEvent( "onRegister", true )
addEventHandler( "onRegister", getRootElement(), onRegister )
Alles anzeigen
MFG. Mister_Denny