├── .github └── images │ ├── qbtarget.jpg │ ├── ox_target.jpg │ └── keep-containers.jpg ├── inventoryImages ├── boltcutter.png ├── container_old_mid.png ├── container_blue_mid.png ├── container_white_mid.png └── container_green_small.png ├── .gitignore ├── client ├── lib.lua ├── targets │ ├── qbtarget.lua │ ├── qtarget.lua │ ├── oxtarget.lua │ └── functions.lua ├── actions.lua ├── client.lua └── creator.lua ├── server ├── lib.lua └── server.lua ├── fxmanifest.lua ├── config.lua ├── .editorconfig ├── README.md ├── shared ├── util.lua └── containers.lua └── LICENSE /.github/images/qbtarget.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/swkeep/keep-containers/HEAD/.github/images/qbtarget.jpg -------------------------------------------------------------------------------- /.github/images/ox_target.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/swkeep/keep-containers/HEAD/.github/images/ox_target.jpg -------------------------------------------------------------------------------- /inventoryImages/boltcutter.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/swkeep/keep-containers/HEAD/inventoryImages/boltcutter.png -------------------------------------------------------------------------------- /.github/images/keep-containers.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/swkeep/keep-containers/HEAD/.github/images/keep-containers.jpg -------------------------------------------------------------------------------- /inventoryImages/container_old_mid.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/swkeep/keep-containers/HEAD/inventoryImages/container_old_mid.png -------------------------------------------------------------------------------- /inventoryImages/container_blue_mid.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/swkeep/keep-containers/HEAD/inventoryImages/container_blue_mid.png -------------------------------------------------------------------------------- /inventoryImages/container_white_mid.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/swkeep/keep-containers/HEAD/inventoryImages/container_white_mid.png -------------------------------------------------------------------------------- /inventoryImages/container_green_small.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/swkeep/keep-containers/HEAD/inventoryImages/container_green_small.png -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Compiled Lua sources 2 | luac.out 3 | /lua 4 | test.lua 5 | # luarocks build files 6 | *.src.rock 7 | *.zip 8 | *.tar.gz 9 | 10 | # Object files 11 | *.o 12 | *.os 13 | *.ko 14 | *.obj 15 | *.elf 16 | 17 | # Precompiled Headers 18 | *.gch 19 | *.pch 20 | 21 | # Libraries 22 | *.lib 23 | *.a 24 | *.la 25 | *.lo 26 | *.def 27 | *.exp 28 | 29 | # Shared objects (inc. Windows DLLs) 30 | *.dll 31 | *.so 32 | *.so.* 33 | *.dylib 34 | 35 | # Executables 36 | *.exe 37 | *.out 38 | *.app 39 | *.i*86 40 | *.x86_64 41 | *.hex 42 | 43 | /.vscode 44 | /watch.js 45 | .editorconfig 46 | -------------------------------------------------------------------------------- /client/lib.lua: -------------------------------------------------------------------------------- 1 | -- _ 2 | -- | | 3 | -- _____ _| | _____ ___ _ __ 4 | -- / __\ \ /\ / / |/ / _ \/ _ \ '_ \ 5 | -- \__ \\ V V /| < __/ __/ |_) | 6 | -- |___/ \_/\_/ |_|\_\___|\___| .__/ 7 | -- | | 8 | -- |_| 9 | -- https://github.com/swkeep 10 | -- this is qb-core's implementation of callbacks all credits to them 11 | ServerCallbacks = {} 12 | 13 | function TriggerCallback( name, cb, ... ) 14 | ServerCallbacks[name] = cb 15 | TriggerServerEvent("Server:TriggerCallback", name, ...) 16 | end 17 | 18 | RegisterNetEvent("Client:TriggerCallback", function( name, ... ) 19 | if ServerCallbacks[name] then 20 | ServerCallbacks[name](...) 21 | ServerCallbacks[name] = nil 22 | end 23 | end) 24 | -------------------------------------------------------------------------------- /server/lib.lua: -------------------------------------------------------------------------------- 1 | -- _ 2 | -- | | 3 | -- _____ _| | _____ ___ _ __ 4 | -- / __\ \ /\ / / |/ / _ \/ _ \ '_ \ 5 | -- \__ \\ V V /| < __/ __/ |_) | 6 | -- |___/ \_/\_/ |_|\_\___|\___| .__/ 7 | -- | | 8 | -- |_| 9 | -- https://github.com/swkeep 10 | ServerCallbacks = {} 11 | 12 | function CreateCallback( name, cb ) ServerCallbacks[name] = cb end 13 | 14 | function TriggerCallback( name, source, cb, ... ) 15 | if not ServerCallbacks[name] then return end 16 | ServerCallbacks[name](source, cb, ...) 17 | end 18 | 19 | RegisterNetEvent("Server:TriggerCallback", function( name, ... ) 20 | local src = source 21 | TriggerCallback(name, src, function( ... ) TriggerClientEvent("Client:TriggerCallback", src, name, ...) end, ...) 22 | end) 23 | 24 | function Notification_S( src, msg, type ) TriggerClientEvent("keep-containers:client:notification", src, msg, type) end 25 | -------------------------------------------------------------------------------- /fxmanifest.lua: -------------------------------------------------------------------------------- 1 | -- _ 2 | -- | | 3 | -- _____ _| | _____ ___ _ __ 4 | -- / __\ \ /\ / / |/ / _ \/ _ \ '_ \ 5 | -- \__ \\ V V /| < __/ __/ |_) | 6 | -- |___/ \_/\_/ |_|\_\___|\___| .__/ 7 | -- | | 8 | -- |_| 9 | -- https://github.com/swkeep 10 | fx_version "cerulean" 11 | games { 12 | "gta5" 13 | } 14 | 15 | author "Swkeep#7049" 16 | version "1.1.0" 17 | 18 | shared_scripts { 19 | "@ox_lib/init.lua", 20 | "shared/containers.lua", 21 | "config.lua", 22 | "shared/util.lua" 23 | } 24 | 25 | client_scripts { 26 | "@PolyZone/client.lua", 27 | "client/lib.lua", 28 | "client/actions.lua", 29 | "client/creator.lua", 30 | "client/targets/functions.lua", 31 | "client/targets/qtarget.lua", 32 | "client/targets/qbtarget.lua", 33 | "client/targets/oxtarget.lua", 34 | "client/client.lua" 35 | } 36 | 37 | server_scripts { 38 | "@oxmysql/lib/MySQL.lua", 39 | "server/lib.lua", 40 | "server/server.lua" 41 | } 42 | 43 | lua54 "yes" 44 | -------------------------------------------------------------------------------- /client/targets/qbtarget.lua: -------------------------------------------------------------------------------- 1 | function Qb_target( private, entity ) 2 | exports["qb-target"]:AddTargetEntity(entity, { 3 | options = { 4 | { 5 | icon = "fas fa-box", 6 | label = "Open Container", 7 | action = function() OpenContainer(private, entity) end 8 | }, 9 | { 10 | icon = "fas fa-box", 11 | label = "Change Password", 12 | action = function() ChangePassword(private, entity) end 13 | }, 14 | { 15 | icon = "fas fa-box", 16 | label = "Transfer Ownership", 17 | action = function() TransferOwnership(private, entity) end 18 | }, 19 | { 20 | icon = "fas fa-box", 21 | label = "Delete Container", 22 | canInteract = function() return SuperUser() end, 23 | action = function() DeleteContainer(private, entity) end 24 | }, 25 | { 26 | icon = "fa-solid fa-arrows-up-down-left-right", 27 | label = "Move Container", 28 | canInteract = function() return SuperUser() end, 29 | action = function() MoveContainer(private, entity) end 30 | }, 31 | { 32 | icon = "fa-solid fa-scissors", 33 | label = "Boltcutter (Police)", 34 | canInteract = function() return HasAccessToBoltCutter() end, 35 | action = function() BoltCutter(private, entity) end 36 | } 37 | }, 38 | distance = 1.0 39 | }) 40 | end 41 | -------------------------------------------------------------------------------- /client/targets/qtarget.lua: -------------------------------------------------------------------------------- 1 | function Qtarget( private, entity ) 2 | exports["qtarget"]:AddTargetEntity(entity, { 3 | options = { 4 | { 5 | icon = "fas fa-box", 6 | label = "Open Container", 7 | action = function() OpenContainer(private, entity) end 8 | }, 9 | { 10 | icon = "fa-solid fa-key", 11 | label = "Change Password", 12 | action = function() ChangePassword(private, entity) end 13 | }, 14 | { 15 | icon = "fa-solid fa-right-left", 16 | label = "Transfer Ownership", 17 | action = function() TransferOwnership(private, entity) end 18 | }, 19 | { 20 | icon = "fas fa-trash", 21 | label = "Delete Container", 22 | canInteract = function() return SuperUser() end, 23 | action = function() DeleteContainer(private, entity) end 24 | }, 25 | { 26 | icon = "fa-solid fa-arrows-up-down-left-right", 27 | label = "Move Container", 28 | canInteract = function() return SuperUser() end, 29 | action = function() MoveContainer(private, entity) end 30 | }, 31 | { 32 | icon = "fa-solid fa-scissors", 33 | label = "Boltcutter (Police)", 34 | canInteract = function() return HasAccessToBoltCutter() end, 35 | action = function() BoltCutter(private, entity) end 36 | } 37 | }, 38 | distance = 1.0 39 | }) 40 | end 41 | -------------------------------------------------------------------------------- /client/targets/oxtarget.lua: -------------------------------------------------------------------------------- 1 | function Ox_target( private, entity ) 2 | exports["ox_target"]:addLocalEntity(entity, { 3 | { 4 | icon = "fas fa-box", 5 | distance = 1.0, 6 | label = "Open Container", 7 | onSelect = function() OpenContainer(private, entity) end 8 | }, 9 | { 10 | icon = "fa-solid fa-key", 11 | distance = 1.0, 12 | label = "Change Password", 13 | onSelect = function() ChangePassword(private, entity) end 14 | }, 15 | { 16 | icon = "fa-solid fa-right-left", 17 | distance = 1.0, 18 | label = "Transfer Ownership", 19 | onSelect = function() TransferOwnership(private, entity) end 20 | }, 21 | { 22 | icon = "fas fa-trash", 23 | distance = 1.0, 24 | label = "Delete Container", 25 | canInteract = function() return SuperUser() end, 26 | onSelect = function() DeleteContainer(private, entity) end 27 | }, 28 | { 29 | icon = "fa-solid fa-arrows-up-down-left-right", 30 | distance = 1.0, 31 | label = "Move Container", 32 | canInteract = function() return SuperUser() end, 33 | onSelect = function() MoveContainer(private, entity) end 34 | }, 35 | { 36 | icon = "fa-solid fa-scissors", 37 | distance = 1.0, 38 | label = "Boltcutter (Police)", 39 | canInteract = function() return HasAccessToBoltCutter() end, 40 | onSelect = function() BoltCutter(private, entity) end 41 | } 42 | }) 43 | end 44 | -------------------------------------------------------------------------------- /config.lua: -------------------------------------------------------------------------------- 1 | -- _ 2 | -- | | 3 | -- _____ _| | _____ ___ _ __ 4 | -- / __\ \ /\ / / |/ / _ \/ _ \ '_ \ 5 | -- \__ \\ V V /| < __/ __/ |_) | 6 | -- |___/ \_/\_/ |_|\_\___|\___| .__/ 7 | -- | | 8 | -- |_| 9 | -- https://github.com/swkeep 10 | Config = Config or {} 11 | 12 | -- to add more items/containers check shared/containers.lua 13 | 14 | Config.MagicTouch = false 15 | Config.FrameWork = "qb" -- qb/esx/qbox 16 | Config.input = "ox_lib" -- keep-input / qb-input / ox_lib (ESX) 17 | Config.esx_target = "ox_target" -- ox_target / qtarget (ONLY ESX won't effect qbcore) 18 | 19 | Config.container_depots = { 20 | -- when adding new zone make sure it has enough minZ and maxZ or might get into issue with placing system 21 | ["LT_WELD_SUPPLY"] = { 22 | name = "LT Weld Ssupply", 23 | positions = { 24 | vector2(1219.7977294922, -1369.8439941406), 25 | vector2(1177.3232421875, -1366.3834228516), 26 | vector2(1183.0499267578, -1292.2061767578), 27 | vector2(1226.3927001953, -1296.7211914062) 28 | }, 29 | minz = 33.00, 30 | maxz = 40.00, 31 | blip = { 32 | name = "Containers Depot", 33 | coords = vector3(1199.14, -1364.4923, 35.21), 34 | scale = 1.5, 35 | color = 43, 36 | sprite = 677 37 | } 38 | }, 39 | ["POSTAL"] = { 40 | name = "Postal Depot", 41 | positions = { 42 | vector2(1178.2783203125, -1287.4509277344), 43 | vector2(1175.4, -1232), 44 | vector2(1203.64, -1222.33), 45 | vector2(1229.0767822266, -1221.9503173828), 46 | vector2(1227.5753173828, -1289.41796875) 47 | }, 48 | minz = 33.00, 49 | maxz = 45.00, 50 | blip = { 51 | name = "Postal Containers Depot", 52 | coords = vector3(1199.14, -1364.4923, 35.21), 53 | scale = 1.5, 54 | color = 43, 55 | sprite = 677 56 | } 57 | } 58 | } 59 | 60 | -- just give it to admins they can access containers and remove them! 61 | Config.super_users = { 62 | ["Gxxxxxxx2"] = true, -- < in qb use character citizen id 63 | ["char1:8xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx5"] = true --- < in esx use users's identifier 64 | } 65 | 66 | -- Who can use BoltCutter (Police by defualt) 67 | 68 | Config.bolt_cutter = { 69 | -- ['jobname'] = {grades} 70 | ["police"] = { 71 | -- [grade(number)] = true/false 72 | [0] = true, 73 | [1] = true 74 | } 75 | } 76 | 77 | Config.remove_bolt_cutter_on_use = true 78 | -- Do not change this value (if you already have a bolt cutter item, you can change it to what you have) 79 | Config.bolt_cutter_item_name = "containerboltcutter" 80 | -------------------------------------------------------------------------------- /client/actions.lua: -------------------------------------------------------------------------------- 1 | -- _ 2 | -- | | 3 | -- _____ _| | _____ ___ _ __ 4 | -- / __\ \ /\ / / |/ / _ \/ _ \ '_ \ 5 | -- \__ \\ V V /| < __/ __/ |_) | 6 | -- |___/ \_/\_/ |_|\_\___|\___| .__/ 7 | -- | | 8 | -- |_| 9 | -- https://github.com/swkeep 10 | local function LoadAnimationDict(animation) 11 | RequestAnimDict(animation) 12 | while not HasAnimDictLoaded(animation) do Wait(25) end 13 | end 14 | 15 | local function makeEntityFaceCoord(entity, coord) 16 | local p1 = GetEntityCoords(entity, true) 17 | 18 | SetEntityHeading(entity, GetHeadingFromVector_2d((coord.x - p1.x), (coord.y - p1.y))) 19 | end 20 | 21 | local function open_animation() 22 | if Framework() == 2 then Wait(1000) end 23 | LoadAnimationDict("amb@prop_human_bum_bin@idle_b") 24 | TaskPlayAnim(PlayerPedId(), "amb@prop_human_bum_bin@idle_b", "idle_d", 4.0, 4.0, -1, 50, 1, false, false, false) 25 | end 26 | 27 | local function close_aimation() 28 | LoadAnimationDict("amb@prop_human_bum_bin@idle_b") 29 | TaskPlayAnim(PlayerPedId(), "amb@prop_human_bum_bin@idle_b", "exit", 4.0, 4.0, -1, 50, 0, false, false, false) 30 | Wait(1500) 31 | ClearPedTasks(PlayerPedId()) 32 | end 33 | 34 | local function Close() 35 | local duration = 1 36 | if Framework() == 1 then 37 | Core.Functions.Progressbar("keep_container_close", "Close", duration * 1000, false, false, { 38 | disableMovement = true, 39 | disableCarMovement = false, 40 | disableMouse = false, 41 | disableCombat = true 42 | }, {}, {}, {}, function() close_aimation() end) 43 | elseif Framework() == 2 or Framework() == 3 then 44 | close_aimation() 45 | end 46 | end 47 | 48 | local function open_stash(metadata) 49 | local id = "Container_" .. metadata.random_id 50 | local framework = Framework() 51 | 52 | if framework == 1 then 53 | open_animation() 54 | TriggerServerEvent("inventory:server:OpenInventory", "stash", id, { 55 | maxweight = metadata.size, 56 | slots = metadata.slots 57 | }) 58 | TriggerEvent("inventory:client:SetCurrentStash", id) 59 | elseif framework == 2 or framework == 3 then 60 | exports["ox_inventory"]:openInventory("stash", { 61 | id = id 62 | }) 63 | open_animation() 64 | end 65 | 66 | Wait(1000) 67 | repeat Wait(100) until IsNuiFocused() == false 68 | Close() 69 | end 70 | 71 | RegisterNetEvent("keep-containers:client:open", function(metadata) 72 | if not metadata then return end 73 | local duration = 1 74 | 75 | if Config.input == "ox_lib" then 76 | if lib.progressCircle({ 77 | duration = 2000, 78 | position = "bottom", 79 | useWhileDead = false, 80 | canCancel = true, 81 | disable = { 82 | car = true, 83 | move = true, 84 | combat = true 85 | 86 | } 87 | }) then 88 | open_stash(metadata) 89 | else 90 | print("Do stuff when cancelled") 91 | end 92 | else 93 | Core.Functions.Progressbar("keep_container_opening", "Open", duration * 1000, false, false, { 94 | disableMovement = true, 95 | disableCarMovement = false, 96 | disableMouse = false, 97 | disableCombat = true 98 | }, {}, {}, {}, function() open_stash(metadata) end) 99 | end 100 | end) 101 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | 2 | # see https://github.com/CppCXY/EmmyLuaCodeStyle 3 | [*.lua] 4 | # [basic] 5 | 6 | # optional space/tab 7 | indent_style = space 8 | # if indent_style is space, this is valid 9 | indent_size = 4 10 | # if indent_style is tab, this is valid 11 | tab_width = 4 12 | # none/single/double 13 | quote_style = none 14 | 15 | # only support number 16 | continuation_indent_size = 4 17 | 18 | # optional crlf/lf/cr/auto, if it is 'auto', in windows it is crlf other platforms are lf 19 | end_of_line = auto 20 | 21 | detect_end_of_line = false 22 | 23 | # this mean utf8 length , if this is 'unset' then the line width is no longer checked 24 | # this option decides when to chopdown the code 25 | max_line_length = 200 26 | 27 | # this will check text end with new line(format always end with new line) 28 | insert_final_newline = true 29 | 30 | # [function] 31 | 32 | # function call expression's args will align to first arg 33 | # optional true/false/only_after_more_indention_statement/only_not_exist_cross_row_expression 34 | align_call_args = false 35 | 36 | # if true, all function define params will align to first param 37 | align_function_define_params = true 38 | 39 | remove_expression_list_finish_comma = true 40 | 41 | # keep/remove/remove_table_only/remove_string_only/unambiguous_remove_string_only 42 | call_arg_parentheses = keep 43 | 44 | # [table] 45 | 46 | # see document for detail 47 | continuous_assign_table_field_align_to_equal_sign = true 48 | 49 | # if true, format like this "local t = { 1, 2, 3 }" 50 | keep_one_space_between_table_and_bracket = true 51 | 52 | # if indent_style is tab, this option is invalid 53 | align_table_field_to_first_field = false 54 | 55 | # [statement] 56 | 57 | align_chained_expression_statement = false 58 | 59 | # continous line distance 60 | max_continuous_line_distance = 1 61 | 62 | # see document for detail 63 | continuous_assign_statement_align_to_equal_sign = true 64 | 65 | # if statement will align like switch case 66 | if_condition_align_with_each_other = false 67 | 68 | # if true, continuation_indent_size for local or assign statement is invalid 69 | # however, if the expression list has cross row expression, it will not be aligned to the first expression 70 | local_assign_continuation_align_to_first_expression = false 71 | 72 | statement_inline_comment_space = 1 73 | 74 | # [indentation] 75 | 76 | # if true, the label loses its current indentation 77 | label_no_indent = false 78 | # if true, there will be no indentation in the do statement 79 | do_statement_no_indent = false 80 | # if true, the conditional expression of the if statement will not be a continuation line indent 81 | if_condition_no_continuation_indent = false 82 | 83 | if_branch_comments_after_block_no_indent = false 84 | 85 | # [space] 86 | 87 | # if true, t[#t+1] will not space wrapper '+' 88 | table_append_expression_no_space = false 89 | 90 | long_chain_expression_allow_one_space_after_colon = false 91 | 92 | remove_empty_header_and_footer_lines_in_function = true 93 | 94 | space_before_function_open_parenthesis = false 95 | 96 | space_before_open_square_bracket = false 97 | 98 | # if true, ormat like this "local t = 1" 99 | keep_one_space_between_namedef_and_attribute = true 100 | 101 | # [row_layout] 102 | # The following configuration supports four expressions 103 | # minLine:${n} 104 | # keepLine 105 | # keepLine:${n} 106 | # maxLine:${n} 107 | 108 | keep_line_after_if_statement = minLine:0 109 | 110 | keep_line_after_do_statement = minLine:0 111 | 112 | keep_line_after_while_statement = minLine:0 113 | 114 | keep_line_after_repeat_statement = minLine:0 115 | 116 | keep_line_after_for_statement = minLine:0 117 | 118 | keep_line_after_local_or_assign_statement = keepLine 119 | 120 | keep_line_after_function_define_statement = keepLine:1 121 | 122 | keep_line_after_expression_statement = keepLine 123 | 124 | # [diagnostic] 125 | 126 | # the following is code diagnostic options 127 | enable_check_codestyle = true 128 | 129 | # [diagnostic.name_style] 130 | enable_name_style_check = false 131 | # the following is name style check rule 132 | # base option off/camel_case/snake_case/upper_snake_case/pascal_case/same(filename/first_param/'', snake_case/pascal_case/camel_case) 133 | # all option can use '|' represent or 134 | # for example: 135 | # snake_case | upper_snake_case 136 | # same(first_param, snake_case) 137 | # same('m') 138 | local_name_define_style = snake_case 139 | 140 | function_param_name_style = snake_case 141 | 142 | function_name_define_style = snake_case 143 | 144 | local_function_name_define_style = snake_case 145 | 146 | table_field_name_define_style = snake_case 147 | 148 | global_variable_name_define_style = snake_case|upper_snake_case 149 | 150 | module_name_define_style = same('m')|same(filename, snake_case) 151 | 152 | require_module_name_style = same(first_param, snake_case) 153 | 154 | class_name_define_style = same(filename, snake_case) 155 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ![Keep-containers](https://raw.githubusercontent.com/swkeep/keep-containers/master/.github/images/keep-containers.jpg) 2 | 3 | # keep-containers 4 | By using this script you're going to have access to custom container depot zones. 5 | In Container Depot you can place containers and have access to them with a password. 6 | 7 | # Dependencies 8 | 9 | - [qb-core](https://github.com/qbcore-framework/qb-core) 10 | - [keep-input](https://github.com/swkeep/keep-input) or [qb-input](https://github.com/qbcore-framework/qb-input) 11 | - [PolyZone](https://github.com/mkafrin/PolyZone) 12 | - [qb-target]() 13 | 14 | OR 15 | 16 | - [esx-legacy](https://github.com/esx-framework/esx-legacy) 17 | - [keep-input](https://github.com/swkeep/keep-input) or [ox_lib](https://github.com/overextended/ox_lib) 18 | - [PolyZone](https://github.com/mkafrin/PolyZone) 19 | - [ox_inventory](https://github.com/overextended/ox_inventory) 20 | - [ox_target](https://github.com/overextended/ox_target) 21 | 22 | ## Features 23 | 24 | - Custom container size and weight 25 | - Ability to transfer ownership of containers 26 | - Locking containers with password (encrypted by bcrypt) 27 | - Container variant 28 | - Dynamic object loading 29 | - Little bit of admin control (WIP) 30 | - Container placer! (i don't know what to call it!) 31 | 32 | ## Preview 33 | 34 | - [Version 1.0.0](https://youtu.be/dTQa6EVSSVc) 35 | 36 | ## Screenshots 37 | ![Keep-containers](https://raw.githubusercontent.com/swkeep/keep-containers/master/.github/images/ox_target.jpg) 38 | ![Keep-containers](https://raw.githubusercontent.com/swkeep/keep-containers/master/.github/images/qbtarget.jpg) 39 | 40 | ## Installation 41 | 42 | - Step 1: Drag and drop resources onto your server! 43 | - Step 1-2: You don't need to import sql in your database script is doing it itself. 44 | - Step 2: Configure the script in the framework of your choice. 45 | - Step 3: Add items to the list 46 | 47 | - QBCore (shared/items.lua) 48 | ```lua 49 | ["containergreensmall"] = { 50 | ["name"] = "containergreensmall", 51 | ["label"] = "Small Green Container", 52 | ["weight"] = 5000, 53 | ["type"] = "item", 54 | ["image"] = "container_green_small.png", 55 | ["unique"] = true, 56 | ["useable"] = true, 57 | ["shouldClose"] = true, 58 | ["combinable"] = nil, 59 | ["description"] = "Small Green Container" 60 | }, 61 | 62 | ["containerbluemid"] = { 63 | ["name"] = "containerbluemid", 64 | ["label"] = "Mid Blue Container", 65 | ["weight"] = 5000, 66 | ["type"] = "item", 67 | ["image"] = "container_blue_mid.png", 68 | ["unique"] = true, 69 | ["useable"] = true, 70 | ["shouldClose"] = true, 71 | ["combinable"] = nil, 72 | ["description"] = "Small Green Container" 73 | }, 74 | 75 | ["containeroldmid"] = { 76 | ["name"] = "containeroldmid", 77 | ["label"] = "Mid Old Container", 78 | ["weight"] = 5000, 79 | ["type"] = "item", 80 | ["image"] = "container_old_mid.png", 81 | ["unique"] = true, 82 | ["useable"] = true, 83 | ["shouldClose"] = true, 84 | ["combinable"] = nil, 85 | ["description"] = "Small Green Container" 86 | }, 87 | 88 | ["containerwhitemid"] = { 89 | ["name"] = "containerwhitemid", 90 | ["label"] = "Mid White Container", 91 | ["weight"] = 5000, 92 | ["type"] = "item", 93 | ["image"] = "container_white_mid.png", 94 | ["unique"] = true, 95 | ["useable"] = true, 96 | ["shouldClose"] = true, 97 | ["combinable"] = nil, 98 | ["description"] = "Small Green Container" 99 | }, 100 | 101 | ["containerboltcutter"] = { 102 | ["name"] = "containerboltcutter", 103 | ["label"] = "Boltcutter", 104 | ["weight"] = 1000, 105 | ["type"] = "item", 106 | ["image"] = "boltcutter.png", 107 | ["unique"] = true, 108 | ["useable"] = false, 109 | ["shouldClose"] = false, 110 | ["combinable"] = nil, 111 | ["description"] = "a boltcutter to open containers by police" 112 | } 113 | ``` 114 | 115 | - ESX (ox_inventory/data/items.lua) 116 | ```lua 117 | ["container_green_small"] = { 118 | label = "Small Green Container", 119 | weight = 5, 120 | stack = false, 121 | close = true, 122 | description = nil 123 | }, 124 | 125 | ["container_blue_mid"] = { 126 | label = "Mid Blue Container", 127 | weight = 15, 128 | stack = false, 129 | close = true, 130 | description = nil 131 | }, 132 | 133 | ["container_old_mid"] = { 134 | label = "Mid Old Container", 135 | weight = 15, 136 | stack = false, 137 | close = true, 138 | description = nil 139 | }, 140 | 141 | ["container_white_mid"] = { 142 | label = "Mid White Container", 143 | weight = 15, 144 | stack = false, 145 | close = true, 146 | description = nil 147 | }, 148 | 149 | ["containerboltcutter"] = { 150 | label = "Boltcutter", 151 | weight = 1, 152 | stack = false, 153 | close = false, 154 | description = 'a boltcutter to open containers by police' 155 | } 156 | ``` 157 | 158 | - Step 4: If you want to use ox_lib, make sure this line "@ox_lib/init.lua" in fxmanifest.lua is uncommented. 159 | -------------------------------------------------------------------------------- /shared/util.lua: -------------------------------------------------------------------------------- 1 | -- _ 2 | -- | | 3 | -- _____ _| | _____ ___ _ __ 4 | -- / __\ \ /\ / / |/ / _ \/ _ \ '_ \ 5 | -- \__ \\ V V /| < __/ __/ |_) | 6 | -- |___/ \_/\_/ |_|\_\___|\___| .__/ 7 | -- | | 8 | -- |_| 9 | -- https://github.com/swkeep 10 | ---print tables : debug 11 | ---@param node table 12 | function print_table(node) 13 | local cache, stack, output = {}, {}, {} 14 | local depth = 1 15 | local output_str = "{\n" 16 | 17 | while true do 18 | local size = 0 19 | for k, v in pairs(node) do size = size + 1 end 20 | 21 | local cur_index = 1 22 | for k, v in pairs(node) do 23 | if (cache[node] == nil) or (cur_index >= cache[node]) then 24 | if (string.find(output_str, "}", output_str:len())) then 25 | output_str = output_str .. ",\n" 26 | elseif not (string.find(output_str, "\n", output_str:len())) then 27 | output_str = output_str .. "\n" 28 | end 29 | 30 | -- This is necessary for working with HUGE tables otherwise we run out of memory using concat on huge strings 31 | table.insert(output, output_str) 32 | output_str = "" 33 | 34 | local key 35 | if (type(k) == "number" or type(k) == "boolean") then 36 | key = "[" .. tostring(k) .. "]" 37 | else 38 | key = "['" .. tostring(k) .. "']" 39 | end 40 | 41 | if (type(v) == "number" or type(v) == "boolean") then 42 | output_str = output_str .. string.rep("\t", depth) .. key .. " = " .. tostring(v) 43 | elseif (type(v) == "table") then 44 | output_str = output_str .. string.rep("\t", depth) .. key .. " = {\n" 45 | table.insert(stack, node) 46 | table.insert(stack, v) 47 | cache[node] = cur_index + 1 48 | break 49 | else 50 | output_str = output_str .. string.rep("\t", depth) .. key .. " = '" .. tostring(v) .. "'" 51 | end 52 | 53 | if (cur_index == size) then 54 | output_str = output_str .. "\n" .. string.rep("\t", depth - 1) .. "}" 55 | else 56 | output_str = output_str .. "," 57 | end 58 | else 59 | -- close the table 60 | if (cur_index == size) then output_str = output_str .. "\n" .. string.rep("\t", depth - 1) .. "}" end 61 | end 62 | 63 | cur_index = cur_index + 1 64 | end 65 | 66 | if (size == 0) then output_str = output_str .. "\n" .. string.rep("\t", depth - 1) .. "}" end 67 | 68 | if (#stack > 0) then 69 | node = stack[#stack] 70 | stack[#stack] = nil 71 | depth = cache[node] == nil and depth + 1 or depth - 1 72 | else 73 | break 74 | end 75 | end 76 | 77 | -- This is necessary for working with HUGE tables otherwise we run out of memory using concat on huge strings 78 | table.insert(output, output_str) 79 | output_str = table.concat(output) 80 | 81 | print(output_str) 82 | end 83 | 84 | -- Return the first index with the given value (or nil if not found). 85 | function IndexOf(array, value) 86 | for i, v in ipairs(array) do if v == value then return i end end 87 | return nil 88 | end 89 | 90 | -- Return a key with the given value (or nil if not found). If there are 91 | -- multiple keys with that value, the particular key returned is arbitrary. 92 | function KeyOf(tbl, value) 93 | for k, v in pairs(tbl) do if v == value then return k end end 94 | return nil 95 | end 96 | 97 | function RoundNum(n) return math.floor(n + 0.5) end 98 | 99 | function Round(num, dp) 100 | local mult = 10 ^ (dp or 0) 101 | return math.floor(num * mult + 0.5) / mult 102 | end 103 | 104 | function RandomID(length) 105 | local string = "" 106 | for i = 1, length do 107 | local str = string.char(math.random(97, 122)) 108 | if math.random(1, 2) == 1 then 109 | if math.random(1, 2) == 1 then 110 | str = str:upper() 111 | else 112 | str = str:lower() 113 | end 114 | else 115 | str = tostring(math.random(0, 9)) 116 | end 117 | string = string .. str 118 | end 119 | return string 120 | end 121 | 122 | function Framework() 123 | if Config.FrameWork:lower() == "qb" then 124 | return 1 125 | elseif Config.FrameWork:lower() == "esx" then 126 | return 2 127 | elseif Config.FrameWork:lower() == "qbox" then 128 | return 3 129 | end 130 | end 131 | 132 | function GetCoreObject() 133 | if Framework() == 1 or Framework() == 3 then 134 | -- QBCore 135 | return exports["qb-core"]:GetCoreObject() 136 | elseif Framework() == 2 then 137 | return exports["es_extended"]:getSharedObject() 138 | end 139 | end 140 | 141 | function TableToVector3(t) return vector3(t.x, t.y, t.z) end 142 | 143 | function LoadModel(hash) 144 | if not HasModelLoaded(hash) then 145 | RequestModel(hash) 146 | while not HasModelLoaded(hash) do Wait(10) end 147 | end 148 | end 149 | 150 | function WaitForEntity(entity) while not DoesEntityExist(entity) do Wait(10) end end 151 | -------------------------------------------------------------------------------- /shared/containers.lua: -------------------------------------------------------------------------------- 1 | -- _ 2 | -- | | 3 | -- _____ _| | _____ ___ _ __ 4 | -- / __\ \ /\ / / |/ / _ \/ _ \ '_ \ 5 | -- \__ \\ V V /| < __/ __/ |_) | 6 | -- |___/ \_/\_/ |_|\_\___|\___| .__/ 7 | -- | | 8 | -- |_| 9 | -- https://github.com/swkeep 10 | -- container's types 11 | local types = { 12 | ["SMALL"] = { 13 | size = 75000, 14 | slots = 25 15 | }, 16 | ["MID"] = { 17 | size = 100000, 18 | slots = 50 19 | }, 20 | ["BIG"] = { 21 | size = 500000, 22 | slots = 75 23 | } 24 | } 25 | 26 | -- container's objects 27 | local Object = { 28 | ["SMALL"] = { 29 | ["green"] = { 30 | -- no logo 31 | name = "prop_container_05mb", -- Embedded Collision, basegame 32 | offset = vector3(0, 0, 0) 33 | }, 34 | ["red"] = { 35 | -- no logo 36 | name = "prop_container_05a", -- Embedded Collision, basegame 37 | offset = vector3(0, 0, 0) 38 | }, 39 | ["redred"] = { 40 | -- no logo 41 | name = "prop_container_ld_pu", -- Embedded Collision, basegame 42 | offset = vector3(0, 0, 0) 43 | } 44 | }, 45 | ["MID"] = { 46 | ["red"] = { 47 | -- no logo 48 | name = "prop_container_03a", -- Embedded Collision, basegame 49 | offset = vector3(0, 0, 0) 50 | }, 51 | ["blue"] = { 52 | -- no logo 53 | name = "prop_container_03b", -- Embedded Collision, basegame 54 | offset = vector3(0, 0, 0) 55 | }, 56 | ["green"] = { 57 | -- no logo 58 | name = "prop_container_01mb", -- Embedded Collision, basegame 59 | offset = vector3(0, 0, 0) 60 | }, 61 | ["old"] = { 62 | -- no logo 63 | name = "prop_container_old1", -- Embedded Collision, basegame 64 | offset = vector3(0, 0, 0) 65 | } 66 | }, 67 | ["BIG"] = { 68 | ["red"] = { 69 | -- no logo 70 | name = "prop_container_01a", -- Embedded Collision, basegame 71 | offset = vector3(0, 0, 0) 72 | }, 73 | ["green"] = { 74 | -- no logo 75 | name = "prop_container_01mb", -- Embedded Collision, basegame 76 | offset = vector3(0, 0, 0) 77 | }, 78 | ["krapea_green"] = { 79 | -- logo krapea 80 | name = "prop_container_01b", -- Embedded Collision, basegame 81 | offset = vector3(0, 0, 0) 82 | }, 83 | ["bilgeco_blue"] = { 84 | -- logo bilgeco 85 | name = "prop_container_01c", -- Embedded Collision, basegame 86 | offset = vector3(0, 0, 0) 87 | }, 88 | ["bilgeco_green"] = { 89 | -- logo bilgeco 90 | name = "prop_container_01e", -- Embedded Collision, basegame 91 | offset = vector3(0, 0, 0) 92 | }, 93 | ["teal"] = { 94 | -- logo jetsam 95 | name = "prop_container_01d", -- Embedded Collision, basegame 96 | offset = vector3(0, 0, 0) 97 | }, 98 | ["white"] = { 99 | -- logo lando-crop 100 | name = "prop_container_01f", -- Embedded Collision, basegame 101 | offset = vector3(0, 0, 0) 102 | }, 103 | ["postal_white"] = { 104 | -- logo lando-crop 105 | name = "prop_container_01g", -- Embedded Collision, basegame 106 | offset = vector3(0, 0, 0) 107 | }, 108 | ["brown"] = { 109 | -- logo lando-crop 110 | name = "prop_container_01h", -- Embedded Collision, basegame 111 | offset = vector3(0, 0, 0) 112 | } 113 | } 114 | } 115 | 116 | -- ESX 117 | local containers = { 118 | ["container_green_small"] = { 119 | type = types.SMALL, 120 | object = Object.SMALL.green 121 | }, 122 | 123 | ["container_blue_mid"] = { 124 | type = types.BIG, 125 | object = Object.BIG.teal 126 | }, 127 | 128 | ["container_old_mid"] = { 129 | type = types.BIG, 130 | object = Object.MID.old 131 | }, 132 | 133 | ["container_white_mid"] = { 134 | type = types.BIG, 135 | object = Object.BIG.white 136 | } 137 | } 138 | 139 | -- QBCORE 140 | local qbcore_containers = { 141 | ["containergreensmall"] = { 142 | type = types.SMALL, 143 | object = Object.SMALL.green 144 | }, 145 | 146 | ["containerbluemid"] = { 147 | type = types.BIG, 148 | object = Object.BIG.teal 149 | }, 150 | 151 | ["containeroldmid"] = { 152 | type = types.BIG, 153 | object = Object.MID.old 154 | }, 155 | 156 | ["containerwhitemid"] = { 157 | type = types.BIG, 158 | object = Object.BIG.white 159 | } 160 | } 161 | 162 | function GetContainerInfromation(container_name) 163 | if Framework() == 1 then 164 | if qbcore_containers[container_name] then return qbcore_containers[container_name] end 165 | elseif Framework() == 2 or Framework() == 3 then 166 | if containers[container_name] then return containers[container_name] end 167 | end 168 | return false 169 | end 170 | 171 | function GetContainerItems() 172 | if Framework() == 1 then 173 | return qbcore_containers 174 | elseif Framework() == 2 or Framework() == 3 then 175 | return containers 176 | end 177 | end 178 | -------------------------------------------------------------------------------- /client/client.lua: -------------------------------------------------------------------------------- 1 | -- _ 2 | -- | | 3 | -- _____ _| | _____ ___ _ __ 4 | -- / __\ \ /\ / / |/ / _ \/ _ \ '_ \ 5 | -- \__ \\ V V /| < __/ __/ |_) | 6 | -- |___/ \_/\_/ |_|\_\___|\___| .__/ 7 | -- | | 8 | -- |_| 9 | -- https://github.com/swkeep 10 | -- TODO 11 | -- [idea] smart load? load all container models when eveything is spawned remove their models from memnory 12 | -- [-] police can access via lockpick!? 13 | -- [-] logging access to containers 14 | local ZONE = {} 15 | local current_zone 16 | local loaded = false 17 | 18 | Core = GetCoreObject() -- framwork 19 | local Framework = Framework() 20 | Containers = { 21 | data = {} 22 | } 23 | 24 | function is_super_user(citizenid) 25 | if Config.super_users[citizenid] and Config.super_users[citizenid] == true then return true end 26 | return false 27 | end 28 | 29 | function PlayerData() 30 | if Framework == 1 then 31 | return Core.Functions.GetPlayerData() 32 | elseif Framework == 2 then 33 | return Core.PlayerData 34 | end 35 | end 36 | 37 | function GetCitizenId(PlayerData) 38 | if Framework == 1 then 39 | if not PlayerData then return -1 end 40 | return PlayerData.citizenid 41 | elseif Framework == 2 then 42 | return PlayerData.identifier 43 | end 44 | end 45 | 46 | function GetJob() 47 | local PlayerData = PlayerData() 48 | if Framework == 1 then 49 | return PlayerData.job.name, PlayerData.job.grade.level 50 | elseif Framework == 2 then 51 | return PlayerData.job.name, PlayerData.job.grade 52 | end 53 | end 54 | 55 | function Notification_c(msg, type) 56 | if Config.input == "ox_lib" then if type == "primary" then type = "inform" end end 57 | 58 | if Config.input ~= "ox_lib" then 59 | if Framework == 1 then 60 | Core.Functions.Notify(msg, type) 61 | elseif Framework == 2 then 62 | if type == "primary" then type = "info" end 63 | TriggerEvent("esx:showNotification", msg, type) 64 | end 65 | else 66 | if type == "error" then 67 | lib.notify({ 68 | title = "Container Depot", 69 | description = msg, 70 | style = { 71 | backgroundColor = "#141517", 72 | color = "#909296" 73 | }, 74 | icon = "ban", 75 | iconColor = "#C53030" 76 | }) 77 | else 78 | lib.notify({ 79 | title = "Container Depot", 80 | description = msg, 81 | type = type 82 | }) 83 | end 84 | end 85 | end 86 | 87 | RegisterNetEvent("keep-containers:client:notification", function(msg, type) Notification_c(msg, type) end) 88 | 89 | local SpawnObject = function(model, coord, rotation, offset) 90 | local modelHash = GetHashKey(model) 91 | LoadModel(modelHash) 92 | local entity = CreateObject(modelHash, coord.x + offset.x, coord.y + offset.y, coord.z + offset.z, false) 93 | WaitForEntity(entity) 94 | 95 | SetEntityAsMissionEntity(entity, true, true) 96 | SetEntityRotation(entity, rotation, 0.0, true) 97 | FreezeEntityPosition(entity, true) 98 | SetEntityProofs(entity, 1, 1, 1, 1, 1, 1, 1, 1) 99 | SetModelAsNoLongerNeeded(modelHash) 100 | return entity 101 | end 102 | 103 | local function ShowDrawText(text) 104 | if Framework == 1 then 105 | exports["qb-core"]:DrawText(text or "Container Depot") 106 | elseif Config.input == "ox_lib" then 107 | lib.showTextUI(text or "Container Depot", { 108 | icon = "warehouse", 109 | style = { 110 | borderRadius = 0, 111 | backgroundColor = "#48BB78", 112 | color = "white" 113 | } 114 | }) 115 | end 116 | end 117 | 118 | local function HideDrawText() 119 | if Framework == 1 then 120 | exports["qb-core"]:HideText() 121 | elseif Config.input == "ox_lib" then 122 | lib.hideTextUI() 123 | end 124 | end 125 | 126 | local CreateBlip = function(options) 127 | local blip = AddBlipForCoord(options.coords) 128 | SetBlipSprite(blip, options.sprite) 129 | SetBlipScale(blip, options.scale or 1.0) 130 | SetBlipColour(blip, options.color or 49) 131 | SetBlipDisplay(blip, 4) 132 | SetBlipAsShortRange(blip, true) 133 | BeginTextCommandSetBlipName("STRING") 134 | AddTextComponentString(options.name or "no-name") 135 | EndTextCommandSetBlipName(blip) 136 | return blip 137 | end 138 | 139 | local function Init() 140 | if loaded then return end 141 | loaded = true 142 | for k, v in pairs(Config.container_depots) do 143 | CreateBlip(v.blip) 144 | ZONE[k] = PolyZone:Create(v.positions, { 145 | name = "c_depot " .. k, 146 | minZ = v.minz, 147 | maxZ = v.maxz, 148 | debugPoly = Config.MagicTouch 149 | }) 150 | ZONE[k]:onPlayerInOut(function(isPointInside) 151 | if isPointInside then 152 | current_zone = k 153 | Wait(50) 154 | ShowDrawText(v.name) 155 | TriggerCallback("keep-containers:server:GET:ZONE:containers", function(containers) for k, container in pairs(containers) do Containers:new(container) end end, current_zone) 156 | else 157 | current_zone = nil 158 | Containers:clean_up() 159 | HideDrawText() 160 | end 161 | end, 500) 162 | end 163 | end 164 | 165 | function Containers:new(options) 166 | local _self = {} 167 | local private = { 168 | random_id = options.random_id, 169 | position = json.decode(options.position), 170 | container_type = options.container_type, 171 | objects = {} 172 | } 173 | 174 | local function add_target(entity) 175 | if (Config.esx_target):lower() == "ox_target" then 176 | Ox_target(private, entity) 177 | elseif (Config.esx_target):lower() == "qtarget" then 178 | Qtarget(private, entity) 179 | elseif (Config.esx_target):lower() == "qb-target" then 180 | Qb_target(private, entity) 181 | end 182 | end 183 | 184 | local function spawn() 185 | local container = GetContainerInfromation(private.container_type) 186 | local coords = TableToVector3(private.position) 187 | local heading = private.position.w 188 | local index = #private.objects + 1 189 | private.objects[index] = SpawnObject(container.object.name, coords, vector3(0, 0, heading), container.object.offset) 190 | add_target(private.objects[index]) 191 | end 192 | 193 | function _self.remove_object() for _, object in pairs(private.objects) do DeleteEntity(object) end end 194 | 195 | local function constructor() spawn() end 196 | 197 | constructor() 198 | 199 | Containers.data[options.random_id] = _self 200 | setmetatable(Containers, _self) 201 | return _self 202 | end 203 | 204 | function Containers:clean_up() for _, Container in pairs(self.data) do Container.remove_object() end end 205 | 206 | function GetCurrentZone() return current_zone, ZONE[current_zone] end 207 | 208 | RegisterNetEvent("keep-containers:client:update_zone", function(zone_name) 209 | local current_zone, zone = GetCurrentZone() 210 | if zone_name == current_zone then 211 | Containers:clean_up() 212 | TriggerCallback("keep-containers:server:GET:ZONE:containers", function(containers) for k, container in pairs(containers) do Containers:new(container) end end, zone_name) 213 | end 214 | end) 215 | 216 | AddEventHandler("onResourceStop", function(resource) 217 | if resource ~= GetCurrentResourceName() then return end 218 | Containers:clean_up() 219 | end) 220 | 221 | AddEventHandler("onResourceStart", function(resourceName) 222 | if (GetCurrentResourceName() ~= resourceName) then return end 223 | Init() 224 | end) 225 | 226 | if Framework == 1 or Framework == 3 then 227 | RegisterNetEvent("QBCore:Client:OnPlayerLoaded", function() Init() end) 228 | elseif Framework == 2 then 229 | RegisterNetEvent("esx:playerLoaded") 230 | AddEventHandler("esx:playerLoaded", function() Init() end) 231 | end 232 | -------------------------------------------------------------------------------- /client/targets/functions.lua: -------------------------------------------------------------------------------- 1 | function MoveContainer(private, entity) 2 | local Framework = Framework() 3 | local zone_name, zone = GetCurrentZone() 4 | 5 | if Config.input == "qb-input" or Config.input == "keep-input" then 6 | local confData = exports[Config.input]:ShowInput({ 7 | inputs = { 8 | { 9 | type = "text", 10 | isRequired = true, 11 | name = "conf", 12 | text = "Type Confirm (^.^)", 13 | icon = "fa-solid fa-money-bill-trend-up", 14 | title = "Confirm" 15 | } 16 | } 17 | }) 18 | if confData and confData.conf == "Confirm" then 19 | TriggerEvent("keep-containers:client:container:update_location", private.random_id, zone_name, private.container_type) 20 | DeleteEntity(entity) 21 | end 22 | elseif Config.input == "ox_lib" then 23 | local inputData = lib.inputDialog("Confirm", { 24 | "Type Confirm (^.^)" 25 | }) 26 | if inputData and inputData[1] == "Confirm" then 27 | TriggerEvent("keep-containers:client:container:update_location", private.random_id, zone_name, private.container_type) 28 | DeleteEntity(entity) 29 | end 30 | end 31 | end 32 | 33 | function DeleteContainer(private, entity) 34 | local Framework = Framework() 35 | local zone_name, zone = GetCurrentZone() 36 | 37 | if Config.input == "qb-input" or Config.input == "keep-input" then 38 | local confData = exports[Config.input]:ShowInput({ 39 | inputs = { 40 | { 41 | type = "text", 42 | isRequired = true, 43 | name = "conf", 44 | text = "Type Confirm (^.^)", 45 | icon = "fa-solid fa-money-bill-trend-up", 46 | title = "Confirm" 47 | } 48 | } 49 | }) 50 | if confData and confData.conf == "Confirm" then TriggerServerEvent("keep-containers:server:container:delete", private.random_id, zone_name) end 51 | elseif Config.input == "ox_lib" then 52 | local inputData = lib.inputDialog("Confirm", { 53 | "Type Confirm (^.^)" 54 | }) 55 | if inputData and inputData[1] == "Confirm" then TriggerServerEvent("keep-containers:server:container:delete", private.random_id, zone_name) end 56 | end 57 | end 58 | 59 | function TransferOwnership(private, entity) 60 | local Framework = Framework() 61 | local zone_name, zone = GetCurrentZone() 62 | 63 | if Config.input == "qb-input" or Config.input == "keep-input" then 64 | local inputData = exports[Config.input]:ShowInput({ 65 | header = "Transfer Ownership", -- qb-input 66 | inputs = { 67 | { 68 | type = "number", 69 | name = "new_owner", 70 | icon = "fa-solid fa-money-bill-trend-up", 71 | title = "New Owner's State Id", 72 | text = "New Owner's State Id", -- qb-input 73 | isRequired = true 74 | } 75 | } 76 | }) 77 | if inputData and inputData.new_owner then 78 | local confData = exports[Config.input]:ShowInput({ 79 | inputs = { 80 | { 81 | type = "text", 82 | isRequired = true, 83 | name = "conf", 84 | text = "Type Confirm (^.^)", 85 | icon = "fa-solid fa-money-bill-trend-up", 86 | title = ("Confirm (transfer ownership to stateId (%s))"):format(inputData.new_owner) 87 | } 88 | } 89 | }) 90 | if confData and confData.conf == "Confirm" then TriggerServerEvent("keep-containers:server:container:transfer_ownership", private.random_id, zone_name, inputData.new_owner) end 91 | end 92 | elseif Config.input == "ox_lib" then 93 | local inputData = lib.inputDialog("Transfer Ownership", { 94 | "New Owner's State Id" 95 | }) 96 | if inputData and inputData[1] then 97 | local alert = lib.alertDialog({ 98 | header = "Transfer Ownership", 99 | content = "Confirm the transfer to the new owner. \n You be able to reverse the operation when it starts. ", 100 | centered = true, 101 | cancel = true 102 | }) 103 | if alert == "confirm" then 104 | TriggerServerEvent("keep-containers:server:container:transfer_ownership", private.random_id, zone_name, inputData[1]) 105 | else 106 | Notification_c("Transfer of ownership has been canceled.", "error") 107 | end 108 | end 109 | end 110 | end 111 | 112 | function ChangePassword(private, entity) 113 | local Framework = Framework() 114 | local zone_name, zone = GetCurrentZone() 115 | if Config.input == "qb-input" or Config.input == "keep-input" then 116 | 117 | elseif Config.input == "ox_lib" then 118 | 119 | end 120 | if Config.input == "qb-input" or Config.input == "keep-input" then 121 | local Input = { 122 | header = "Change Password", -- qb-input 123 | inputs = { 124 | { 125 | type = "password", 126 | name = "current_password", 127 | icon = "fa-solid fa-money-bill-trend-up", 128 | title = "Current Password", 129 | text = "Current Password", -- qb-input 130 | isRequired = true 131 | }, 132 | { 133 | type = "password", 134 | name = "new_password", 135 | icon = "fa-solid fa-money-bill-trend-up", 136 | title = "New Password", 137 | text = "New Password", -- qb-input 138 | isRequired = true 139 | } 140 | } 141 | } 142 | 143 | local inputData = exports[Config.input]:ShowInput(Input) 144 | if inputData and inputData.current_password and inputData.new_password and (zone_name ~= -1) then 145 | TriggerServerEvent("keep-containers:server:container:change_password", private.random_id, inputData.current_password, inputData.new_password, zone_name) 146 | end 147 | elseif Config.input == "ox_lib" then 148 | local inputData = lib.inputDialog("Change Passowrd", { 149 | { 150 | type = "input", 151 | label = "Current Password", 152 | password = true, 153 | icon = "lock" 154 | }, 155 | { 156 | type = "input", 157 | label = "New Password", 158 | password = true, 159 | icon = "lock" 160 | } 161 | }) 162 | if inputData and inputData[1] and inputData[2] then 163 | TriggerServerEvent("keep-containers:server:container:change_password", private.random_id, inputData[1], inputData[2], zone_name) 164 | end 165 | end 166 | end 167 | 168 | function OpenContainer(private, entity) 169 | local Framework = Framework() 170 | local zone_name, zone = GetCurrentZone() 171 | 172 | if Config.input == "qb-input" or Config.input == "keep-input" then 173 | local Input = { 174 | header = "Container Password", -- qb-input 175 | inputs = { 176 | { 177 | type = "password", 178 | name = "password", 179 | icon = "fa-solid fa-money-bill-trend-up", 180 | title = "Password", 181 | text = "Enter Password", -- qb-input 182 | isRequired = true 183 | } 184 | } 185 | } 186 | 187 | local inputData = exports[Config.input]:ShowInput(Input) 188 | if inputData and inputData.password then TriggerServerEvent("keep-containers:server:container:check_password", private.random_id, inputData.password, zone_name) end 189 | elseif Config.input == "ox_lib" then 190 | local inputData = lib.inputDialog("Container", { 191 | { 192 | type = "input", 193 | label = "Password", 194 | password = true, 195 | icon = "lock" 196 | } 197 | }) 198 | if inputData and inputData[1] then TriggerServerEvent("keep-containers:server:container:check_password", private.random_id, inputData[1], zone_name) end 199 | end 200 | end 201 | 202 | local function LoadAnimationDict(animation) 203 | RequestAnimDict(animation) 204 | while not HasAnimDictLoaded(animation) do Wait(25) end 205 | return true 206 | end 207 | 208 | local function bolt_cutter(entity, random_id, zone_name) 209 | local scene 210 | local playerped = PlayerPedId() 211 | local playercoords, pedRotation = GetEntityCoords(playerped), GetEntityRotation(playerped) 212 | local animDict = "anim@scripted@heist@ig4_bolt_cutters@male@" 213 | local scenePos = vector3(playercoords.x, playercoords.y, playercoords.z + 0.2) 214 | local sceneRot = pedRotation 215 | LoadAnimationDict(animDict) 216 | 217 | local cutter = GetHashKey("h4_prop_h4_bolt_cutter_01a") 218 | local bag = GetHashKey("ch_p_m_bag_var02_arm_s") 219 | LoadModel(cutter) 220 | LoadModel(bag) 221 | -- spawn cutter 222 | cutter = CreateObject(cutter, playercoords, 1, 1, 0) 223 | -- spawn bag 224 | bag = CreateObject(bag, playercoords, 1, 1, 0) 225 | 226 | Wait(50) 227 | scene = NetworkCreateSynchronisedScene(scenePos, sceneRot, 2, true, false, 1065353216, 0, 1.3) 228 | NetworkAddPedToSynchronisedScene(playerped, scene, animDict, "action_male", 4.0, -4.0, 1033, 0, 1000.0, 0) 229 | NetworkAddEntityToSynchronisedScene(cutter, scene, animDict, "action_cutter", 1.0, -1.0, 1148846080) 230 | NetworkAddEntityToSynchronisedScene(bag, scene, animDict, "action_bag", 1.0, -1.0, 1148846080) 231 | NetworkStartSynchronisedScene(scene) 232 | Wait(5750) 233 | NetworkStopSynchronisedScene(scene) 234 | DeleteEntity(bag) 235 | DeleteEntity(cutter) 236 | 237 | TriggerServerEvent("keep-containers:server:open_with_bolt_cutter", random_id, zone_name) 238 | end 239 | 240 | RegisterNetEvent("keep-containers:targets:use_bolt_cutter", function(entity, random_id, zone_name) bolt_cutter(entity, random_id, zone_name) end) 241 | 242 | function BoltCutter(private, entity) 243 | local zone_name, Zone = GetCurrentZone() 244 | if not zone_name or not Zone then 245 | Notification_c("The container cannot be outside the depot!", "error") 246 | return 247 | end 248 | TriggerServerEvent("keep-containers:server:use_bolt_cutter", entity, private.random_id, zone_name) 249 | end 250 | 251 | function SuperUser() 252 | local PlayerData = PlayerData() 253 | local citizenid = GetCitizenId(PlayerData) 254 | return is_super_user(citizenid) 255 | end 256 | 257 | function HasAccessToBoltCutter() 258 | local job_name, job_grade = GetJob() 259 | if Config.bolt_cutter[tostring(job_name)] then 260 | if Config.bolt_cutter[tostring(job_name)][tonumber(job_grade)] and Config.bolt_cutter[tostring(job_name)][tonumber(job_grade)] == true then return true end 261 | return false 262 | end 263 | return false 264 | end 265 | -------------------------------------------------------------------------------- /client/creator.lua: -------------------------------------------------------------------------------- 1 | -- _ 2 | -- | | 3 | -- _____ _| | _____ ___ _ __ 4 | -- / __\ \ /\ / / |/ / _ \/ _ \ '_ \ 5 | -- \__ \\ V V /| < __/ __/ |_) | 6 | -- |___/ \_/\_/ |_|\_\___|\___| .__/ 7 | -- | | 8 | -- |_| 9 | -- https://github.com/swkeep 10 | local function Draw2DText( content, font, colour, scale, x, y ) 11 | SetTextFont(font) 12 | SetTextScale(scale, scale) 13 | SetTextColour(colour[1], colour[2], colour[3], 255) 14 | SetTextEntry("STRING") 15 | SetTextDropShadow(0, 0, 0, 0, 255) 16 | SetTextDropShadow() 17 | SetTextEdge(4, 0, 0, 0, 255) 18 | SetTextOutline() 19 | AddTextComponentString(content) 20 | DrawText(x, y) 21 | end 22 | 23 | local function RotationToDirection( rotation ) 24 | local adjustedRotation = { 25 | x = (math.pi / 180) * rotation.x, 26 | y = (math.pi / 180) * rotation.y, 27 | z = (math.pi / 180) * rotation.z 28 | } 29 | local direction = { 30 | x = -math.sin(adjustedRotation.z) * math.abs(math.cos(adjustedRotation.x)), 31 | y = math.cos(adjustedRotation.z) * math.abs(math.cos(adjustedRotation.x)), 32 | z = math.sin(adjustedRotation.x) 33 | } 34 | return direction 35 | end 36 | 37 | local function RayCastGamePlayCamera( distance ) 38 | local cameraRotation = GetGameplayCamRot() 39 | local cameraCoord = GetGameplayCamCoord() 40 | local direction = RotationToDirection(cameraRotation) 41 | local destination = { 42 | x = cameraCoord.x + direction.x * distance, 43 | y = cameraCoord.y + direction.y * distance, 44 | z = cameraCoord.z + direction.z * distance 45 | } 46 | local a, b, c, d, e = GetShapeTestResult(StartShapeTestRay(cameraCoord.x, cameraCoord.y, cameraCoord.z, destination.x, destination.y, destination.z, -1, PlayerPedId(), 0)) 47 | return c, e 48 | end 49 | 50 | local function up( object, offset ) 51 | DisableControlAction(0, 27, true) 52 | if IsDisabledControlPressed(0, 27) then -- arrow up 53 | local delta = 0.05 54 | DisableControlAction(0, 36, true) 55 | if IsDisabledControlPressed(0, 36) then -- ctrl held down 56 | delta = 0.10 57 | end 58 | local object_coords = GetEntityCoords(object) 59 | SetEntityCoords(object, object_coords.x + offset.x, object_coords.y + offset.y, object_coords.z + offset.z + delta) 60 | end 61 | end 62 | 63 | local function down( object, offset ) 64 | DisableControlAction(0, 173, true) 65 | if IsDisabledControlPressed(0, 173) then -- arrow up 66 | local delta = 0.05 67 | DisableControlAction(0, 36, true) 68 | if IsDisabledControlPressed(0, 36) then -- ctrl held down 69 | delta = 0.10 70 | end 71 | local object_coords = GetEntityCoords(object) 72 | SetEntityCoords(object, object_coords.x + offset.x, object_coords.y + offset.y, object_coords.z + offset.z - delta) 73 | end 74 | end 75 | 76 | local function left( object, offset, xy ) 77 | DisableControlAction(0, 174, true) 78 | if IsDisabledControlPressed(0, 174) then -- arrow up 79 | local delta = 0.05 80 | DisableControlAction(0, 36, true) 81 | if IsDisabledControlPressed(0, 36) then -- ctrl held down 82 | delta = 0.10 83 | end 84 | local object_coords = GetEntityCoords(object) 85 | if xy == "x" then 86 | SetEntityCoords(object, object_coords.x + offset.x + delta, object_coords.y + offset.y, object_coords.z + offset.z) 87 | else 88 | SetEntityCoords(object, object_coords.x + offset.x, object_coords.y + offset.y + delta, object_coords.z + offset.z) 89 | end 90 | end 91 | end 92 | 93 | local function right( object, offset, xy ) 94 | DisableControlAction(0, 175, true) 95 | if IsDisabledControlPressed(0, 175) then -- arrow up 96 | local delta = 0.05 97 | DisableControlAction(0, 36, true) 98 | if IsDisabledControlPressed(0, 36) then -- ctrl held down 99 | delta = 0.10 100 | end 101 | local object_coords = GetEntityCoords(object) 102 | if xy == "x" then 103 | SetEntityCoords(object, object_coords.x + offset.x - delta, object_coords.y + offset.y, object_coords.z + offset.z) 104 | else 105 | SetEntityCoords(object, object_coords.x + offset.x, object_coords.y + offset.y - delta, object_coords.z + offset.z) 106 | end 107 | end 108 | end 109 | 110 | local object 111 | local function ChooseSpawnLocation( model, offset ) 112 | local plyped = PlayerPedId() 113 | local pedCoord = GetEntityCoords(plyped) 114 | local object_placed = false 115 | local xy = "x" 116 | object = CreateObject(GetHashKey(model), pedCoord.x + offset.x, pedCoord.y + offset.y, pedCoord.z + offset.z, 1, 0, 0) 117 | SetEntityAlpha(object, 150, true) 118 | SetEntityCollision(object, false, false) 119 | while true do 120 | BlockWeaponWheelThisFrame() 121 | local coords, entity = RayCastGamePlayCamera(50.0) 122 | Draw2DText("Press ~g~E~w~ To Lock Position | ~g~Mouse Wheel~w~ To Rotate | Press ~g~ESC~w~ To Exit", 4, { 123 | 255, 124 | 255, 125 | 255 126 | }, 0.4, 0.43, 0.888) 127 | Draw2DText("Press ~g~Up~w~/~g~Down~w~/~g~Left~w~/~g~Right~w~ After Position Is Locked", 4, { 128 | 255, 129 | 255, 130 | 255 131 | }, 0.4, 0.43, 0.888 + 0.025) 132 | Draw2DText("Press ~g~Page Up~w~ to change X Axis | Press ~g~Page Down~w~ to Y Axis | Current Axis: " .. xy, 4, { 133 | 255, 134 | 255, 135 | 255 136 | }, 0.4, 0.43, 0.888 + 0.05) 137 | Draw2DText("Press ~g~ENTER~w~ To Confirm", 4, { 138 | 255, 139 | 255, 140 | 255 141 | }, 0.4, 0.5, 0.86) 142 | if IsControlJustReleased(0, 38) then object_placed = true end 143 | 144 | if IsControlJustReleased(0, 191) then 145 | local ec = GetEntityCoords(object) 146 | local w = GetEntityHeading(object) 147 | DeleteEntity(object) 148 | return vector4(ec.x - offset.x, ec.y - offset.y, ec.z - offset.z, w) 149 | end 150 | 151 | up(object, offset) 152 | down(object, offset) 153 | right(object, offset, xy) 154 | left(object, offset, xy) 155 | 156 | DisableControlAction(0, 81, true) 157 | if IsDisabledControlJustPressed(0, 81) then 158 | local head = GetEntityHeading(object) 159 | local delta = 7.5 160 | DisableControlAction(0, 36, true) 161 | if IsDisabledControlPressed(0, 36) then -- ctrl held down 162 | delta = 1.0 163 | end 164 | head = head + delta 165 | SetEntityHeading(object, head) 166 | end 167 | 168 | DisableControlAction(0, 99, true) 169 | if IsDisabledControlJustPressed(0, 99) then 170 | local head = GetEntityHeading(object) 171 | local delta = 7.5 172 | DisableControlAction(0, 36, true) 173 | if IsDisabledControlPressed(0, 36) then -- ctrl held down 174 | delta = 1.0 175 | end 176 | head = head - delta 177 | SetEntityHeading(object, head) 178 | end 179 | 180 | DisableControlAction(0, 200, true) 181 | if IsDisabledControlJustPressed(0, 200) then 182 | DeleteEntity(object) 183 | return "exit" 184 | end 185 | 186 | if IsControlPressed(0, 10) then xy = "x" end 187 | 188 | if IsControlPressed(0, 11) then xy = "y" end 189 | 190 | DisableControlAction(0, 36, true) 191 | 192 | if not object_placed then SetEntityCoords(object, coords.x + offset.x, coords.y + offset.y, coords.z + offset.z) end 193 | Wait(10) 194 | end 195 | end 196 | 197 | RegisterNetEvent("keep-containers:client:container:place", function( container_type ) 198 | local zone_name, Zone = GetCurrentZone() 199 | if not zone_name or not Zone then 200 | Notification_c("The container cannot be placed outside the depot!", "error") 201 | return 202 | end 203 | if Config.input ~= "ox_lib" then 204 | local Input = { 205 | header = "Set Password", -- qb-input 206 | inputs = { 207 | { 208 | type = "password", 209 | name = "password", 210 | icon = "fa-solid fa-money-bill-trend-up", 211 | title = "Password", 212 | text = "Enter Password", -- qb-input 213 | isRequired = true 214 | } 215 | } 216 | } 217 | 218 | local inputData = exports[Config.input]:ShowInput(Input) 219 | 220 | if inputData and inputData.password and inputData.password ~= "" then 221 | local container = GetContainerInfromation(container_type) 222 | if not container then 223 | print("contaienr type is wrong!") 224 | return 225 | end 226 | local position = ChooseSpawnLocation(container.object.name, container.object.offset) 227 | 228 | if position == "exit" then return end 229 | local is_in_zone = Zone:isPointInside(position) -- this should be somehow server-side 230 | if is_in_zone then 231 | TriggerServerEvent("keep-containers:server:create_container", inputData.password, position, zone_name) 232 | else 233 | Notification_c("The container is outside of depot!", "error") 234 | end 235 | else 236 | Notification_c("Use a better password!", "error") 237 | end 238 | else 239 | local inputData = lib.inputDialog("Enter Password", { 240 | { 241 | type = "input", 242 | label = "Password", 243 | password = true, 244 | icon = "lock" 245 | } 246 | }) 247 | if inputData and inputData[1] then 248 | local container = GetContainerInfromation(container_type) 249 | local position = ChooseSpawnLocation(container.object.name, container.object.offset) 250 | 251 | if position == "exit" then 252 | Notification_c("The container placement has been cancelled!", "error") 253 | return 254 | end 255 | 256 | local is_in_zone = Zone:isPointInside(position) -- this should be somehow server-side 257 | if is_in_zone then 258 | TriggerServerEvent("keep-containers:server:create_container", inputData[1], position, zone_name) 259 | else 260 | Notification_c("The container is outside of depot!", "error") 261 | end 262 | end 263 | end 264 | end) 265 | 266 | AddEventHandler("keep-containers:client:container:update_location", function( random_id, zone_name, container_type ) 267 | local _, Zone = GetCurrentZone() 268 | if not zone_name or not Zone then 269 | Notification_c("The container cannot be placed outside the depot!", "error") 270 | return 271 | end 272 | local container = GetContainerInfromation(container_type) 273 | local position = ChooseSpawnLocation(container.object.name, container.object.offset) 274 | if position == "exit" then 275 | TriggerEvent("keep-containers:client:update_zone", zone_name) 276 | return 277 | end 278 | local is_in_zone = Zone:isPointInside(position) -- this should be somehow server-side 279 | if is_in_zone then 280 | TriggerServerEvent("keep-containers:server:container:update_position", random_id, zone_name, position) 281 | else 282 | TriggerEvent("keep-containers:client:update_zone", zone_name) 283 | Notification_c("The container is outside of depot!", "error") 284 | end 285 | end) 286 | 287 | AddEventHandler("onResourceStop", function( resource ) 288 | if resource ~= GetCurrentResourceName() then return end 289 | DeleteEntity(object) 290 | end) 291 | -------------------------------------------------------------------------------- /server/server.lua: -------------------------------------------------------------------------------- 1 | -- _ 2 | -- | | 3 | -- _____ _| | _____ ___ _ __ 4 | -- / __\ \ /\ / / |/ / _ \/ _ \ '_ \ 5 | -- \__ \\ V V /| < __/ __/ |_) | 6 | -- |___/ \_/\_/ |_|\_\___|\___| .__/ 7 | -- | | 8 | -- |_| 9 | -- https://github.com/swkeep 10 | Core = GetCoreObject() -- framwork 11 | local Framework = Framework() 12 | local creation_list = {} 13 | 14 | local function init_database() 15 | local array = { 16 | [[ 17 | CREATE TABLE IF NOT EXISTS `keep_containers` ( 18 | `id` int(11) NOT NULL AUTO_INCREMENT, 19 | `random_id` varchar(50) NOT NULL, 20 | `container_type` varchar(50) NOT NULL, 21 | `owner_citizenid` varchar(50) DEFAULT NULL, 22 | `password` CHAR(60) DEFAULT NULL, 23 | `position` TEXT DEFAULT NULL, 24 | `zone` varchar(50) DEFAULT NULL, 25 | `deleted` BOOLEAN NOT NULL DEFAULT TRUE, 26 | `deleted_by` varchar(50) DEFAULT NULL, 27 | PRIMARY KEY (`id`), 28 | KEY `random_id` (`random_id`) 29 | ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4; 30 | ]], 31 | [[ 32 | CREATE TABLE IF NOT EXISTS `keep_containers_access_log` ( 33 | `id` int(11) NOT NULL AUTO_INCREMENT, 34 | `random_id` varchar(50) NOT NULL, 35 | `citizenid` varchar(50) DEFAULT NULL, 36 | `action` varchar(50) DEFAULT NULL, 37 | `metadata` TEXT DEFAULT NULL, 38 | PRIMARY KEY (`id`), 39 | KEY `random_id` (`random_id`) 40 | ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4; 41 | ]] 42 | } 43 | 44 | local function trim1(s) return (s:gsub("^%s*(.-)%s*$", "%1")) end 45 | 46 | for key, query in pairs(array) do MySQL.Sync.fetchScalar(trim1(query), {}) end 47 | end 48 | 49 | CreateThread(function() init_database() end) 50 | 51 | local function Player(source) 52 | if Framework == 1 or Framework == 3 then 53 | return Core.Functions.GetPlayer(source) 54 | elseif Framework == 2 then 55 | return Core.GetPlayerFromId(source) 56 | end 57 | end 58 | 59 | local function GetCitizenId(Player) 60 | if Framework == 1 or Framework == 3 then 61 | if not Player then return -1 end 62 | return Player.PlayerData.citizenid 63 | elseif Framework == 2 then 64 | return Player.getIdentifier() 65 | end 66 | end 67 | 68 | local function GetJob(source) 69 | local player = Player(source) 70 | if Framework == 1 or Framework == 3 then 71 | return player.PlayerData.job.name, player.PlayerData.job.grade.level 72 | elseif Framework == 2 then 73 | local job = player.getJob() 74 | return job.name, job.grade 75 | end 76 | end 77 | 78 | local function HasAccessToBoltCutter(source) 79 | local job_name, job_grade = GetJob(source) 80 | 81 | if Config.bolt_cutter[tostring(job_name)] then 82 | if Config.bolt_cutter[tostring(job_name)][tonumber(job_grade)] and Config.bolt_cutter[tostring(job_name)][tonumber(job_grade)] == true then return true end 83 | return false 84 | end 85 | return false 86 | end 87 | 88 | local function HasBoltCutter(source, player) 89 | if Framework == 1 then 90 | local item = player.Functions.GetItemByName(Config.bolt_cutter_item_name) 91 | if item then 92 | return true 93 | end 94 | return false 95 | elseif Framework == 2 then 96 | if not player.hasItem(Config.bolt_cutter_item_name) then return false end 97 | local count = player.hasItem(Config.bolt_cutter_item_name).count 98 | if count > 0 then 99 | return true 100 | else 101 | return false 102 | end 103 | end 104 | end 105 | 106 | local function remove_item(source, Player, item_name, amount, slot) 107 | local res = Player.Functions.RemoveItem(item_name, amount, slot) 108 | TriggerClientEvent("qb-inventory:client:ItemBox", source, Core.Shared.Items[item_name], "remove") 109 | return res 110 | end 111 | 112 | local function RemoveItem(source, Player, item_name, amount, slot) 113 | if Framework == 1 or Framework == 3 then 114 | return remove_item(source, Player, item_name, amount, slot) 115 | elseif Framework == 2 then 116 | return Player.removeInventoryItem(item_name, amount) 117 | end 118 | end 119 | 120 | RegisterNetEvent("keep-containers:server:create_container", function(password, position, zone_name) 121 | local function is_a_valid_zone() 122 | if Config.container_depots[zone_name] then return true end 123 | return false 124 | end 125 | 126 | local src = source 127 | local Player = Player(src) 128 | local citizenid = GetCitizenId(Player) 129 | local container_type = creation_list[src] 130 | 131 | -- validate zone_name 132 | if not is_a_valid_zone() then 133 | Notification_S(src, "Depot is not valid", "error") 134 | return 135 | end 136 | 137 | if not password or password == "" then 138 | Notification_S(src, "Enter a better password", "primary") 139 | return 140 | end 141 | 142 | if not container_type then 143 | Notification_S(src, "Wrong container type", "error") 144 | return 145 | end 146 | 147 | if not RemoveItem(src, Player, container_type, 1) then 148 | Notification_S(src, "The requested container was not found in your inventory!", "error") 149 | return 150 | end 151 | 152 | local sqlQuery = "INSERT INTO keep_containers (random_id,container_type,owner_citizenid,password,position,zone,deleted,deleted_by) VALUES (?,?,?,?,?,?,?,?)" 153 | local QueryData = { 154 | RandomID(9), 155 | container_type, 156 | citizenid, 157 | GetPasswordHash(password), 158 | json.encode(position), 159 | zone_name, 160 | false, 161 | "" 162 | } 163 | MySQL.Async.insert(sqlQuery, QueryData, function() 164 | creation_list[src] = nil 165 | TriggerClientEvent("keep-containers:client:update_zone", -1, zone_name) 166 | Notification_S(src, "Success", "success") 167 | end) 168 | end) 169 | 170 | CreateCallback("keep-containers:server:GET:ZONE:containers", function(source, cb, zone_name) 171 | MySQL.Async.fetchAll("SELECT random_id,position,container_type FROM keep_containers WHERE zone = ? and deleted = false", { 172 | zone_name 173 | }, function(res) cb(res) end) 174 | end) 175 | 176 | function VerifyPassword(src, password, passwordHash, notification) 177 | if not password or password == "" or not passwordHash then 178 | if notification then Notification_S(src, "Bad password input!", "error") end 179 | return false 180 | end 181 | if VerifyPasswordHash(password, passwordHash) == 1 then 182 | if notification then Notification_S(src, "Success", "success") end 183 | return true 184 | else 185 | if notification then Notification_S(src, "Password is wrong", "error") end 186 | return false 187 | end 188 | end 189 | 190 | local query = "SELECT container_type, password FROM keep_containers WHERE random_id = ?" 191 | 192 | RegisterNetEvent("keep-containers:server:container:check_password", function(random_id, password, zone_name) 193 | local src = source 194 | MySQL.Async.fetchAll(query, { random_id }, function(results) 195 | local result = results[1] 196 | local container_info = GetContainerInfromation(result.container_type) 197 | if not container_info then return end 198 | local stash_info = container_info.type 199 | 200 | if VerifyPassword(src, password, result.password, true) then 201 | local container_id = "container-" .. random_id 202 | if Framework == 1 then 203 | exports['qb-inventory']:OpenInventory(src, container_id, { 204 | slots = stash_info.slots or 10, 205 | maxweight = stash_info.size or 10000 206 | }) 207 | -- TriggerClientEvent("keep-containers:client:open", src, container_type.type) -- old qb-inventory 208 | elseif Framework == 2 or Framework == 3 then 209 | local stash_id = "Container_" .. random_id 210 | exports["ox_inventory"]:RegisterStash(stash_id, "Container", stash_info.slots or 10, stash_info.size or 10000) 211 | TriggerClientEvent("keep_containers:client:open", src, stash_info.type) 212 | end 213 | end 214 | end) 215 | end) 216 | 217 | RegisterNetEvent("keep-containers:server:use_bolt_cutter", function(entity, random_id, zone_name) 218 | local src = source 219 | local player = Player(src) 220 | if not HasBoltCutter(src, player) then 221 | Notification_S(src, "You don't have on a single boltcutter on you", "error") 222 | return 223 | end 224 | if not HasAccessToBoltCutter(src) then 225 | Notification_S(src, "You can't use boltcutter", "error") 226 | return 227 | end 228 | TriggerClientEvent("keep-containers:targets:use_bolt_cutter", src, entity, random_id, zone_name) 229 | end) 230 | 231 | RegisterNetEvent("keep-containers:server:open_with_bolt_cutter", function(random_id, zone_name) 232 | local src = source 233 | local player = Player(src) 234 | if not HasAccessToBoltCutter(src) then 235 | Notification_S(src, "You can't use boltcutter", "error") 236 | return 237 | end 238 | if not HasBoltCutter(src, player) then 239 | Notification_S(src, "You don't have on a single boltcutter on you", "error") 240 | return 241 | end 242 | 243 | if Config.remove_bolt_cutter_on_use then 244 | if not RemoveItem(src, player, Config.bolt_cutter_item_name, 1) then 245 | Notification_S(src, "Can't remove boltcutter from you!", "error") 246 | return 247 | end 248 | end 249 | 250 | MySQL.Async.fetchAll("SELECT container_type FROM keep_containers WHERE random_id = ?", { 251 | random_id 252 | }, function(res) 253 | res = res[1] 254 | local container_type = GetContainerInfromation(res.container_type) 255 | local type = container_type.type 256 | type.random_id = random_id 257 | 258 | if Framework == 1 then 259 | local container_id = "container-" .. random_id 260 | exports['qb-inventory']:OpenInventory(src, container_id, { 261 | slots = type.slots or 10, 262 | maxweight = type.size or 10000 263 | }) 264 | -- TriggerClientEvent("keep-containers:client:open", src, container_type.type) 265 | elseif Framework == 2 or Framework == 3 then 266 | local id = "Container_" .. random_id 267 | exports["ox_inventory"]:RegisterStash(id, "Container", type.slots, type.size) 268 | TriggerClientEvent("keep-containers:client:open", src, container_type.type) 269 | end 270 | end) 271 | end) 272 | 273 | function is_owner(owner_citizenid, current_citizenid) 274 | if owner_citizenid == current_citizenid then return true end 275 | return false 276 | end 277 | 278 | RegisterNetEvent("keep-containers:server:container:change_password", function(random_id, current_password, new_password, zone_name) 279 | local src = source 280 | local Player = Player(src) 281 | local citizenid = GetCitizenId(Player) 282 | 283 | -- Verify new password 284 | if not new_password or new_password == "" then 285 | Notification_S(src, "Bad password input.", "error") 286 | return 287 | end 288 | 289 | MySQL.Async.fetchAll("SELECT id,owner_citizenid, password FROM keep_containers WHERE random_id = ?", { 290 | random_id 291 | }, function(res) 292 | res = res[1] 293 | if not is_owner(res.owner_citizenid, citizenid) then 294 | Notification_S(src, "Only the owner of this container can change the password!", "error") 295 | return 296 | end 297 | 298 | if VerifyPassword(src, current_password, res.password, notification) == true then 299 | MySQL.Async.execute("UPDATE keep_containers SET password = ? WHERE id = ?", { 300 | GetPasswordHash(new_password), 301 | res.id 302 | }, function() Notification_S(src, "Password Updated.", "primary") end) 303 | else 304 | Notification_S(src, "Current password is wrong.", "error") 305 | end 306 | end) 307 | end) 308 | 309 | RegisterNetEvent("keep-containers:server:container:transfer_ownership", function(random_id, zone_name, new_owner) 310 | local src = source 311 | new_owner = tonumber(new_owner) 312 | if src == new_owner then 313 | Notification_S(src, "You can't transfer it to yourself.", "primary") 314 | return 315 | end 316 | 317 | local player = Player(src) 318 | local o_citizenid = GetCitizenId(player) 319 | 320 | player = Player(new_owner) 321 | local citizenid = GetCitizenId(player) 322 | if not player or not citizenid == -1 then 323 | Notification_S(src, "Hmm, is new owner in the city? we can't find him/her!", "primary") 324 | return 325 | end 326 | 327 | MySQL.Async.fetchAll("SELECT id,owner_citizenid FROM keep_containers WHERE random_id = ?", { 328 | random_id 329 | }, function(res) 330 | res = res[1] 331 | if not is_owner(res.owner_citizenid, o_citizenid) then 332 | Notification_S(src, "Only owner of this container can change transfer ownership!", "primary") 333 | return 334 | end 335 | 336 | MySQL.Async.execute("UPDATE keep_containers SET owner_citizenid = ?, password = ? WHERE id = ?", { 337 | citizenid, 338 | GetPasswordHash("0000"), 339 | res.id 340 | }, function() 341 | Notification_S(src, "Transfer completed.", "primary") 342 | Notification_S(new_owner, "Transfer completed.", "primary") 343 | Notification_S(new_owner, "Password is set to '0000'", "success") 344 | end) 345 | end) 346 | end) 347 | 348 | local function is_super_user(citizenid) 349 | if Config.super_users[citizenid] and Config.super_users[citizenid] == true then return true end 350 | return false 351 | end 352 | 353 | RegisterNetEvent("keep-containers:server:container:delete", function(random_id, zone_name) 354 | local src = source 355 | local player = Player(src) 356 | local citizenid = GetCitizenId(player) 357 | 358 | if not is_super_user(citizenid) then 359 | Notification_S(src, "Hmm, you can't do that!", "primary") 360 | return 361 | end 362 | 363 | MySQL.Async.execute("UPDATE keep_containers SET deleted = ?, deleted_by = ? WHERE random_id = ? AND zone = ?", { 364 | true, 365 | citizenid, 366 | random_id, 367 | zone_name 368 | }, function() 369 | Notification_S(src, "Container has been removed!", "primary") 370 | TriggerClientEvent("keep-containers:client:update_zone", -1, zone_name) 371 | end) 372 | end) 373 | 374 | RegisterNetEvent("keep-containers:server:container:update_position", function(random_id, zone_name, new_position) 375 | local src = source 376 | local player = Player(src) 377 | local citizenid = GetCitizenId(player) 378 | 379 | if type(new_position) ~= "vector4" then 380 | Notification_S(src, "Wrong position type!", "primary") 381 | return 382 | end 383 | 384 | if not is_super_user(citizenid) then 385 | Notification_S(src, "Hmm, you can't do that!", "primary") 386 | TriggerClientEvent("keep-containers:client:update_zone", src, zone_name) 387 | return 388 | end 389 | 390 | MySQL.Async.fetchAll("SELECT id,owner_citizenid,container_type FROM keep_containers WHERE random_id = ?", { 391 | random_id 392 | }, function(res) 393 | res = res[1] 394 | MySQL.Async.execute("UPDATE keep_containers SET position = ? WHERE id = ?", { 395 | json.encode(new_position), 396 | res.id 397 | }, function(res) 398 | if res then 399 | Notification_S(src, "Completed.", "primary") 400 | TriggerClientEvent("keep-containers:client:update_zone", -1, zone_name) 401 | end 402 | end) 403 | end) 404 | end) 405 | 406 | ------------------------------ 407 | -- ITEMS 408 | ------------------------------ 409 | 410 | if Framework == 1 or Framework == 3 then 411 | for k, v in pairs(GetContainerItems()) do 412 | Core.Functions.CreateUseableItem(k, function(source, item) 413 | local player = Player(source) 414 | if not player then return end 415 | creation_list[source] = k 416 | TriggerClientEvent("keep-containers:client:container:place", source, k) 417 | end) 418 | end 419 | elseif Framework == 2 then 420 | for k, v in pairs(GetContainerItems()) do 421 | Core.RegisterUsableItem(k, function(playerId) 422 | local player = Player(playerId) 423 | if not player then return end 424 | creation_list[playerId] = k 425 | TriggerClientEvent("keep-containers:client:container:place", playerId, k) 426 | end) 427 | end 428 | end 429 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | 635 | Copyright (C) 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | Copyright (C) 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | --------------------------------------------------------------------------------