<commit_before>/*==============================================================================


	Southclaw's Scavenge and Survive

		Big thanks to Onfire559/Adam for the initial concept and developing
		the idea a lot long ago with some very productive discussions!
		Recently influenced by Minecraft and DayZ, credits to the creators of
		those games and their fundamental mechanics and concepts.


==============================================================================*/


#include <a_samp>

/*==============================================================================

	Library Predefinitions

==============================================================================*/

#undef MAX_PLAYERS
#define MAX_PLAYERS	(32)

native IsValidVehicle(vehicleid);
native gpci(playerid, serial[], len);

#define DB_DEBUG					false
#define DB_MAX_STATEMENTS			(54)
#define STRLIB_RETURN_SIZE			(256)
#define NOTEBOOK_FILE				"SSS/Notebook/%s.dat"
#define MAX_NOTEBOOK_FILE_NAME		(MAX_PLAYER_NAME + 18)
#define ITM_DROP_ON_DEATH			false

#define DEFAULT_POS_X				(10000.0)
#define DEFAULT_POS_Y				(10000.0)
#define DEFAULT_POS_Z				(1.0)

/*==============================================================================

	Libraries and respective links to their release pages

==============================================================================*/

#include <sscanf2>					// By Y_Less:				http://forum.sa-mp.com/showthread.php?t=120356
#include <YSI\y_utils>				// By Y_Less:				http://forum.sa-mp.com/showthread.php?p=1696956
#include <YSI\y_va>
#include <YSI\y_timers>
#include <YSI\y_hooks>
#include <YSI\y_iterate>
#include <YSI\y_ini>

#include "SS/Core/Server/Hooks.pwn"	// Internal library for hooking functions before they are used in external libraries.

#include <streamer>					// By Incognito:			http://forum.sa-mp.com/showthread.php?t=102865
//#include <irc>						// By Incognito:			http://forum.sa-mp.com/showthread.php?t=98803

#include <sqlitei>					// By Slice:				http://forum.sa-mp.com/showthread.php?t=303682
#include <formatex>					// By Slice:				http://forum.sa-mp.com/showthread.php?t=313488
#include <strlib>					// By Slice:				http://forum.sa-mp.com/showthread.php?t=362764
#include <md-sort>					// By Slice:				http://forum.sa-mp.com/showthread.php?t=343172

#define result GeoIP_result
#include <GeoIP>					// By Whitetiger:			http://forum.sa-mp.com/showthread.php?t=296171
#undef result

#define time ctime_time
#include <CTime>					// By RyDeR:				http://forum.sa-mp.com/showthread.php?t=294054
#undef time

#include <playerprogress>			// By Torbido/Southclaw:	https://github.com/Southclaw/PlayerProgressBar
#include <FileManager>				// By JaTochNietDan:		http://forum.sa-mp.com/showthread.php?t=92246
#include <djson>					// By DracoBlue:			http://forum.sa-mp.com/showthread.php?t=48439

#include <SIF/SIF>					// By Southclaw:			https://github.com/Southclaw/SIF
#include <SIF/extensions/InventoryDialog>
#include <SIF/extensions/InventoryKeys>
#include <SIF/extensions/ContainerDialog>
#include <SIF/extensions/Craft>
#include <SIF/extensions/Notebook>
#include <WeaponData>				// By Southclaw:			https://github.com/Southclaw/AdvancedWeaponData
#include <Balloon>					// By Southclaw:			https://github.com/Southclaw/Balloon
#include <Line>						// By Southclaw:			https://github.com/Southclaw/Line
#include <Zipline>					// By Southclaw:			https://github.com/Southclaw/Zipline
#include <Ladder>					// By Southclaw:			https://github.com/Southclaw/Ladder

native WP_Hash(buffer[], len, const str[]);
									// By Y_Less:				http://forum.sa-mp.com/showthread.php?t=65290


/*==============================================================================

	Definitions

==============================================================================*/


// Limits
#define MAX_MOTD_LEN				(128)
#define MAX_WEBSITE_NAME			(64)
#define MAX_INFO_MESSAGE			(8)
#define MAX_INFO_MESSAGE_LEN		(128)
#define MAX_RULE					(8)
#define MAX_RULE_LEN				(128)
#define MAX_STAFF					(8)
#define MAX_STAFF_LEN				(24)
#define MAX_PLAYER_FILE				(MAX_PLAYER_NAME+16)
#define MAX_ADMIN					(48)
#define MAX_PASSWORD_LEN			(<PASSWORD>)
#define MAX_SERVER_UPTIME			(3600 * 9)
#define MAX_SPAWNED_VEHICLES		(250)


// Directories
#define DIRECTORY_SCRIPTFILES		"./scriptfiles/"
#define DIRECTORY_MAIN				"SSS/"
#define DIRECTORY_VEHICLESPAWNS		"Vehicles/"
#define DIRECTORY_CARMOUR			DIRECTORY_VEHICLESPAWNS"Mods/"
#define DIRECTORY_LOGS				DIRECTORY_MAIN"Logs/"
#define DIRECTORY_PLAYER			DIRECTORY_MAIN"Player/"
#define DIRECTORY_INVENTORY			DIRECTORY_MAIN"Inventory/"
#define DIRECTORY_NOTEBOOK			DIRECTORY_MAIN"Notebook/"
#define DIRECTORY_VEHICLE_DAT		DIRECTORY_MAIN"VehicleDat/"
#define DIRECTORY_VEHICLE_INV		DIRECTORY_MAIN"VehicleInv/"
#define DIRECTORY_SAFEBOX			DIRECTORY_MAIN"Safebox/"
#define DIRECTORY_TENT				DIRECTORY_MAIN"Tents/"
#define DIRECTORY_DEFENCES			DIRECTORY_MAIN"Defences/"
#define DIRECTORY_SIGNS				DIRECTORY_MAIN"Signs/"
#define DIRECTORY_DETFIELD			DIRECTORY_MAIN"Detfield/"


// Files
#define PLAYER_DATA_FILE			DIRECTORY_PLAYER"%s.dat"
#define PLAYER_ITEM_FILE			DIRECTORY_INVENTORY"%s.dat"
#define ACCOUNT_DATABASE			"SSS/Accounts.db"
#define WORLD_DATABASE				"SSS/World.db"
#define SETTINGS_FILE				"SSS/settings.json"


// Database
#define ACCOUNTS_TABLE_PLAYER		"Player"
#define ACCOUNTS_TABLE_BANS			"Bans"
#define ACCOUNTS_TABLE_REPORTS		"Reports"
#define ACCOUNTS_TABLE_BUGS			"Bugs"
#define ACCOUNTS_TABLE_WHITELIST	"Whitelist"
#define ACCOUNTS_TABLE_ADMINS		"Admins"
#define WORLD_TABLE_SPRAYTAG		"SprayTag"

// Player
#define FIELD_PLAYER_NAME			"name"		// 00
#define FIELD_PLAYER_PASS			"pass"		// 01
#define FIELD_PLAYER_IPV4			"ipv4"		// 02
#define FIELD_PLAYER_ALIVE			"alive"		// 03
#define FIELD_PLAYER_KARMA			"karma"		// 04
#define FIELD_PLAYER_REGDATE		"regdate"	// 05
#define FIELD_PLAYER_LASTLOG		"lastlog"	// 06
#define FIELD_PLAYER_SPAWNTIME		"spawntime"	// 07
#define FIELD_PLAYER_TOTALSPAWNS	"spawns"	// 08
#define FIELD_PLAYER_WARNINGS		"warnings"	// 09
#define FIELD_PLAYER_AIMSHOUT		"aimshout"	// 10
#define FIELD_PLAYER_GPCI			"gpci"		// 11

enum
{
	FIELD_ID_PLAYER_NAME,
	FIELD_ID_PLAYER_PASS,
	FIELD_ID_PLAYER_IPV4,
	FIELD_ID_PLAYER_ALIVE,
	FIELD_ID_PLAYER_KARMA,
	FIELD_ID_PLAYER_REGDATE,
	FIELD_ID_PLAYER_LASTLOG,
	FIELD_ID_PLAYER_SPAWNTIME,
	FIELD_ID_PLAYER_TOTALSPAWNS,
	FIELD_ID_PLAYER_WARNINGS,
	FIELD_ID_PLAYER_AIMSHOUT,
	FIELD_ID_PLAYER_GPCI
}

// Bans
#define FIELD_BANS_NAME				"name"		// 00
#define FIELD_BANS_IPV4				"ipv4"		// 01
#define FIELD_BANS_DATE				"date"		// 02
#define FIELD_BANS_REASON			"reason"	// 03
#define FIELD_BANS_BY				"by"		// 04
#define FIELD_BANS_DURATION			"duration"	// 05

enum
{
	FIELD_ID_BANS_NAME,
	FIELD_ID_BANS_IPV4,
	FIELD_ID_BANS_DATE,
	FIELD_ID_BANS_REASON,
	FIELD_ID_BANS_BY,
	FIELD_ID_BANS_DURATION
}

// Reports
#define FIELD_REPORTS_NAME			"name"		// 00
#define FIELD_REPORTS_REASON		"reason"	// 01
#define FIELD_REPORTS_DATE			"date"		// 02
#define FIELD_REPORTS_READ			"read"		// 03
#define FIELD_REPORTS_TYPE			"type"		// 04
#define FIELD_REPORTS_POSX			"posx"		// 05
#define FIELD_REPORTS_POSY			"posy"		// 06
#define FIELD_REPORTS_POSZ			"posz"		// 07
#define FIELD_REPORTS_INFO			"info"		// 08
#define FIELD_REPORTS_BY			"by"		// 09

enum
{
	FIELD_ID_REPORTS_NAME,
	FIELD_ID_REPORTS_REASON,
	FIELD_ID_REPORTS_DATE,
	FIELD_ID_REPORTS_READ,
	FIELD_ID_REPORTS_TYPE,
	FIELD_ID_REPORTS_POSX,
	FIELD_ID_REPORTS_POSY,
	FIELD_ID_REPORTS_POSZ,
	FIELD_ID_REPORTS_INFO,
	FIELD_ID_REPORTS_BY
}

// Bugs
#define FIELD_BUGS_NAME				"name"		// 00
#define FIELD_BUGS_REASON			"reason"	// 01
#define FIELD_BUGS_DATE				"date"		// 02

enum
{
	FIELD_ID_BUGS_NAME,
	FIELD_ID_BUGS_REASON,
	FIELD_ID_BUGS_DATE
}

// Whitelist
#define FIELD_WHITELIST_NAME		"name"		// 00

// Admins
#define FIELD_ADMINS_NAME			"name"		// 00
#define FIELD_ADMINS_LEVEL			"level"		// 01

// SprayTag
#define FIELD_SPRAYTAG_NAME			"name"		// 00
#define FIELD_SPRAYTAG_POSX			"posx"		// 01
#define FIELD_SPRAYTAG_POSY			"posy"		// 02
#define FIELD_SPRAYTAG_POSZ			"posz"		// 03
#define FIELD_SPRAYTAG_ROTX			"rotx"		// 04
#define FIELD_SPRAYTAG_ROTY			"roty"		// 05
#define FIELD_SPRAYTAG_ROTZ			"rotz"		// 06

enum
{
	FIELD_ID_SPRAYTAG_NAME,
	FIELD_ID_SPRAYTAG_POSX,
	FIELD_ID_SPRAYTAG_POSY,
	FIELD_ID_SPRAYTAG_POSZ,
	FIELD_ID_SPRAYTAG_ROTX,
	FIELD_ID_SPRAYTAG_ROTY,
	FIELD_ID_SPRAYTAG_ROTZ
}

enum
{
	STAFF_LEVEL_NONE,						// 0
	STAFF_LEVEL_GAME_MASTER,				// 1
	STAFF_LEVEL_MODERATOR,					// 2
	STAFF_LEVEL_ADMINISTRATOR,				// 3
	STAFF_LEVEL_DEVELOPER,					// 4
	STAFF_LEVEL_SECRET						// 5
}

// Macros
#define t:%1<%2>					((%1)|=(%2))
#define f:%1<%2>					((%1)&=~(%2))

#define SetSpawn(%0,%1,%2,%3,%4)	SetSpawnInfo(%0, NO_TEAM, 0, %1, %2, %3, %4, 0,0,0,0,0,0)
#define PLAYER_DAT_FILE(%0,%1)		format(%1, MAX_PLAYER_FILE, PLAYER_DATA_FILE, %0)
#define PLAYER_INV_FILE(%0,%1)		format(%1, MAX_PLAYER_FILE, PLAYER_ITEM_FILE, %0)

#define CMD:%1(%2)					forward cmd_%1(%2);\
									public cmd_%1(%2)

#define ACMD:%1[%2](%3)				forward acmd_%1_%2(%3);\
									public acmd_%1_%2(%3)

#define HOLDING(%0)					((newkeys & (%0)) == (%0))
#define RELEASED(%0)				(((newkeys & (%0)) != (%0)) && ((oldkeys & (%0)) == (%0)))
#define PRESSED(%0)					(((newkeys & (%0)) == (%0)) && ((oldkeys & (%0)) != (%0)))


// Colours
#define YELLOW						0xFFFF00FF

#define RED							0xE85454FF
#define GREEN						0x33AA33FF
#define BLUE						0x33CCFFFF

#define ORANGE						0xFFAA00FF
#define GREY						0xAFAFAFFF
#define PINK						0xFFC0CBFF
#define NAVY						0x000080FF
#define GOLD						0xB8860BFF
#define LGREEN						0x00FD4DFF
#define TEAL						0x008080FF
#define BROWN						0xA52A2AFF
#define AQUA						0xF0F8FFFF

#define BLACK						0x000000FF
#define WHITE						0xFFFFFFFF
#define CHAT_LOCAL					0xADABD1FF
#define CHAT_RADIO					0xCFD1ABFF


// Embedding Colours
#define C_YELLOW					"{FFFF00}"

#define C_RED						"{E85454}"
#define C_GREEN						"{33AA33}"
#define C_BLUE						"{33CCFF}"

#define C_ORANGE					"{FFAA00}"
#define C_GREY						"{AFAFAF}"
#define C_PINK						"{FFC0CB}"
#define C_NAVY						"{000080}"
#define C_GOLD						"{B8860B}"
#define C_LGREEN					"{00FD4D}"
#define C_TEAL						"{008080}"
#define C_BROWN						"{A52A2A}"
#define C_AQUA						"{F0F8FF}"

#define C_BLACK						"{000000}"
#define C_WHITE						"{FFFFFF}"

#define C_SPECIAL					"{0025AA}"


#define GENDER_MALE					(0)
#define GENDER_FEMALE				(1)

enum
{
	ATTACHSLOT_ITEM,		// 0 - Same as SIF/Item
	ATTACHSLOT_BAG,			// 1 - Bag on back
	ATTACHSLOT_USE,			// 2 - Item use temp slot
	ATTACHSLOT_HOLSTER,		// 3 - Item holstering
	ATTACHSLOT_HOLD,		// 4 - Unused
	ATTACHSLOT_CUFFS,		// 5 - Handcuff slot
	ATTACHSLOT_HAT,			// 6 - Head-wear slot
	ATTACHSLOT_FACE,		// 7 - Face-wear slot
	ATTACHSLOT_BLOOD,		// 8 - Bleeding particle effect
	ATTACHSLOT_ARMOUR		// 9 - Armour model slot
}

enum
{
	DRUG_TYPE_ANTIBIOTIC,	// 0 - Remove infection
	DRUG_TYPE_PAINKILL,		// 1 - +10 HP, 5 minutes no darkness or knockouts from low HP
	DRUG_TYPE_LSD,			// 2 - Weather effects
	DRUG_TYPE_AIR,			// 3 - Health loss and death
	DRUG_TYPE_MORPHINE,		// 4 - Shaky screen and health regen
	DRUG_TYPE_ADRENALINE,	// 5 - No knockouts, camera shaking and slow health regen
	DRUG_TYPE_HEROINE		// 6 - Weather effects
}

enum
{
	CHAT_MODE_LOCAL,		// 0 - Speak to players within chatbubble distance
	CHAT_MODE_GLOBAL,		// 1 - Speak to all players
	CHAT_MODE_RADIO,		// 2 - Speak to players on the same radio frequency
	CHAT_MODE_ADMIN			// 3 - Speak to admins
}


#define KEYTEXT_INTERACT			"~k~~VEHICLE_ENTER_EXIT~"
#define KEYTEXT_PUT_AWAY			"~k~~CONVERSATION_YES~"
#define KEYTEXT_DROP_ITEM			"~k~~CONVERSATION_NO~"
#define KEYTEXT_INVENTORY			"~k~~GROUP_CONTROL_BWD~"
#define KEYTEXT_ENGINE				"~k~~CONVERSATION_YES~"
#define KEYTEXT_LIGHTS				"~k~~CONVERSATION_NO~"
#define KEYTEXT_DOORS				"~k~~TOGGLE_SUBMISSIONS~"
#define KEYTEXT_RADIO				"R"

// Dialog IDs
enum
{
	d_NULL,

// Internal Dialogs
	d_Login,
	d_Register,
	d_WelcomeMessage,

// External Dialogs
	d_SignEdit,
	d_Tires,
	d_Lights,
	d_Radio,
	d_GraveStone,

	d_ReportMenu,
	d_ReportPlayerList,
	d_ReportNameInput,
	d_ReportReason,

	d_ReportList,
	d_Report,
	d_ReportOptions,
	d_ReportBanDuration,

	d_IssueSubmit,
	d_IssueList,
	d_Issue,

	d_DefenceSetPass,
	d_DefenceEnterPass,

	d_TransferAmmoToGun,
	d_TransferAmmoToBox,
	d_TransferAmmoGun2Gun,

	d_BanReason,
	d_BanDuration,
	d_BanOptions,
	d_BanList,
	d_BanInfo,

	d_DetFieldList
}

// Keypad IDs
enum
{
	k_ControlTower,
	k_MainGate,
	k_AirstripGate,
	k_BlastDoor,
	k_Storage,
	k_StorageWatch,
	k_Generator,
	k_PassageTop,
	k_PassageBottom,
	k_Catwalk,
	k_Headquarters1,
	k_Headquarters2,
	k_Shaft,
	k_Lockup
}


/*==============================================================================

	Global Variables

==============================================================================*/


// DATABASES AND STATEMENTS
new
DB:				gAccounts,
DB:				gWorld,

// ACCOUNTS_TABLE_PLAYER
DBStatement:	gStmt_AccountExists,
DBStatement:	gStmt_AccountCreate,
DBStatement:	gStmt_AccountLoad,
DBStatement:	gStmt_AccountUpdate,
DBStatement:	gStmt_AccountDelete,
DBStatement:	gStmt_AccountSetPassword,
DBStatement:	gStmt_AccountSetIpv4,
DBStatement:	gStmt_AccountSetGpci,
DBStatement:	gStmt_AccountSetLastLog,
DBStatement:	gStmt_AccountSetSpawnTime,
DBStatement:	gStmt_AccountSetTotalSpawns,
DBStatement:	gStmt_AccountGetIpv4,
DBStatement:	gStmt_AccountGetPass,
DBStatement:	gStmt_AccountGetHash,
DBStatement:	gStmt_AccountGetAliasesIp,
DBStatement:	gStmt_AccountGetAliasesPass,
DBStatement:	gStmt_AccountGetAliasesHash,
DBStatement:	gStmt_AccountSetAimShout,

// ACCOUNTS_TABLE_BANS
DBStatement:	gStmt_BanInsert,
DBStatement:	gStmt_BanDelete,
DBStatement:	gStmt_BanGetFromNameIp,
DBStatement:	gStmt_BanGetList,
DBStatement:	gStmt_BanGetTotal,
DBStatement:	gStmt_BanGetInfo,
DBStatement:	gStmt_BanNameCheck,
DBStatement:	gStmt_BanUpdateIpv4,
DBStatement:	gStmt_BanUpdateInfo,

// ACCOUNTS_TABLE_REPORTS
DBStatement:	gStmt_ReportInsert,
DBStatement:	gStmt_ReportDelete,
DBStatement:	gStmt_ReportDeleteName,
DBStatement:	gStmt_ReportNameExists,
DBStatement:	gStmt_ReportList,
DBStatement:	gStmt_ReportInfo,
DBStatement:	gStmt_ReportSetRead,
DBStatement:	gStmt_ReportGetUnread,

// ACCOUNTS_TABLE_BUGS
DBStatement:	gStmt_BugInsert,
DBStatement:	gStmt_BugDelete,
DBStatement:	gStmt_BugList,
DBStatement:	gStmt_BugTotal,
DBStatement:	gStmt_BugInfo,

// ACCOUNTS_TABLE_WHITELIST
DBStatement:	gStmt_WhitelistExists,
DBStatement:	gStmt_WhitelistInsert,
DBStatement:	gStmt_WhitelistDelete,

// ACCOUNTS_TABLE_ADMINS
DBStatement:	gStmt_AdminLoadAll,
DBStatement:	gStmt_AdminExists,
DBStatement:	gStmt_AdminInsert,
DBStatement:	gStmt_AdminUpdate,
DBStatement:	gStmt_AdminDelete,
DBStatement:	gStmt_AdminGetLevel,

// WORLD_TABLE_SPRAYTAG
DBStatement:	gStmt_SprayTagExists,
DBStatement:	gStmt_SprayTagInsert,
DBStatement:	gStmt_SprayTagLoad,
DBStatement:	gStmt_SprayTagSave;


// SERVER SETTINGS (JSON LOADED)
new
		// player
		gMessageOfTheDay[MAX_MOTD_LEN],
		gWebsiteURL[MAX_WEBSITE_NAME],
		gGameModeName[32],
		gInfoMessage[MAX_INFO_MESSAGE][MAX_INFO_MESSAGE_LEN],
		gRuleList[MAX_RULE][MAX_RULE_LEN],
		gStaffList[MAX_STAFF][MAX_STAFF_LEN],
bool:	gWhitelist,
		gInfoMessageInterval,
		gPerformFileCheck,

		// server
bool:	gPauseMap,
bool:	gInteriorEntry,
bool:	gPlayerAnimations,
bool:	gVehicleSurfing,
Float:	gNameTagDistance,
		gCombatLogWindow,
		gLoginFreezeTime,
		gMaxTaboutTime,
		gPingLimit;

// INTERNAL
new
		gServerUptime,
bool:	gServerRestarting,
		gBigString[MAX_PLAYERS][2048],
		gTotalInfoMessage,
		gTotalRules,
		gTotalStaff,
		gCurrentInfoMessage;

// SKINS/CLOTHES
new
	skin_MainM,
	skin_MainF,

	skin_Civ1M,
	skin_Civ2M,
	skin_Civ3M,
	skin_Civ4M,
	skin_MechM,
	skin_BikeM,
	skin_ArmyM,
	skin_ClawM,
	skin_FreeM,

	skin_Civ1F,
	skin_Civ2F,
	skin_Civ3F,
	skin_Civ4F,
	skin_ArmyF,
	skin_IndiF;

// ITEM ATTACK ANIMATION HANDLES
new
	anim_Blunt,
	anim_Stab,
	anim_Heavy;


// LOOT INDEXES
enum
{
	loot_Civilian,
	loot_Industrial,
	loot_Police,
	loot_Military,
	loot_Medical,
	loot_CarCivilian,
	loot_CarIndustrial,
	loot_CarPolice,
	loot_CarMilitary,
	loot_Survivor,
	loot_SupplyCrate
}

// ITEM TYPES
new stock
ItemType:		item_Parachute		= INVALID_ITEM_TYPE,
ItemType:		item_Medkit			= INVALID_ITEM_TYPE,
ItemType:		item_HardDrive		= INVALID_ITEM_TYPE,
ItemType:		item_Key			= INVALID_ITEM_TYPE,
// 50
ItemType:		item_FireworkBox	= INVALID_ITEM_TYPE,
ItemType:		item_FireLighter	= INVALID_ITEM_TYPE,
ItemType:		item_Timer			= INVALID_ITEM_TYPE,
ItemType:		item_Explosive		= INVALID_ITEM_TYPE,
ItemType:		item_TntTimebomb	= INVALID_ITEM_TYPE,
ItemType:		item_Battery		= INVALID_ITEM_TYPE,
ItemType:		item_Fusebox		= INVALID_ITEM_TYPE,
ItemType:		item_Bottle			= INVALID_ITEM_TYPE,
ItemType:		item_Sign			= INVALID_ITEM_TYPE,
ItemType:		item_Armour			= INVALID_ITEM_TYPE,
// 60
ItemType:		item_Bandage		= INVALID_ITEM_TYPE,
ItemType:		item_FishRod		= INVALID_ITEM_TYPE,
ItemType:		item_Wrench			= INVALID_ITEM_TYPE,
ItemType:		item_Crowbar		= INVALID_ITEM_TYPE,
ItemType:		item_Hammer			= INVALID_ITEM_TYPE,
ItemType:		item_Shield			= INVALID_ITEM_TYPE,
ItemType:		item_Flashlight		= INVALID_ITEM_TYPE,
ItemType:		item_Taser			= INVALID_ITEM_TYPE,
ItemType:		item_LaserPoint		= INVALID_ITEM_TYPE,
ItemType:		item_Screwdriver	= INVALID_ITEM_TYPE,
// 70
ItemType:		item_MobilePhone	= INVALID_ITEM_TYPE,
ItemType:		item_Pager			= INVALID_ITEM_TYPE,
ItemType:		item_Rake			= INVALID_ITEM_TYPE,
ItemType:		item_HotDog			= INVALID_ITEM_TYPE,
ItemType:		item_EasterEgg		= INVALID_ITEM_TYPE,
ItemType:		item_Cane			= INVALID_ITEM_TYPE,
ItemType:		item_HandCuffs		= INVALID_ITEM_TYPE,
ItemType:		item_Bucket			= INVALID_ITEM_TYPE,
ItemType:		item_GasMask		= INVALID_ITEM_TYPE,
ItemType:		item_Flag			= INVALID_ITEM_TYPE,
// 80
ItemType:		item_DoctorBag		= INVALID_ITEM_TYPE,
ItemType:		item_Backpack		= INVALID_ITEM_TYPE,
ItemType:		item_Satchel		= INVALID_ITEM_TYPE,
ItemType:		item_Wheel			= INVALID_ITEM_TYPE,
ItemType:		item_MotionSense	= INVALID_ITEM_TYPE,
ItemType:		item_Accelerometer	= INVALID_ITEM_TYPE,
ItemType:		item_TntProxMine	= INVALID_ITEM_TYPE,
ItemType:		item_IedBomb		= INVALID_ITEM_TYPE,
ItemType:		item_Pizza			= INVALID_ITEM_TYPE,
ItemType:		item_Burger			= INVALID_ITEM_TYPE,
// 90
ItemType:		item_BurgerBox		= INVALID_ITEM_TYPE,
ItemType:		item_Taco			= INVALID_ITEM_TYPE,
ItemType:		item_GasCan			= INVALID_ITEM_TYPE,
ItemType:		item_Clothes		= INVALID_ITEM_TYPE,
ItemType:		item_HelmArmy		= INVALID_ITEM_TYPE,
ItemType:		item_MediumBox		= INVALID_ITEM_TYPE,
ItemType:		item_SmallBox		= INVALID_ITEM_TYPE,
ItemType:		item_LargeBox		= INVALID_ITEM_TYPE,
ItemType:		item_HockeyMask		= INVALID_ITEM_TYPE,
ItemType:		item_Meat			= INVALID_ITEM_TYPE,
// 100
ItemType:		item_DeadLeg		= INVALID_ITEM_TYPE,
ItemType:		item_Torso			= INVALID_ITEM_TYPE,
ItemType:		item_LongPlank		= INVALID_ITEM_TYPE,
ItemType:		item_GreenGloop		= INVALID_ITEM_TYPE,
ItemType:		item_Capsule		= INVALID_ITEM_TYPE,
ItemType:		item_RadioPole		= INVALID_ITEM_TYPE,
ItemType:		item_SignShot		= INVALID_ITEM_TYPE,
ItemType:		item_Mailbox		= INVALID_ITEM_TYPE,
ItemType:		item_Pumpkin		= INVALID_ITEM_TYPE,
ItemType:		item_Nailbat		= INVALID_ITEM_TYPE,
// 110
ItemType:		item_ZorroMask		= INVALID_ITEM_TYPE,
ItemType:		item_Barbecue		= INVALID_ITEM_TYPE,
ItemType:		item_Headlight		= INVALID_ITEM_TYPE,
ItemType:		item_Pills			= INVALID_ITEM_TYPE,
ItemType:		item_AutoInjec		= INVALID_ITEM_TYPE,
ItemType:		item_BurgerBag		= INVALID_ITEM_TYPE,
ItemType:		item_CanDrink		= INVALID_ITEM_TYPE,
ItemType:		item_Detergent		= INVALID_ITEM_TYPE,
ItemType:		item_Dice			= INVALID_ITEM_TYPE,
ItemType:		item_Dynamite		= INVALID_ITEM_TYPE,
// 120
ItemType:		item_Door			= INVALID_ITEM_TYPE,
ItemType:		item_MetPanel		= INVALID_ITEM_TYPE,
ItemType:		item_MetalGate		= INVALID_ITEM_TYPE,
ItemType:		item_CrateDoor		= INVALID_ITEM_TYPE,
ItemType:		item_CorPanel		= INVALID_ITEM_TYPE,
ItemType:		item_ShipDoor		= INVALID_ITEM_TYPE,
ItemType:		item_RustyDoor		= INVALID_ITEM_TYPE,
ItemType:		item_MetalStand		= INVALID_ITEM_TYPE,
ItemType:		item_RustyMetal		= INVALID_ITEM_TYPE,
ItemType:		item_WoodPanel		= INVALID_ITEM_TYPE,
// 130
ItemType:		item_Flare			= INVALID_ITEM_TYPE,
ItemType:		item_TntPhoneBomb	= INVALID_ITEM_TYPE,
ItemType:		item_ParaBag		= INVALID_ITEM_TYPE,
ItemType:		item_Keypad			= INVALID_ITEM_TYPE,
ItemType:		item_TentPack		= INVALID_ITEM_TYPE,
ItemType:		item_Campfire		= INVALID_ITEM_TYPE,
ItemType:		item_CowboyHat		= INVALID_ITEM_TYPE,
ItemType:		item_TruckCap		= INVALID_ITEM_TYPE,
ItemType:		item_BoaterHat		= INVALID_ITEM_TYPE,
ItemType:		item_BowlerHat		= INVALID_ITEM_TYPE,
// 140
ItemType:		item_PoliceCap		= INVALID_ITEM_TYPE,
ItemType:		item_TopHat			= INVALID_ITEM_TYPE,
ItemType:		item_Ammo9mm		= INVALID_ITEM_TYPE,
ItemType:		item_Ammo50			= INVALID_ITEM_TYPE,
ItemType:		item_AmmoBuck		= INVALID_ITEM_TYPE,
ItemType:		item_Ammo556		= INVALID_ITEM_TYPE,
ItemType:		item_Ammo357		= INVALID_ITEM_TYPE,
ItemType:		item_AmmoRocket		= INVALID_ITEM_TYPE,
ItemType:		item_MolotovEmpty	= INVALID_ITEM_TYPE,
ItemType:		item_Money			= INVALID_ITEM_TYPE,
// 150
ItemType:		item_PowerSupply	= INVALID_ITEM_TYPE,
ItemType:		item_StorageUnit	= INVALID_ITEM_TYPE,
ItemType:		item_Fluctuator		= INVALID_ITEM_TYPE,
ItemType:		item_IoUnit			= INVALID_ITEM_TYPE,
ItemType:		item_FluxCap		= INVALID_ITEM_TYPE,
ItemType:		item_DataInterface	= INVALID_ITEM_TYPE,
ItemType:		item_HackDevice		= INVALID_ITEM_TYPE,
ItemType:		item_PlantPot		= INVALID_ITEM_TYPE,
ItemType:		item_HerpDerp		= INVALID_ITEM_TYPE,
ItemType:		item_Parrot			= INVALID_ITEM_TYPE,
// 160
ItemType:		item_TntTripMine	= INVALID_ITEM_TYPE,
ItemType:		item_IedTimebomb	= INVALID_ITEM_TYPE,
ItemType:		item_IedProxMine	= INVALID_ITEM_TYPE,
ItemType:		item_IedTripMine	= INVALID_ITEM_TYPE,
ItemType:		item_IedPhoneBomb	= INVALID_ITEM_TYPE,
ItemType:		item_EmpTimebomb	= INVALID_ITEM_TYPE,
ItemType:		item_EmpProxMine	= INVALID_ITEM_TYPE,
ItemType:		item_EmpTripMine	= INVALID_ITEM_TYPE,
ItemType:		item_EmpPhoneBomb	= INVALID_ITEM_TYPE,
ItemType:		item_Gyroscope		= INVALID_ITEM_TYPE,
// 170
ItemType:		item_Motor			= INVALID_ITEM_TYPE,
ItemType:		item_StarterMotor	= INVALID_ITEM_TYPE,
ItemType:		item_FlareGun		= INVALID_ITEM_TYPE,
ItemType:		item_PetrolBomb		= INVALID_ITEM_TYPE,
ItemType:		item_CodePart		= INVALID_ITEM_TYPE,
ItemType:		item_LargeBackpack	= INVALID_ITEM_TYPE,
ItemType:		item_LocksmithKit	= INVALID_ITEM_TYPE,
ItemType:		item_XmasHat		= INVALID_ITEM_TYPE;


// UI HANDLES
new
Text:			DeathText			= Text:INVALID_TEXT_DRAW,
Text:			DeathButton			= Text:INVALID_TEXT_DRAW,
Text:			RestartCount		= Text:INVALID_TEXT_DRAW,
Text:			HitMark_centre		= Text:INVALID_TEXT_DRAW,
Text:			HitMark_offset		= Text:INVALID_TEXT_DRAW,
Text:			Branding			= Text:INVALID_TEXT_DRAW,

PlayerText:		ClassBackGround		[MAX_PLAYERS]	= {PlayerText:INVALID_TEXT_DRAW, ...},
PlayerText:		ClassButtonMale		[MAX_PLAYERS]	= {PlayerText:INVALID_TEXT_DRAW, ...},
PlayerText:		ClassButtonFemale	[MAX_PLAYERS]	= {PlayerText:INVALID_TEXT_DRAW, ...},
PlayerText:		WeaponAmmo			[MAX_PLAYERS]	= {PlayerText:INVALID_TEXT_DRAW, ...},
PlayerText:		HungerBarBackground	[MAX_PLAYERS]	= {PlayerText:INVALID_TEXT_DRAW, ...},
PlayerText:		HungerBarForeground	[MAX_PLAYERS]	= {PlayerText:INVALID_TEXT_DRAW, ...},
PlayerText:		WatchBackground		[MAX_PLAYERS]	= {PlayerText:INVALID_TEXT_DRAW, ...},
PlayerText:		WatchTime			[MAX_PLAYERS]	= {PlayerText:INVALID_TEXT_DRAW, ...},
PlayerText:		WatchBear			[MAX_PLAYERS]	= {PlayerText:INVALID_TEXT_DRAW, ...},
PlayerText:		WatchFreq			[MAX_PLAYERS]	= {PlayerText:INVALID_TEXT_DRAW, ...},
PlayerText:		ToolTip				[MAX_PLAYERS]	= {PlayerText:INVALID_TEXT_DRAW, ...},
PlayerText:		HelpTipText			[MAX_PLAYERS]	= {PlayerText:INVALID_TEXT_DRAW, ...},
PlayerText:		VehicleFuelText		[MAX_PLAYERS]	= {PlayerText:INVALID_TEXT_DRAW, ...},
PlayerText:		VehicleDamageText	[MAX_PLAYERS]	= {PlayerText:INVALID_TEXT_DRAW, ...},
PlayerText:		VehicleEngineText	[MAX_PLAYERS]	= {PlayerText:INVALID_TEXT_DRAW, ...},
PlayerText:		VehicleDoorsText	[MAX_PLAYERS]	= {PlayerText:INVALID_TEXT_DRAW, ...},
PlayerText:		VehicleNameText		[MAX_PLAYERS]	= {PlayerText:INVALID_TEXT_DRAW, ...},
PlayerText:		VehicleSpeedText	[MAX_PLAYERS]	= {PlayerText:INVALID_TEXT_DRAW, ...},

PlayerBar:		OverheatBar			= INVALID_PLAYER_BAR_ID,
PlayerBar:		ActionBar			= INVALID_PLAYER_BAR_ID,
PlayerBar:		KnockoutBar			= INVALID_PLAYER_BAR_ID,
				MiniMapOverlay;


forward OnLoad();
forward SetRestart(seconds);


/*==============================================================================

	Gamemode Scripts

==============================================================================*/


// UTILITIES
#include "SS/utils/math.pwn"
#include "SS/utils/misc.pwn"
#include "SS/utils/time.pwn"
#include "SS/utils/camera.pwn"
#include "SS/utils/message.pwn"
#include "SS/utils/vehicle.pwn"
#include "SS/utils/vehicledata.pwn"
#include "SS/utils/vehicleparts.pwn"
#include "SS/utils/zones.pwn"
#include "SS/utils/player.pwn"
#include "SS/utils/object.pwn"
#include "SS/utils/tickcountfix.pwn"

// GAME DATA
#include "SS/Data/Vehicle.pwn"
#include "SS/Data/Weapon.pwn"
#include "SS/Data/Loot.pwn"

// SERVER CORE
#include "SS/Core/Server/Settings.pwn"
#include "SS/Core/Server/TextTags.pwn"
#include "SS/Core/Server/Weather.pwn"
#include "SS/Core/Server/Whitelist.pwn"
#include "SS/Core/Server/SaveBlock.pwn"
#include "SS/Core/Server/ActivityLog.pwn"
#include "SS/Core/Server/FileCheck.pwn"
#include "SS/Core/Server/IRC.pwn"

// UI
#include "SS/Core/UI/PlayerUI.pwn"
#include "SS/Core/UI/GlobalUI.pwn"
#include "SS/Core/UI/HoldAction.pwn"
#include "SS/Core/UI/Radio.pwn"
#include "SS/Core/UI/TipText.pwn"
#include "SS/Core/UI/KeyActions.pwn"
#include "SS/Core/UI/ToolTips.pwn"
#include "SS/Core/UI/Watch.pwn"
#include "SS/Core/UI/Keypad.pwn"

// VEHICLE
#include "SS/Core/Vehicle/Core.pwn"
#include "SS/Core/Vehicle/Spawn.pwn"
#include "SS/Core/Vehicle/PlayerVehicle.pwn"
#include "SS/Core/Vehicle/Repair.pwn"
#include "SS/Core/Vehicle/LockBreak.pwn"
#include "SS/Core/Vehicle/Locksmith.pwn"
#include "SS/Core/Vehicle/Carmour.pwn"

// WEAPON
#include "SS/Core/Weapon/Core.pwn"

// LOOT
#include "SS/Core/Loot/Spawn.pwn"
#include "SS/Core/Loot/HouseLoot.pwn"

// PLAYER INTERNAL SCRIPTS
#include "SS/Core/Player/Core.pwn"
#include "SS/Core/Player/Accounts.pwn"
#include "SS/Core/Player/Aliases.pwn"
#include "SS/Core/Player/SaveLoad.pwn"
#include "SS/Core/Player/Spawn.pwn"
#include "SS/Core/Player/Damage.pwn"
#include "SS/Core/Player/Death.pwn"
#include "SS/Core/Player/Tutorial.pwn"
#include "SS/Core/Player/WelcomeMessage.pwn"
#include "SS/Core/Player/AntiCombatLog.pwn"
#include "SS/Core/Player/Chat.pwn"
#include "SS/Core/Player/CmdProcess.pwn"
#include "SS/Core/Player/Commands.pwn"
#include "SS/Core/Player/AfkCheck.pwn"
#include "SS/Core/Player/AltTabCheck.pwn"
#include "SS/Core/Player/DisallowActions.pwn"
#include "SS/Core/Player/Profile.pwn"

// CHARACTER SCRIPTS
#include "SS/Core/Char/Food.pwn"
#include "SS/Core/Char/Clothes.pwn"
#include "SS/Core/Char/Hats.pwn"
#include "SS/Core/Char/Inventory.pwn"
#include "SS/Core/Char/Animations.pwn"
#include "SS/Core/Char/MeleeItems.pwn"
#include "SS/Core/Char/KnockOut.pwn"
#include "SS/Core/Char/Disarm.pwn"
#include "SS/Core/Char/Overheat.pwn"
#include "SS/Core/Char/Towtruck.pwn"
#include "SS/Core/Char/Holster.pwn"
#include "SS/Core/Char/Infection.pwn"
#include "SS/Core/Char/Backpack.pwn"
#include "SS/Core/Char/HandCuffs.pwn"
#include "SS/Core/Char/Medical.pwn"
#include "SS/Core/Char/AimShout.pwn"
#include "SS/Core/Char/Masks.pwn"
#include "SS/Core/Char/Drugs.pwn"

// WORLD ENTITIES
#include "SS/Core/World/Fuel.pwn"
#include "SS/Core/World/Barbecue.pwn"
#include "SS/Core/World/Defences.pwn"
#include "SS/Core/World/GraveStone.pwn"
#include "SS/Core/World/SafeBox.pwn"
#include "SS/Core/World/Tent.pwn"
#include "SS/Core/World/Campfire.pwn"
#include "SS/Core/World/Workbench.pwn"
#include "SS/Core/World/Emp.pwn"
#include "SS/Core/World/Explosive.pwn"
#include "SS/Core/World/SprayTag.pwn"
#include "SS/Core/World/Sign.pwn"
#include "SS/Core/World/SupplyCrate.pwn"

// ADMINISTRATION TOOLS
#include "SS/Core/Admin/Report.pwn"
#include "SS/Core/Admin/HackDetect.pwn"
#include "SS/Core/Admin/HackTrap.pwn"
#include "SS/Core/Admin/Level1.pwn"
#include "SS/Core/Admin/Level2.pwn"
#include "SS/Core/Admin/Level3.pwn"
#include "SS/Core/Admin/Level4.pwn"
#include "SS/Core/Admin/Duty.pwn"
#include "SS/Core/Admin/Ban.pwn"
#include "SS/Core/Admin/BanCommand.pwn"
#include "SS/Core/Admin/BanList.pwn"
#include "SS/Core/Admin/Spectate.pwn"
#include "SS/Core/Admin/Core.pwn"
#include "SS/Core/Admin/BugReport.pwn"
#include "SS/Core/Admin/DetectionField.pwn"
#include "SS/Core/Admin/Mute.pwn"

// ITEMS
#include "SS/Core/Item/Food.pwn"
#include "SS/Core/Item/firework.pwn"
#include "SS/Core/Item/bottle.pwn"
#include "SS/Core/Item/TntTimeBomb.pwn"
#include "SS/Core/Item/Sign.pwn"
#include "SS/Core/Item/shield.pwn"
#include "SS/Core/Item/HandCuffs.pwn"
#include "SS/Core/Item/wheel.pwn"
#include "SS/Core/Item/gascan.pwn"
#include "SS/Core/Item/armyhelm.pwn"
#include "SS/Core/Item/zorromask.pwn"
#include "SS/Core/Item/headlight.pwn"
#include "SS/Core/Item/pills.pwn"
#include "SS/Core/Item/dice.pwn"
#include "SS/Core/Item/armour.pwn"
#include "SS/Core/Item/injector.pwn"
#include "SS/Core/Item/TntPhoneBomb.pwn"
#include "SS/Core/Item/TntTripMine.pwn"
#include "SS/Core/Item/parachute.pwn"
#include "SS/Core/Item/molotov.pwn"
#include "SS/Core/Item/screwdriver.pwn"
#include "SS/Core/Item/torso.pwn"
#include "SS/Core/Item/ammotin.pwn"
#include "SS/Core/Item/tentpack.pwn"
#include "SS/Core/Item/campfire.pwn"
#include "SS/Core/Item/cowboyhat.pwn"
#include "SS/Core/Item/truckcap.pwn"
#include "SS/Core/Item/boaterhat.pwn"
#include "SS/Core/Item/bowlerhat.pwn"
#include "SS/Core/Item/policecap.pwn"
#include "SS/Core/Item/tophat.pwn"
#include "SS/Core/Item/herpderp.pwn"
#include "SS/Core/Item/candrink.pwn"
#include "SS/Core/Item/TntProxMine.pwn"
#include "SS/Core/Item/IedTimebomb.pwn"
#include "SS/Core/Item/IedTripMine.pwn"
#include "SS/Core/Item/IedProxMine.pwn"
#include "SS/Core/Item/IedPhoneBomb.pwn"
#include "SS/Core/Item/EmpTimebomb.pwn"
#include "SS/Core/Item/EmpTripMine.pwn"
#include "SS/Core/Item/EmpProxMine.pwn"
#include "SS/Core/Item/EmpPhoneBomb.pwn"
#include "SS/Core/Item/GasMask.pwn"
#include "SS/Core/Item/HockeyMask.pwn"
#include "SS/Core/Item/XmasHat.pwn"


// POST-CODE

#include "SS/Core/Server/Autosave.pwn"

// WORLD

#include "SS/World/World.pwn"

#if !defined gMapName
	#error World script MUST have a "gMapName" variable!
#endif

#if !defined GenerateSpawnPoint
	#error World script MUST have a "GenerateSpawnPoint" function!
#endif


main()
{
	print("\n\n/*==============================================================================\n\n");
	print("    Southclaw's Scavenge and Survive");
	print("\n\n==============================================================================*/\n\n");
}




























public OnGameModeInit()
{
	print("Starting Main Game Script 'SSS' ...");

	log("*\n*\n*\n*\n*\n*\n*\n*\n*\n*\nGamemode initializing...*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*");

	djson_GameModeInit();

	if(!dir_exists(DIRECTORY_SCRIPTFILES))
	{
		print("ERROR: Directory '"DIRECTORY_SCRIPTFILES"' not found. Creating directory.");
		dir_create(DIRECTORY_SCRIPTFILES);
	}

	if(!dir_exists(DIRECTORY_SCRIPTFILES DIRECTORY_MAIN))
	{
		print("ERROR: Directory '"DIRECTORY_SCRIPTFILES DIRECTORY_MAIN"' not found. Creating directory.");
		dir_create(DIRECTORY_SCRIPTFILES DIRECTORY_MAIN);
	}

	if(!dir_exists(DIRECTORY_SCRIPTFILES DIRECTORY_VEHICLESPAWNS))
	{
		print("ERROR: Directory '"DIRECTORY_SCRIPTFILES DIRECTORY_VEHICLESPAWNS"' not found. Creating directory.");
		dir_create(DIRECTORY_SCRIPTFILES DIRECTORY_VEHICLESPAWNS);
	}

	if(!dir_exists(DIRECTORY_SCRIPTFILES DIRECTORY_DEFENCES))
	{
		print("ERROR: Directory '"DIRECTORY_SCRIPTFILES DIRECTORY_DEFENCES"' not found. Creating directory.");
		dir_create(DIRECTORY_SCRIPTFILES DIRECTORY_DEFENCES);
	}

	if(!dir_exists(DIRECTORY_SCRIPTFILES DIRECTORY_DETFIELD))
	{
		print("ERROR: Directory '"DIRECTORY_SCRIPTFILES DIRECTORY_DETFIELD"' not found. Creating directory.");
		dir_create(DIRECTORY_SCRIPTFILES DIRECTORY_DETFIELD);
	}

	if(!dir_exists(DIRECTORY_SCRIPTFILES DIRECTORY_INVENTORY))
	{
		print("ERROR: Directory '"DIRECTORY_SCRIPTFILES DIRECTORY_INVENTORY"' not found. Creating directory.");
		dir_create(DIRECTORY_SCRIPTFILES DIRECTORY_INVENTORY);
	}

	if(!dir_exists(DIRECTORY_SCRIPTFILES DIRECTORY_LOGS))
	{
		print("ERROR: Directory '"DIRECTORY_SCRIPTFILES DIRECTORY_LOGS"' not found. Creating directory.");
		dir_create(DIRECTORY_SCRIPTFILES DIRECTORY_LOGS);
	}

	if(!dir_exists(DIRECTORY_SCRIPTFILES DIRECTORY_NOTEBOOK))
	{
		print("ERROR: Directory '"DIRECTORY_SCRIPTFILES DIRECTORY_NOTEBOOK"' not found. Creating directory.");
		dir_create(DIRECTORY_SCRIPTFILES DIRECTORY_NOTEBOOK);
	}

	if(!dir_exists(DIRECTORY_SCRIPTFILES DIRECTORY_PLAYER))
	{
		print("ERROR: Directory '"DIRECTORY_SCRIPTFILES DIRECTORY_PLAYER"' not found. Creating directory.");
		dir_create(DIRECTORY_SCRIPTFILES DIRECTORY_PLAYER);
	}

	if(!dir_exists(DIRECTORY_SCRIPTFILES DIRECTORY_SAFEBOX))
	{
		print("ERROR: Directory '"DIRECTORY_SCRIPTFILES DIRECTORY_SAFEBOX"' not found. Creating directory.");
		dir_create(DIRECTORY_SCRIPTFILES DIRECTORY_SAFEBOX);
	}

	if(!dir_exists(DIRECTORY_SCRIPTFILES DIRECTORY_SIGNS))
	{
		print("ERROR: Directory '"DIRECTORY_SCRIPTFILES DIRECTORY_SIGNS"' not found. Creating directory.");
		dir_create(DIRECTORY_SCRIPTFILES DIRECTORY_SIGNS);
	}

	if(!dir_exists(DIRECTORY_SCRIPTFILES DIRECTORY_VEHICLE_DAT))
	{
		print("ERROR: Directory '"DIRECTORY_SCRIPTFILES DIRECTORY_VEHICLE_DAT"' not found. Creating directory.");
		dir_create(DIRECTORY_SCRIPTFILES DIRECTORY_VEHICLE_DAT);
	}

	if(!dir_exists(DIRECTORY_SCRIPTFILES DIRECTORY_VEHICLE_INV))
	{
		print("ERROR: Directory '"DIRECTORY_SCRIPTFILES DIRECTORY_VEHICLE_INV"' not found. Creating directory.");
		dir_create(DIRECTORY_SCRIPTFILES DIRECTORY_VEHICLE_INV);
	}

	gAccounts = db_open_persistent(ACCOUNT_DATABASE);
	gWorld = db_open_persistent(WORLD_DATABASE);

	db_free_result(db_query(gAccounts, "CREATE TABLE IF NOT EXISTS "ACCOUNTS_TABLE_PLAYER" (\
		"FIELD_PLAYER_NAME" TEXT,\
		"FIELD_PLAYER_PASS" TEXT,\
		"FIELD_PLAYER_IPV4" INTEGER,\
		"FIELD_PLAYER_ALIVE" INTEGER,\
		"FIELD_PLAYER_KARMA" INTEGER,\
		"FIELD_PLAYER_REGDATE" INTEGER,\
		"FIELD_PLAYER_LASTLOG" INTEGER,\
		"FIELD_PLAYER_SPAWNTIME" INTEGER,\
		"FIELD_PLAYER_TOTALSPAWNS" INTEGER,\
		"FIELD_PLAYER_WARNINGS" INTEGER,\
		"FIELD_PLAYER_AIMSHOUT" TEXT,\
		"FIELD_PLAYER_GPCI" TEXT)"));

	db_free_result(db_query(gAccounts, "CREATE TABLE IF NOT EXISTS "ACCOUNTS_TABLE_BANS" (\
		"FIELD_BANS_NAME" TEXT,\
		"FIELD_BANS_IPV4" INTEGER,\
		"FIELD_BANS_DATE" INTEGER,\
		"FIELD_BANS_REASON" TEXT,\
		"FIELD_BANS_BY" TEXT,\
		"FIELD_BANS_DURATION" INTEGER)"));

	db_free_result(db_query(gAccounts, "CREATE TABLE IF NOT EXISTS "ACCOUNTS_TABLE_REPORTS" (\
		"FIELD_REPORTS_NAME" TEXT,\
		"FIELD_REPORTS_REASON" TEXT,\
		"FIELD_REPORTS_DATE" INTEGER,\
		"FIELD_REPORTS_READ" INTEGER,\
		"FIELD_REPORTS_TYPE" INTEGER,\
		"FIELD_REPORTS_POSX" REAL,\
		"FIELD_REPORTS_POSY" REAL,\
		"FIELD_REPORTS_POSZ" REAL,\
		"FIELD_REPORTS_INFO" TEXT,\
		"FIELD_REPORTS_BY" TEXT)"));

	db_free_result(db_query(gAccounts, "CREATE TABLE IF NOT EXISTS "ACCOUNTS_TABLE_BUGS" (\
		"FIELD_BUGS_NAME" TEXT,\
		"FIELD_BUGS_REASON" TEXT,\
		"FIELD_BUGS_DATE" INTEGER)"));

	db_free_result(db_query(gAccounts, "CREATE TABLE IF NOT EXISTS "ACCOUNTS_TABLE_WHITELIST" (\
		"FIELD_WHITELIST_NAME" TEXT)"));

	db_free_result(db_query(gAccounts, "CREATE TABLE IF NOT EXISTS "ACCOUNTS_TABLE_ADMINS" (\
		"FIELD_ADMINS_NAME" TEXT,\
		"FIELD_ADMINS_LEVEL" INTEGER)"));


	db_free_result(db_query(gWorld, "CREATE TABLE IF NOT EXISTS "WORLD_TABLE_SPRAYTAG" (\
		"FIELD_SPRAYTAG_NAME" TEXT,\
		"FIELD_SPRAYTAG_POSX" REAL,\
		"FIELD_SPRAYTAG_POSY" REAL,\
		"FIELD_SPRAYTAG_POSZ" REAL,\
		"FIELD_SPRAYTAG_ROTX" REAL,\
		"FIELD_SPRAYTAG_ROTY" REAL,\
		"FIELD_SPRAYTAG_ROTZ" REAL)"));


	gStmt_AccountExists			= db_prepare(gAccounts, "SELECT COUNT(*) FROM "ACCOUNTS_TABLE_PLAYER" WHERE "FIELD_PLAYER_NAME" = ? COLLATE NOCASE");
	gStmt_AccountCreate			= db_prepare(gAccounts, "INSERT INTO "ACCOUNTS_TABLE_PLAYER" VALUES(?, ?, ?, 0, 0, ?, ?, 0, 0, 0, ?, ?)");
	gStmt_AccountLoad			= db_prepare(gAccounts, "SELECT * FROM "ACCOUNTS_TABLE_PLAYER" WHERE "FIELD_PLAYER_NAME" = ? COLLATE NOCASE");
	gStmt_AccountUpdate			= db_prepare(gAccounts, "UPDATE "ACCOUNTS_TABLE_PLAYER" SET "FIELD_PLAYER_ALIVE" = ?, "FIELD_PLAYER_KARMA" = ?, "FIELD_PLAYER_WARNINGS" = ? WHERE "FIELD_PLAYER_NAME" = ? COLLATE NOCASE");
	gStmt_AccountDelete			= db_prepare(gAccounts, "DELETE FROM "ACCOUNTS_TABLE_PLAYER" WHERE "FIELD_PLAYER_NAME" = ?");
	gStmt_AccountSetPassword	= db_prepare(gAccounts, "UPDATE "ACCOUNTS_TABLE_PLAYER" SET "FIELD_PLAYER_PASS" = ? WHERE "FIELD_PLAYER_NAME" = ? COLLATE NOCASE");
	gStmt_AccountSetIpv4		= db_prepare(gAccounts, "UPDATE "ACCOUNTS_TABLE_PLAYER" SET "FIELD_PLAYER_IPV4" = ? WHERE "FIELD_PLAYER_NAME" = ? COLLATE NOCASE");
	gStmt_AccountSetGpci		= db_prepare(gAccounts, "UPDATE "ACCOUNTS_TABLE_PLAYER" SET "FIELD_PLAYER_GPCI" = ? WHERE "FIELD_PLAYER_NAME" = ? COLLATE NOCASE");
	gStmt_AccountSetLastLog		= db_prepare(gAccounts, "UPDATE "ACCOUNTS_TABLE_PLAYER" SET "FIELD_PLAYER_LASTLOG" = ? WHERE "FIELD_PLAYER_NAME" = ? COLLATE NOCASE");
	gStmt_AccountSetSpawnTime	= db_prepare(gAccounts, "UPDATE "ACCOUNTS_TABLE_PLAYER" SET "FIELD_PLAYER_SPAWNTIME" = ? WHERE "FIELD_PLAYER_NAME" = ? COLLATE NOCASE");
	gStmt_AccountSetTotalSpawns	= db_prepare(gAccounts, "UPDATE "ACCOUNTS_TABLE_PLAYER" SET "FIELD_PLAYER_TOTALSPAWNS" = ? WHERE "FIELD_PLAYER_NAME" = ? COLLATE NOCASE");
	gStmt_AccountGetIpv4		= db_prepare(gAccounts, "SELECT "FIELD_PLAYER_IPV4" FROM "ACCOUNTS_TABLE_PLAYER" WHERE "FIELD_PLAYER_NAME" = ? COLLATE NOCASE");
	gStmt_AccountGetPass		= db_prepare(gAccounts, "SELECT "FIELD_PLAYER_PASS" FROM "ACCOUNTS_TABLE_PLAYER" WHERE "FIELD_PLAYER_NAME" = ? COLLATE NOCASE");
	gStmt_AccountGetHash		= db_prepare(gAccounts, "SELECT "FIELD_PLAYER_GPCI" FROM "ACCOUNTS_TABLE_PLAYER" WHERE "FIELD_PLAYER_NAME" = ? COLLATE NOCASE");
	gStmt_AccountGetAliasesIp	= db_prepare(gAccounts, "SELECT "FIELD_PLAYER_NAME" FROM "ACCOUNTS_TABLE_PLAYER" WHERE "FIELD_PLAYER_IPV4" = ? AND "FIELD_PLAYER_NAME" != ? COLLATE NOCASE");
	gStmt_AccountGetAliasesPass	= db_prepare(gAccounts, "SELECT "FIELD_PLAYER_NAME" FROM "ACCOUNTS_TABLE_PLAYER" WHERE "FIELD_PLAYER_PASS" = ? AND "FIELD_PLAYER_NAME" != ? COLLATE NOCASE");
	gStmt_AccountGetAliasesHash	= db_prepare(gAccounts, "SELECT "FIELD_PLAYER_NAME" FROM "ACCOUNTS_TABLE_PLAYER" WHERE "FIELD_PLAYER_GPCI" = ? AND "FIELD_PLAYER_NAME" != ? COLLATE NOCASE");
	gStmt_AccountSetAimShout	= db_prepare(gAccounts, "UPDATE "ACCOUNTS_TABLE_PLAYER" SET "FIELD_PLAYER_AIMSHOUT" = ? WHERE "FIELD_PLAYER_NAME" = ? COLLATE NOCASE");

	gStmt_BanInsert				= db_prepare(gAccounts, "INSERT INTO "ACCOUNTS_TABLE_BANS" VALUES(?, ?, ?, ?, ?, ?)");
	gStmt_BanDelete				= db_prepare(gAccounts, "DELETE FROM "ACCOUNTS_TABLE_BANS" WHERE "FIELD_BANS_NAME" = ? COLLATE NOCASE");
	gStmt_BanGetFromNameIp		= db_prepare(gAccounts, "SELECT COUNT(*), "FIELD_BANS_DATE", "FIELD_BANS_REASON", "FIELD_BANS_DURATION" FROM "ACCOUNTS_TABLE_BANS" WHERE "FIELD_BANS_NAME" = ? COLLATE NOCASE OR "FIELD_BANS_IPV4" = ? ORDER BY "FIELD_BANS_DATE" DESC");
	gStmt_BanGetList			= db_prepare(gAccounts, "SELECT * FROM "ACCOUNTS_TABLE_BANS" ORDER BY "FIELD_BANS_DATE" DESC LIMIT ?, ? COLLATE NOCASE");
	gStmt_BanGetTotal			= db_prepare(gAccounts, "SELECT COUNT(*) FROM "ACCOUNTS_TABLE_BANS"");
	gStmt_BanGetInfo			= db_prepare(gAccounts, "SELECT * FROM "ACCOUNTS_TABLE_BANS" WHERE "FIELD_BANS_NAME" = ? COLLATE NOCASE");
	gStmt_BanNameCheck			= db_prepare(gAccounts, "SELECT COUNT(*) FROM "ACCOUNTS_TABLE_BANS" WHERE "FIELD_BANS_NAME" = ? COLLATE NOCASE ORDER BY "FIELD_BANS_DATE" DESC");
	gStmt_BanUpdateIpv4			= db_prepare(gAccounts, "UPDATE "ACCOUNTS_TABLE_BANS" SET "FIELD_BANS_IPV4" = ? WHERE "FIELD_BANS_NAME" = ? COLLATE NOCASE");
	gStmt_BanUpdateInfo			= db_prepare(gAccounts, "UPDATE "ACCOUNTS_TABLE_BANS" SET "FIELD_BANS_REASON" = ?, "FIELD_BANS_DURATION" = ? WHERE "FIELD_BANS_NAME" = ? COLLATE NOCASE");

	gStmt_ReportInsert			= db_prepare(gAccounts, "INSERT INTO "ACCOUNTS_TABLE_REPORTS" VALUES(?, ?, ?, '0', ?, ?, ?, ?, ?, ?)");
	gStmt_ReportDelete			= db_prepare(gAccounts, "DELETE FROM "ACCOUNTS_TABLE_REPORTS" WHERE "FIELD_REPORTS_NAME" = ? AND "FIELD_REPORTS_DATE" = ?");
	gStmt_ReportDeleteName		= db_prepare(gAccounts, "DELETE FROM "ACCOUNTS_TABLE_REPORTS" WHERE "FIELD_REPORTS_NAME" = ?");
	gStmt_ReportNameExists		= db_prepare(gAccounts, "SELECT COUNT(*) FROM "ACCOUNTS_TABLE_REPORTS" WHERE "FIELD_REPORTS_NAME" = ?");
	gStmt_ReportList			= db_prepare(gAccounts, "SELECT * FROM "ACCOUNTS_TABLE_REPORTS"");
	gStmt_ReportInfo			= db_prepare(gAccounts, "SELECT * FROM "ACCOUNTS_TABLE_REPORTS" WHERE "FIELD_REPORTS_NAME" = ? AND "FIELD_REPORTS_DATE" = ?");
	gStmt_ReportSetRead			= db_prepare(gAccounts, "UPDATE "ACCOUNTS_TABLE_REPORTS" SET "FIELD_REPORTS_READ" = ? WHERE "FIELD_REPORTS_NAME" = ? AND "FIELD_REPORTS_DATE" = ?");
	gStmt_ReportGetUnread		= db_prepare(gAccounts, "SELECT COUNT(*) FROM "ACCOUNTS_TABLE_REPORTS" WHERE "FIELD_REPORTS_READ" = 0");

	gStmt_BugInsert				= db_prepare(gAccounts, "INSERT INTO "ACCOUNTS_TABLE_BUGS" VALUES(?, ?, ?)");
	gStmt_BugDelete				= db_prepare(gAccounts, "DELETE FROM "ACCOUNTS_TABLE_BUGS" WHERE "FIELD_BUGS_DATE" = ?");
	gStmt_BugList				= db_prepare(gAccounts, "SELECT * FROM "ACCOUNTS_TABLE_BUGS"");
	gStmt_BugTotal				= db_prepare(gAccounts, "SELECT COUNT(*) FROM "ACCOUNTS_TABLE_BUGS"");
	gStmt_BugInfo				= db_prepare(gAccounts, "SELECT * FROM "ACCOUNTS_TABLE_BUGS" WHERE "FIELD_BUGS_DATE" = ?");

	gStmt_WhitelistExists		= db_prepare(gAccounts, "SELECT COUNT(*) FROM "ACCOUNTS_TABLE_WHITELIST" WHERE "FIELD_WHITELIST_NAME" = ? COLLATE NOCASE");
	gStmt_WhitelistInsert		= db_prepare(gAccounts, "INSERT INTO "ACCOUNTS_TABLE_WHITELIST" ("FIELD_WHITELIST_NAME") VALUES(?)");
	gStmt_WhitelistDelete		= db_prepare(gAccounts, "DELETE FROM "ACCOUNTS_TABLE_WHITELIST" WHERE "FIELD_WHITELIST_NAME" = ?");

	gStmt_AdminLoadAll			= db_prepare(gAccounts, "SELECT * FROM "ACCOUNTS_TABLE_ADMINS" ORDER BY "FIELD_ADMINS_LEVEL" DESC");
	gStmt_AdminExists			= db_prepare(gAccounts, "SELECT COUNT(*) FROM "ACCOUNTS_TABLE_ADMINS" WHERE "FIELD_ADMINS_NAME" = ?");
	gStmt_AdminInsert			= db_prepare(gAccounts, "INSERT INTO "ACCOUNTS_TABLE_ADMINS" VALUES(?, ?)");
	gStmt_AdminUpdate			= db_prepare(gAccounts, "UPDATE "ACCOUNTS_TABLE_ADMINS" SET "FIELD_ADMINS_LEVEL" = ? WHERE "FIELD_ADMINS_NAME" = ?");
	gStmt_AdminDelete			= db_prepare(gAccounts, "DELETE FROM "ACCOUNTS_TABLE_ADMINS" WHERE "FIELD_ADMINS_NAME" = ?");
	gStmt_AdminGetLevel			= db_prepare(gAccounts, "SELECT * FROM "ACCOUNTS_TABLE_ADMINS" WHERE "FIELD_ADMINS_NAME" = ?");

	gStmt_SprayTagExists		= db_prepare(gWorld, "SELECT COUNT(*) FROM "WORLD_TABLE_SPRAYTAG" WHERE "FIELD_SPRAYTAG_POSX" = ? AND "FIELD_SPRAYTAG_POSY" = ? AND "FIELD_SPRAYTAG_POSZ" = ?");
	gStmt_SprayTagInsert		= db_prepare(gWorld, "INSERT INTO "WORLD_TABLE_SPRAYTAG" VALUES(?, ?, ?, ?, ?, ?, ?)");
	gStmt_SprayTagLoad			= db_prepare(gWorld, "SELECT * FROM "WORLD_TABLE_SPRAYTAG"");
	gStmt_SprayTagSave			= db_prepare(gWorld, "UPDATE "WORLD_TABLE_SPRAYTAG" SET "FIELD_SPRAYTAG_NAME" = ? WHERE "FIELD_SPRAYTAG_POSX" = ? AND "FIELD_SPRAYTAG_POSY" = ? AND "FIELD_SPRAYTAG_POSZ" = ?");

	LoadSettings();

	SendRconCommand(sprintf("mapname %s", gMapName));

	item_Parachute		= DefineItemType("Parachute",			371,	ITEM_SIZE_MEDIUM,	90.0, 0.0, 0.0,			0.0,	0.350542, 0.017385, 0.060469, 0.000000, 260.845062, 0.000000);
	item_Medkit			= DefineItemType("Medkit",				1580,	ITEM_SIZE_SMALL,	0.0, 0.0, 0.0,			0.0,	0.269091, 0.166367, 0.000000, 90.000000, 0.000000, 0.000000);
	item_HardDrive		= DefineItemType("Hard Drive",			328,	ITEM_SIZE_SMALL,	90.0, 0.0, 0.0,			0.0);
	item_Key			= DefineItemType("Key",					327,	ITEM_SIZE_SMALL,	0.0, 0.0, 0.0,			0.01, .colour = 0xFFCCCCCC);
// 50
	item_FireworkBox	= DefineItemType("Fireworks",			2039,	ITEM_SIZE_MEDIUM,	0.0, 0.0, 0.0,			0.0,	0.096996, 0.044811, 0.035688, 4.759557, 255.625167, 0.000000);
	item_FireLighter	= DefineItemType("Lighter",				327,	ITEM_SIZE_SMALL,	0.0, 0.0, 0.0,			0.0);
	item_Timer			= DefineItemType("Timer Device",		2922,	ITEM_SIZE_SMALL,	90.0, 0.0, 0.0,			0.0,	0.231612, 0.050027, 0.017069, 0.000000, 343.020019, 180.000000);
	item_Explosive		= DefineItemType("TNT",					1576,	ITEM_SIZE_SMALL,	0.0, 0.0, 0.0,			0.0,	0.269091, 0.166367, 0.000000, 90.000000, 0.000000, 0.000000);
	item_TntTimebomb	= DefineItemType("Timed TNT",			1252,	ITEM_SIZE_SMALL,	270.0, 0.0, 0.0,		0.0);
	item_Battery		= DefineItemType("Battery",				1579,	ITEM_SIZE_MEDIUM,	0.0, 0.0, 0.0,			0.0,	0.269091, 0.166367, 0.000000, 90.000000, 0.000000, 0.000000);
	item_Fusebox		= DefineItemType("Fuse Box",			328,	ITEM_SIZE_SMALL,	90.0, 0.0, 0.0,			0.0);
	item_Bottle			= DefineItemType("Bottle",				1543,	ITEM_SIZE_SMALL,	0.0, 0.0, 0.0,			0.0,	0.060376, 0.032063, -0.204802, 0.000000, 0.000000, 0.000000);
	item_Sign			= DefineItemType("Sign",				19471,	ITEM_SIZE_LARGE,	0.0, 0.0, 270.0,		0.0);
	item_Armour			= DefineItemType("Armour",				19515,	ITEM_SIZE_MEDIUM,	90.0, 0.0, 0.0,			0.0,	0.300333, -0.090105, 0.000000, 0.000000, 0.000000, 180.000000);
// 60
	item_Bandage		= DefineItemType("Bandage",				1575,	ITEM_SIZE_SMALL,	0.0, 0.0, 0.0,			0.0,	0.269091, 0.166367, 0.000000, 90.000000, 0.000000, 0.000000);
	item_FishRod		= DefineItemType("Fishing Rod",			18632,	ITEM_SIZE_LARGE,	90.0, 0.0, 0.0,			0.0,	0.091496, 0.019614, 0.000000, 185.619995, 354.958374, 0.000000);
	item_Wrench			= DefineItemType("Wrench",				18633,	ITEM_SIZE_SMALL,	0.0, 90.0, 0.0,			0.0,	0.084695, -0.009181, 0.152275, 98.865089, 270.085449, 0.000000);
	item_Crowbar		= DefineItemType("Crowbar",				18634,	ITEM_SIZE_SMALL,	0.0, 90.0, 0.0,			0.0,	0.066177, 0.011153, 0.038410, 97.289527, 270.962554, 1.114514);
	item_Hammer			= DefineItemType("Hammer",				18635,	ITEM_SIZE_SMALL,	270.0, 0.0, 0.0,		0.01,	0.000000, -0.008230, 0.000000, 6.428617, 0.000000, 0.000000);
	item_Shield			= DefineItemType("Shield",				18637,	ITEM_SIZE_LARGE,	0.0, 0.0, 0.0,			0.0,	-0.262389, 0.016478, -0.151046, 103.597534, 6.474381, 38.321765);
	item_Flashlight		= DefineItemType("Flashlight",			18641,	ITEM_SIZE_SMALL,	90.0, 0.0, 0.0,			0.0,	0.061910, 0.022700, 0.039052, 190.938354, 0.000000, 0.000000);
	item_Taser			= DefineItemType("Taser",				18642,	ITEM_SIZE_SMALL,	90.0, 0.0, 0.0,			0.0,	0.079878, 0.014009, 0.029525, 180.000000, 0.000000, 0.000000);
	item_LaserPoint		= DefineItemType("Laser Pointer",		18643,	ITEM_SIZE_SMALL,	0.0, 0.0, 90.0,			0.0,	0.066244, 0.010838, -0.000024, 6.443027, 287.441467, 0.000000);
	item_Screwdriver	= DefineItemType("Screwdriver",			18644,	ITEM_SIZE_SMALL,	90.0, 0.0, 0.0,			0.0,	0.099341, 0.021018, 0.009145, 193.644195, 0.000000, 0.000000);
// 70
	item_MobilePhone	= DefineItemType("Mobile Phone",		18865,	ITEM_SIZE_SMALL,	0.0, 0.0, 0.0,			0.0,	0.103904, -0.003697, -0.015173, 94.655189, 184.031860, 0.000000);<commit_msg>Fixed weird key invisibility bug with texture<commit_after>/*==============================================================================


	Southclaw's Scavenge and Survive

		Big thanks to Onfire559/Adam for the initial concept and developing
		the idea a lot long ago with some very productive discussions!
		Recently influenced by Minecraft and DayZ, credits to the creators of
		those games and their fundamental mechanics and concepts.


==============================================================================*/


#include <a_samp>

/*==============================================================================

	Library Predefinitions

==============================================================================*/

#undef MAX_PLAYERS
#define MAX_PLAYERS	(32)

native IsValidVehicle(vehicleid);
native gpci(playerid, serial[], len);

#define DB_DEBUG					false
#define DB_MAX_STATEMENTS			(54)
#define STRLIB_RETURN_SIZE			(256)
#define NOTEBOOK_FILE				"SSS/Notebook/%s.dat"
#define MAX_NOTEBOOK_FILE_NAME		(MAX_PLAYER_NAME + 18)
#define ITM_DROP_ON_DEATH			false

#define DEFAULT_POS_X				(10000.0)
#define DEFAULT_POS_Y				(10000.0)
#define DEFAULT_POS_Z				(1.0)

/*==============================================================================

	Libraries and respective links to their release pages

==============================================================================*/

#include <sscanf2>					// By Y_Less:				http://forum.sa-mp.com/showthread.php?t=120356
#include <YSI\y_utils>				// By Y_Less:				http://forum.sa-mp.com/showthread.php?p=1696956
#include <YSI\y_va>
#include <YSI\y_timers>
#include <YSI\y_hooks>
#include <YSI\y_iterate>
#include <YSI\y_ini>

#include "SS/Core/Server/Hooks.pwn"	// Internal library for hooking functions before they are used in external libraries.

#include <streamer>					// By Incognito:			http://forum.sa-mp.com/showthread.php?t=102865
//#include <irc>						// By Incognito:			http://forum.sa-mp.com/showthread.php?t=98803

#include <sqlitei>					// By Slice:				http://forum.sa-mp.com/showthread.php?t=303682
#include <formatex>					// By Slice:				http://forum.sa-mp.com/showthread.php?t=313488
#include <strlib>					// By Slice:				http://forum.sa-mp.com/showthread.php?t=362764
#include <md-sort>					// By Slice:				http://forum.sa-mp.com/showthread.php?t=343172

#define result GeoIP_result
#include <GeoIP>					// By Whitetiger:			http://forum.sa-mp.com/showthread.php?t=296171
#undef result

#define time ctime_time
#include <CTime>					// By RyDeR:				http://forum.sa-mp.com/showthread.php?t=294054
#undef time

#include <playerprogress>			// By Torbido/Southclaw:	https://github.com/Southclaw/PlayerProgressBar
#include <FileManager>				// By JaTochNietDan:		http://forum.sa-mp.com/showthread.php?t=92246
#include <djson>					// By DracoBlue:			http://forum.sa-mp.com/showthread.php?t=48439

#include <SIF/SIF>					// By Southclaw:			https://github.com/Southclaw/SIF
#include <SIF/extensions/InventoryDialog>
#include <SIF/extensions/InventoryKeys>
#include <SIF/extensions/ContainerDialog>
#include <SIF/extensions/Craft>
#include <SIF/extensions/Notebook>
#include <WeaponData>				// By Southclaw:			https://github.com/Southclaw/AdvancedWeaponData
#include <Balloon>					// By Southclaw:			https://github.com/Southclaw/Balloon
#include <Line>						// By Southclaw:			https://github.com/Southclaw/Line
#include <Zipline>					// By Southclaw:			https://github.com/Southclaw/Zipline
#include <Ladder>					// By Southclaw:			https://github.com/Southclaw/Ladder

native WP_Hash(buffer[], len, const str[]);
									// By Y_Less:				http://forum.sa-mp.com/showthread.php?t=65290


/*==============================================================================

	Definitions

==============================================================================*/


// Limits
#define MAX_MOTD_LEN				(128)
#define MAX_WEBSITE_NAME			(64)
#define MAX_INFO_MESSAGE			(8)
#define MAX_INFO_MESSAGE_LEN		(128)
#define MAX_RULE					(8)
#define MAX_RULE_LEN				(128)
#define MAX_STAFF					(8)
#define MAX_STAFF_LEN				(24)
#define MAX_PLAYER_FILE				(MAX_PLAYER_NAME+16)
#define MAX_ADMIN					(48)
#define MAX_PASSWORD_LEN			(129)
#define MAX_SERVER_UPTIME			(3600 * 9)
#define MAX_SPAWNED_VEHICLES		(250)


// Directories
#define DIRECTORY_SCRIPTFILES		"./scriptfiles/"
#define DIRECTORY_MAIN				"SSS/"
#define DIRECTORY_VEHICLESPAWNS		"Vehicles/"
#define DIRECTORY_CARMOUR			DIRECTORY_VEHICLESPAWNS"Mods/"
#define DIRECTORY_LOGS				DIRECTORY_MAIN"Logs/"
#define DIRECTORY_PLAYER			DIRECTORY_MAIN"Player/"
#define DIRECTORY_INVENTORY			DIRECTORY_MAIN"Inventory/"
#define DIRECTORY_NOTEBOOK			DIRECTORY_MAIN"Notebook/"
#define DIRECTORY_VEHICLE_DAT		DIRECTORY_MAIN"VehicleDat/"
#define DIRECTORY_VEHICLE_INV		DIRECTORY_MAIN"VehicleInv/"
#define DIRECTORY_SAFEBOX			DIRECTORY_MAIN"Safebox/"
#define DIRECTORY_TENT				DIRECTORY_MAIN"Tents/"
#define DIRECTORY_DEFENCES			DIRECTORY_MAIN"Defences/"
#define DIRECTORY_SIGNS				DIRECTORY_MAIN"Signs/"
#define DIRECTORY_DETFIELD			DIRECTORY_MAIN"Detfield/"


// Files
#define PLAYER_DATA_FILE			DIRECTORY_PLAYER"%s.dat"
#define PLAYER_ITEM_FILE			DIRECTORY_INVENTORY"%s.dat"
#define ACCOUNT_DATABASE			"SSS/Accounts.db"
#define WORLD_DATABASE				"SSS/World.db"
#define SETTINGS_FILE				"SSS/settings.json"


// Database
#define ACCOUNTS_TABLE_PLAYER		"Player"
#define ACCOUNTS_TABLE_BANS			"Bans"
#define ACCOUNTS_TABLE_REPORTS		"Reports"
#define ACCOUNTS_TABLE_BUGS			"Bugs"
#define ACCOUNTS_TABLE_WHITELIST	"Whitelist"
#define ACCOUNTS_TABLE_ADMINS		"Admins"
#define WORLD_TABLE_SPRAYTAG		"SprayTag"

// Player
#define FIELD_PLAYER_NAME			"name"		// 00
#define FIELD_PLAYER_PASS			"<PASSWORD>"		// 01
#define FIELD_PLAYER_IPV4			"ipv4"		// 02
#define FIELD_PLAYER_ALIVE			"alive"		// 03
#define FIELD_PLAYER_KARMA			"karma"		// 04
#define FIELD_PLAYER_REGDATE		"regdate"	// 05
#define FIELD_PLAYER_LASTLOG		"lastlog"	// 06
#define FIELD_PLAYER_SPAWNTIME		"spawntime"	// 07
#define FIELD_PLAYER_TOTALSPAWNS	"spawns"	// 08
#define FIELD_PLAYER_WARNINGS		"warnings"	// 09
#define FIELD_PLAYER_AIMSHOUT		"aimshout"	// 10
#define FIELD_PLAYER_GPCI			"gpci"		// 11

enum
{
	FIELD_ID_PLAYER_NAME,
	FIELD_ID_PLAYER_PASS,
	FIELD_ID_PLAYER_IPV4,
	FIELD_ID_PLAYER_ALIVE,
	FIELD_ID_PLAYER_KARMA,
	FIELD_ID_PLAYER_REGDATE,
	FIELD_ID_PLAYER_LASTLOG,
	FIELD_ID_PLAYER_SPAWNTIME,
	FIELD_ID_PLAYER_TOTALSPAWNS,
	FIELD_ID_PLAYER_WARNINGS,
	FIELD_ID_PLAYER_AIMSHOUT,
	FIELD_ID_PLAYER_GPCI
}

// Bans
#define FIELD_BANS_NAME				"name"		// 00
#define FIELD_BANS_IPV4				"ipv4"		// 01
#define FIELD_BANS_DATE				"date"		// 02
#define FIELD_BANS_REASON			"reason"	// 03
#define FIELD_BANS_BY				"by"		// 04
#define FIELD_BANS_DURATION			"duration"	// 05

enum
{
	FIELD_ID_BANS_NAME,
	FIELD_ID_BANS_IPV4,
	FIELD_ID_BANS_DATE,
	FIELD_ID_BANS_REASON,
	FIELD_ID_BANS_BY,
	FIELD_ID_BANS_DURATION
}

// Reports
#define FIELD_REPORTS_NAME			"name"		// 00
#define FIELD_REPORTS_REASON		"reason"	// 01
#define FIELD_REPORTS_DATE			"date"		// 02
#define FIELD_REPORTS_READ			"read"		// 03
#define FIELD_REPORTS_TYPE			"type"		// 04
#define FIELD_REPORTS_POSX			"posx"		// 05
#define FIELD_REPORTS_POSY			"posy"		// 06
#define FIELD_REPORTS_POSZ			"posz"		// 07
#define FIELD_REPORTS_INFO			"info"		// 08
#define FIELD_REPORTS_BY			"by"		// 09

enum
{
	FIELD_ID_REPORTS_NAME,
	FIELD_ID_REPORTS_REASON,
	FIELD_ID_REPORTS_DATE,
	FIELD_ID_REPORTS_READ,
	FIELD_ID_REPORTS_TYPE,
	FIELD_ID_REPORTS_POSX,
	FIELD_ID_REPORTS_POSY,
	FIELD_ID_REPORTS_POSZ,
	FIELD_ID_REPORTS_INFO,
	FIELD_ID_REPORTS_BY
}

// Bugs
#define FIELD_BUGS_NAME				"name"		// 00
#define FIELD_BUGS_REASON			"reason"	// 01
#define FIELD_BUGS_DATE				"date"		// 02

enum
{
	FIELD_ID_BUGS_NAME,
	FIELD_ID_BUGS_REASON,
	FIELD_ID_BUGS_DATE
}

// Whitelist
#define FIELD_WHITELIST_NAME		"name"		// 00

// Admins
#define FIELD_ADMINS_NAME			"name"		// 00
#define FIELD_ADMINS_LEVEL			"level"		// 01

// SprayTag
#define FIELD_SPRAYTAG_NAME			"name"		// 00
#define FIELD_SPRAYTAG_POSX			"posx"		// 01
#define FIELD_SPRAYTAG_POSY			"posy"		// 02
#define FIELD_SPRAYTAG_POSZ			"posz"		// 03
#define FIELD_SPRAYTAG_ROTX			"rotx"		// 04
#define FIELD_SPRAYTAG_ROTY			"roty"		// 05
#define FIELD_SPRAYTAG_ROTZ			"rotz"		// 06

enum
{
	FIELD_ID_SPRAYTAG_NAME,
	FIELD_ID_SPRAYTAG_POSX,
	FIELD_ID_SPRAYTAG_POSY,
	FIELD_ID_SPRAYTAG_POSZ,
	FIELD_ID_SPRAYTAG_ROTX,
	FIELD_ID_SPRAYTAG_ROTY,
	FIELD_ID_SPRAYTAG_ROTZ
}

enum
{
	STAFF_LEVEL_NONE,						// 0
	STAFF_LEVEL_GAME_MASTER,				// 1
	STAFF_LEVEL_MODERATOR,					// 2
	STAFF_LEVEL_ADMINISTRATOR,				// 3
	STAFF_LEVEL_DEVELOPER,					// 4
	STAFF_LEVEL_SECRET						// 5
}

// Macros
#define t:%1<%2>					((%1)|=(%2))
#define f:%1<%2>					((%1)&=~(%2))

#define SetSpawn(%0,%1,%2,%3,%4)	SetSpawnInfo(%0, NO_TEAM, 0, %1, %2, %3, %4, 0,0,0,0,0,0)
#define PLAYER_DAT_FILE(%0,%1)		format(%1, MAX_PLAYER_FILE, PLAYER_DATA_FILE, %0)
#define PLAYER_INV_FILE(%0,%1)		format(%1, MAX_PLAYER_FILE, PLAYER_ITEM_FILE, %0)

#define CMD:%1(%2)					forward cmd_%1(%2);\
									public cmd_%1(%2)

#define ACMD:%1[%2](%3)				forward acmd_%1_%2(%3);\
									public acmd_%1_%2(%3)

#define HOLDING(%0)					((newkeys & (%0)) == (%0))
#define RELEASED(%0)				(((newkeys & (%0)) != (%0)) && ((oldkeys & (%0)) == (%0)))
#define PRESSED(%0)					(((newkeys & (%0)) == (%0)) && ((oldkeys & (%0)) != (%0)))


// Colours
#define YELLOW						0xFFFF00FF

#define RED							0xE85454FF
#define GREEN						0x33AA33FF
#define BLUE						0x33CCFFFF

#define ORANGE						0xFFAA00FF
#define GREY						0xAFAFAFFF
#define PINK						0xFFC0CBFF
#define NAVY						0x000080FF
#define GOLD						0xB8860BFF
#define LGREEN						0x00FD4DFF
#define TEAL						0x008080FF
#define BROWN						0xA52A2AFF
#define AQUA						0xF0F8FFFF

#define BLACK						0x000000FF
#define WHITE						0xFFFFFFFF
#define CHAT_LOCAL					0xADABD1FF
#define CHAT_RADIO					0xCFD1ABFF


// Embedding Colours
#define C_YELLOW					"{FFFF00}"

#define C_RED						"{E85454}"
#define C_GREEN						"{33AA33}"
#define C_BLUE						"{33CCFF}"

#define C_ORANGE					"{FFAA00}"
#define C_GREY						"{AFAFAF}"
#define C_PINK						"{FFC0CB}"
#define C_NAVY						"{000080}"
#define C_GOLD						"{B8860B}"
#define C_LGREEN					"{00FD4D}"
#define C_TEAL						"{008080}"
#define C_BROWN						"{A52A2A}"
#define C_AQUA						"{F0F8FF}"

#define C_BLACK						"{000000}"
#define C_WHITE						"{FFFFFF}"

#define C_SPECIAL					"{0025AA}"


#define GENDER_MALE					(0)
#define GENDER_FEMALE				(1)

enum
{
	ATTACHSLOT_ITEM,		// 0 - Same as SIF/Item
	ATTACHSLOT_BAG,			// 1 - Bag on back
	ATTACHSLOT_USE,			// 2 - Item use temp slot
	ATTACHSLOT_HOLSTER,		// 3 - Item holstering
	ATTACHSLOT_HOLD,		// 4 - Unused
	ATTACHSLOT_CUFFS,		// 5 - Handcuff slot
	ATTACHSLOT_HAT,			// 6 - Head-wear slot
	ATTACHSLOT_FACE,		// 7 - Face-wear slot
	ATTACHSLOT_BLOOD,		// 8 - Bleeding particle effect
	ATTACHSLOT_ARMOUR		// 9 - Armour model slot
}

enum
{
	DRUG_TYPE_ANTIBIOTIC,	// 0 - Remove infection
	DRUG_TYPE_PAINKILL,		// 1 - +10 HP, 5 minutes no darkness or knockouts from low HP
	DRUG_TYPE_LSD,			// 2 - Weather effects
	DRUG_TYPE_AIR,			// 3 - Health loss and death
	DRUG_TYPE_MORPHINE,		// 4 - Shaky screen and health regen
	DRUG_TYPE_ADRENALINE,	// 5 - No knockouts, camera shaking and slow health regen
	DRUG_TYPE_HEROINE		// 6 - Weather effects
}

enum
{
	CHAT_MODE_LOCAL,		// 0 - Speak to players within chatbubble distance
	CHAT_MODE_GLOBAL,		// 1 - Speak to all players
	CHAT_MODE_RADIO,		// 2 - Speak to players on the same radio frequency
	CHAT_MODE_ADMIN			// 3 - Speak to admins
}


#define KEYTEXT_INTERACT			"~k~~VEHICLE_ENTER_EXIT~"
#define KEYTEXT_PUT_AWAY			"~k~~CONVERSATION_YES~"
#define KEYTEXT_DROP_ITEM			"~k~~CONVERSATION_NO~"
#define KEYTEXT_INVENTORY			"~k~~GROUP_CONTROL_BWD~"
#define KEYTEXT_ENGINE				"~k~~CONVERSATION_YES~"
#define KEYTEXT_LIGHTS				"~k~~CONVERSATION_NO~"
#define KEYTEXT_DOORS				"~k~~TOGGLE_SUBMISSIONS~"
#define KEYTEXT_RADIO				"R"

// Dialog IDs
enum
{
	d_NULL,

// Internal Dialogs
	d_Login,
	d_Register,
	d_WelcomeMessage,

// External Dialogs
	d_SignEdit,
	d_Tires,
	d_Lights,
	d_Radio,
	d_GraveStone,

	d_ReportMenu,
	d_ReportPlayerList,
	d_ReportNameInput,
	d_ReportReason,

	d_ReportList,
	d_Report,
	d_ReportOptions,
	d_ReportBanDuration,

	d_IssueSubmit,
	d_IssueList,
	d_Issue,

	d_DefenceSetPass,
	d_DefenceEnterPass,

	d_TransferAmmoToGun,
	d_TransferAmmoToBox,
	d_TransferAmmoGun2Gun,

	d_BanReason,
	d_BanDuration,
	d_BanOptions,
	d_BanList,
	d_BanInfo,

	d_DetFieldList
}

// Keypad IDs
enum
{
	k_ControlTower,
	k_MainGate,
	k_AirstripGate,
	k_BlastDoor,
	k_Storage,
	k_StorageWatch,
	k_Generator,
	k_PassageTop,
	k_PassageBottom,
	k_Catwalk,
	k_Headquarters1,
	k_Headquarters2,
	k_Shaft,
	k_Lockup
}


/*==============================================================================

	Global Variables

==============================================================================*/


// DATABASES AND STATEMENTS
new
DB:				gAccounts,
DB:				gWorld,

// ACCOUNTS_TABLE_PLAYER
DBStatement:	gStmt_AccountExists,
DBStatement:	gStmt_AccountCreate,
DBStatement:	gStmt_AccountLoad,
DBStatement:	gStmt_AccountUpdate,
DBStatement:	gStmt_AccountDelete,
DBStatement:	gStmt_AccountSetPassword,
DBStatement:	gStmt_AccountSetIpv4,
DBStatement:	gStmt_AccountSetGpci,
DBStatement:	gStmt_AccountSetLastLog,
DBStatement:	gStmt_AccountSetSpawnTime,
DBStatement:	gStmt_AccountSetTotalSpawns,
DBStatement:	gStmt_AccountGetIpv4,
DBStatement:	gStmt_AccountGetPass,
DBStatement:	gStmt_AccountGetHash,
DBStatement:	gStmt_AccountGetAliasesIp,
DBStatement:	gStmt_AccountGetAliasesPass,
DBStatement:	gStmt_AccountGetAliasesHash,
DBStatement:	gStmt_AccountSetAimShout,

// ACCOUNTS_TABLE_BANS
DBStatement:	gStmt_BanInsert,
DBStatement:	gStmt_BanDelete,
DBStatement:	gStmt_BanGetFromNameIp,
DBStatement:	gStmt_BanGetList,
DBStatement:	gStmt_BanGetTotal,
DBStatement:	gStmt_BanGetInfo,
DBStatement:	gStmt_BanNameCheck,
DBStatement:	gStmt_BanUpdateIpv4,
DBStatement:	gStmt_BanUpdateInfo,

// ACCOUNTS_TABLE_REPORTS
DBStatement:	gStmt_ReportInsert,
DBStatement:	gStmt_ReportDelete,
DBStatement:	gStmt_ReportDeleteName,
DBStatement:	gStmt_ReportNameExists,
DBStatement:	gStmt_ReportList,
DBStatement:	gStmt_ReportInfo,
DBStatement:	gStmt_ReportSetRead,
DBStatement:	gStmt_ReportGetUnread,

// ACCOUNTS_TABLE_BUGS
DBStatement:	gStmt_BugInsert,
DBStatement:	gStmt_BugDelete,
DBStatement:	gStmt_BugList,
DBStatement:	gStmt_BugTotal,
DBStatement:	gStmt_BugInfo,

// ACCOUNTS_TABLE_WHITELIST
DBStatement:	gStmt_WhitelistExists,
DBStatement:	gStmt_WhitelistInsert,
DBStatement:	gStmt_WhitelistDelete,

// ACCOUNTS_TABLE_ADMINS
DBStatement:	gStmt_AdminLoadAll,
DBStatement:	gStmt_AdminExists,
DBStatement:	gStmt_AdminInsert,
DBStatement:	gStmt_AdminUpdate,
DBStatement:	gStmt_AdminDelete,
DBStatement:	gStmt_AdminGetLevel,

// WORLD_TABLE_SPRAYTAG
DBStatement:	gStmt_SprayTagExists,
DBStatement:	gStmt_SprayTagInsert,
DBStatement:	gStmt_SprayTagLoad,
DBStatement:	gStmt_SprayTagSave;


// SERVER SETTINGS (JSON LOADED)
new
		// player
		gMessageOfTheDay[MAX_MOTD_LEN],
		gWebsiteURL[MAX_WEBSITE_NAME],
		gGameModeName[32],
		gInfoMessage[MAX_INFO_MESSAGE][MAX_INFO_MESSAGE_LEN],
		gRuleList[MAX_RULE][MAX_RULE_LEN],
		gStaffList[MAX_STAFF][MAX_STAFF_LEN],
bool:	gWhitelist,
		gInfoMessageInterval,
		gPerformFileCheck,

		// server
bool:	gPauseMap,
bool:	gInteriorEntry,
bool:	gPlayerAnimations,
bool:	gVehicleSurfing,
Float:	gNameTagDistance,
		gCombatLogWindow,
		gLoginFreezeTime,
		gMaxTaboutTime,
		gPingLimit;

// INTERNAL
new
		gServerUptime,
bool:	gServerRestarting,
		gBigString[MAX_PLAYERS][2048],
		gTotalInfoMessage,
		gTotalRules,
		gTotalStaff,
		gCurrentInfoMessage;

// SKINS/CLOTHES
new
	skin_MainM,
	skin_MainF,

	skin_Civ1M,
	skin_Civ2M,
	skin_Civ3M,
	skin_Civ4M,
	skin_MechM,
	skin_BikeM,
	skin_ArmyM,
	skin_ClawM,
	skin_FreeM,

	skin_Civ1F,
	skin_Civ2F,
	skin_Civ3F,
	skin_Civ4F,
	skin_ArmyF,
	skin_IndiF;

// ITEM ATTACK ANIMATION HANDLES
new
	anim_Blunt,
	anim_Stab,
	anim_Heavy;


// LOOT INDEXES
enum
{
	loot_Civilian,
	loot_Industrial,
	loot_Police,
	loot_Military,
	loot_Medical,
	loot_CarCivilian,
	loot_CarIndustrial,
	loot_CarPolice,
	loot_CarMilitary,
	loot_Survivor,
	loot_SupplyCrate
}

// ITEM TYPES
new stock
ItemType:		item_Parachute		= INVALID_ITEM_TYPE,
ItemType:		item_Medkit			= INVALID_ITEM_TYPE,
ItemType:		item_HardDrive		= INVALID_ITEM_TYPE,
ItemType:		item_Key			= INVALID_ITEM_TYPE,
// 50
ItemType:		item_FireworkBox	= INVALID_ITEM_TYPE,
ItemType:		item_FireLighter	= INVALID_ITEM_TYPE,
ItemType:		item_Timer			= INVALID_ITEM_TYPE,
ItemType:		item_Explosive		= INVALID_ITEM_TYPE,
ItemType:		item_TntTimebomb	= INVALID_ITEM_TYPE,
ItemType:		item_Battery		= INVALID_ITEM_TYPE,
ItemType:		item_Fusebox		= INVALID_ITEM_TYPE,
ItemType:		item_Bottle			= INVALID_ITEM_TYPE,
ItemType:		item_Sign			= INVALID_ITEM_TYPE,
ItemType:		item_Armour			= INVALID_ITEM_TYPE,
// 60
ItemType:		item_Bandage		= INVALID_ITEM_TYPE,
ItemType:		item_FishRod		= INVALID_ITEM_TYPE,
ItemType:		item_Wrench			= INVALID_ITEM_TYPE,
ItemType:		item_Crowbar		= INVALID_ITEM_TYPE,
ItemType:		item_Hammer			= INVALID_ITEM_TYPE,
ItemType:		item_Shield			= INVALID_ITEM_TYPE,
ItemType:		item_Flashlight		= INVALID_ITEM_TYPE,
ItemType:		item_Taser			= INVALID_ITEM_TYPE,
ItemType:		item_LaserPoint		= INVALID_ITEM_TYPE,
ItemType:		item_Screwdriver	= INVALID_ITEM_TYPE,
// 70
ItemType:		item_MobilePhone	= INVALID_ITEM_TYPE,
ItemType:		item_Pager			= INVALID_ITEM_TYPE,
ItemType:		item_Rake			= INVALID_ITEM_TYPE,
ItemType:		item_HotDog			= INVALID_ITEM_TYPE,
ItemType:		item_EasterEgg		= INVALID_ITEM_TYPE,
ItemType:		item_Cane			= INVALID_ITEM_TYPE,
ItemType:		item_HandCuffs		= INVALID_ITEM_TYPE,
ItemType:		item_Bucket			= INVALID_ITEM_TYPE,
ItemType:		item_GasMask		= INVALID_ITEM_TYPE,
ItemType:		item_Flag			= INVALID_ITEM_TYPE,
// 80
ItemType:		item_DoctorBag		= INVALID_ITEM_TYPE,
ItemType:		item_Backpack		= INVALID_ITEM_TYPE,
ItemType:		item_Satchel		= INVALID_ITEM_TYPE,
ItemType:		item_Wheel			= INVALID_ITEM_TYPE,
ItemType:		item_MotionSense	= INVALID_ITEM_TYPE,
ItemType:		item_Accelerometer	= INVALID_ITEM_TYPE,
ItemType:		item_TntProxMine	= INVALID_ITEM_TYPE,
ItemType:		item_IedBomb		= INVALID_ITEM_TYPE,
ItemType:		item_Pizza			= INVALID_ITEM_TYPE,
ItemType:		item_Burger			= INVALID_ITEM_TYPE,
// 90
ItemType:		item_BurgerBox		= INVALID_ITEM_TYPE,
ItemType:		item_Taco			= INVALID_ITEM_TYPE,
ItemType:		item_GasCan			= INVALID_ITEM_TYPE,
ItemType:		item_Clothes		= INVALID_ITEM_TYPE,
ItemType:		item_HelmArmy		= INVALID_ITEM_TYPE,
ItemType:		item_MediumBox		= INVALID_ITEM_TYPE,
ItemType:		item_SmallBox		= INVALID_ITEM_TYPE,
ItemType:		item_LargeBox		= INVALID_ITEM_TYPE,
ItemType:		item_HockeyMask		= INVALID_ITEM_TYPE,
ItemType:		item_Meat			= INVALID_ITEM_TYPE,
// 100
ItemType:		item_DeadLeg		= INVALID_ITEM_TYPE,
ItemType:		item_Torso			= INVALID_ITEM_TYPE,
ItemType:		item_LongPlank		= INVALID_ITEM_TYPE,
ItemType:		item_GreenGloop		= INVALID_ITEM_TYPE,
ItemType:		item_Capsule		= INVALID_ITEM_TYPE,
ItemType:		item_RadioPole		= INVALID_ITEM_TYPE,
ItemType:		item_SignShot		= INVALID_ITEM_TYPE,
ItemType:		item_Mailbox		= INVALID_ITEM_TYPE,
ItemType:		item_Pumpkin		= INVALID_ITEM_TYPE,
ItemType:		item_Nailbat		= INVALID_ITEM_TYPE,
// 110
ItemType:		item_ZorroMask		= INVALID_ITEM_TYPE,
ItemType:		item_Barbecue		= INVALID_ITEM_TYPE,
ItemType:		item_Headlight		= INVALID_ITEM_TYPE,
ItemType:		item_Pills			= INVALID_ITEM_TYPE,
ItemType:		item_AutoInjec		= INVALID_ITEM_TYPE,
ItemType:		item_BurgerBag		= INVALID_ITEM_TYPE,
ItemType:		item_CanDrink		= INVALID_ITEM_TYPE,
ItemType:		item_Detergent		= INVALID_ITEM_TYPE,
ItemType:		item_Dice			= INVALID_ITEM_TYPE,
ItemType:		item_Dynamite		= INVALID_ITEM_TYPE,
// 120
ItemType:		item_Door			= INVALID_ITEM_TYPE,
ItemType:		item_MetPanel		= INVALID_ITEM_TYPE,
ItemType:		item_MetalGate		= INVALID_ITEM_TYPE,
ItemType:		item_CrateDoor		= INVALID_ITEM_TYPE,
ItemType:		item_CorPanel		= INVALID_ITEM_TYPE,
ItemType:		item_ShipDoor		= INVALID_ITEM_TYPE,
ItemType:		item_RustyDoor		= INVALID_ITEM_TYPE,
ItemType:		item_MetalStand		= INVALID_ITEM_TYPE,
ItemType:		item_RustyMetal		= INVALID_ITEM_TYPE,
ItemType:		item_WoodPanel		= INVALID_ITEM_TYPE,
// 130
ItemType:		item_Flare			= INVALID_ITEM_TYPE,
ItemType:		item_TntPhoneBomb	= INVALID_ITEM_TYPE,
ItemType:		item_ParaBag		= INVALID_ITEM_TYPE,
ItemType:		item_Keypad			= INVALID_ITEM_TYPE,
ItemType:		item_TentPack		= INVALID_ITEM_TYPE,
ItemType:		item_Campfire		= INVALID_ITEM_TYPE,
ItemType:		item_CowboyHat		= INVALID_ITEM_TYPE,
ItemType:		item_TruckCap		= INVALID_ITEM_TYPE,
ItemType:		item_BoaterHat		= INVALID_ITEM_TYPE,
ItemType:		item_BowlerHat		= INVALID_ITEM_TYPE,
// 140
ItemType:		item_PoliceCap		= INVALID_ITEM_TYPE,
ItemType:		item_TopHat			= INVALID_ITEM_TYPE,
ItemType:		item_Ammo9mm		= INVALID_ITEM_TYPE,
ItemType:		item_Ammo50			= INVALID_ITEM_TYPE,
ItemType:		item_AmmoBuck		= INVALID_ITEM_TYPE,
ItemType:		item_Ammo556		= INVALID_ITEM_TYPE,
ItemType:		item_Ammo357		= INVALID_ITEM_TYPE,
ItemType:		item_AmmoRocket		= INVALID_ITEM_TYPE,
ItemType:		item_MolotovEmpty	= INVALID_ITEM_TYPE,
ItemType:		item_Money			= INVALID_ITEM_TYPE,
// 150
ItemType:		item_PowerSupply	= INVALID_ITEM_TYPE,
ItemType:		item_StorageUnit	= INVALID_ITEM_TYPE,
ItemType:		item_Fluctuator		= INVALID_ITEM_TYPE,
ItemType:		item_IoUnit			= INVALID_ITEM_TYPE,
ItemType:		item_FluxCap		= INVALID_ITEM_TYPE,
ItemType:		item_DataInterface	= INVALID_ITEM_TYPE,
ItemType:		item_HackDevice		= INVALID_ITEM_TYPE,
ItemType:		item_PlantPot		= INVALID_ITEM_TYPE,
ItemType:		item_HerpDerp		= INVALID_ITEM_TYPE,
ItemType:		item_Parrot			= INVALID_ITEM_TYPE,
// 160
ItemType:		item_TntTripMine	= INVALID_ITEM_TYPE,
ItemType:		item_IedTimebomb	= INVALID_ITEM_TYPE,
ItemType:		item_IedProxMine	= INVALID_ITEM_TYPE,
ItemType:		item_IedTripMine	= INVALID_ITEM_TYPE,
ItemType:		item_IedPhoneBomb	= INVALID_ITEM_TYPE,
ItemType:		item_EmpTimebomb	= INVALID_ITEM_TYPE,
ItemType:		item_EmpProxMine	= INVALID_ITEM_TYPE,
ItemType:		item_EmpTripMine	= INVALID_ITEM_TYPE,
ItemType:		item_EmpPhoneBomb	= INVALID_ITEM_TYPE,
ItemType:		item_Gyroscope		= INVALID_ITEM_TYPE,
// 170
ItemType:		item_Motor			= INVALID_ITEM_TYPE,
ItemType:		item_StarterMotor	= INVALID_ITEM_TYPE,
ItemType:		item_FlareGun		= INVALID_ITEM_TYPE,
ItemType:		item_PetrolBomb		= INVALID_ITEM_TYPE,
ItemType:		item_CodePart		= INVALID_ITEM_TYPE,
ItemType:		item_LargeBackpack	= INVALID_ITEM_TYPE,
ItemType:		item_LocksmithKit	= INVALID_ITEM_TYPE,
ItemType:		item_XmasHat		= INVALID_ITEM_TYPE;


// UI HANDLES
new
Text:			DeathText			= Text:INVALID_TEXT_DRAW,
Text:			DeathButton			= Text:INVALID_TEXT_DRAW,
Text:			RestartCount		= Text:INVALID_TEXT_DRAW,
Text:			HitMark_centre		= Text:INVALID_TEXT_DRAW,
Text:			HitMark_offset		= Text:INVALID_TEXT_DRAW,
Text:			Branding			= Text:INVALID_TEXT_DRAW,

PlayerText:		ClassBackGround		[MAX_PLAYERS]	= {PlayerText:INVALID_TEXT_DRAW, ...},
PlayerText:		ClassButtonMale		[MAX_PLAYERS]	= {PlayerText:INVALID_TEXT_DRAW, ...},
PlayerText:		ClassButtonFemale	[MAX_PLAYERS]	= {PlayerText:INVALID_TEXT_DRAW, ...},
PlayerText:		WeaponAmmo			[MAX_PLAYERS]	= {PlayerText:INVALID_TEXT_DRAW, ...},
PlayerText:		HungerBarBackground	[MAX_PLAYERS]	= {PlayerText:INVALID_TEXT_DRAW, ...},
PlayerText:		HungerBarForeground	[MAX_PLAYERS]	= {PlayerText:INVALID_TEXT_DRAW, ...},
PlayerText:		WatchBackground		[MAX_PLAYERS]	= {PlayerText:INVALID_TEXT_DRAW, ...},
PlayerText:		WatchTime			[MAX_PLAYERS]	= {PlayerText:INVALID_TEXT_DRAW, ...},
PlayerText:		WatchBear			[MAX_PLAYERS]	= {PlayerText:INVALID_TEXT_DRAW, ...},
PlayerText:		WatchFreq			[MAX_PLAYERS]	= {PlayerText:INVALID_TEXT_DRAW, ...},
PlayerText:		ToolTip				[MAX_PLAYERS]	= {PlayerText:INVALID_TEXT_DRAW, ...},
PlayerText:		HelpTipText			[MAX_PLAYERS]	= {PlayerText:INVALID_TEXT_DRAW, ...},
PlayerText:		VehicleFuelText		[MAX_PLAYERS]	= {PlayerText:INVALID_TEXT_DRAW, ...},
PlayerText:		VehicleDamageText	[MAX_PLAYERS]	= {PlayerText:INVALID_TEXT_DRAW, ...},
PlayerText:		VehicleEngineText	[MAX_PLAYERS]	= {PlayerText:INVALID_TEXT_DRAW, ...},
PlayerText:		VehicleDoorsText	[MAX_PLAYERS]	= {PlayerText:INVALID_TEXT_DRAW, ...},
PlayerText:		VehicleNameText		[MAX_PLAYERS]	= {PlayerText:INVALID_TEXT_DRAW, ...},
PlayerText:		VehicleSpeedText	[MAX_PLAYERS]	= {PlayerText:INVALID_TEXT_DRAW, ...},

PlayerBar:		OverheatBar			= INVALID_PLAYER_BAR_ID,
PlayerBar:		ActionBar			= INVALID_PLAYER_BAR_ID,
PlayerBar:		KnockoutBar			= INVALID_PLAYER_BAR_ID,
				MiniMapOverlay;


forward OnLoad();
forward SetRestart(seconds);


/*==============================================================================

	Gamemode Scripts

==============================================================================*/


// UTILITIES
#include "SS/utils/math.pwn"
#include "SS/utils/misc.pwn"
#include "SS/utils/time.pwn"
#include "SS/utils/camera.pwn"
#include "SS/utils/message.pwn"
#include "SS/utils/vehicle.pwn"
#include "SS/utils/vehicledata.pwn"
#include "SS/utils/vehicleparts.pwn"
#include "SS/utils/zones.pwn"
#include "SS/utils/player.pwn"
#include "SS/utils/object.pwn"
#include "SS/utils/tickcountfix.pwn"

// GAME DATA
#include "SS/Data/Vehicle.pwn"
#include "SS/Data/Weapon.pwn"
#include "SS/Data/Loot.pwn"

// SERVER CORE
#include "SS/Core/Server/Settings.pwn"
#include "SS/Core/Server/TextTags.pwn"
#include "SS/Core/Server/Weather.pwn"
#include "SS/Core/Server/Whitelist.pwn"
#include "SS/Core/Server/SaveBlock.pwn"
#include "SS/Core/Server/ActivityLog.pwn"
#include "SS/Core/Server/FileCheck.pwn"
#include "SS/Core/Server/IRC.pwn"

// UI
#include "SS/Core/UI/PlayerUI.pwn"
#include "SS/Core/UI/GlobalUI.pwn"
#include "SS/Core/UI/HoldAction.pwn"
#include "SS/Core/UI/Radio.pwn"
#include "SS/Core/UI/TipText.pwn"
#include "SS/Core/UI/KeyActions.pwn"
#include "SS/Core/UI/ToolTips.pwn"
#include "SS/Core/UI/Watch.pwn"
#include "SS/Core/UI/Keypad.pwn"

// VEHICLE
#include "SS/Core/Vehicle/Core.pwn"
#include "SS/Core/Vehicle/Spawn.pwn"
#include "SS/Core/Vehicle/PlayerVehicle.pwn"
#include "SS/Core/Vehicle/Repair.pwn"
#include "SS/Core/Vehicle/LockBreak.pwn"
#include "SS/Core/Vehicle/Locksmith.pwn"
#include "SS/Core/Vehicle/Carmour.pwn"

// WEAPON
#include "SS/Core/Weapon/Core.pwn"

// LOOT
#include "SS/Core/Loot/Spawn.pwn"
#include "SS/Core/Loot/HouseLoot.pwn"

// PLAYER INTERNAL SCRIPTS
#include "SS/Core/Player/Core.pwn"
#include "SS/Core/Player/Accounts.pwn"
#include "SS/Core/Player/Aliases.pwn"
#include "SS/Core/Player/SaveLoad.pwn"
#include "SS/Core/Player/Spawn.pwn"
#include "SS/Core/Player/Damage.pwn"
#include "SS/Core/Player/Death.pwn"
#include "SS/Core/Player/Tutorial.pwn"
#include "SS/Core/Player/WelcomeMessage.pwn"
#include "SS/Core/Player/AntiCombatLog.pwn"
#include "SS/Core/Player/Chat.pwn"
#include "SS/Core/Player/CmdProcess.pwn"
#include "SS/Core/Player/Commands.pwn"
#include "SS/Core/Player/AfkCheck.pwn"
#include "SS/Core/Player/AltTabCheck.pwn"
#include "SS/Core/Player/DisallowActions.pwn"
#include "SS/Core/Player/Profile.pwn"

// CHARACTER SCRIPTS
#include "SS/Core/Char/Food.pwn"
#include "SS/Core/Char/Clothes.pwn"
#include "SS/Core/Char/Hats.pwn"
#include "SS/Core/Char/Inventory.pwn"
#include "SS/Core/Char/Animations.pwn"
#include "SS/Core/Char/MeleeItems.pwn"
#include "SS/Core/Char/KnockOut.pwn"
#include "SS/Core/Char/Disarm.pwn"
#include "SS/Core/Char/Overheat.pwn"
#include "SS/Core/Char/Towtruck.pwn"
#include "SS/Core/Char/Holster.pwn"
#include "SS/Core/Char/Infection.pwn"
#include "SS/Core/Char/Backpack.pwn"
#include "SS/Core/Char/HandCuffs.pwn"
#include "SS/Core/Char/Medical.pwn"
#include "SS/Core/Char/AimShout.pwn"
#include "SS/Core/Char/Masks.pwn"
#include "SS/Core/Char/Drugs.pwn"

// WORLD ENTITIES
#include "SS/Core/World/Fuel.pwn"
#include "SS/Core/World/Barbecue.pwn"
#include "SS/Core/World/Defences.pwn"
#include "SS/Core/World/GraveStone.pwn"
#include "SS/Core/World/SafeBox.pwn"
#include "SS/Core/World/Tent.pwn"
#include "SS/Core/World/Campfire.pwn"
#include "SS/Core/World/Workbench.pwn"
#include "SS/Core/World/Emp.pwn"
#include "SS/Core/World/Explosive.pwn"
#include "SS/Core/World/SprayTag.pwn"
#include "SS/Core/World/Sign.pwn"
#include "SS/Core/World/SupplyCrate.pwn"

// ADMINISTRATION TOOLS
#include "SS/Core/Admin/Report.pwn"
#include "SS/Core/Admin/HackDetect.pwn"
#include "SS/Core/Admin/HackTrap.pwn"
#include "SS/Core/Admin/Level1.pwn"
#include "SS/Core/Admin/Level2.pwn"
#include "SS/Core/Admin/Level3.pwn"
#include "SS/Core/Admin/Level4.pwn"
#include "SS/Core/Admin/Duty.pwn"
#include "SS/Core/Admin/Ban.pwn"
#include "SS/Core/Admin/BanCommand.pwn"
#include "SS/Core/Admin/BanList.pwn"
#include "SS/Core/Admin/Spectate.pwn"
#include "SS/Core/Admin/Core.pwn"
#include "SS/Core/Admin/BugReport.pwn"
#include "SS/Core/Admin/DetectionField.pwn"
#include "SS/Core/Admin/Mute.pwn"

// ITEMS
#include "SS/Core/Item/Food.pwn"
#include "SS/Core/Item/firework.pwn"
#include "SS/Core/Item/bottle.pwn"
#include "SS/Core/Item/TntTimeBomb.pwn"
#include "SS/Core/Item/Sign.pwn"
#include "SS/Core/Item/shield.pwn"
#include "SS/Core/Item/HandCuffs.pwn"
#include "SS/Core/Item/wheel.pwn"
#include "SS/Core/Item/gascan.pwn"
#include "SS/Core/Item/armyhelm.pwn"
#include "SS/Core/Item/zorromask.pwn"
#include "SS/Core/Item/headlight.pwn"
#include "SS/Core/Item/pills.pwn"
#include "SS/Core/Item/dice.pwn"
#include "SS/Core/Item/armour.pwn"
#include "SS/Core/Item/injector.pwn"
#include "SS/Core/Item/TntPhoneBomb.pwn"
#include "SS/Core/Item/TntTripMine.pwn"
#include "SS/Core/Item/parachute.pwn"
#include "SS/Core/Item/molotov.pwn"
#include "SS/Core/Item/screwdriver.pwn"
#include "SS/Core/Item/torso.pwn"
#include "SS/Core/Item/ammotin.pwn"
#include "SS/Core/Item/tentpack.pwn"
#include "SS/Core/Item/campfire.pwn"
#include "SS/Core/Item/cowboyhat.pwn"
#include "SS/Core/Item/truckcap.pwn"
#include "SS/Core/Item/boaterhat.pwn"
#include "SS/Core/Item/bowlerhat.pwn"
#include "SS/Core/Item/policecap.pwn"
#include "SS/Core/Item/tophat.pwn"
#include "SS/Core/Item/herpderp.pwn"
#include "SS/Core/Item/candrink.pwn"
#include "SS/Core/Item/TntProxMine.pwn"
#include "SS/Core/Item/IedTimebomb.pwn"
#include "SS/Core/Item/IedTripMine.pwn"
#include "SS/Core/Item/IedProxMine.pwn"
#include "SS/Core/Item/IedPhoneBomb.pwn"
#include "SS/Core/Item/EmpTimebomb.pwn"
#include "SS/Core/Item/EmpTripMine.pwn"
#include "SS/Core/Item/EmpProxMine.pwn"
#include "SS/Core/Item/EmpPhoneBomb.pwn"
#include "SS/Core/Item/GasMask.pwn"
#include "SS/Core/Item/HockeyMask.pwn"
#include "SS/Core/Item/XmasHat.pwn"


// POST-CODE

#include "SS/Core/Server/Autosave.pwn"

// WORLD

#include "SS/World/World.pwn"

#if !defined gMapName
	#error World script MUST have a "gMapName" variable!
#endif

#if !defined GenerateSpawnPoint
	#error World script MUST have a "GenerateSpawnPoint" function!
#endif


main()
{
	print("\n\n/*==============================================================================\n\n");
	print("    Southclaw's Scavenge and Survive");
	print("\n\n==============================================================================*/\n\n");
}




























public OnGameModeInit()
{
	print("Starting Main Game Script 'SSS' ...");

	log("*\n*\n*\n*\n*\n*\n*\n*\n*\n*\nGamemode initializing...*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*");

	djson_GameModeInit();

	if(!dir_exists(DIRECTORY_SCRIPTFILES))
	{
		print("ERROR: Directory '"DIRECTORY_SCRIPTFILES"' not found. Creating directory.");
		dir_create(DIRECTORY_SCRIPTFILES);
	}

	if(!dir_exists(DIRECTORY_SCRIPTFILES DIRECTORY_MAIN))
	{
		print("ERROR: Directory '"DIRECTORY_SCRIPTFILES DIRECTORY_MAIN"' not found. Creating directory.");
		dir_create(DIRECTORY_SCRIPTFILES DIRECTORY_MAIN);
	}

	if(!dir_exists(DIRECTORY_SCRIPTFILES DIRECTORY_VEHICLESPAWNS))
	{
		print("ERROR: Directory '"DIRECTORY_SCRIPTFILES DIRECTORY_VEHICLESPAWNS"' not found. Creating directory.");
		dir_create(DIRECTORY_SCRIPTFILES DIRECTORY_VEHICLESPAWNS);
	}

	if(!dir_exists(DIRECTORY_SCRIPTFILES DIRECTORY_DEFENCES))
	{
		print("ERROR: Directory '"DIRECTORY_SCRIPTFILES DIRECTORY_DEFENCES"' not found. Creating directory.");
		dir_create(DIRECTORY_SCRIPTFILES DIRECTORY_DEFENCES);
	}

	if(!dir_exists(DIRECTORY_SCRIPTFILES DIRECTORY_DETFIELD))
	{
		print("ERROR: Directory '"DIRECTORY_SCRIPTFILES DIRECTORY_DETFIELD"' not found. Creating directory.");
		dir_create(DIRECTORY_SCRIPTFILES DIRECTORY_DETFIELD);
	}

	if(!dir_exists(DIRECTORY_SCRIPTFILES DIRECTORY_INVENTORY))
	{
		print("ERROR: Directory '"DIRECTORY_SCRIPTFILES DIRECTORY_INVENTORY"' not found. Creating directory.");
		dir_create(DIRECTORY_SCRIPTFILES DIRECTORY_INVENTORY);
	}

	if(!dir_exists(DIRECTORY_SCRIPTFILES DIRECTORY_LOGS))
	{
		print("ERROR: Directory '"DIRECTORY_SCRIPTFILES DIRECTORY_LOGS"' not found. Creating directory.");
		dir_create(DIRECTORY_SCRIPTFILES DIRECTORY_LOGS);
	}

	if(!dir_exists(DIRECTORY_SCRIPTFILES DIRECTORY_NOTEBOOK))
	{
		print("ERROR: Directory '"DIRECTORY_SCRIPTFILES DIRECTORY_NOTEBOOK"' not found. Creating directory.");
		dir_create(DIRECTORY_SCRIPTFILES DIRECTORY_NOTEBOOK);
	}

	if(!dir_exists(DIRECTORY_SCRIPTFILES DIRECTORY_PLAYER))
	{
		print("ERROR: Directory '"DIRECTORY_SCRIPTFILES DIRECTORY_PLAYER"' not found. Creating directory.");
		dir_create(DIRECTORY_SCRIPTFILES DIRECTORY_PLAYER);
	}

	if(!dir_exists(DIRECTORY_SCRIPTFILES DIRECTORY_SAFEBOX))
	{
		print("ERROR: Directory '"DIRECTORY_SCRIPTFILES DIRECTORY_SAFEBOX"' not found. Creating directory.");
		dir_create(DIRECTORY_SCRIPTFILES DIRECTORY_SAFEBOX);
	}

	if(!dir_exists(DIRECTORY_SCRIPTFILES DIRECTORY_SIGNS))
	{
		print("ERROR: Directory '"DIRECTORY_SCRIPTFILES DIRECTORY_SIGNS"' not found. Creating directory.");
		dir_create(DIRECTORY_SCRIPTFILES DIRECTORY_SIGNS);
	}

	if(!dir_exists(DIRECTORY_SCRIPTFILES DIRECTORY_VEHICLE_DAT))
	{
		print("ERROR: Directory '"DIRECTORY_SCRIPTFILES DIRECTORY_VEHICLE_DAT"' not found. Creating directory.");
		dir_create(DIRECTORY_SCRIPTFILES DIRECTORY_VEHICLE_DAT);
	}

	if(!dir_exists(DIRECTORY_SCRIPTFILES DIRECTORY_VEHICLE_INV))
	{
		print("ERROR: Directory '"DIRECTORY_SCRIPTFILES DIRECTORY_VEHICLE_INV"' not found. Creating directory.");
		dir_create(DIRECTORY_SCRIPTFILES DIRECTORY_VEHICLE_INV);
	}

	gAccounts = db_open_persistent(ACCOUNT_DATABASE);
	gWorld = db_open_persistent(WORLD_DATABASE);

	db_free_result(db_query(gAccounts, "CREATE TABLE IF NOT EXISTS "ACCOUNTS_TABLE_PLAYER" (\
		"FIELD_PLAYER_NAME" TEXT,\
		"FIELD_PLAYER_PASS" TEXT,\
		"FIELD_PLAYER_IPV4" INTEGER,\
		"FIELD_PLAYER_ALIVE" INTEGER,\
		"FIELD_PLAYER_KARMA" INTEGER,\
		"FIELD_PLAYER_REGDATE" INTEGER,\
		"FIELD_PLAYER_LASTLOG" INTEGER,\
		"FIELD_PLAYER_SPAWNTIME" INTEGER,\
		"FIELD_PLAYER_TOTALSPAWNS" INTEGER,\
		"FIELD_PLAYER_WARNINGS" INTEGER,\
		"FIELD_PLAYER_AIMSHOUT" TEXT,\
		"FIELD_PLAYER_GPCI" TEXT)"));

	db_free_result(db_query(gAccounts, "CREATE TABLE IF NOT EXISTS "ACCOUNTS_TABLE_BANS" (\
		"FIELD_BANS_NAME" TEXT,\
		"FIELD_BANS_IPV4" INTEGER,\
		"FIELD_BANS_DATE" INTEGER,\
		"FIELD_BANS_REASON" TEXT,\
		"FIELD_BANS_BY" TEXT,\
		"FIELD_BANS_DURATION" INTEGER)"));

	db_free_result(db_query(gAccounts, "CREATE TABLE IF NOT EXISTS "ACCOUNTS_TABLE_REPORTS" (\
		"FIELD_REPORTS_NAME" TEXT,\
		"FIELD_REPORTS_REASON" TEXT,\
		"FIELD_REPORTS_DATE" INTEGER,\
		"FIELD_REPORTS_READ" INTEGER,\
		"FIELD_REPORTS_TYPE" INTEGER,\
		"FIELD_REPORTS_POSX" REAL,\
		"FIELD_REPORTS_POSY" REAL,\
		"FIELD_REPORTS_POSZ" REAL,\
		"FIELD_REPORTS_INFO" TEXT,\
		"FIELD_REPORTS_BY" TEXT)"));

	db_free_result(db_query(gAccounts, "CREATE TABLE IF NOT EXISTS "ACCOUNTS_TABLE_BUGS" (\
		"FIELD_BUGS_NAME" TEXT,\
		"FIELD_BUGS_REASON" TEXT,\
		"FIELD_BUGS_DATE" INTEGER)"));

	db_free_result(db_query(gAccounts, "CREATE TABLE IF NOT EXISTS "ACCOUNTS_TABLE_WHITELIST" (\
		"FIELD_WHITELIST_NAME" TEXT)"));

	db_free_result(db_query(gAccounts, "CREATE TABLE IF NOT EXISTS "ACCOUNTS_TABLE_ADMINS" (\
		"FIELD_ADMINS_NAME" TEXT,\
		"FIELD_ADMINS_LEVEL" INTEGER)"));


	db_free_result(db_query(gWorld, "CREATE TABLE IF NOT EXISTS "WORLD_TABLE_SPRAYTAG" (\
		"FIELD_SPRAYTAG_NAME" TEXT,\
		"FIELD_SPRAYTAG_POSX" REAL,\
		"FIELD_SPRAYTAG_POSY" REAL,\
		"FIELD_SPRAYTAG_POSZ" REAL,\
		"FIELD_SPRAYTAG_ROTX" REAL,\
		"FIELD_SPRAYTAG_ROTY" REAL,\
		"FIELD_SPRAYTAG_ROTZ" REAL)"));


	gStmt_AccountExists			= db_prepare(gAccounts, "SELECT COUNT(*) FROM "ACCOUNTS_TABLE_PLAYER" WHERE "FIELD_PLAYER_NAME" = ? COLLATE NOCASE");
	gStmt_AccountCreate			= db_prepare(gAccounts, "INSERT INTO "ACCOUNTS_TABLE_PLAYER" VALUES(?, ?, ?, 0, 0, ?, ?, 0, 0, 0, ?, ?)");
	gStmt_AccountLoad			= db_prepare(gAccounts, "SELECT * FROM "ACCOUNTS_TABLE_PLAYER" WHERE "FIELD_PLAYER_NAME" = ? COLLATE NOCASE");
	gStmt_AccountUpdate			= db_prepare(gAccounts, "UPDATE "ACCOUNTS_TABLE_PLAYER" SET "FIELD_PLAYER_ALIVE" = ?, "FIELD_PLAYER_KARMA" = ?, "FIELD_PLAYER_WARNINGS" = ? WHERE "FIELD_PLAYER_NAME" = ? COLLATE NOCASE");
	gStmt_AccountDelete			= db_prepare(gAccounts, "DELETE FROM "ACCOUNTS_TABLE_PLAYER" WHERE "FIELD_PLAYER_NAME" = ?");
	gStmt_AccountSetPassword	= db_prepare(gAccounts, "UPDATE "ACCOUNTS_TABLE_PLAYER" SET "FIELD_PLAYER_PASS" = ? WHERE "FIELD_PLAYER_NAME" = ? COLLATE NOCASE");
	gStmt_AccountSetIpv4		= db_prepare(gAccounts, "UPDATE "ACCOUNTS_TABLE_PLAYER" SET "FIELD_PLAYER_IPV4" = ? WHERE "FIELD_PLAYER_NAME" = ? COLLATE NOCASE");
	gStmt_AccountSetGpci		= db_prepare(gAccounts, "UPDATE "ACCOUNTS_TABLE_PLAYER" SET "FIELD_PLAYER_GPCI" = ? WHERE "FIELD_PLAYER_NAME" = ? COLLATE NOCASE");
	gStmt_AccountSetLastLog		= db_prepare(gAccounts, "UPDATE "ACCOUNTS_TABLE_PLAYER" SET "FIELD_PLAYER_LASTLOG" = ? WHERE "FIELD_PLAYER_NAME" = ? COLLATE NOCASE");
	gStmt_AccountSetSpawnTime	= db_prepare(gAccounts, "UPDATE "ACCOUNTS_TABLE_PLAYER" SET "FIELD_PLAYER_SPAWNTIME" = ? WHERE "FIELD_PLAYER_NAME" = ? COLLATE NOCASE");
	gStmt_AccountSetTotalSpawns	= db_prepare(gAccounts, "UPDATE "ACCOUNTS_TABLE_PLAYER" SET "FIELD_PLAYER_TOTALSPAWNS" = ? WHERE "FIELD_PLAYER_NAME" = ? COLLATE NOCASE");
	gStmt_AccountGetIpv4		= db_prepare(gAccounts, "SELECT "FIELD_PLAYER_IPV4" FROM "ACCOUNTS_TABLE_PLAYER" WHERE "FIELD_PLAYER_NAME" = ? COLLATE NOCASE");
	gStmt_AccountGetPass		= db_prepare(gAccounts, "SELECT "FIELD_PLAYER_PASS" FROM "ACCOUNTS_TABLE_PLAYER" WHERE "FIELD_PLAYER_NAME" = ? COLLATE NOCASE");
	gStmt_AccountGetHash		= db_prepare(gAccounts, "SELECT "FIELD_PLAYER_GPCI" FROM "ACCOUNTS_TABLE_PLAYER" WHERE "FIELD_PLAYER_NAME" = ? COLLATE NOCASE");
	gStmt_AccountGetAliasesIp	= db_prepare(gAccounts, "SELECT "FIELD_PLAYER_NAME" FROM "ACCOUNTS_TABLE_PLAYER" WHERE "FIELD_PLAYER_IPV4" = ? AND "FIELD_PLAYER_NAME" != ? COLLATE NOCASE");
	gStmt_AccountGetAliasesPass	= db_prepare(gAccounts, "SELECT "FIELD_PLAYER_NAME" FROM "ACCOUNTS_TABLE_PLAYER" WHERE "FIELD_PLAYER_PASS" = ? AND "FIELD_PLAYER_NAME" != ? COLLATE NOCASE");
	gStmt_AccountGetAliasesHash	= db_prepare(gAccounts, "SELECT "FIELD_PLAYER_NAME" FROM "ACCOUNTS_TABLE_PLAYER" WHERE "FIELD_PLAYER_GPCI" = ? AND "FIELD_PLAYER_NAME" != ? COLLATE NOCASE");
	gStmt_AccountSetAimShout	= db_prepare(gAccounts, "UPDATE "ACCOUNTS_TABLE_PLAYER" SET "FIELD_PLAYER_AIMSHOUT" = ? WHERE "FIELD_PLAYER_NAME" = ? COLLATE NOCASE");

	gStmt_BanInsert				= db_prepare(gAccounts, "INSERT INTO "ACCOUNTS_TABLE_BANS" VALUES(?, ?, ?, ?, ?, ?)");
	gStmt_BanDelete				= db_prepare(gAccounts, "DELETE FROM "ACCOUNTS_TABLE_BANS" WHERE "FIELD_BANS_NAME" = ? COLLATE NOCASE");
	gStmt_BanGetFromNameIp		= db_prepare(gAccounts, "SELECT COUNT(*), "FIELD_BANS_DATE", "FIELD_BANS_REASON", "FIELD_BANS_DURATION" FROM "ACCOUNTS_TABLE_BANS" WHERE "FIELD_BANS_NAME" = ? COLLATE NOCASE OR "FIELD_BANS_IPV4" = ? ORDER BY "FIELD_BANS_DATE" DESC");
	gStmt_BanGetList			= db_prepare(gAccounts, "SELECT * FROM "ACCOUNTS_TABLE_BANS" ORDER BY "FIELD_BANS_DATE" DESC LIMIT ?, ? COLLATE NOCASE");
	gStmt_BanGetTotal			= db_prepare(gAccounts, "SELECT COUNT(*) FROM "ACCOUNTS_TABLE_BANS"");
	gStmt_BanGetInfo			= db_prepare(gAccounts, "SELECT * FROM "ACCOUNTS_TABLE_BANS" WHERE "FIELD_BANS_NAME" = ? COLLATE NOCASE");
	gStmt_BanNameCheck			= db_prepare(gAccounts, "SELECT COUNT(*) FROM "ACCOUNTS_TABLE_BANS" WHERE "FIELD_BANS_NAME" = ? COLLATE NOCASE ORDER BY "FIELD_BANS_DATE" DESC");
	gStmt_BanUpdateIpv4			= db_prepare(gAccounts, "UPDATE "ACCOUNTS_TABLE_BANS" SET "FIELD_BANS_IPV4" = ? WHERE "FIELD_BANS_NAME" = ? COLLATE NOCASE");
	gStmt_BanUpdateInfo			= db_prepare(gAccounts, "UPDATE "ACCOUNTS_TABLE_BANS" SET "FIELD_BANS_REASON" = ?, "FIELD_BANS_DURATION" = ? WHERE "FIELD_BANS_NAME" = ? COLLATE NOCASE");

	gStmt_ReportInsert			= db_prepare(gAccounts, "INSERT INTO "ACCOUNTS_TABLE_REPORTS" VALUES(?, ?, ?, '0', ?, ?, ?, ?, ?, ?)");
	gStmt_ReportDelete			= db_prepare(gAccounts, "DELETE FROM "ACCOUNTS_TABLE_REPORTS" WHERE "FIELD_REPORTS_NAME" = ? AND "FIELD_REPORTS_DATE" = ?");
	gStmt_ReportDeleteName		= db_prepare(gAccounts, "DELETE FROM "ACCOUNTS_TABLE_REPORTS" WHERE "FIELD_REPORTS_NAME" = ?");
	gStmt_ReportNameExists		= db_prepare(gAccounts, "SELECT COUNT(*) FROM "ACCOUNTS_TABLE_REPORTS" WHERE "FIELD_REPORTS_NAME" = ?");
	gStmt_ReportList			= db_prepare(gAccounts, "SELECT * FROM "ACCOUNTS_TABLE_REPORTS"");
	gStmt_ReportInfo			= db_prepare(gAccounts, "SELECT * FROM "ACCOUNTS_TABLE_REPORTS" WHERE "FIELD_REPORTS_NAME" = ? AND "FIELD_REPORTS_DATE" = ?");
	gStmt_ReportSetRead			= db_prepare(gAccounts, "UPDATE "ACCOUNTS_TABLE_REPORTS" SET "FIELD_REPORTS_READ" = ? WHERE "FIELD_REPORTS_NAME" = ? AND "FIELD_REPORTS_DATE" = ?");
	gStmt_ReportGetUnread		= db_prepare(gAccounts, "SELECT COUNT(*) FROM "ACCOUNTS_TABLE_REPORTS" WHERE "FIELD_REPORTS_READ" = 0");

	gStmt_BugInsert				= db_prepare(gAccounts, "INSERT INTO "ACCOUNTS_TABLE_BUGS" VALUES(?, ?, ?)");
	gStmt_BugDelete				= db_prepare(gAccounts, "DELETE FROM "ACCOUNTS_TABLE_BUGS" WHERE "FIELD_BUGS_DATE" = ?");
	gStmt_BugList				= db_prepare(gAccounts, "SELECT * FROM "ACCOUNTS_TABLE_BUGS"");
	gStmt_BugTotal				= db_prepare(gAccounts, "SELECT COUNT(*) FROM "ACCOUNTS_TABLE_BUGS"");
	gStmt_BugInfo				= db_prepare(gAccounts, "SELECT * FROM "ACCOUNTS_TABLE_BUGS" WHERE "FIELD_BUGS_DATE" = ?");

	gStmt_WhitelistExists		= db_prepare(gAccounts, "SELECT COUNT(*) FROM "ACCOUNTS_TABLE_WHITELIST" WHERE "FIELD_WHITELIST_NAME" = ? COLLATE NOCASE");
	gStmt_WhitelistInsert		= db_prepare(gAccounts, "INSERT INTO "ACCOUNTS_TABLE_WHITELIST" ("FIELD_WHITELIST_NAME") VALUES(?)");
	gStmt_WhitelistDelete		= db_prepare(gAccounts, "DELETE FROM "ACCOUNTS_TABLE_WHITELIST" WHERE "FIELD_WHITELIST_NAME" = ?");

	gStmt_AdminLoadAll			= db_prepare(gAccounts, "SELECT * FROM "ACCOUNTS_TABLE_ADMINS" ORDER BY "FIELD_ADMINS_LEVEL" DESC");
	gStmt_AdminExists			= db_prepare(gAccounts, "SELECT COUNT(*) FROM "ACCOUNTS_TABLE_ADMINS" WHERE "FIELD_ADMINS_NAME" = ?");
	gStmt_AdminInsert			= db_prepare(gAccounts, "INSERT INTO "ACCOUNTS_TABLE_ADMINS" VALUES(?, ?)");
	gStmt_AdminUpdate			= db_prepare(gAccounts, "UPDATE "ACCOUNTS_TABLE_ADMINS" SET "FIELD_ADMINS_LEVEL" = ? WHERE "FIELD_ADMINS_NAME" = ?");
	gStmt_AdminDelete			= db_prepare(gAccounts, "DELETE FROM "ACCOUNTS_TABLE_ADMINS" WHERE "FIELD_ADMINS_NAME" = ?");
	gStmt_AdminGetLevel			= db_prepare(gAccounts, "SELECT * FROM "ACCOUNTS_TABLE_ADMINS" WHERE "FIELD_ADMINS_NAME" = ?");

	gStmt_SprayTagExists		= db_prepare(gWorld, "SELECT COUNT(*) FROM "WORLD_TABLE_SPRAYTAG" WHERE "FIELD_SPRAYTAG_POSX" = ? AND "FIELD_SPRAYTAG_POSY" = ? AND "FIELD_SPRAYTAG_POSZ" = ?");
	gStmt_SprayTagInsert		= db_prepare(gWorld, "INSERT INTO "WORLD_TABLE_SPRAYTAG" VALUES(?, ?, ?, ?, ?, ?, ?)");
	gStmt_SprayTagLoad			= db_prepare(gWorld, "SELECT * FROM "WORLD_TABLE_SPRAYTAG"");
	gStmt_SprayTagSave			= db_prepare(gWorld, "UPDATE "WORLD_TABLE_SPRAYTAG" SET "FIELD_SPRAYTAG_NAME" = ? WHERE "FIELD_SPRAYTAG_POSX" = ? AND "FIELD_SPRAYTAG_POSY" = ? AND "FIELD_SPRAYTAG_POSZ" = ?");

	LoadSettings();

	SendRconCommand(sprintf("mapname %s", gMapName));

	item_Parachute		= DefineItemType("Parachute",			371,	ITEM_SIZE_MEDIUM,	90.0, 0.0, 0.0,			0.0,	0.350542, 0.017385, 0.060469, 0.000000, 260.845062, 0.000000);
	item_Medkit			= DefineItemType("Medkit",				1580,	ITEM_SIZE_SMALL,	0.0, 0.0, 0.0,			0.0,	0.269091, 0.166367, 0.000000, 90.000000, 0.000000, 0.000000);
	item_HardDrive		= DefineItemType("Hard Drive",			328,	ITEM_SIZE_SMALL,	90.0, 0.0, 0.0,			0.0);
	item_Key			= DefineItemType("Key",					327,	ITEM_SIZE_SMALL,	0.0, 0.0, 0.0,			0.01);//, .colour = 0xFFDEDEDE);
// 50
	item_FireworkBox	= DefineItemType("Fireworks",			2039,	ITEM_SIZE_MEDIUM,	0.0, 0.0, 0.0,			0.0,	0.096996, 0.044811, 0.035688, 4.759557, 255.625167, 0.000000);
	item_FireLighter	= DefineItemType("Lighter",				327,	ITEM_SIZE_SMALL,	0.0, 0.0, 0.0,			0.0);
	item_Timer			= DefineItemType("Timer Device",		2922,	ITEM_SIZE_SMALL,	90.0, 0.0, 0.0,			0.0,	0.231612, 0.050027, 0.017069, 0.000000, 343.020019, 180.000000);
	item_Explosive		= DefineItemType("TNT",					1576,	ITEM_SIZE_SMALL,	0.0, 0.0, 0.0,			0.0,	0.269091, 0.166367, 0.000000, 90.000000, 0.000000, 0.000000);
	item_TntTimebomb	= DefineItemType("Timed TNT",			1252,	ITEM_SIZE_SMALL,	270.0, 0.0, 0.0,		0.0);
	item_Battery		= DefineItemType("Battery",				1579,	ITEM_SIZE_MEDIUM,	0.0, 0.0, 0.0,			0.0,	0.269091, 0.166367, 0.000000, 90.000000, 0.000000, 0.000000);
	item_Fusebox		= DefineItemType("Fuse Box",			328,	ITEM_SIZE_SMALL,	90.0, 0.0, 0.0,			0.0);
	item_Bottle			= DefineItemType("Bottle",				1543,	ITEM_SIZE_SMALL,	0.0, 0.0, 0.0,			0.0,	0.060376, 0.032063, -0.204802, 0.000000, 0.000000, 0.000000);
	item_Sign			= DefineItemType("Sign",				19471,	ITEM_SIZE_LARGE,	0.0, 0.0, 270.0,		0.0);
	item_Armour			= DefineItemType("Armour",				19515,	ITEM_SIZE_MEDIUM,	90.0, 0.0, 0.0,			0.0,	0.300333, -0.090105, 0.000000, 0.000000, 0.000000, 180.000000);
// 60
	item_Bandage		= DefineItemType("Bandage",				1575,	ITEM_SIZE_SMALL,	0.0, 0.0, 0.0,			0.0,	0.269091, 0.166367, 0.000000, 90.000000, 0.000000, 0.000000);
	item_FishRod		= DefineItemType("Fishing Rod",			18632,	ITEM_SIZE_LARGE,	90.0, 0.0, 0.0,			0.0,	0.091496, 0.019614, 0.000000, 185.619995, 354.958374, 0.000000);
	item_Wrench			= DefineItemType("Wrench",				18633,	ITEM_SIZE_SMALL,	0.0, 90.0, 0.0,			0.0,	0.084695, -0.009181, 0.152275, 98.865089, 270.085449, 0.000000);
	item_Crowbar		= DefineItemType("Crowbar",				18634,	ITEM_SIZE_SMALL,	0.0, 90.0, 0.0,			0.0,	0.066177, 0.011153, 0.038410, 97.289527, 270.962554, 1.114514);
	item_Hammer			= DefineItemType("Hammer",				18635,	ITEM_SIZE_SMALL,	270.0, 0.0, 0.0,		0.01,	0.000000, -0.008230, 0.000000, 6.428617, 0.000000, 0.000000);
	item_Shield			= DefineItemType("Shield",				18637,	ITEM_SIZE_LARGE,	0.0, 0.0, 0.0,			0.0,	-0.262389, 0.016478, -0.151046, 103.597534, 6.474381, 38.321765);
	item_Flashlight		= DefineItemType("Flashlight",			18641,	ITEM_SIZE_SMALL,	90.0, 0.0, 0.0,			0.0,	0.061910, 0.022700, 0.039052, 190.938354, 0.000000, 0.000000);
	item_Taser			= DefineItemType("Taser",				18642,	ITEM_SIZE_SMALL,	90.0, 0.0, 0.0,			0.0,	0.079878, 0.014009, 0.029525, 180.000000, 0.000000, 0.000000);
	item_LaserPoint		= DefineItemType("Laser Pointer",		18643,	ITEM_SIZE_SMALL,	0.0, 0.0, 90.0,			0.0,	0.066244, 0.010838, -0.000024, 6.443027, 287.441467, 0.000000);
	item_Screwdriver	= DefineItemType("Screwdriver",			18644,	ITEM_SIZE_SMALL,	90.0, 0.0, 0.0,			0.0,	0.099341, 0.021018, 0.009145, 193.644195, 0.000000, 0.000000);
// 70
	item_MobilePhone	= DefineItemType("Mobile Phone",		18865,	ITEM_SIZE_SMALL,	0.0, 0.0, 0.0,			0.0,	0.103904, -0.003697, -0.015173, 94.655189, 184.031860, 0.000000);
{'fraction_non_alphanumeric': 0.14177108115252446, 'fraction_numerical': 0.03555908009516257, 'mean_word_length': 5.532845202735373, 'pattern_counts': {'":': 0, '<': 69, '<?xml version=': 0, '>': 69, 'https://': 14, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 2, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '97358', 'n_tokens_mistral': 44035, 'n_tokens_neox': 39777, 'n_words': 6333}