Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local LogonDialog
- addEvent("onClientPlayerLogon", true)
- addEvent("onClientPlayerAuthorized" )
- local function onClientPlayerLogon(errorCode, id)
- if LogonDialog then
- if errorCode == 0 then
- LogonDialog:delete()
- LogonDialog = nil
- triggerEvent( "onClientPlayerAuthorized", localPlayer, id )
- elseif errorCode == 1 then
- LogonDialog.elements.message = "Не правильное имя или пароль" --"Invalid name or password"
- elseif errorCode == 2 then
- LogonDialog.elements.message = "Ошибка при регистрации, попробуйте другое имя" --"Registration error, try oher name"--
- end
- end
- end
- addEventHandler ("onClientPlayerLogon", localPlayer, onClientPlayerLogon)
- addEvent("onPlayerLogon", true)
- local function OnClientResourceStart()
- LogonDialog = Dialog:new({{ "window", acquireControls = true,
- x = 0, y = 0, width = -0.6, height = -0.3, anchor = "cm", text = "Logon",
- style = { style = "secondary", closable = false, sizable = false, movable = false, alfa = 1 },
- {
- { "label", x = 0.05, y = 0.00, width = 0.9, height = 0.14, text = "Username:", style = { valign = "m" } },
- username = { "edit", x = 0.05, y = 0.15, width = 0.9, height = 0.14, text = "" },
- { "label", x = 0.05, y = 0.30, width = 0.9, height = 0.14, text = "Password:", style = { valign = "m" } },
- password = { "edit", x = 0.05, y = 0.45, width = 0.9, height = 0.14, text = "", masked = true },
- message = { "label", x = 0.05, y = 0.60, width = 0.9, height = 0.14, text = "", style = { valign = "m" } },
- logon = { "button", x = -0.05, y = -0.05, width = 0.25, height = 0.14, anchor = "rb", text = "Logon",
- onClick = function(dialog,template,button,state)
- if button == "left" and state == "down" then
- local username = dialog.elements.username
- local password = dialog.elements.password
- dialog.elements.message = ""
- triggerServerEvent( "onPlayerLogon", localPlayer, username, password )
- end
- end
- },
- registration = { "button", x = 0.05, y = -0.05, width = 0.25, height = 0.14, anchor = "lb", text = "Registration",
- onClick = function(dialog,template,button,state)
- if button == "left" and state == "down" then
- local username = dialog.elements.username
- local password = dialog.elements.password
- dialog.elements.message = ""
- triggerServerEvent( "onPlayerLogon", localPlayer, username, password, true )
- end
- end
- }
- }
- }})
- end
- addEventHandler ("onClientResourceStart", resourceRoot, OnClientResourceStart)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement