Advertisement
Guest User

Squirrel Code

a guest
Sep 20th, 2014
354
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
D 20.12 KB | None | 0 0
  1. // ------------------------------------------------------------------------------------------------
  2. local t_Weapons = {}
  3.  
  4. t_Weapons[WEP_FIST] <- {Id = "FIST", Name = "Unarmed", Reward = 100, Points = 10};
  5. t_Weapons[WEP_BRASSKNUCKLES] <- {Id = "BRASSKNUCKLES", Name = "Brass Knuckles", Reward = 100, Points = 10};
  6. t_Weapons[WEP_SCREWDRIVER] <- {Id = "SCREWDRIVER", Name = "Screwdriver", Reward = 100, Points = 10};
  7. t_Weapons[WEP_GOLFCLUB] <- {Id = "GOLFCLUB", Name = "Golf Club", Reward = 100, Points = 10};
  8. t_Weapons[WEP_NIGHTSTICK] <- {Id = "NIGHTSTICK", Name = "Night Stick", Reward = 100, Points = 10};
  9. t_Weapons[WEP_KNIFE] <- {Id = "KNIFE", Name = "Knife", Reward = 100, Points = 10};
  10. t_Weapons[WEP_BASEBALLBAT] <- {Id = "BASEBALLBAT", Name = "Baseball Bat", Reward = 100, Points = 10};
  11. t_Weapons[WEP_HAMMER] <- {Id = "HAMMER", Name = "Hammer", Reward = 100, Points = 10};
  12. t_Weapons[WEP_MEATCLEAVER] <- {Id = "MEATCLEAVER", Name = "Meat Cleaver", Reward = 100, Points = 10};
  13. t_Weapons[WEP_MACHETE] <- {Id = "MACHETE", Name = "Machete", Reward = 100, Points = 10};
  14. t_Weapons[WEP_KATANA] <- {Id = "KATANA", Name = "Katana", Reward = 100, Points = 10};
  15. t_Weapons[WEP_CHAINSAW] <- {Id = "CHAINSAW", Name = "Chainsaw", Reward = 100, Points = 10};
  16. t_Weapons[WEP_GRENADE] <- {Id = "GRENADE", Name = "Grenade", Reward = 100, Points = 10};
  17. t_Weapons[WEP_REMOTE] <- {Id = "REMOTE", Name = "Remote Detonation Grenades", Reward = 100, Points = 10};
  18. t_Weapons[WEP_TEARGAS] <- {Id = "TEARGAS", Name = "Tear Gas", Reward = 100, Points = 10};
  19. t_Weapons[WEP_MOLOTOV] <- {Id = "MOLOTOV", Name = "Molotov Cocktails", Reward = 100, Points = 10};
  20. t_Weapons[WEP_ROCKET] <- {Id = "ROCKET", Name = "Rocket Launcher", Reward = 100, Points = 10};
  21. t_Weapons[WEP_COLT45] <- {Id = "COLT45", Name = "Colt45", Reward = 100, Points = 10};
  22. t_Weapons[WEP_PYTHON] <- {Id = "PYTHON", Name = "Python", Reward = 100, Points = 10};
  23. t_Weapons[WEP_SHOTGUN] <- {Id = "SHOTGUN", Name = "Shotgun", Reward = 100, Points = 10};
  24. t_Weapons[WEP_SPAS12] <- {Id = "SPAS12", Name = "Spas12 Shotgun", Reward = 100, Points = 10};
  25. t_Weapons[WEP_STUBBY] <- {Id = "STUBBY", Name = "Stubby Shotgun", Reward = 100, Points = 10};
  26. t_Weapons[WEP_TEC9] <- {Id = "TEC9", Name = "Tec9", Reward = 100, Points = 10};
  27. t_Weapons[WEP_UZI] <- {Id = "UZI", Name = "Uzi", Reward = 100, Points = 10};
  28. t_Weapons[WEP_INGRAM] <- {Id = "INGRAM", Name = "Silenced Ingram", Reward = 100, Points = 10};
  29. t_Weapons[WEP_MP5] <- {Id = "MP5", Name = "Mp5", Reward = 100, Points = 10};
  30. t_Weapons[WEP_M4] <- {Id = "M4", Name = "m4", Reward = 100, Points = 10};
  31. t_Weapons[WEP_RUGER] <- {Id = "RUGER", Name = "Ruger", Reward = 100, Points = 10};
  32. t_Weapons[WEP_SNIPER] <- {Id = "SNIPER", Name = "Sniper Rifle", Reward = 100, Points = 10};
  33. t_Weapons[WEP_LASERSCOPE] <- {Id = "LASERSCOPE", Name = "PSG-1/.308 Sniper", Reward = 100, Points = 10};
  34. t_Weapons[WEP_ROCKETLAUNCHER] <- {Id = "ROCKETLAUNCHER", Name = "Rocket Launcher", Reward = 100, Points = 10};
  35. t_Weapons[WEP_FLAMETHROWER] <- {Id = "FLAMETHROWER", Name = "Flame Thrower", Reward = 100, Points = 10};
  36. t_Weapons[WEP_M60] <- {Id = "M60", Name = "M-60", Reward = 100, Points = 10};
  37. t_Weapons[WEP_MINIGUN] <- {Id = "MINIGUN", Name = "Minigun", Reward = 100, Points = 10};
  38. t_Weapons[WEP_BOMB] <- {Id = "BOMB", Name = "Detonator", Reward = 100, Points = 10};
  39. t_Weapons[WEP_HELICANNON] <- {Id = "HELICANNON", Name = "HeliCannon", Reward = 100, Points = 10};
  40. t_Weapons[WEP_CAMERA] <- {Id = "CAMERA", Name = "Camera", Reward = 100, Points = 10};
  41. t_Weapons[WEP_VEHICLE] <- {Id = "VEHICLE", Name = "Vehicle", Reward = 100, Points = 10};
  42. t_Weapons[WEP_DRIVEBY] <- {Id = "DRIVEBY", Name = "DryveBy", Reward = 100, Points = 10};
  43. t_Weapons[WEP_DROWNED] <- {Id = "DROWNED", Name = "Drown", Reward = 100, Points = 10};
  44. t_Weapons[WEP_FALL] <- {Id = "FALL", Name = "Fall", Reward = 100, Points = 10};
  45. t_Weapons[WEP_EXPLOSION] <- {Id = "EXPLOSION", Name = "Explosion", Reward = 100, Points = 10};
  46. t_Weapons[WEP_SUICIDE] <- {Id = "SUICIDE", Name = "Suicide", Reward = 100, Points = 10};
  47.  
  48. // ------------------------------------------------------------------------------------------------
  49.  
  50. local t_BodyPart = {};
  51.  
  52. t_BodyPart[BODYPART_BODY] <- {Reward = 2.6, Id = "BODY", Name = "Body", LcName = "body"};
  53. t_BodyPart[BODYPART_TORSO] <- {Reward = 2.2, Id = "TORSO", Name = "Torso", LcName = "torso"};
  54. t_BodyPart[BODYPART_LEFTARM] <- {Reward = 2.4, Id = "LEFTARM", Name = "Left Arm", LcName = "left arm"};
  55. t_BodyPart[BODYPART_RIGHTARM] <- {Reward = 2.4, Id = "RIGHTARM", Name = "Right Arm", LcName = "right arm"};
  56. t_BodyPart[BODYPART_LEFTLEG] <- {Reward = 2.4, Id = "LEFTLEG", Name = "Left Leg", LcName = "left leg"};
  57. t_BodyPart[BODYPART_RIGHTLEG] <- {Reward = 2.4, Id = "RIGHTLEG", Name = "Right Leg", LcName = "right leg"};
  58. t_BodyPart[BODYPART_HEAD] <- {Reward = 1.4, Id = "HEAD", Name = "Head", LcName = "head"};
  59.  
  60. // ------------------------------------------------------------------------------------------------
  61. const DB_LW_QUEUE = 0;
  62. const DB_MD_QUEUE = 1;
  63. const DB_HI_QUEUE = 2;
  64. // ------------------------------------------------------------------------------------------------
  65. class _Result
  66. {
  67.     // --------------------------------------------------------------------------------------------
  68.     _Res = null;
  69.     // --------------------------------------------------------------------------------------------
  70.     function constructor(res) {
  71.         // Be sure that the passed argument is a valid query result
  72.         if (typeof _Res != "userdata") return print("Cannot construct query result from an invalid result.");
  73.         // Save the passed query result
  74.         else _Res = res;
  75.     }
  76.     // --------------------------------------------------------------------------------------------
  77.     function destructor() {
  78.         // Free the query result if it's a vlid one
  79.         if (typeof _Res == "userdata") ::FreeSQLQuery(_Res)
  80.     }
  81.     // @TODO Implement...
  82. }
  83. // ------------------------------------------------------------------------------------------------
  84. _DB <- {
  85.     // --------------------------------------------------------------------------------------------
  86.     _File = "stats.db"
  87.     // --------------------------------------------------------------------------------------------
  88.     _Handle = null
  89.     // --------------------------------------------------------------------------------------------
  90.     _Queue = {}
  91.     // --------------------------------------------------------------------------------------------
  92.     function Queue(level, ...) {
  93.         // Make sure that the specified level exists and is valid
  94.         if (!_Queue.rawin(level) || typeof _Queue[level] != "array") return print("Cannot find a valid queue for the specified level.");
  95.         // Make sure that the correct arguments were passed to the function
  96.         else if (vargv.len() < 1 || typeof vargv[0] != "string") return print("Invalid arguments passed to the queue function.");
  97.         // Push the (this) environment into the query arguments
  98.         else vargv.insert(0, this);
  99.         // Format the query
  100.         local query = ::format.acall(vargv);
  101.         // Be sure that the query was formatted successfully
  102.         if (typeof query != "string" || query.len() < 1) return print("Cannot queue invalid or empty query string.");
  103.         // Add the query to the specified queue
  104.         else _Queue[level].pushback(query);
  105.     }
  106.     // --------------------------------------------------------------------------------------------
  107.     function Exec(...) {
  108.         // Make sure that the correct arguments were passed to the function
  109.         if (vargv.len() < 1 || typeof vargv[0] != "string") return print("Invalid arguments passed to the exec function.");
  110.         // Push the (this) environment into the query arguments
  111.         else vargv.insert(0, this);
  112.         // Create an empty result and format the query
  113.         local result = null, query = ::format.acall(vargv);
  114.         // Be sure that the query was formatted successfully
  115.         if (typeof query != "string" || query.len() < 1) return print("Cannot exec invalid or empty query string.");
  116.         // Try to execute the specified query
  117.        
  118.        
  119.         // Generates invalid query
  120.         //else result = ::QuerySQL(_Handle, ::escapeSQLString(query)); // Generates invalid query by adding unnecessary symbols
  121.        
  122.         /*
  123.         local fp = file("query.txt", "a");
  124.         local str = ::escapeSQLString(query);
  125.         foreach (c in str) fp.writen(c, 'b');
  126.         fp.writen('\n', 'b');
  127.         */
  128.        
  129.         // Generates valid query
  130.         else result = ::QuerySQL(_Handle, query); // Executes the original query
  131.         /*
  132.         local fp = file("query.txt", "a");
  133.         foreach (c in query) fp.writen(c, 'b');
  134.         fp.writen('\n', 'b');
  135.         */
  136.        
  137.         // Did the query returned a valid result?
  138.         if (typeof result == "userdata") return _Result(result);
  139.     }
  140.     // --------------------------------------------------------------------------------------------
  141.     function Flush(level) {
  142.         // @TODO Implement...
  143.     }
  144.     // --------------------------------------------------------------------------------------------
  145.     function Open()
  146.     {
  147.         // Make sure the previous handle was closed or that there wasn't one to begin with
  148.         if (typeof _Handle == "userdata") return print("Another database handle was found. Operation will be aborted.");
  149.         // Make sure that a database file was specified and that it's a valid path
  150.         else if (typeof _File != "string") return print("Unknown or missing database location. Operation will be aborted.");
  151.         // Try to open the file as an SQLite3 database now
  152.         _Handle = ::ConnectSQL(_File);
  153.         // Check if the previous operation succeeded and notify someone in case of failure
  154.         if (_Handle == null) return print("Unable to open the SQLite database from: " + _File);
  155.         // The database was opened successfully and the operation is complete
  156.         else return print("Successfully aquired a database handle to: " + _File);
  157.     }
  158.     // --------------------------------------------------------------------------------------------
  159.     function Close()
  160.     {
  161.         // Make sure that we have a valid database handle to begin with
  162.         if (typeof _Handle != "userdata") return print("No handle to close for database: " + _File);
  163.         // Close the database handle and notify someone in case of failure
  164.         else if (!::DisconnectSQL(_File)) return print("Unable to close handle for database: " + _File);
  165.         // The database was closed successfully and the operation is complete
  166.         else return print("Successfully closed handle for database: " + _File);
  167.     }
  168.  
  169.     // ------------------------------------------------------------------------------------------------
  170.     function Initialize()
  171.     {
  172.         // Make sure that the database has the Account table
  173.         Exec(@"CREATE TABLE IF NOT EXISTS [Account] (
  174.             [Username] VARCHAR(32)  UNIQUE NOT NULL,
  175.             [Password] VARCHAR(32)  NOT NULL,
  176.             [Email] VARCHAR(64)  NOT NULL,
  177.             [Nickname] VARCHAR(128)  NOT NULL,
  178.             [Faction] NUMERIC DEFAULT '0' NULL,
  179.             [Wealth] NUMERIC DEFAULT '0' NULL,
  180.             [Points] NUMERIC DEFAULT '0' NULL,
  181.             [Karma] FLOAT DEFAULT '0.0' NULL,
  182.             [Level] NUMERIC DEFAULT '0' NULL
  183.         )");
  184.  
  185.         // Make sure that the database has the Bans table @TODO Embed in user profile...
  186.         Exec(@"CREATE TABLE IF NOT EXISTS [Bans] (
  187.             [User] NUMERIC DEFAULT '0' NOT NULL,
  188.             [Timestamp] TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL,
  189.             [Duration] TIMESTAMP  NOT NULL,
  190.             [Reason] VARCHAR(64)  NULL,
  191.             [Admin] NUMERIC DEFAULT '0' NOT NULL,
  192.             [Expired] BOOLEAN DEFAULT 'FALSE' NOT NULL
  193.         )");
  194.  
  195.         // Make sure that the database has the Profile table
  196.         Exec(@"CREATE TABLE IF NOT EXISTS [Profile] (
  197.             [Firstname] VARCHAR(64)  NULL,
  198.             [Lastname] VARCHAR(64)  NULL,
  199.             [City] VARCHAR(64)  NULL,
  200.             [State] VARCHAR(64)  NULL,
  201.             [Country] VARCHAR(64)  NULL,
  202.             [CanKick] BOOLEAN DEFAULT 'TRUE' NOT NULL,
  203.             [CanBan] BOOLEAN DEFAULT 'TRUE' NOT NULL,
  204.             [CanJoin] BOOLEAN DEFAULT 'TRUE' NOT NULL,
  205.             [CanSpeak] BOOLEAN DEFAULT 'TRUE' NOT NULL,
  206.             [CanDrive] BOOLEAN DEFAULT 'TRUE' NOT NULL,
  207.             [CanGetOnBoard] BOOLEAN DEFAULT 'TRUE' NOT NULL,
  208.             [CanTakeDamage] BOOLEAN DEFAULT 'TRUE' NOT NULL,
  209.             [CanChangeName] BOOLEAN DEFAULT 'TRUE' NOT NULL,
  210.             [CanSpawn] BOOLEAN DEFAULT 'TRUE' NOT NULL,
  211.             [CanSpectate] BOOLEAN DEFAULT 'TRUE' NOT NULL,
  212.             [CanReceivePM] BOOLEAN DEFAULT 'TRUE' NOT NULL,
  213.             [CanSendPM] BOOLEAN DEFAULT 'TRUE' NOT NULL,
  214.             [CanTeamKill] BOOLEAN DEFAULT 'TRUE' NOT NULL,
  215.             [Visited] TIMESTAMP DEFAULT '0' NULL,
  216.             [LastIP] VARCHAR(16)  NULL,
  217.             [Activity] NUMERIC DEFAULT '0' NULL,
  218.             [LastSpree] NUMERIC DEFAULT '0' NULL,
  219.             [BestSpree] NUMERIC DEFAULT '0' NULL,
  220.             [Spawns] NUMERIC DEFAULT '0' NULL,
  221.             [Joins] NUMERIC DEFAULT '0' NULL,
  222.             [Wrecks] NUMERIC DEFAULT '0' NULL,
  223.             [Chats] NUMERIC DEFAULT '0' NULL,
  224.             [Actions] NUMERIC DEFAULT '0' NULL,
  225.             [TeamKills] NUMERIC DEFAULT '0' NULL
  226.         )");
  227.  
  228.         // Make sure that the database has the Body table
  229.         Exec(@"CREATE TABLE IF NOT EXISTS [Body] (
  230.                 [K%s] NUMERIC DEFAULT '0' NOT NULL, [K%s] NUMERIC DEFAULT '0' NOT NULL, [K%s] NUMERIC DEFAULT '0' NOT NULL,
  231.                 [K%s] NUMERIC DEFAULT '0' NOT NULL, [K%s] NUMERIC DEFAULT '0' NOT NULL, [K%s] NUMERIC DEFAULT '0' NOT NULL,
  232.                 [K%s] NUMERIC DEFAULT '0' NOT NULL,
  233.                 [D%s] NUMERIC DEFAULT '0' NOT NULL, [D%s] NUMERIC DEFAULT '0' NOT NULL, [D%s] NUMERIC DEFAULT '0' NOT NULL,
  234.                 [D%s] NUMERIC DEFAULT '0' NOT NULL, [D%s] NUMERIC DEFAULT '0' NOT NULL, [D%s] NUMERIC DEFAULT '0' NOT NULL,
  235.                 [D%s] NUMERIC DEFAULT '0' NOT NULL
  236.             )"
  237.             , t_BodyPart[BODYPART_BODY].Id,     t_BodyPart[BODYPART_TORSO].Id,      t_BodyPart[BODYPART_LEFTARM].Id
  238.             , t_BodyPart[BODYPART_RIGHTARM].Id, t_BodyPart[BODYPART_LEFTLEG].Id,    t_BodyPart[BODYPART_RIGHTLEG].Id
  239.             , t_BodyPart[BODYPART_HEAD].Id
  240.             , t_BodyPart[BODYPART_BODY].Id,     t_BodyPart[BODYPART_TORSO].Id,      t_BodyPart[BODYPART_LEFTARM].Id
  241.             , t_BodyPart[BODYPART_RIGHTARM].Id, t_BodyPart[BODYPART_LEFTLEG].Id,    t_BodyPart[BODYPART_RIGHTLEG].Id
  242.             , t_BodyPart[BODYPART_HEAD].Id
  243.         );
  244.  
  245.         // Make sure that the database has the Deaths table
  246.         Exec(@"CREATE TABLE IF NOT EXISTS [Deaths] (
  247.             [%s] NUMERIC DEFAULT '0' NOT NULL, [%s] NUMERIC DEFAULT '0' NOT NULL, [%s] NUMERIC DEFAULT '0' NOT NULL,
  248.             [%s] NUMERIC DEFAULT '0' NOT NULL, [%s] NUMERIC DEFAULT '0' NOT NULL, [%s] NUMERIC DEFAULT '0' NOT NULL,
  249.             [%s] NUMERIC DEFAULT '0' NOT NULL, [%s] NUMERIC DEFAULT '0' NOT NULL, [%s] NUMERIC DEFAULT '0' NOT NULL,
  250.             [%s] NUMERIC DEFAULT '0' NOT NULL, [%s] NUMERIC DEFAULT '0' NOT NULL, [%s] NUMERIC DEFAULT '0' NOT NULL,
  251.             [%s] NUMERIC DEFAULT '0' NOT NULL, [%s] NUMERIC DEFAULT '0' NOT NULL, [%s] NUMERIC DEFAULT '0' NOT NULL,
  252.             [%s] NUMERIC DEFAULT '0' NOT NULL, [%s] NUMERIC DEFAULT '0' NOT NULL, [%s] NUMERIC DEFAULT '0' NOT NULL,
  253.             [%s] NUMERIC DEFAULT '0' NOT NULL, [%s] NUMERIC DEFAULT '0' NOT NULL, [%s] NUMERIC DEFAULT '0' NOT NULL,
  254.             [%s] NUMERIC DEFAULT '0' NOT NULL, [%s] NUMERIC DEFAULT '0' NOT NULL, [%s] NUMERIC DEFAULT '0' NOT NULL,
  255.             [%s] NUMERIC DEFAULT '0' NOT NULL, [%s] NUMERIC DEFAULT '0' NOT NULL, [%s] NUMERIC DEFAULT '0' NOT NULL,
  256.             [%s] NUMERIC DEFAULT '0' NOT NULL, [%s] NUMERIC DEFAULT '0' NOT NULL, [%s] NUMERIC DEFAULT '0' NOT NULL,
  257.             [%s] NUMERIC DEFAULT '0' NOT NULL, [%s] NUMERIC DEFAULT '0' NOT NULL, [%s] NUMERIC DEFAULT '0' NOT NULL,
  258.             [%s] NUMERIC DEFAULT '0' NOT NULL, [%s] NUMERIC DEFAULT '0' NOT NULL, [%s] NUMERIC DEFAULT '0' NOT NULL,
  259.             [%s] NUMERIC DEFAULT '0' NOT NULL, [%s] NUMERIC DEFAULT '0' NOT NULL, [%s] NUMERIC DEFAULT '0' NOT NULL,
  260.             [%s] NUMERIC DEFAULT '0' NOT NULL, [%s] NUMERIC DEFAULT '0' NOT NULL, [%s] NUMERIC DEFAULT '0' NOT NULL,
  261.             [%s] NUMERIC DEFAULT '0' NOT NULL
  262.             )"
  263.             , t_Weapons[WEP_FIST].Id,               t_Weapons[WEP_BRASSKNUCKLES].Id,    t_Weapons[WEP_SCREWDRIVER].Id
  264.             , t_Weapons[WEP_GOLFCLUB].Id,           t_Weapons[WEP_NIGHTSTICK].Id,       t_Weapons[WEP_KNIFE].Id
  265.             , t_Weapons[WEP_BASEBALLBAT].Id,        t_Weapons[WEP_HAMMER].Id,           t_Weapons[WEP_MEATCLEAVER].Id
  266.             , t_Weapons[WEP_MACHETE].Id,            t_Weapons[WEP_KATANA].Id,           t_Weapons[WEP_CHAINSAW].Id
  267.             , t_Weapons[WEP_GRENADE].Id,            t_Weapons[WEP_REMOTE].Id,           t_Weapons[WEP_TEARGAS].Id
  268.             , t_Weapons[WEP_MOLOTOV].Id,            t_Weapons[WEP_ROCKET].Id,           t_Weapons[WEP_COLT45].Id
  269.             , t_Weapons[WEP_PYTHON].Id,             t_Weapons[WEP_SHOTGUN].Id,          t_Weapons[WEP_SPAS12].Id
  270.             , t_Weapons[WEP_STUBBY].Id,             t_Weapons[WEP_TEC9].Id,             t_Weapons[WEP_UZI].Id
  271.             , t_Weapons[WEP_INGRAM].Id,             t_Weapons[WEP_MP5].Id,              t_Weapons[WEP_M4].Id
  272.             , t_Weapons[WEP_RUGER].Id,              t_Weapons[WEP_SNIPER].Id,           t_Weapons[WEP_LASERSCOPE].Id
  273.             , t_Weapons[WEP_ROCKETLAUNCHER].Id,     t_Weapons[WEP_FLAMETHROWER].Id,     t_Weapons[WEP_M60].Id
  274.             , t_Weapons[WEP_MINIGUN].Id,            t_Weapons[WEP_BOMB].Id,             t_Weapons[WEP_HELICANNON].Id
  275.             , t_Weapons[WEP_CAMERA].Id,             t_Weapons[WEP_VEHICLE].Id,          t_Weapons[WEP_DRIVEBY].Id
  276.             , t_Weapons[WEP_DROWNED].Id,            t_Weapons[WEP_FALL].Id,             t_Weapons[WEP_EXPLOSION].Id
  277.             , t_Weapons[WEP_SUICIDE].Id
  278.         );
  279.  
  280.         // Make sure that the database has the Kills table
  281.         Exec(@"CREATE TABLE IF NOT EXISTS [Kills] (
  282.             [%s] NUMERIC DEFAULT '0' NOT NULL, [%s] NUMERIC DEFAULT '0' NOT NULL, [%s] NUMERIC DEFAULT '0' NOT NULL,
  283.             [%s] NUMERIC DEFAULT '0' NOT NULL, [%s] NUMERIC DEFAULT '0' NOT NULL, [%s] NUMERIC DEFAULT '0' NOT NULL,
  284.             [%s] NUMERIC DEFAULT '0' NOT NULL, [%s] NUMERIC DEFAULT '0' NOT NULL, [%s] NUMERIC DEFAULT '0' NOT NULL,
  285.             [%s] NUMERIC DEFAULT '0' NOT NULL, [%s] NUMERIC DEFAULT '0' NOT NULL, [%s] NUMERIC DEFAULT '0' NOT NULL,
  286.             [%s] NUMERIC DEFAULT '0' NOT NULL, [%s] NUMERIC DEFAULT '0' NOT NULL, [%s] NUMERIC DEFAULT '0' NOT NULL,
  287.             [%s] NUMERIC DEFAULT '0' NOT NULL, [%s] NUMERIC DEFAULT '0' NOT NULL, [%s] NUMERIC DEFAULT '0' NOT NULL,
  288.             [%s] NUMERIC DEFAULT '0' NOT NULL, [%s] NUMERIC DEFAULT '0' NOT NULL, [%s] NUMERIC DEFAULT '0' NOT NULL,
  289.             [%s] NUMERIC DEFAULT '0' NOT NULL, [%s] NUMERIC DEFAULT '0' NOT NULL, [%s] NUMERIC DEFAULT '0' NOT NULL,
  290.             [%s] NUMERIC DEFAULT '0' NOT NULL, [%s] NUMERIC DEFAULT '0' NOT NULL, [%s] NUMERIC DEFAULT '0' NOT NULL,
  291.             [%s] NUMERIC DEFAULT '0' NOT NULL, [%s] NUMERIC DEFAULT '0' NOT NULL, [%s] NUMERIC DEFAULT '0' NOT NULL,
  292.             [%s] NUMERIC DEFAULT '0' NOT NULL, [%s] NUMERIC DEFAULT '0' NOT NULL, [%s] NUMERIC DEFAULT '0' NOT NULL,
  293.             [%s] NUMERIC DEFAULT '0' NOT NULL, [%s] NUMERIC DEFAULT '0' NOT NULL, [%s] NUMERIC DEFAULT '0' NOT NULL,
  294.             [%s] NUMERIC DEFAULT '0' NOT NULL, [%s] NUMERIC DEFAULT '0' NOT NULL, [%s] NUMERIC DEFAULT '0' NOT NULL,
  295.             [%s] NUMERIC DEFAULT '0' NOT NULL, [%s] NUMERIC DEFAULT '0' NOT NULL, [%s] NUMERIC DEFAULT '0' NOT NULL,
  296.             [%s] NUMERIC DEFAULT '0' NOT NULL
  297.             )"
  298.             , t_Weapons[WEP_FIST].Id,               t_Weapons[WEP_BRASSKNUCKLES].Id,    t_Weapons[WEP_SCREWDRIVER].Id
  299.             , t_Weapons[WEP_GOLFCLUB].Id,           t_Weapons[WEP_NIGHTSTICK].Id,       t_Weapons[WEP_KNIFE].Id
  300.             , t_Weapons[WEP_BASEBALLBAT].Id,        t_Weapons[WEP_HAMMER].Id,           t_Weapons[WEP_MEATCLEAVER].Id
  301.             , t_Weapons[WEP_MACHETE].Id,            t_Weapons[WEP_KATANA].Id,           t_Weapons[WEP_CHAINSAW].Id
  302.             , t_Weapons[WEP_GRENADE].Id,            t_Weapons[WEP_REMOTE].Id,           t_Weapons[WEP_TEARGAS].Id
  303.             , t_Weapons[WEP_MOLOTOV].Id,            t_Weapons[WEP_ROCKET].Id,           t_Weapons[WEP_COLT45].Id
  304.             , t_Weapons[WEP_PYTHON].Id,             t_Weapons[WEP_SHOTGUN].Id,          t_Weapons[WEP_SPAS12].Id
  305.             , t_Weapons[WEP_STUBBY].Id,             t_Weapons[WEP_TEC9].Id,             t_Weapons[WEP_UZI].Id
  306.             , t_Weapons[WEP_INGRAM].Id,             t_Weapons[WEP_MP5].Id,              t_Weapons[WEP_M4].Id
  307.             , t_Weapons[WEP_RUGER].Id,              t_Weapons[WEP_SNIPER].Id,           t_Weapons[WEP_LASERSCOPE].Id
  308.             , t_Weapons[WEP_ROCKETLAUNCHER].Id,     t_Weapons[WEP_FLAMETHROWER].Id,     t_Weapons[WEP_M60].Id
  309.             , t_Weapons[WEP_MINIGUN].Id,            t_Weapons[WEP_BOMB].Id,             t_Weapons[WEP_HELICANNON].Id
  310.             , t_Weapons[WEP_CAMERA].Id,             t_Weapons[WEP_VEHICLE].Id,          t_Weapons[WEP_DRIVEBY].Id
  311.             , t_Weapons[WEP_DROWNED].Id,            t_Weapons[WEP_FALL].Id,             t_Weapons[WEP_EXPLOSION].Id
  312.             , t_Weapons[WEP_SUICIDE].Id
  313.         );
  314.  
  315.         // Make sure that the database has the Faction table
  316.         Exec(@"CREATE TABLE IF NOT EXISTS [Faction] (
  317.             [Name] VARCHAR(32)  NOT NULL,
  318.             [Tag] VARCHAR(8)  NOT NULL,
  319.             [Wealth] NUMERIC DEFAULT '0' NOT NULL,
  320.             [Points] NUMERIC DEFAULT '0' NOT NULL
  321.         )");
  322.  
  323.         // Notify someone about the success
  324.         print("Database was successfully initialized.");
  325.     }
  326. }
  327. // ------------------------------------------------------------------------------------------------
  328. _DB._Queue[DB_LW_QUEUE] <- [];
  329. _DB._Queue[DB_MD_QUEUE] <- [];
  330. _DB._Queue[DB_HI_QUEUE] <- [];
  331.  
  332. // ------------------------------------------------------------------------------------------------
  333. function onServerStart()
  334. {
  335.     _DB.Open();
  336.     _DB.Initialize();
  337. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement