MuhammadZeeshan

ggggggggggggg

Jun 5th, 2017
35
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.54 KB | None | 0 0
  1. SPRITE_LOGO <- null;
  2.  
  3.  
  4. // ===== Errors handler =====
  5. function errorHandling(err)
  6. {
  7. /* credits: ysc3839 */
  8. local stackInfos = getstackinfos(2);
  9.  
  10. if (stackInfos)
  11. {
  12. local locals = "";
  13.  
  14. foreach( index, value in stackInfos.locals )
  15. {
  16. if( index != "this" )
  17. locals = locals + "[" + index + "] " + value + "\n";
  18. }
  19.  
  20. local callStacks = "";
  21. local level = 2;
  22. do {
  23. callStacks += "*FUNCTION [" + stackInfos.func + "()] " + stackInfos.src + " line [" + stackInfos.line + "]\n";
  24. level++;
  25. } while ((stackInfos = getstackinfos(level)));
  26.  
  27. local errorMsg = "AN ERROR HAS OCCURRED [" + err + "]\n";
  28. errorMsg += "\nCALLSTACK\n";
  29. errorMsg += callStacks;
  30. errorMsg += "\nLOCALS\n";
  31. errorMsg += locals;
  32.  
  33. Console.Print(errorMsg);
  34. }
  35. }
  36. seterrorhandler(errorHandling);
  37.  
  38. // ===== Animated Announcement functions ======
  39. Timer <- {
  40. Timers = {}
  41.  
  42. function Create(environment, listener, interval, repeat, ...)
  43. {
  44. // Prepare the arguments pack
  45. vargv.insert(0, environment);
  46.  
  47. // Store timer information into a table
  48. local TimerInfo = {
  49. Environment = environment,
  50. Listener = listener,
  51. Interval = interval,
  52. Repeat = repeat,
  53. Args = vargv,
  54. LastCall = Script.GetTicks(),
  55. CallCount = 0
  56. };
  57.  
  58. local hash = split(TimerInfo.tostring(), ":")[1].slice(3, -1).tointeger(16);
  59.  
  60. // Store the timer information
  61. Timers.rawset(hash, TimerInfo);
  62.  
  63. // Return the hash that identifies this timer
  64. return hash;
  65. }
  66.  
  67. function Destroy(hash)
  68. {
  69. // See if the specified timer exists
  70. if (Timers.rawin(hash))
  71. {
  72. // Remove the timer information
  73. Timers.rawdelete(hash);
  74. }
  75. }
  76.  
  77. function Exists(hash)
  78. {
  79. // See if the specified timer exists
  80. return Timers.rawin(hash);
  81. }
  82.  
  83. function Fetch(hash)
  84. {
  85. // Return the timer information
  86. return Timers.rawget(hash);
  87. }
  88.  
  89. function Clear()
  90. {
  91. // Clear existing timers
  92. Timers.clear();
  93. }
  94.  
  95. function Process()
  96. {
  97. local CurrTime = Script.GetTicks();
  98. foreach (hash, tm in Timers)
  99. {
  100. if (tm != null)
  101. {
  102. if (CurrTime - tm.LastCall >= tm.Interval)
  103. {
  104. tm.CallCount++;
  105. tm.LastCall = CurrTime;
  106.  
  107. tm.Listener.pacall(tm.Args);
  108.  
  109. if (tm.Repeat != 0 && tm.CallCount >= tm.Repeat)
  110. Timers.rawdelete(hash);
  111. }
  112. }
  113. }
  114. }
  115. };
  116.  
  117. ThreeD <-
  118. {
  119. text = null
  120. Label = null
  121. style = null
  122. R = null
  123. G = null
  124. B = null
  125. Timer = null
  126. }
  127.  
  128. function VScreen( pos_x, pos_y )//Credits goes to Doom_Kill3R for this function
  129. {
  130. local
  131. screenSize = GUI.GetScreenSize( ),
  132. x = floor( pos_x * screenSize.X / 1920 ),
  133. y = floor( pos_y * screenSize.Y / 1080 );
  134.  
  135. return VectorScreen( x, y );
  136. }
  137.  
  138. function Server::ServerData( stream )
  139. {
  140. local StreamReadInt = stream.ReadInt( ),
  141. StreamReadString = stream.ReadString( );
  142. switch( StreamReadInt.tointeger( ) )
  143. {
  144. case 1:
  145. Create3DAnnouncement( StreamReadString );
  146. break;
  147.  
  148. case 5:
  149. SPRITE_LOGO <- GUISprite( "onjoin.png", VectorScreen( 100, 0 ) );
  150. SPRITE_LOGO.Size = VectorScreen( 250, 144 );
  151. Console.Print("called");
  152. break;
  153. }
  154. }
  155.  
  156. function Script::ScriptProcess( )
  157. {
  158. Timer.Process();
  159. }
  160.  
  161. function Create3DAnnouncement( strread )
  162. {
  163. if ( ThreeD.Label ) Timer.Destroy( ThreeD.Timer );
  164.  
  165. ThreeD.text = strread;
  166. ThreeD.style = rand()%10;
  167.  
  168. ThreeD.R = rand()%255;
  169. ThreeD.G = rand()%255;
  170. ThreeD.B = rand()%255;
  171.  
  172. ThreeD.Label = GUILabel( VScreen(800,500),Colour( ThreeD.R, ThreeD.G, ThreeD.B ), ThreeD.text );
  173. ThreeD.Label.TextAlignment = GUI_ALIGN_CENTER;
  174. ThreeD.Label.FontFlags = GUI_FFLAG_BOLD | GUI_FFLAG_OUTLINE;
  175. ThreeD.Label.FontSize = 18;
  176.  
  177. ThreeD.Timer = Timer.Create( this, Update3DAnnouncement, 0.1, 128);
  178. }
  179.  
  180. function Update3DAnnouncement( )
  181. {
  182. if ( ThreeD.Label )
  183. {
  184. switch( ThreeD.style )
  185. {
  186. case 1:
  187. ThreeD.Label.Pos.X -= 1;
  188. ThreeD.Label.Pos.Y -= 1;
  189. break;
  190. case 2:
  191. ThreeD.Label.Pos.X += 1;
  192. ThreeD.Label.Pos.Y += 1;
  193. break;
  194. case 3:
  195. ThreeD.Label.Pos.X -= 1;
  196. ThreeD.Label.Pos.Y += 1;
  197. break;
  198. case 4:
  199. ThreeD.Label.Pos.X += 1;
  200. ThreeD.Label.Pos.Y -= 1;
  201. break;
  202. case 5:
  203. ThreeD.Label.Pos.X -= 1;
  204. break;
  205. case 6:
  206. ThreeD.Label.Pos.Y -= 1;
  207. break;
  208. case 7:
  209. ThreeD.Label.Pos.X += 1;
  210. break;
  211. case 8:
  212. ThreeD.Label.Pos.Y += 1;
  213. break;
  214. default:
  215. ThreeD.Label.Pos.X -= 2;
  216. ThreeD.Label.Pos.Y += 1;
  217. break;
  218. }
  219. ThreeD.Label.Alpha -=2;
  220. if ( ThreeD.Label.Alpha < 2 )
  221. {
  222. Timer.Destroy( ThreeD.Timer );
  223. ThreeD.Label = null;
  224. }
  225. }
  226. }
Add Comment
Please, Sign In to add comment