Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- SPRITE_LOGO <- null;
- // ===== Errors handler =====
- function errorHandling(err)
- {
- /* credits: ysc3839 */
- local stackInfos = getstackinfos(2);
- if (stackInfos)
- {
- local locals = "";
- foreach( index, value in stackInfos.locals )
- {
- if( index != "this" )
- locals = locals + "[" + index + "] " + value + "\n";
- }
- local callStacks = "";
- local level = 2;
- do {
- callStacks += "*FUNCTION [" + stackInfos.func + "()] " + stackInfos.src + " line [" + stackInfos.line + "]\n";
- level++;
- } while ((stackInfos = getstackinfos(level)));
- local errorMsg = "AN ERROR HAS OCCURRED [" + err + "]\n";
- errorMsg += "\nCALLSTACK\n";
- errorMsg += callStacks;
- errorMsg += "\nLOCALS\n";
- errorMsg += locals;
- Console.Print(errorMsg);
- }
- }
- seterrorhandler(errorHandling);
- // ===== Animated Announcement functions ======
- Timer <- {
- Timers = {}
- function Create(environment, listener, interval, repeat, ...)
- {
- // Prepare the arguments pack
- vargv.insert(0, environment);
- // Store timer information into a table
- local TimerInfo = {
- Environment = environment,
- Listener = listener,
- Interval = interval,
- Repeat = repeat,
- Args = vargv,
- LastCall = Script.GetTicks(),
- CallCount = 0
- };
- local hash = split(TimerInfo.tostring(), ":")[1].slice(3, -1).tointeger(16);
- // Store the timer information
- Timers.rawset(hash, TimerInfo);
- // Return the hash that identifies this timer
- return hash;
- }
- function Destroy(hash)
- {
- // See if the specified timer exists
- if (Timers.rawin(hash))
- {
- // Remove the timer information
- Timers.rawdelete(hash);
- }
- }
- function Exists(hash)
- {
- // See if the specified timer exists
- return Timers.rawin(hash);
- }
- function Fetch(hash)
- {
- // Return the timer information
- return Timers.rawget(hash);
- }
- function Clear()
- {
- // Clear existing timers
- Timers.clear();
- }
- function Process()
- {
- local CurrTime = Script.GetTicks();
- foreach (hash, tm in Timers)
- {
- if (tm != null)
- {
- if (CurrTime - tm.LastCall >= tm.Interval)
- {
- tm.CallCount++;
- tm.LastCall = CurrTime;
- tm.Listener.pacall(tm.Args);
- if (tm.Repeat != 0 && tm.CallCount >= tm.Repeat)
- Timers.rawdelete(hash);
- }
- }
- }
- }
- };
- ThreeD <-
- {
- text = null
- Label = null
- style = null
- R = null
- G = null
- B = null
- Timer = null
- }
- function VScreen( pos_x, pos_y )//Credits goes to Doom_Kill3R for this function
- {
- local
- screenSize = GUI.GetScreenSize( ),
- x = floor( pos_x * screenSize.X / 1920 ),
- y = floor( pos_y * screenSize.Y / 1080 );
- return VectorScreen( x, y );
- }
- function Server::ServerData( stream )
- {
- local StreamReadInt = stream.ReadInt( ),
- StreamReadString = stream.ReadString( );
- switch( StreamReadInt.tointeger( ) )
- {
- case 1:
- Create3DAnnouncement( StreamReadString );
- break;
- case 2:
- SPRITE_LOGO <- GUISprite( "onjoin.png", VectorScreen( 790, 620 ) );
- SPRITE_LOGO.Size = VectorScreen( 250, 144 );
- break;
- }
- }
- function Script::ScriptProcess( )
- {
- Timer.Process();
- }
- function Create3DAnnouncement( strread )
- {
- if ( ThreeD.Label ) Timer.Destroy( ThreeD.Timer );
- ThreeD.text = strread;
- ThreeD.style = rand()%10;
- ThreeD.R = rand()%255;
- ThreeD.G = rand()%255;
- ThreeD.B = rand()%255;
- ThreeD.Label = GUILabel( VScreen(800,500),Colour( ThreeD.R, ThreeD.G, ThreeD.B ), ThreeD.text );
- ThreeD.Label.TextAlignment = GUI_ALIGN_CENTER;
- ThreeD.Label.FontFlags = GUI_FFLAG_BOLD | GUI_FFLAG_OUTLINE;
- ThreeD.Label.FontSize = 18;
- ThreeD.Timer = Timer.Create( this, Update3DAnnouncement, 0.1, 128);
- }
- function Update3DAnnouncement( )
- {
- if ( ThreeD.Label )
- {
- switch( ThreeD.style )
- {
- case 1:
- ThreeD.Label.Pos.X -= 1;
- ThreeD.Label.Pos.Y -= 1;
- break;
- case 2:
- ThreeD.Label.Pos.X += 1;
- ThreeD.Label.Pos.Y += 1;
- break;
- case 3:
- ThreeD.Label.Pos.X -= 1;
- ThreeD.Label.Pos.Y += 1;
- break;
- case 4:
- ThreeD.Label.Pos.X += 1;
- ThreeD.Label.Pos.Y -= 1;
- break;
- case 5:
- ThreeD.Label.Pos.X -= 1;
- break;
- case 6:
- ThreeD.Label.Pos.Y -= 1;
- break;
- case 7:
- ThreeD.Label.Pos.X += 1;
- break;
- case 8:
- ThreeD.Label.Pos.Y += 1;
- break;
- default:
- ThreeD.Label.Pos.X -= 2;
- ThreeD.Label.Pos.Y += 1;
- break;
- }
- ThreeD.Label.Alpha -=2;
- if ( ThreeD.Label.Alpha < 2 )
- {
- Timer.Destroy( ThreeD.Timer );
- ThreeD.Label = null;
- }
- }
- }
Add Comment
Please, Sign In to add comment