Permalink
executable file 225 lines (191 sloc) 6.87 KB
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET time_zone = "+00:00";
--
-- Compatible with newer MySQL versions. (After MySQL-5.5)
-- This SQL uses utf8mb4 and has CURRENT_TIMESTAMP function.
--
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8mb4 */;
--
-- Creates database `altislife` unless it already exists and uses `altislife`
-- Default Schema
--
CREATE DATABASE IF NOT EXISTS `altislife` DEFAULT CHARACTER SET utf8mb4;
USE `altislife`;
--
-- Drop procedures to ensure no conflicts
--
DROP PROCEDURE IF EXISTS `resetLifeVehicles`;
DROP PROCEDURE IF EXISTS `deleteDeadVehicles`;
DROP PROCEDURE IF EXISTS `deleteOldHouses`;
DROP PROCEDURE IF EXISTS `deleteOldGangs`;
DROP PROCEDURE IF EXISTS `deleteOldContainers`;
DROP PROCEDURE IF EXISTS `deleteOldWanted`;
DELIMITER $$
--
-- Procedures
-- CURRENT_USER function returns the name of the current user in the SQL Server database.
--
CREATE DEFINER=CURRENT_USER PROCEDURE `resetLifeVehicles`()
BEGIN
UPDATE `vehicles` SET `active`= 0;
END$$
CREATE DEFINER=CURRENT_USER PROCEDURE `deleteDeadVehicles`()
BEGIN
DELETE FROM `vehicles` WHERE `alive` = 0;
END$$
CREATE DEFINER=CURRENT_USER PROCEDURE `deleteOldHouses`()
BEGIN
DELETE FROM `houses` WHERE `owned` = 0;
END$$
CREATE DEFINER=CURRENT_USER PROCEDURE `deleteOldGangs`()
BEGIN
DELETE FROM `gangs` WHERE `active` = 0;
END$$
CREATE DEFINER=CURRENT_USER PROCEDURE `deleteOldContainers`()
BEGIN
DELETE FROM `containers` WHERE `owned` = 0;
END$$
CREATE DEFINER=CURRENT_USER PROCEDURE `deleteOldWanted`()
BEGIN
DELETE FROM `wanted` WHERE `active` = 0;
END$$
DELIMITER ;
-- --------------------------------------------------------
--
-- Table structure for table `players`
--
CREATE TABLE IF NOT EXISTS `players` (
`uid` int(6) NOT NULL AUTO_INCREMENT,
`name` varchar(32) NOT NULL,
`aliases` text NOT NULL,
`pid` varchar(17) NOT NULL,
`cash` int(100) NOT NULL DEFAULT '0',
`bankacc` int(100) NOT NULL DEFAULT '0',
`coplevel` enum('0','1','2','3','4','5','6','7') NOT NULL DEFAULT '0',
`mediclevel` enum('0','1','2','3','4','5') NOT NULL DEFAULT '0',
`civ_licenses` text NOT NULL,
`cop_licenses` text NOT NULL,
`med_licenses` text NOT NULL,
`civ_gear` text NOT NULL,
`cop_gear` text NOT NULL,
`med_gear` text NOT NULL,
`civ_stats` varchar(32) NOT NULL DEFAULT '"[100,100,0]"',
`cop_stats` varchar(32) NOT NULL DEFAULT '"[100,100,0]"',
`med_stats` varchar(32) NOT NULL DEFAULT '"[100,100,0]"',
`arrested` tinyint(1) NOT NULL DEFAULT '0',
`adminlevel` enum('0','1','2','3','4','5') NOT NULL DEFAULT '0',
`donorlevel` enum('0','1','2','3','4','5') NOT NULL DEFAULT '0',
`blacklist` tinyint(1) NOT NULL DEFAULT '0',
`civ_alive` tinyint(1) NOT NULL DEFAULT '0',
`civ_position` varchar(64) NOT NULL DEFAULT '"[]"',
`playtime` varchar(32) NOT NULL DEFAULT '"[0,0,0]"',
`insert_time` timestamp DEFAULT CURRENT_TIMESTAMP,
`last_seen` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (`uid`),
UNIQUE KEY `pid` (`pid`),
KEY `name` (`name`),
KEY `blacklist` (`blacklist`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 AUTO_INCREMENT=12 ;
-- --------------------------------------------------------
--
-- Table structure for table `vehicles`
--
CREATE TABLE IF NOT EXISTS `vehicles` (
`id` int(6) NOT NULL AUTO_INCREMENT,
`side` varchar(16) NOT NULL,
`classname` varchar(64) NOT NULL,
`type` varchar(16) NOT NULL,
`pid` varchar(17) NOT NULL,
`alive` tinyint(1) NOT NULL DEFAULT '1',
`blacklist` tinyint(1) NOT NULL DEFAULT '0',
`active` tinyint(1) NOT NULL DEFAULT '0',
`plate` int(20) NOT NULL,
`color` int(20) NOT NULL,
`inventory` text NOT NULL,
`gear` text NOT NULL,
`fuel` double NOT NULL DEFAULT '1',
`damage` varchar(256) NOT NULL,
`insert_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (`id`),
KEY `side` (`side`),
KEY `pid` (`pid`),
KEY `type` (`type`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 AUTO_INCREMENT=2 ;
-- --------------------------------------------------------
--
-- Table structure for table `houses`
-- Needed for extDB latest update on git
--
CREATE TABLE IF NOT EXISTS `houses` (
`id` int(6) NOT NULL AUTO_INCREMENT,
`pid` varchar(17) NOT NULL,
`pos` varchar(64) DEFAULT NULL,
`owned` tinyint(1) DEFAULT '0',
`garage` tinyint(1) NOT NULL DEFAULT '0',
`insert_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (`id`,`pid`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 AUTO_INCREMENT=4 ;
-- --------------------------------------------------------
--
-- Table structure for table `gangs`
-- Needed for extDB latest update on git
--
CREATE TABLE IF NOT EXISTS `gangs` (
`id` int(6) NOT NULL AUTO_INCREMENT,
`owner` varchar(32) DEFAULT NULL,
`name` varchar(32) DEFAULT NULL,
`members` text,
`maxmembers` int(3) DEFAULT '8',
`bank` int(100) DEFAULT '0',
`active` tinyint(1) DEFAULT '1',
`insert_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (`id`),
UNIQUE KEY `name_UNIQUE` (`name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
-- --------------------------------------------------------
--
-- Table structure for table `containers`
-- Needed for extDB latest update on git
--
CREATE TABLE IF NOT EXISTS `containers` (
`id` int(6) NOT NULL AUTO_INCREMENT,
`pid` varchar(17) NOT NULL,
`classname` varchar(32) NOT NULL,
`pos` varchar(64) DEFAULT NULL,
`inventory` text NOT NULL,
`gear` text NOT NULL,
`dir` varchar(128) DEFAULT NULL,
`active` tinyint(1) NOT NULL DEFAULT '0',
`owned` tinyint(1) DEFAULT '0',
`insert_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (`id`,`pid`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 AUTO_INCREMENT=4;
-- --------------------------------------------------------
--
-- Table structure for table `wanted`
-- Needed for extDB latest update on git
--
CREATE TABLE IF NOT EXISTS `wanted` (
`wantedID` varchar(64) NOT NULL,
`wantedName` varchar(32) NOT NULL,
`wantedCrimes` text NOT NULL,
`wantedBounty` int(100) NOT NULL,
`active` tinyint(1) NOT NULL DEFAULT '0',
`insert_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (`wantedID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
-- --------------------------------------------------------
--
-- Creates default user `arma3` with password `changeme` unless it already exists
-- Granting permissions to user `arma3`, created below
-- Reloads the privileges from the grant tables in the MySQL system database.
--
CREATE USER IF NOT EXISTS `arma3`@`localhost` IDENTIFIED BY 'changeme';
GRANT SELECT, UPDATE, INSERT, EXECUTE ON `altislife`.* TO 'arma3'@'localhost';
FLUSH PRIVILEGES;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;