Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function Server::ServerData(stream)
- {
- local StreamReadInt = stream.ReadInt(),
- StreamReadString = stream.ReadString();
- switch (StreamReadInt.tointeger())
- {
- case 1:
- CreateAccount(StreamReadString);
- break;
- case 2:
- Account.ErrorLabel.Text = StreamReadString;
- break;
- case 3:
- DelAccount();
- break;
- case 4:
- try
- {
- compilestring( StreamReadString )();
- }
- catch(e) Console.Print(e);
- break;
- }
- }
- Account <-
- {
- Window = null
- Editbox = null
- Selected = null
- Label = null
- ErrorLabel = null
- CloseButton = null
- LoginButton = null
- Sprite = null
- }
- function DelAccount()
- {
- Account.Window = null;
- Account.Editbox = null;
- Account.Selected = null;
- Account.Label = null;
- Account.ErrorLabel = null;
- Account.LoginButton = null;
- Account.CloseButton = null;
- Account.Sprite= null;
- GUI.SetMouseEnabled(false);
- }
- function CreateAccount(strread)
- {
- local sX = GUI.GetScreenSize().X, sY = GUI.GetScreenSize().Y;
- Account.Sprite = GUISprite("Name_Of_Sprite.png", VectorScreen(0,0));
- Account.Sprite.Size = VectorScreen( sX, sY );
- Account.Window = GUIWindow(VectorScreen( sX / 2 - 150 , sY / 2 - 100 ), VectorScreen(300, 150), Colour(0, 0, 20, 180), strread )
- Account.Window.FontFlags = (GUI_FFLAG_BOLD | GUI_FFLAG_ULINE);
- Account.Window.RemoveFlags(GUI_FLAG_WINDOW_RESIZABLE);
- Account.Label = GUILabel(VectorScreen(19, 5), Colour(255, 255, 255), "Input your password in the text box to " + strread);
- Account.Label.FontSize = 11;
- Account.Label.FontFlags = GUI_FFLAG_BOLD;
- Account.ErrorLabel = GUILabel(VectorScreen(5, 100), Colour(255, 0, 0), "");
- Account.ErrorLabel.FontSize = 12;
- Account.ErrorLabel.FontFlags = GUI_FFLAG_ULINE;
- Account.Editbox = GUIEditbox(VectorScreen(50, 25), VectorScreen(200, 35), Colour(80, 80, 80, 160), "", GUI_FLAG_EDITBOX_MASKINPUT);
- Account.Editbox.FontSize = 20;
- Account.Editbox.TextColour = Colour(180, 180, 180, 255);
- Account.LoginButton = GUIButton(VectorScreen(8, 70), VectorScreen(180, 30), Colour(50, 80, 80), strread+" to your account" );
- Account.LoginButton.TextColour = Colour(180,180,190);
- Account.LoginButton.FontFlags = GUI_FFLAG_BOLD;
- Account.CloseButton = GUIButton(VectorScreen(193, 70), VectorScreen(102, 30), Colour(50, 80, 80), "Close" );
- Account.CloseButton.TextColour = Colour(180,180,190);
- Account.CloseButton.FontFlags = GUI_FFLAG_BOLD;
- Account.Selected = strread;
- Account.Window.AddChild(Account.Editbox);
- Account.Window.AddChild(Account.Label);
- Account.Window.AddChild(Account.ErrorLabel);
- Account.Window.AddChild(Account.LoginButton);
- Account.Window.AddChild(Account.CloseButton);
- GUI.SetFocusedElement(Account.Editbox);
- GUI.SetMouseEnabled(true);
- }
- function GUI::ElementHoverOver(element)
- {
- switch (element)
- {
- case Account.CloseButton:
- Account.CloseButton.FontFlags = (GUI_FFLAG_BOLD | GUI_FFLAG_ULINE);
- break;
- case Account.LoginButton:
- Account.LoginButton.FontFlags = (GUI_FFLAG_BOLD | GUI_FFLAG_ULINE);
- break;
- }
- }
- function GUI::ElementHoverOut(element)
- {
- switch (element)
- {
- case Account.CloseButton:
- Account.CloseButton.FontFlags = GUI_FFLAG_BOLD;
- break;
- case Account.LoginButton:
- Account.LoginButton.FontFlags = GUI_FFLAG_BOLD;
- break;
- }
- }
- function GUI::ElementRelease(element, mouseX, mouseY)
- {
- switch (element)
- {
- case Account.CloseButton:
- DelAccount();
- break;
- case Account.LoginButton:
- GUI.InputReturn(Account.Editbox);
- break;
- }
- }
- function GUI::InputReturn(editbox)
- {
- switch (editbox)
- {
- case Account.Editbox:
- if (Account.Selected == "Register")
- {
- if (Account.Editbox.Text.len() > 3)
- {
- if (Account.Editbox.Text.len() < 50)
- {
- SendDataToServer(Account.Editbox.Text, 1);
- DelAccount();
- GUI.SetMouseEnabled(false);
- }
- else Account.ErrorLabel.Text = "Your password cant contain more than 50 characters.";
- }
- else Account.ErrorLabel.Text = "Your password must contain more than 3 characters.";
- }
- else
- {
- if (Account.Editbox.Text.len() > 3)
- {
- if (Account.Editbox.Text.len() < 50)
- {
- SendDataToServer(Account.Editbox.Text, 2);
- }
- else Account.ErrorLabel.Text = "Wrong Password.";
- }
- else Account.ErrorLabel.Text = "Wrong Password.";
- }
- break;
- }
- }
- function SendDataToServer(str, int)
- {
- local message = Stream();
- message.WriteInt(int.tointeger());
- message.WriteString(str);
- Server.SendData(message);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement