MuhammadZeeshan

asdasddadsd

Nov 11th, 2017
34
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.31 KB | None | 0 0
  1. /*============================================= The Usefull Server inbuilt Functions=========================================
  2. *
  3. *This script is created by Zeeshan.Bhatti :)
  4. *
  5. */
  6.  
  7. /*===========================================================================================================================
  8.  
  9.  
  10.  
  11.  
  12. class PlayerStats
  13. {
  14.  
  15. LastIPUsed = 0.0.0.0;
  16. Registered = false;
  17. Logged = false;
  18. Deaths = 0;
  19. Kills = 0;
  20. Joins = 0;
  21. Level = 0;
  22. Cash = 0;
  23. Bank = 0;
  24. LoginAttempt = 0;
  25. }
  26.  
  27.  
  28. //======================= IRC CONSTANTS ====================================================================================
  29. const ICOL_WHITE = "\x000300";
  30. const ICOL_BLACK = "\x000301";
  31. const ICOL_BLUE = "\x000302";
  32. const RED = "[#FF0000]";
  33. const PINK = "[#FF1493]";
  34. const ORANGE = "[#FF8C00]";
  35. const YELLOW = "[#FFFF81]";
  36. const PURPLE = "[#9400D3]";
  37. const GREEN = "[#008000]";
  38. const LBLUE = "[#1E90FF]";
  39. const BLUE = "[#4682B4]";
  40. const BROWN = "[#8B4513]";
  41. const WHITE = "[#FFFFFF]";
  42. const BLACK = "[#000000]";
  43. const GREY = "[#808080]";
  44. const LOWRED = "[#ed4242]";
  45. const LOWGREEN = "[#e9e9e9]";
  46. const ICOL_GREEN = "\x000303";
  47. const ICOL_RED = "\x000304";
  48. const ICOL_BROWN = "\x000305";
  49. const ICOL_PURPLE = "\x000306";
  50. const ICOL_ORANGE = "\x000307";
  51. const ICOL_YELLOW = "\x000308";
  52. const ICOL_LGREEN = "\x000309";
  53. const ICOL_CYAN = "\x000310";
  54. const ICOL_LCYAN = "\x000311";
  55. const ICOL_LBLUE = "\x000312";
  56. const ICOL_PINK = "\x000313";
  57. const ICOL_GREY = "\x000314";
  58. const ICOL_LGREY = "\x000315";
  59. const ICOL = "\x0003";
  60. const ICOL_BOLD = "\x0002";
  61. const ICOL_ULINE = "\x0031";
  62. //=========================== CONSTANTS ====================================================================================
  63.  
  64.  
  65.  
  66. const Author = "Zeeshan.Bhatti";
  67. const Mode = "UF";
  68. const Version = "version 1.0";
  69. const Credits = "Zeeshan.Bhatti";
  70. const Helper = "Decent_946";
  71. const SERVER = "[UF] Unique Force Server";
  72. const Forum = "uf-clan.vc-mp.net";
  73. const IP = "Comming soon";
  74. const IRC = "Comming soon";
  75.  
  76.  
  77. //===========================================================================================================================
  78.  
  79.  
  80.  
  81. function onScriptLoad()
  82. {
  83.  
  84. //==== prints server info ==============================
  85. print( "=======================================================" );
  86. print( "= [UF] Unique Force Server scripted by Zeeshan.Bhatti =" );
  87. print( "=======================================================" );
  88.  
  89. //==== needed to connect to the database file===========
  90.  
  91. db <- ConnectSQL( "files/Database.db" );
  92. print( "[LOADED] SQL database succesfully" );
  93.  
  94. //==== needed to load the other server files.===========
  95.  
  96. dofile( "script/functions.nut" );
  97. dofile( "script/cmds.nut" );
  98. dofile( "script/Accounts.nut" );
  99.  
  100. //==== needed to load and create the tables.============
  101. CreateTables();
  102.  
  103. //==== lets create some arrays to load the functions.===
  104. status <- array(GetMaxPlayers(), null );
  105.  
  106. //==== auto mute arrays =============
  107. IsMuted <- array( GetMaxPlayers(), false);
  108. antiSpamTime <- array( GetMaxPlayers(), 0 );
  109. antiSpamWarnings <- array( GetMaxPlayers(), 0 );
  110.  
  111.  
  112. }
  113.  
  114. function onScriptUnload()
  115. {
  116. //====saves players stats.=========
  117.  
  118. for ( local i = 0; i < GetMaxPlayers(); i++ )
  119. {
  120. local player = FindPlayer( i );
  121. if( player )
  122. {
  123. SaveStatus( player );
  124. }
  125. }
  126.  
  127. //===Disconnects the database.===== ( always disconnect database in last )
  128. DisconnectSQL( db );
  129. print( "Disconnected SQL Database" );
  130. }
  131.  
  132.  
  133. function onPlayerJoin( player )
  134. {
  135. try
  136. {
  137. //===loads the player info.========
  138.  
  139. status[ player.ID ] = PlayerStats();
  140. playerinfo( player );
  141.  
  142. catch(e) print( "PlayerJoin Function Error: " + e );
  143. }
  144.  
  145. }
  146.  
  147.  
  148. function onPlayerRequestClass( player, classID, team, skin )
  149. {
  150. try
  151. {
  152. Announce( "~0~ -"+GetPlayerTeamName( team )+"- ", player, 2 );
  153. return 1;
  154.  
  155. catch(e) print( "PlayerReqClass Function Error: " + e );
  156. }
  157. }
  158.  
  159.  
  160. function onPlayerRequestSpawn( player )
  161. {
  162. try
  163. {
  164. if ( status[ player.ID ].Registered == false )
  165. {
  166. MessagePlayer(RED+"/register to play", player );
  167. return 0;
  168. }
  169. else if ( ( status[ player.ID ].Registered == true ) && ( status[ player.ID ].Logged == false ) )
  170. {
  171. MessagePlayer(RED+"/login to play", player );
  172. return 0;
  173. }
  174. else return 1;
  175.  
  176. catch(e) print( "PlayerReqSpawn Function Error: " + e );
  177. }
  178. }
  179.  
  180. function onPlayerSpawn( player )
  181. {
  182. try
  183. {
  184. //====Spawn messages/sound======/send messages and sound when player spawns
  185. Message(LBLUE + player.Name +" spawned as "+GetPlayerTeamName( player.Team )+"." );
  186.  
  187. catch(e) print( "PlayerSpawn Function Error: " + e );
  188. }
  189.  
  190. }
  191.  
  192.  
  193. function onPlayerDeath( player, reason )
  194. {
  195. try
  196. {
  197.  
  198. if ( status[ player.ID ].Registered )
  199. {
  200. status[ player.ID ].Deaths++;
  201. local DCash = player.Cash;
  202. if ( DCash >= 250 ) DecCash( player, 250 );
  203. else DecCash( player, DCash );
  204. if (GetPlayerSpree(player) >= 1) DecPlayerSpree(player,GetPlayerSpree(player));
  205. }
  206.  
  207. //========Spree Functions=======
  208. EndKillingSpree(player,255);
  209. if (GetPlayerSpree(player) >= 1) DecPlayerSpree(player,GetPlayerSpree(player));
  210.  
  211. catch(e) print( "PlayerDeath Function Error: " + e );
  212. }
  213. }
  214.  
  215. function onPlayerKill( killer, player, reason, bodypart )
  216. {
  217. try
  218. {
  219.  
  220. //===increases players kills/Deaths+score======
  221.  
  222. killer.Score++;
  223. status[ killer.ID ].Kills++;
  224. status[ player.ID ].Deaths++;
  225. IncCash( killer, 500 );
  226. if ( player.Cash >= 250 ) DecCash( player, 250 );
  227.  
  228. //==========Spree Functions========
  229.  
  230. IncPlayerSpree(killer,1);
  231. StartKillingSpree(killer);
  232. EndKillingSpree(player,killer);
  233. if (GetPlayerSpree(player) >= 1) DecPlayerSpree(player,GetPlayerSpree(player));
  234.  
  235. catch(e) print( "PlayerKill Function Error: " + e );
  236. }
  237.  
  238.  
  239. }
  240. function onPlayerTeamKill( player, killer, reason, bodypart )
  241. {
  242. if ( killer.Team == 255 && player.Team == 255 )
  243. {
  244. onPlayerKill( player, killer, reason, bodypart );
  245. }
  246. }
  247.  
  248.  
  249. function onPlayerChat( player, text )
  250. {
  251. try
  252. {
  253.  
  254. //====== Team chat function====================
  255.  
  256. if ( text.slice(0,1) == "\\" )
  257. {
  258. local text = text.slice(1);
  259. for ( local i = 0; i < GetMaxPlayers(); i++ )
  260. {
  261. local plr = FindPlayer( i );
  262. if ( plr && plr.Team == player.Team )
  263. {
  264. ClientMessage("[Team-Chat] "+player.Name+": "+text+".",plr,0,255,255);
  265. }
  266. }
  267. return 0;
  268. }
  269.  
  270. return 1;
  271.  
  272. catch(e) print( "PlayerChat Function Error: " + e );
  273. }
  274. }
  275.  
  276.  
  277. function onPlayerPart( player, reason )
  278. {
  279. try
  280. {
  281. if ( ( GetLevel( player ) > 0 ) && ( status[ player.ID ].Logged == true ) )
  282. {
  283.  
  284. //====saves players stats.=========
  285. SaveStatus( player );
  286.  
  287. }
  288.  
  289.  
  290. //==Part Reason? ==================
  291.  
  292. local Text = "Unknown"
  293. switch ( reason )
  294. {
  295. case PARTREASON_DISCONNECTED:
  296. Text = "Disconnected";
  297. break;
  298. case PARTREASON_TIMEOUT:
  299. Text = "Timeout";
  300. break;
  301. case PARTREASON_QUIT:
  302. Text = "Quit";
  303. break;
  304. case PARTREASON_KICKED:
  305. Text = "Kicked";
  306. break;
  307. case PARTREASON_CRASHED:
  308. Text = "Crashed";
  309. break;
  310. }
  311.  
  312. //==========Spree Functions======
  313. EndKillingSpree(player,255);
  314. SetPlayerSpree(player);
  315.  
  316. print("** " + player + " has left the game. ( " + Text + " ) at " + GetFullTime() + ".");
  317.  
  318. catch(e) print( "PlayerPart Function Error: " + e );
  319. }
  320. }
Add Comment
Please, Sign In to add comment