# Configs, Locales & SQL

{% tabs %}
{% tab title="Config" %}

```lua
Config = {}
Config.Keys={['ESC']=322,['F1']=288,['F2']=289,['F3']=170,['F5']=166,['F6']=167,['F7']=168,['F8']=169,['F9']=56,['F10']=57,['~']=243,['1']=157,['2']=158,['3']=160,['4']=164,['5']=165,['6']=159,['7']=161,['8']=162,['9']=163,['-']=84,['=']=83,['BACKSPACE']=177,['TAB']=37,['Q']=44,['W']=32,['E']=38,['R']=45,['T']=245,['Y']=246,['U']=303,['P']=199,['[']=39,[']']=40,['ENTER']=18,['CAPS']=137,['A']=34,['S']=8,['D']=9,['F']=23,['G']=47,['H']=74,['K']=311,['L']=182,['LEFTSHIFT']=21,['Z']=20,['X']=73,['C']=26,['V']=0,['B']=29,['N']=249,['M']=244,[',']=82,['.']=81,['LEFTCTRL']=36,['LEFTALT']=19,['SPACE']=22,['RIGHTCTRL']=70,['HOME']=213,['PAGEUP']=10,['PAGEDOWN']=11,['DELETE']=178,['LEFTARROW']=174,['RIGHTARROW']=175,['TOP']=27,['DOWNARROW']=173,['NENTER']=201,['N4']=108,['N5']=60,['N6']=107,['N+']=96,['N-']=97,['N7']=117,['N8']=61,['N9']=118,['UPARROW']=172,['INSERT']=121}


--███████╗██████╗  █████╗ ███╗   ███╗███████╗██╗    ██╗ ██████╗ ██████╗ ██╗  ██╗
--██╔════╝██╔══██╗██╔══██╗████╗ ████║██╔════╝██║    ██║██╔═══██╗██╔══██╗██║ ██╔╝
--█████╗  ██████╔╝███████║██╔████╔██║█████╗  ██║ █╗ ██║██║   ██║██████╔╝█████╔╝ 
--██╔══╝  ██╔══██╗██╔══██║██║╚██╔╝██║██╔══╝  ██║███╗██║██║   ██║██╔══██╗██╔═██╗ 
--██║     ██║  ██║██║  ██║██║ ╚═╝ ██║███████╗╚███╔███╔╝╚██████╔╝██║  ██║██║  ██╗
--╚═╝     ╚═╝  ╚═╝╚═╝  ╚═╝╚═╝     ╚═╝╚══════╝ ╚══╝╚══╝  ╚═════╝ ╚═╝  ╚═╝╚═╝  ╚═╝


Config.Database = 'mysql' --[ 'mysql' / 'ghmattimysql' / 'oxmysql' ] Choose your sql database script.
Config.Framework = 'esx' ---[ 'esx' / 'qbcore' / 'vrp' / 'none' / 'other' ] Choose your framework.
Config.Language = 'EN' --[ 'EN' / 'BG' / 'DE' / 'CZ' / 'ES' / 'FI' / 'FR' / 'NL'  / 'SE' / 'SK' ] You can add your own locales to the Locales.lua. But make sure to change the Config.Language to match it.

Config.ESX_version = '1.1' --[ '1.1' / '1.2' / '1.final' / 'exm' / 'legacy' ] "IF" you are using esx, choose the version you are using.
Config.FrameworkTriggers = { --You can change the esx/qbcore events (IF NEEDED).
    main = 'esx:getSharedObject',   --ESX = 'esx:getSharedObject'   QBCORE = 'QBCore:GetObject'
    load = 'esx:playerLoaded',      --ESX = 'esx:playerLoaded'      QBCORE = 'QBCore:Client:OnPlayerLoaded'
    job = 'esx:setJob',             --ESX = 'esx:setJob'            QBCORE = 'QBCore:Client:OnJobUpdate'
	resource_name = 'es_extended'   --ESX = 'es_extended'           QBCORE = 'qb-core'
}

Config.NotificationType = { --[ 'esx' / 'qbcore' / 'mythic_old' / 'mythic_new' / 'chat' / 'other' ] Choose your notification script.
    server = 'esx',
    client = 'esx' 
}


--███╗   ███╗ █████╗ ██╗███╗   ██╗
--████╗ ████║██╔══██╗██║████╗  ██║
--██╔████╔██║███████║██║██╔██╗ ██║
--██║╚██╔╝██║██╔══██║██║██║╚██╗██║
--██║ ╚═╝ ██║██║  ██║██║██║ ╚████║
--╚═╝     ╚═╝╚═╝  ╚═╝╚═╝╚═╝  ╚═══╝


Config.LoopWait = 500 --(in ms) The refresh timer for updating the values on the UI. (a lower number will use more ms in resmon and a higher number will use less).
Config.PlaySound = true --Do you want to use the sounds when using the watch?

Config.StaffCommands = {
    ResetStatus = 'resetstatus', --The command for staff to reset their hunger/thirst/stress stats.

    Perms = { --You decide which permission groups can use the staff command ^.
        ['esx'] = {'superadmin', 'admin', 'mod'},
        ['qbcore'] = {'god', 'admin'},
        ['other'] = {'change_me', 'change_me'}
    }
}


--██╗  ██╗███████╗██╗   ██╗███████╗     █████╗ ███╗   ██╗██████╗      ██████╗ ██████╗ ███╗   ███╗███╗   ███╗ █████╗ ███╗   ██╗██████╗ ███████╗
--██║ ██╔╝██╔════╝╚██╗ ██╔╝██╔════╝    ██╔══██╗████╗  ██║██╔══██╗    ██╔════╝██╔═══██╗████╗ ████║████╗ ████║██╔══██╗████╗  ██║██╔══██╗██╔════╝
--█████╔╝ █████╗   ╚████╔╝ ███████╗    ███████║██╔██╗ ██║██║  ██║    ██║     ██║   ██║██╔████╔██║██╔████╔██║███████║██╔██╗ ██║██║  ██║███████╗
--██╔═██╗ ██╔══╝    ╚██╔╝  ╚════██║    ██╔══██║██║╚██╗██║██║  ██║    ██║     ██║   ██║██║╚██╔╝██║██║╚██╔╝██║██╔══██║██║╚██╗██║██║  ██║╚════██║
--██║  ██╗███████╗   ██║   ███████║    ██║  ██║██║ ╚████║██████╔╝    ╚██████╗╚██████╔╝██║ ╚═╝ ██║██║ ╚═╝ ██║██║  ██║██║ ╚████║██████╔╝███████║
--╚═╝  ╚═╝╚══════╝   ╚═╝   ╚══════╝    ╚═╝  ╚═╝╚═╝  ╚═══╝╚═════╝      ╚═════╝ ╚═════╝ ╚═╝     ╚═╝╚═╝     ╚═╝╚═╝  ╚═╝╚═╝  ╚═══╝╚═════╝ ╚══════╝


Config.Keys = {
	move_mode = Config.Keys['K'], --Key to activate move mode. (K by default and right mouse click to disable).
	next_screen = Config.Keys['RIGHTARROW'], --This is the key to cycle to the next screen. (RIGHT ARROW by default).
	previous_screen = Config.Keys['LEFTARROW'], --If Config.ToggleMode is set to double, then this is the key to move back to the previous screen. (LEFT ARROW by default).
}

Config.OpenWatch = {
	key_mapping = {
		ENABLE = true, --If this is disabled, none of the options below in this table will not used.
		command = 'watchhud', --Customise the chat command.
		key = 'i', --Customise the key.
		description = 'Open the watch UI', --Customise the description for the chat message.
	},

	usable_item = {
		ENABLE = true, --If this is disabled, none of the options below in this table will not used.
    	item_name = 'watch', --Customise the item name.
	}
}


--██████╗  █████╗ ███████╗██╗ ██████╗    ███╗   ██╗███████╗███████╗██████╗ ███████╗
--██╔══██╗██╔══██╗██╔════╝██║██╔════╝    ████╗  ██║██╔════╝██╔════╝██╔══██╗██╔════╝
--██████╔╝███████║███████╗██║██║         ██╔██╗ ██║█████╗  █████╗  ██║  ██║███████╗
--██╔══██╗██╔══██║╚════██║██║██║         ██║╚██╗██║██╔══╝  ██╔══╝  ██║  ██║╚════██║
--██████╔╝██║  ██║███████║██║╚██████╗    ██║ ╚████║███████╗███████╗██████╔╝███████║
--╚═════╝ ╚═╝  ╚═╝╚══════╝╚═╝ ╚═════╝    ╚═╝  ╚═══╝╚══════╝╚══════╝╚═════╝ ╚══════╝


--NOTE: The built in basic needs system will only work on ESX servers; unless you change the code.
Config.BasicNeeds = {
	ENABLE = true, --Do you want to use the built in hunger & thirst basic needs system?
	save_in_database = true, --Do you want the hunger & thirst to be saved in the database?
	cache_status_timer = 10, --(in minutes) Every x amount of minutes a player's hunger & thirst will be cached in the server side. (it will only be saved to the database when a player exits the server).
	timer = 1, --(in minutes) Every x amount of minutes a player's hunger & thirst will be decreased by 1. (100 is full and 0 is empty).

	EmptyEffect = {
		screenblur = false, --When a player's hunger or thirst is 0 their screen will blur.

		healthloss = false, --When a player's hunger or thirst is 0 their health will start to decrease.
		healthloss_timer = 5, --(in seconds) Every x amount of seconds a player's health will decrease by 1. (max health is 200, 0 means they will die).
	},


	Items = { --A list of usable food/drink items for the built in basic needs system.
        [1] = {
			item_name = 'bread', --The usable item spawn name.
			item_label = 'Sandwich', --The label of the usable item.
			item_type = 'food', --[ 'food' / 'drink' ]
			StatusInfo = {
				hunger = 20, --20 will add 20 hunger. -20 will remove 20 hunger. 0 will not add/remove anything. (100 is full hunger and 0 is empty).
				thirst = 0, --20 will add 20 thirst. -20 will remove 20 thirst. 0 will not add/remove anything. (100 is full thirst and 0 is empty).
				stress = 0 --20 will add 20 stress. -20 will remove 20 stress. 0 will not add/remove anything. (100 is full stress and 0 is empty).
			},
			PropInfo = {
				hash = `prop_sandwich_01`, --The spawn name of the prop.
				anim_dict = 'mp_player_inteat@burger', --An eating animation.
				anim_name = 'mp_player_int_eat_burger_fp', --An eating animation.
				duration = 5000, --How long the animation will last.
				x = 0.13, y = 0.05, z = 0.02, pitch = 50.0, roll = 50.0, yaw = 60.0, bone = 18905 --Position of the prop on the player. (DON'T CHANGE THIS IF YOU DONT KNOW WHAT YOUR DOING).
			}  
		},

        [2] = {
			item_name = 'water',
			item_label = 'Water',
			item_type = 'drink',            
            StatusInfo = {
                hunger = 0,
                thirst = 20,
                stress = 0
            },
            PropInfo = {
                hash = `prop_ld_flow_bottle`,
                anim_dict = 'mp_player_intdrink', --A drinking animation.
                anim_name = 'loop_bottle', --A drinking animation.
                duration = 5000,
                x = 0.10, y = -0.03, z = 0.03, pitch = -100.0, roll = 0.0, yaw = -10.0, bone = 18905
            }  
        },
		
		--[[ YOU CAN ADD MORE USABLE FOOD/DRINK ITEMS HERE BY COPY AND PASTING THIS TABLE.
		[3] = {
			item_name = 'bread',
			item_label = 'Sandwich',
			item_type = 'food',
			StatusInfo = {
				hunger = 20,
				thirst = 0,
				stress = 0
			},
			PropInfo = {
				hash = `prop_sandwich_01`,
				anim_dict = 'mp_player_inteat@burger',
				anim_name = 'mp_player_int_eat_burger_fp',
				duration = 5000,
				x = 0.13, y = 0.05, z = 0.02, pitch = 50.0, roll = 50.0, yaw = 60.0, bone = 18905
			}  
		},
		]]
    }
}


--███████╗████████╗██████╗ ███████╗███████╗███████╗
--██╔════╝╚══██╔══╝██╔══██╗██╔════╝██╔════╝██╔════╝
--███████╗   ██║   ██████╔╝█████╗  ███████╗███████╗
--╚════██║   ██║   ██╔══██╗██╔══╝  ╚════██║╚════██║
--███████║   ██║   ██║  ██║███████╗███████║███████║
--╚══════╝   ╚═╝   ╚═╝  ╚═╝╚══════╝╚══════╝╚══════╝


Config.Stress = {
	ENABLE = true, --Do you want to use our built in stress system?
	save_in_database = true, --Do you want the stress to be saved in the database? NOTE: Stress will only save to the database on ESX/QBCore servers; unless you change the code.
	cache_status_timer = 10, --(in minutes) Every x amount of minutes a player's stress will be cached in the server side. (it will only be saved to the database when a player exits the server). (if 'Config.BasicNeeds.ENABLE' is enabled, the timer from that table will overwrite this timer).
	health_decrease_amount = 5, --If your stress is high you will loose health slowly.

	Values = { --0 is no stress and 100 stress is max stress.
		Bike = {
			GainStress = true, --Do you want player's to gain stress when on motorcycles.
			IncreaseSpeed = 150, --If you are above 150mph you will gain stress.
			IncreaseAmount = 5, --Stress will increase by this amount (out of 100) if your speed is above the amount set above.
			LowerSpeed_min = 20,
			LowerSpeed_max = 70, --Stress will decrease if your speed in mph is between the min and max ^.
			LowerAmount = 2, --Stress will decrease by this amount (out of 100) if your speed is between the min and max.
		},
	
		Car = {
			GainStress = true,
			IncreaseSpeed = 150,
			IncreaseAmount = 2,
			LowerSpeed_min = 20,
			LowerSpeed_max = 60,
			LowerAmount = 1,
		},
	
		Plane = {
			GainStress = true,
			IncreaseSpeed = 150,
			IncreaseAmount = 2,
		},
	
		Swimming = {
			LowerStress = true,
			LowerAmount = 3,
		},
	
		Combat = {
			GainStress = true,
			MeleeAmount = 1,
			FirearmAmount = 2,
		},
	
		Yoga = {
			LowerStress = true,
			LowerAmount = 1,
		},
	
		Damage = {
			GainStress = true,
			IncreaseAmount = 2,
		}
	}
}


--██╗    ██╗ █████╗ ████████╗███████╗██████╗      ██████╗ ██╗  ██╗██╗   ██╗ ██████╗ ███████╗███╗   ██╗
--██║    ██║██╔══██╗╚══██╔══╝██╔════╝██╔══██╗    ██╔═══██╗╚██╗██╔╝╚██╗ ██╔╝██╔════╝ ██╔════╝████╗  ██║
--██║ █╗ ██║███████║   ██║   █████╗  ██████╔╝    ██║   ██║ ╚███╔╝  ╚████╔╝ ██║  ███╗█████╗  ██╔██╗ ██║
--██║███╗██║██╔══██║   ██║   ██╔══╝  ██╔══██╗    ██║   ██║ ██╔██╗   ╚██╔╝  ██║   ██║██╔══╝  ██║╚██╗██║
--╚███╔███╔╝██║  ██║   ██║   ███████╗██║  ██║    ╚██████╔╝██╔╝ ██╗   ██║   ╚██████╔╝███████╗██║ ╚████║
-- ╚══╝╚══╝ ╚═╝  ╚═╝   ╚═╝   ╚══════╝╚═╝  ╚═╝     ╚═════╝ ╚═╝  ╚═╝   ╚═╝    ╚═════╝ ╚══════╝╚═╝  ╚═══╝


Config.WaterOxygen = {
	ENABLE = true,
	--Note: After a player's oxygen reaches 0, the player will start to slowly die as they would normally. This will take around 15 extra seconds.
	underwater_decrease = 5, --Every 1 second the player will loose x amount of oxygen when under water. (0 is empty and 100 is full).
	underwater_recovery = 5, --Every 1 second the player will regain x amount of oxygen when NOT under water. (0 is empty and 100 is full).
}


-- ██████╗ ████████╗██╗  ██╗███████╗██████╗ 
--██╔═══██╗╚══██╔══╝██║  ██║██╔════╝██╔══██╗
--██║   ██║   ██║   ███████║█████╗  ██████╔╝
--██║   ██║   ██║   ██╔══██║██╔══╝  ██╔══██╗
--╚██████╔╝   ██║   ██║  ██║███████╗██║  ██║
-- ╚═════╝    ╚═╝   ╚═╝  ╚═╝╚══════╝╚═╝  ╚═╝


function L(cd) if Locales[Config.Language][cd] then return Locales[Config.Language][cd] else print('Locale is nil ('..cd..')') end end
function Round(cd, debug) return math.floor(cd+0.5) end
function Trim(cd) return cd:gsub('%s+', '') end

if Config.Framework ~= 'esx' then
	Config.BasicNeeds.ENABLE = false --NOTE: The built in basic needs system will only work on ESX servers; unless you change the code.
end
if Config.Framework ~= 'esx' and Config.Framework ~= 'qbcore' then
	Config.Stress.save_in_database = false --NOTE: Stress will only save to the database on ESX/QBCore servers; unless you change the code.
end

```

{% endtab %}

{% tab title="Config UI" %}

```javascript
CONFIG_CURRENCY = "$"; // Currency
CONFIG_BANK = "Provided by Fleeca"; // Text on the bottom of the bank screen

CONFIG_LOCALE = "EN"; // "EN" / "ES" / "DE" / "CZ" / "CUSTOM"

moment.locale('en'); // The locale of the moment.js message ( example: 1 mins ago ) - https://momentjs.com/docs/#/i18n/changing-locale/
CONFIG_INVERT_HUNGER_THIRST = false; // IF SET TO TRUE - HUNGER AND THIRST WILL GO FROM 0 TO 100, REVERSED IF FALSE
```

{% endtab %}

{% tab title="Custom Apps" %}

```javascript
// Tips for creating Your own app screens

// The position in the screens.list array determines the order of displaying the screens.
// Do not change screens.current unless you want a different screen to display first (screens.current goes from 0 to screens.list.length-1)

// Currently the screens.list.name value has no use, however it is reserved for future use such as setting options for certain apps.
// The screens.list.id is the id of the element containing the app screen. It will be displayed once it is cycled to.

// In order to make your app functional you would either need to create another javascript file and include it through the html or add inline javascript to the index.html file itself.

// To place the screen on the correct position simply use the .app-screen class on your html element.

// The existing apps are not editable, however you can change their order if you wish to do so.

let screens = {
    current: 0,
    list: [
    {
      name:"Clock",
      id:"clock"
    },{
      name:"Main",
      id:"main"
    },{
      name:"Bank",
      id:"money"
    },{
      name:"Job",
      id:"job"
    },{
      name:"Settings",
      id:"settings"
    }]
}
```

{% endtab %}

{% tab title="Locales" %}
<https://github.com/RampBST/Codesign_Locales/blob/main/cd_playerhud/locales.lua>
{% endtab %}

{% tab title="Locales UI" %}
<https://github.com/RampBST/Codesign_Locales/blob/main/cd_playerhud/locales_ui.js>
{% endtab %}

{% tab title="SQL" %}
Watch this video if you are unsure how to insert an SQL Query into your database.\
[HeidiSQL ](https://youtu.be/s3tqlHV3yb0)/ [PHPMyAdmin](https://youtu.be/NXqmYn7bbMM).

```sql
ALTER TABLE `users` ADD COLUMN `status` LONGTEXT NULL;
```

{% endtab %}
{% endtabs %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.codesign.pro/paid-scripts/player-hud-smart-watch/configs-locales-and-sql.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
