Accessible Code
Shared = {
Locale = 'en',
Notify = {
duration = 5000, -- miliseconds
position = 'top-right' -- 'top' or 'top-right' or 'top-left' or 'bottom' or 'bottom-right' or 'bottom-left' or 'center-right' or 'center-left'
},
Logs = {
enabled = true,
webhook = '',
servername = 'Uniq Scripts',
color = 6579450,
icon_url = 'https://dunb17ur4ymx4.cloudfront.net/webstore/logos/046c8efd198a2806b6ae46490f6aa780a225125e.png'
},
Commands = {
adminpanel = {
name = 'solaradmin', -- command for accessing admin panel
restricted = 'group.admin', -- group that will have access to the command
}
},
Keys = { -- https://docs.fivem.net/docs/game-references/controls/
finish = 191,
cancel = 194,
moveUp = 85,
moveDown = 48,
moveRight = 175,
moveLeft = 174,
moveForward = 172,
moveBack = 173,
rotateRight = 313,
rotateLeft = 312,
cancel = 194,
},
HackPanel = { -- settings for hacking panels
policeOnly = false,
policeJobs = { -- required
['police'] = true
},
policeNotify = true, -- notify police about panels being hacked
hackDelay = 300000, -- delay for restoring all hacked cameras - ms
},
Items = {
solarpanel = 'solarpanel',
remotecontrol = 'remotecontrol'
},
PowerPrices = { -- do not change any of the values in []
['200'] = 0, -- 200 (default one) will be free
['300'] = 10000,
['400'] = 20000
},
BatteryPrices = { -- do not change any of the values in []
['12.5'] = 0, -- 12.5 (default one) will be free
['15'] = 15000,
['20'] = 30000
},
CitizenIDChars = 8, -- number of characters for citizen id on your server
vSync = false, -- whether you are using vSync or not (for blackout/power loss)
BlockedLocations = { -- locations where installation of solar panels is blocked
{x = 188.4132, y = -949.5950, z = 30.0919, radius = 500.0},
}
}
function sendNotify(title, description, type)
lib.notify({
title = title,
description = description,
duration = Shared.Notify.duration,
type = type,
position = Shared.Notify.position
})
end
RegisterNetEvent('solarpanels:notify', sendNotify)
-- Target
exports["qtarget"]:AddTargetModel(objectName, {
options = targetOptions, -- unreachable with escrow version, join our Discord Server & get open source version to access full code
distance = 2
})
-- Blackout
RegisterNetEvent('solarpanels:client:blackoutOn')
AddEventHandler('solarpanels:client:blackoutOn', function()
SetArtificialLightsState(true)
PlaySoundFrontend(-1, "Power_Down", "DLC_HEIST_HACKING_SNAKE_SOUNDS", 1)
SetArtificialLightsStateAffectsVehicles(false)
sendNotify('', L('notify.power_outage'), 'warning')
end)
RegisterNetEvent('solarpanels:client:blackoutOff')
AddEventHandler('solarpanels:client:blackoutOff', function()
SetArtificialLightsState(false)
PlaySoundFrontend(-1, "police_notification", "DLC_AS_VNT_Sounds", 1)
SetArtificialLightsStateAffectsVehicles(true)
sendNotify('', L('notify.power_restored'), 'warning')
end)
-- Hack Solar Panel
function hackPanel(panelId) -- you can change this to your desired minigame
if panelId then
local playerCoords = GetEntityCoords(PlayerPedId())
local thisPanel = SolarPanels[panelId]
lib.callback('solarpanels:server:checkSecurity', false, function(hasSecurity)
if not hasSecurity then
local success = lib.skillCheck({'hard'}, {'w', 'a', 's', 'd'})
if success then
if lib.progressCircle({
duration = 5000,
label = L('notify.loading_data'),
position = 'middle',
useWhileDead = false,
canCancel = true,
disable = {
car = true,
},
}) then
thisPanel.hacked = true
thisPanel.broken = true
accessPanel(panelId)
if Shared.HackPanel.policeNotify then
lib.callback('solarpanels:server:policeNotify', false, function() end, SolarPanels[panelId].data.coords.x, SolarPanels[panelId].data.coords.y)
end
sendNotify('', L('notify.panel_data_loaded'), 'success')
sendNotify('', L('notify.power_exhausted'), 'warning')
lib.callback('solarpanels:server:updateEnergyValues', false, function() end, panelId, 0, thisPanel.data.maxPower, thisPanel.data.batteryVoltage, false, false)
else end
else
sendNotify('', L('notify.failed_hack'), 'error')
failedHack = true
Citizen.CreateThread(function()
while true do
Citizen.Wait(2 * 60000) -- 2 minutes
failedHack = false
end
end)
end
else
local success = lib.skillCheck({areaSize = 10, speedMultiplier = 5}, {'w', 'a', 's', 'd', 'g', 'h', 'k', 'j', 'l', 'f', 'r'})
if success then
thisPanel.hacked = true
thisPanel.broken = true
accessPanel(panelId)
if Shared.HackPanel.policeNotify then
lib.callback('solarpanels:server:policeNotify', false, function() end, SolarPanels[panelId].data.coords.x, SolarPanels[panelId].data.coords.y)
end
sendNotify('', L('notify.panel_data_loaded'), 'success')
sendNotify('', L('notify.power_exhausted'), 'warning')
lib.callback('solarpanels:server:updateEnergyValues', false, function() end, panelId, 0, thisPanel.data.maxPower, thisPanel.data.batteryVoltage, false, false)
else
sendNotify('', L('notify.failed_hack'), 'error')
failedHack = true
Citizen.CreateThread(function()
while true do
Citizen.Wait(2 * 60000) -- 2 minutes
failedHack = false
end
end)
end
end
end, panelId)
else
sendNotify('', L('notify.cant_hack_camera'), 'error')
end
end
-- this one is for QBCore, ESX version is the same expect it uses ESX things
-- Discord Logs
local webhook = Shared.Logs.webhook
function logger(message)
if Shared.Logs.enabled then
if webhook ~= '' then
PerformHttpRequest(webhook, function(status) end, 'POST', json.encode({
username = cache.resource,
embeds = {{
color = Shared.Logs.color,
title = Shared.Logs.servername,
description = message,
footer = {
text = os.date(),
icon_url = Shared.Logs.icon_url
}
}}
}), { ['Content-Type'] = 'application/json' })
end
end
end
-- Command
lib.addCommand(Shared.Commands.adminpanel.name, {
help = L('commands.adminpanel'),
restricted = Shared.Commands.adminpanel.restricted
}, function(source)
TriggerClientEvent("solarpanels:adminMenu", source)
end)
-- Usable Items
QBCore.Functions.CreateUseableItem(Shared.Items.solarpanel, function(source, item)
local Player = QBCore.Functions.GetPlayer(source)
if not Player.Functions.GetItemByName(item.name) then return end
TriggerClientEvent("solarpanels:createPanel", source)
end)
QBCore.Functions.CreateUseableItem(Shared.Items.remotecontrol, function(source, item)
local Player = QBCore.Functions.GetPlayer(source)
if not Player.Functions.GetItemByName(item.name) then return end
TriggerClientEvent("solarpanels:remoteControl", source)
end)
-- Your function for getting weather type
function getWeather()
return exports["qb-weathersync"]:getWeatherState()
end
-- Your function for getting time
function getTime()
return exports["qb-weathersync"]:getTime()
end
-- Blackout
function SetCityElectricity(value)
if value == 0 then -- electricity (city power) off
TriggerClientEvent('solarpanels:client:blackoutOn', -1)
elseif value == 1 then -- electricity (city power) on
TriggerClientEvent('solarpanels:client:blackoutOff', -1)
end
if Shared.vSync then
TriggerEvent('vSync:requestSync')
end
end
Locales['en'] = {
commands = {
adminpanel = 'Access the solar panels Admin Menu',
},
admin_panel = {
label = 'Admin Menu',
panels_list = {
label = 'Solar Panels List',
no_panels = 'No Installed Solar Panels',
solar_panel = 'Solar Panel #%s',
},
settings = 'Settings',
settings_options = {
security_desc = 'Price owners have to pay for protection from hackers (less chance of the solar panel being hacked and disabled)',
remote_desc = 'Price owners have to pay for remote control device (control solar panel from anywhere)',
currency = 'Currency',
currency_desc = 'Currency used for Solar Panel purchases etc..',
object = 'Object Name',
object_desc = 'Solar Panel object name | suggested: \'prop_solarpanel_02\', \'prop_solarpanel_03\'',
jobs_options = 'Jobs Options',
jobs_options_desc = 'Jobs options for "Allowed Jobs" section when creating solar panel',
display_3d_text = 'Display 3D Text',
power_interval = 'Power Interval',
power_interval_desc = 'Time every so often during the day and in sunny weather (ingame), power will be added to each solar panel. (minutes)',
blackout_interval = 'Blackout Interval',
blackout_interval_desc = 'How often will it be checked whether there is enough electricity in the city and whether there will be a blackout. (minutes)',
required_electricity = 'Electricity Required',
required_electricity_desc = 'The amount of power required for the city to have electricity, the total number is the sum of the electricity in all installed solar panels',
},
context = {
change_owner = 'Change Owner',
change_owner_description = 'Change the owner of this Solar Panel',
new_owner = 'New Owner',
new_owner_description = 'Input citizen id of the new owner for Solar Panel #%s',
change_name = 'Change Name',
change_name_description = 'Rename this Solar Panel',
teleport = 'Teleport To Solar Panel',
teleport_description = 'This will teleport you to Solar Panel #%s',
delete_solar_panel = 'Delete Solar Panel',
delete_solar_panel_description = 'Remove this Solar Panel permanently from the system',
delete_solar_panel_sure = {
('Are you sure you want to delete this Solar Panel permanently? \n'),
('It is not possible to return it later. \n'),
},
energy_values = 'Energy Values',
energy_values_description = 'Replace the power & battery voltage value on this Solar Panel',
power_value = 'Power Value',
settings = 'Settings',
settings_desc = 'Manage Solar Panel settings & values',
earnings = 'Earnings (income)',
earnings_desc = 'Change the earnings value (available income). Current earnings - ',
},
refresh = 'Refresh data & respawn all Solar Panels',
},
place_panel = {
title = 'Place Panel',
access_label = 'Panel Access',
access_desc = 'Select the players who will have access to this solar panel, you can\'t edit this later (optional)',
name = 'Panel Name',
name_desc = 'Unique name (label) for this Solar Panel',
name_placeholder = 'Solar Panel - Vinewood',
security = 'Security',
allowed_jobs = 'Allowed Jobs',
allowed_jobs_desc = 'Jobs that are allowed access to access this solar panel (optional)',
remote_control = 'Remote Control',
max_power = 'Maximum Panel Power Capacity',
max_power_desc = 'Maximum power capacity that the solar panel has, higher power capacity means better and faster electricity production and higher income.',
battery_voltage = 'Battery Voltage',
battery_voltage_desc = 'Higher battery voltage gives more power to the solar panel when there is sun',
},
notify = {
success_cancel = 'You have successfully canceled creating solar panel',
panel_created = 'Solar Panel "%s" successfully installed',
cant_install_here = 'You cannot install a Solar Panel at this location',
in_vehicle = 'This action cannot be performed while in vehicle',
settings_updated = 'You have successfully updated settings for Solar Panels System',
panels_reloaded = 'All panels with refreshed data have been successfully created',
teleported = 'Successfully teleported to Solar Panel #%s - "%s"',
not_enough_money = 'You don\'t have enough money - %s',
panel_deleted = 'Solar Panel #%s is permanently deleted from the database',
energy_values_updated = 'Energy values for Solar Panel #%s are successfully updated. \nNew Power Value: %s (W) \nNew Max Power Value: %s (W) \nNew Battery Voltage Value: %s (V)',
panel_name_updated = 'Solar Panel #%s name has been updated to %s',
panel_owner_updated = 'Solar Panel #%s owner has been updated to Citizen ID %s. \nOld Owner: %s',
power_outage = 'Power outage detected in the city!',
power_restored = 'Power has been restored in the city!',
no_access = 'You don\'t have access to this Solar Panel',
not_owner = 'You are not the owner of this Solar Panel',
repair_failed = 'You failed to repair this Solar Panel',
repair_success = 'You have successfully repaired this Solar Panel',
police_only_hack = 'Only Law Enforcement can hack Solar Panels',
cant_hack_own_panel = 'You can\'t hack a Solar Panel you have access to',
already_hacked = 'This solar panel is already hacked before, try again later',
cant_hack_camera = 'This panel can\'t be hacked',
loading_data = 'Loading Panel Data',
hack_police_notify = 'Someone is hacking the camera, the camera location is marked on the map',
panel_data_loaded = 'Panel successfully hacked & data loaded',
failed_hack = 'You failed to hack the panel',
power_exhausted = 'You have exhausted all the power from this Solar Panel',
hack_failed_wait = 'You already tried to hack the solar panel and failed, wait a while before the next attempt',
panel_access_updated = 'Solar Panel #%s access has been updated.',
already_secured = 'This Solar Panel already has security protection',
already_remote_control = 'This Solar Panel already has Remote Control installed',
success_secured = 'You have successfully bought hack protection for Solar Panel #%s',
remote_control_bought = 'You have successfully installed remote control for Solar Panel #%s',
power_capacity_updated = 'You have successfully updated Solar Panel #%s maximum power capacity. New value: %s (W)',
battery_voltage_updated = 'You have successfully updated Solar Panel #%s battery voltage. New value: %s (V)',
transfer_successfull = 'You have successfully transferred this Solar Panel to player - %s',
transfered_to_me = '%s just transferred Solar Panel #%s to you',
not_enough_income = 'There is not enough income for this Solar Panel',
income_withdrawn = 'You have successfully withdrawn %s from the Solar Panel\'s income',
panel_located = 'Solar Panel location is marked on the GPS',
no_panels_with_remote = 'You do not own solar panels with installed Remote Control',
},
buttons = {
cancel = 'Cancel',
finish = 'Finish',
move_down = 'Move Down',
move_up = 'Move Up',
move_right = 'Move Right',
move_left = 'Move Left',
move_forward = 'Move Forward',
move_back = 'Move Back',
rotate_right = 'Rotate Right',
rotate_left = 'Rotate Left',
},
logs = {
panels_created = 'All solar panels have been successfully created',
panel_created = '**%s** created a new Solar Panel.\n- Panel Name: **%s**',
update_settings = '**%s** updated settings for Solar Panels System.\n- New Settings: **%s**',
panel_deleted = '**%s** deleted Solar Panel permanently from the database.\n- Panel ID: **%s**',
energy_values_updated = '**%s** updated energy values for Solar Panel #%s.\n- New Power Value: **%s (W)**\n- New Maximum Power Value: **%s (W)**\n- New Battery Voltage Value: **%s (V)**',
panel_name_updated = '**%s** updated Solar Panel name.\n- Panel ID: **%s**\n- New Name: **%s**',
panel_owner_updated = '**%s** updated Solar Panel\'s owner.\n- Panel ID: **%s**\n- Old Owner Citizen ID: **%s**\n- New Owner Citizen ID: **%s**',
panel_access_updated = '**%s** updated Solar Panel access.\n- Panel ID: **%s**\n- Allowed Jobs: **%s**\n- Allowed Players: **%s**',
security_bought = '**%s** has just bought security protection for Solar Panel #%s',
remote_control_bought = '**%s** has just installed remote control for Solar Panel #%s',
panel_earnings_updated = '**%s** has just updated Solar Panel\'s earnings.\n- Panel ID: **%s**\n- New Earnings (Income): **%s**\n- Previous Earnings (Income): **%s**',
panel_security_remote_updated = '**%s** has just updated Solar Panel\'s settings.\n- Panel ID: **%s**\n- Security Enabled: **%s**\n- Remote Control Enabled: **%s**',
},
target = {
manage_panel = 'Manage Solar Panel',
hack_panel = 'Hack Solar Panel'
},
panel_3dtext = '%s\nStatus: %s~w~\nPower: %s/%s (W)\nBattery Voltage: %s (V)',
active = 'Active',
inactive = 'Inactive',
manage_panel = {
close = 'Close',
panel_info = 'Panel Info',
panel_info_description = 'Read all important information for this Solar Panel',
panel_info_info = {
('ID: **%s** \n'),
('Name: **%s** \n'),
('Owner: **%s** \n'),
(' \n'),
('Power: **%s (W)** \n'),
('Maximum Power: **%s (W)** \n'),
('Battery Voltage: **%s (V)** \n'),
(' \n'),
('Security: **%s** \n'),
('Remote Control: **%s** \n'),
(' \n'),
('Income: **%s** \n'),
('Total Power Produced: **%s (W)** \n'),
('Total Income: **%s** \n'),
},
enabled = 'Enabled',
disabled = 'Disabled',
rename_panel = 'Rename Panel',
rename_panel_description = 'Change the name of your Solar Panel',
panel_broken = 'Solar Panel Broken',
panel_broken_desc = 'This Solar Panel is broken, you have to repair it before you can access it. Do you want to repair it now?',
hack_panel = 'Hack Solar Panel',
hack_panel_sure = 'Are you sure you want to hack this Solar Panel?',
remove_panel = 'Remove Panel',
remove_panel_description = 'Permanently remove this Solar Panel. This will erase all earnings from the panel and it will not be recoverable',
remove_panel_sure = {
('Are you sure you want to remove this Solar Panel permanently? \n'),
('It is not possible to return it later. \n'),
},
update_access = 'Update Access',
update_access_desc = 'Update the access of jobs & players for this Solar Panel',
access_desc = 'Select the NEW players who will have access to this solar panel, you can\'t edit this later (optional)',
buy_security = 'Purchase Security (%s)',
buy_security_desc = 'Secure your Solar Panel from hackers',
buy_security_sure = 'Are you sure you want to purchase security for this solar panel?',
buy_remote_control = 'Install Remote Control (%s)',
buy_remote_control_desc = 'Access your Solar Panel from anywhere',
buy_remote_control_sure = 'Are you sure you want to install remote control for this solar panel?',
current_capacity = 'Current Capacity',
update_power_capacity = 'Update Power Capacity',
update_power_capacity_desc = 'Update power capacity for this Solar Panel. Power is used for producing city electricity. The more capacity Solar Panel has, the more it produces and earns',
current_voltage = 'Current Battery Voltage',
update_battery_voltage = 'Update Battery (Voltage)',
update_battery_voltage_desc = 'Update battery voltage for this Solar Panel. Battery is used for producing Solar Panel energy (power). The bigger the battery the more power is produced and money earned',
transfer_ownership = 'Transfer Ownership',
transfer_ownership_desc = 'Transfer ownership of this Solar Panel to another citizen',
transfer_ownership_option_desc = 'Choose to whom you will transfer this Solar Panel',
transfer_ownership_option_online = 'Transfer to online player',
transfer_ownership_option_offline = 'Transfer to offline player',
transfer_ownership_option_select_player = 'Select the player want to transfer this Solar Panel to',
transfer_ownership_option_input_citizen = 'Enter the Citizen ID of the player you want to transfer this solar panel to',
withdraw_earnings = 'Withdraw Earnings',
withdraw_earnings_desc = 'Withdraw the income earned from this Solar Panel, you can check the total income in "Panel Info"',
available = 'Available',
withdraw_earnings_amouunt = 'Amount you want to withdraw',
},
remote_control_device = {
label = 'Remote Control Device',
set_waypoint = 'Set Waypoint',
set_waypoint_desc = 'Set a waypoint and mark your solar panel on the GPS',
}
}
Last updated