diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index dfe0770..0000000 --- a/.gitattributes +++ /dev/null @@ -1,2 +0,0 @@ -# Auto detect text files and perform LF normalization -* text=auto diff --git a/README.md b/README.md index 8280131..46700f6 100644 --- a/README.md +++ b/README.md @@ -1,18 +1,18 @@ -# redemrp_inventory 2.0v +## [Latest Documentation](https://sinatra.gitbook.io/redemrp/ "Latest Documentation") +![](https://img.shields.io/github/stars/RedEM-RP/redemrp_inventory) ![](https://img.shields.io/github/forks/RedEM-RP/redemrp_inventory) ![](https://img.shields.io/github/tag/RedEM-RP/redemrp_inventory) ![](https://img.shields.io/github/release/RedEM-RP/redemrp_inventory) ![](https://img.shields.io/github/issues/RedEM-RP/redemrp_inventory) ![](https://img.shields.io/discord/648268213859254309) -## 1. Requirements +[![](https://i.ibb.co/FnNr3Z3/redemrpn.png)](https://discord.gg/nbmTmZR "") -[redem-roleplay](https://github.com/RedEM-RP/redem_roleplay/) +# redemrp_inventory 2023.01 -[redemrp_identity](https://github.com/RedEM-RP/redemrp_identity/) +## 1. Requirements +[redem-roleplay](https://github.com/RedEM-RP/redem_roleplay/) +[redemrp_charselect](https://github.com/RedEM-RP/redemrp_charselect/) [redemrp_respawn](https://github.com/RedEM-RP/redemrp_respawn/) -[pNotify](https://github.com/Nick78111/pNotify) - ## 2. Installation -- Insert the .sql file into your database. -- Add ```ensure redemrp_inventory``` in server.cfg +- Add ```ensure redemrp_inventory``` in server.cfg after redem_roleplay, redem_charselect ## 3. How to use Press [B] to open inventory @@ -66,52 +66,17 @@ ItemData.AddItem(7) local ItemInfo = data.getItemData('bread') -- return info from config -==================== ---- -1 is send to all ---- type is id "this_is_my_locker" ---- job is job name or nill -data.createLocker(type, x , y , z , job) -data.removeLocker(-1 , id) - remove locker with DB -data.changeLockerData(id , x , y , z , job) -- change locker data -data.updateLockers(-1) -- update locker for everyone - -======================== - ---- obj is unique id ---- -1 is send to all -data.CreateCraftingStation(obj, x, y, z , "cooking" , "sheriff") -data.updateCraftings(-1) - -data.updateRemoveCraftings(obj) -data.updateCraftings(-1) - ======================== local playerInventory = data.getPlayerInventory(source) --- return player items data.removePlayerInventory(source) -- remove player inventory TriggerEvent("redemrp_inventory:SearchPlayer", target) -- search player -``` -Basic Example for lockers and crafting stations: - -``` -data.CreateCraftingStation("doctor_1", -290.01, 816.25, 118.39, "doctor" , "doctor") -data.CreateCraftingStation("doctor_2", 1362.1,-1301.91,77.76, "doctor" , "doctor") -data.CreateCraftingStation("doctor_3", -1805.77,-428.35,158.83, "doctor" , "doctor") -data.CreateCraftingStation("doctor_4", -833.24,-1186.80,43.89, "doctor" , "doctor") - -MySQL.ready(function() -data.createLocker("doctor_1" , -284.97, 810.51 ,119.39, "doctor") -data.createLocker("doctor_2" , -1361.28,-1306.01,77.76, "doctor") -data.createLocker("doctor_3" , -1802.88,-432.84,158.83, "doctor") -data.createLocker("doctor_4" , -833.24,-1186.80,43.89, "doctor") -end) - ``` -![alt text](https://i.imgur.com/ivrqvgt.png) - ## 6. Credits [Ktos93](http://github.com/Ktos93) +[youngsinatra99](http://github.com/youngsinatra99) + Join discord to get support! - https://discord.gg/FKH4uwb diff --git a/client/cl_main.lua b/client/cl_main.lua deleted file mode 100644 index 5df12f7..0000000 --- a/client/cl_main.lua +++ /dev/null @@ -1,551 +0,0 @@ -local isInventoryOpen = false -local isOtherOpen = false -local InventoryItems = {} -local OtherItems = {} -local PlayerMoney = 0 -local InventoryWeight = 0.0 -local DroppedItems = {} -local CreatedLockers = {} -local LockerZone -local UsedWeapons = {} -local CreatedCraftings = lock -local PlayerJob = job -local CurrentCraftingType = "empty" - -local WeaponsWithoutAmmo = { - ["WEAPON_FISHINGROD"] = true, - ["WEAPON_MELEE_KNIFE"] = true, - ["WEAPON_MELEE_KNIFE_MINER"] = true, - ["WEAPON_MELEE_KNIFE_VAMPIRE"] = true, - ["WEAPON_LASSO"] = true, - ["WEAPON_MELEE_CLEAVER"] = true, - ["WEAPON_MELEE_LANTERN_ELECTRIC"] = true, - ["WEAPON_MELEE_TORCH"] = true, - ["WEAPON_MELEE_TORCH"] = true, - -} -Citizen.CreateThread(function() - TriggerServerEvent("redemrp_inventory:playerJoined") - while true do - Wait(1) - if IsDisabledControlJustReleased(0, 0x4CC0E2FE) then - if LockerZone then - TriggerServerEvent("redemrp_inventory:GetLocker", LockerZone) - else - isInventoryOpen = not isInventoryOpen - - if isInventoryOpen then - for i,k in pairs(InventoryItems) do - if k.type == "item_weapon" and not WeaponsWithoutAmmo[k.name] then - if HasPedGotWeapon(PlayerPedId(), tonumber(k.weaponHash)) then - if UsedWeapons[tonumber(k.weaponHash)] and UsedWeapons[tonumber(k.weaponHash)].meta.uid == k.meta.uid then - InventoryItems[i].amount = GetAmmoInPedWeapon(PlayerPedId(), tonumber(k.weaponHash)) - end - end - end - end - CurrentCraftingType = "empty" - SendNUIMessage({ - type = 1, - inventory = isInventoryOpen, - otherinventory = isOtherOpen, - crafting = true, - items = InventoryItems, - otheritems = OtherItems, - money = PlayerMoney, - time = GetClockHours()..":"..GetClockMinutes(), - weight = InventoryWeight , - target = 0, - }) - - SetNuiFocus(true, true) - else - SendNUIMessage({ - type = 2 - }) - SetNuiFocus(false, false) - isOtherOpen = false - LockerZone = nil - CurrentCraftingType = "empty" - end - end - end - end - -end) - - - -RegisterNetEvent('redemrp_inventory:SearchPlayer') -AddEventHandler('redemrp_inventory:SearchPlayer', function(target) - TriggerServerEvent("redemrp_inventory:GetPlayer", target) -end) - - -RegisterNetEvent('redemrp_inventory:removeWeapon') -AddEventHandler('redemrp_inventory:removeWeapon', function(hash) - if UsedWeapons[tonumber(hash)] then - UsedWeapons[tonumber(hash)] = nil - ReloadWeapons() - end -end) - - -RegisterNetEvent('redemrp_inventory:UseWeapon') -AddEventHandler('redemrp_inventory:UseWeapon', function(hash , ammoAmount, meta , name) - local id = false - if not UsedWeapons[tonumber(hash)] then - for i,k in pairs(UsedWeapons) do - if k.WeaponType == Citizen.InvokeNative(0x5C2EA6C44F515F34, tonumber(hash)) then - id = i - break - end - end - if id then - UsedWeapons[id] = nil - end - UsedWeapons[tonumber(hash)] = {WeaponHash = tonumber(hash), WeaponType = Citizen.InvokeNative(0x5C2EA6C44F515F34, tonumber(hash)), Ammo = tonumber(ammoAmount) , name = name , meta = meta} - else - if not WeaponsWithoutAmmo[UsedWeapons[tonumber(hash)].name] then - UsedWeapons[tonumber(hash)].Ammo = GetAmmoInPedWeapon(PlayerPedId(), tonumber(hash)) - end - TriggerServerEvent("redemrp_inventory:ChangeAmmoAmount", {UsedWeapons[tonumber(hash)]}) - UsedWeapons[tonumber(hash)] = nil - end - ReloadWeapons() -end) - -function ReloadWeapons() - Citizen.InvokeNative(0x1B83C0DEEBCBB214, PlayerPedId()) - RemoveAllPedWeapons(PlayerPedId() , true , true) - for i,k in pairs(UsedWeapons) do - Citizen.InvokeNative(0x5E3BDDBCB83F3D84, PlayerPedId(), k.WeaponHash, 0, false, true) - SetPedAmmo(PlayerPedId(), k.WeaponHash , k.Ammo) - end -end - -Citizen.CreateThread(function() - while true do - Wait(60000) - if next(UsedWeapons) ~= nil then - for i,k in pairs(UsedWeapons) do - if not WeaponsWithoutAmmo[k.name] then - UsedWeapons[i].Ammo = GetAmmoInPedWeapon(PlayerPedId(), i) - end - end - TriggerServerEvent("redemrp_inventory:ChangeAmmoAmount", UsedWeapons) - end - end - -end) -RegisterNetEvent("redemrp_inventory:SaveAmmo") -AddEventHandler("redemrp_inventory:SaveAmmo", function() - if next(UsedWeapons) ~= nil then - for i,k in pairs(UsedWeapons) do - if not WeaponsWithoutAmmo[k.name] then - UsedWeapons[i].Ammo = GetAmmoInPedWeapon(PlayerPedId(), i) - end - end - TriggerServerEvent("redemrp_inventory:ChangeAmmoAmount", UsedWeapons) - end -end) -RegisterNetEvent("redemrp_inventory:SendItems") -AddEventHandler("redemrp_inventory:SendItems", function(data, data2, weight , other , target) - InventoryItems = data - OtherItems = data2 - InventoryWeight = weight - local _target = 0 - local crafting = true - if other then - isOtherOpen = true - isInventoryOpen = true - crafting = false - end - if target then - _target = target - for i,k in pairs(InventoryItems) do - if k.type == "item_weapon" and not WeaponsWithoutAmmo[k.name] then - if HasPedGotWeapon(PlayerPedId(), tonumber(k.weaponHash)) then - if UsedWeapons[tonumber(k.weaponHash)].meta.uid == k.meta.uid then - InventoryItems[i].amount = GetAmmoInPedWeapon(PlayerPedId(), tonumber(k.weaponHash)) - end - end - end - end - end - if isInventoryOpen then - SendNUIMessage({ - type = 1, - inventory = isInventoryOpen, - otherinventory = isOtherOpen, - crafting = crafting, - items = InventoryItems, - otheritems = OtherItems, - money = PlayerMoney, - time = GetClockHours()..":"..GetClockMinutes(), - weight = InventoryWeight , - target = _target, - }) - SetNuiFocus(true, true) - end -end) - -RegisterNetEvent("redem:addMoney") -AddEventHandler("redem:addMoney", function(_money) - PlayerMoney = tonumber(string.format("%.2f",tostring(_money))) -end) - -RegisterNetEvent("redem:activateMoney") -AddEventHandler("redem:activateMoney", function(_money) - PlayerMoney = tonumber(string.format("%.2f",tostring(_money))) -end) - -RegisterNUICallback('additem', function(data) - TriggerServerEvent("redemrp_inventory:update", "add", data.data , data.target ,LockerZone) -end) - -RegisterNUICallback('removeitem', function(data) - TriggerServerEvent("redemrp_inventory:update", "delete" ,data.data, data.target, LockerZone) -end) - ---==================== D R O P ======================================= - -RegisterNUICallback('dropitem', function(data) - TriggerServerEvent("redemrp_inventory:drop",data.data) -end) - -function modelrequest( model ) - Citizen.CreateThread(function() - RequestModel( model ) - end) -end - -function DrawText3D(x, y, z, text) - local onScreen,_x,_y=GetScreenCoordFromWorldCoord(x, y, z) - local px,py,pz=table.unpack(GetGameplayCamCoord()) - SetTextScale(0.35, 0.35) - SetTextFontForCurrentCommand(1) - SetTextColor(255, 255, 255, 215) - local str = CreateVarString(10, "LITERAL_STRING", text, Citizen.ResultAsLong()) - SetTextCentre(1) - DisplayText(str,_x,_y) - local factor = (string.len(text)) / 150 - DrawSprite("generic_textures", "hud_menu_4a", _x, _y+0.0125,0.015+ factor, 0.03, 0.1, 100, 1, 1, 190, 0) -end - -RegisterNetEvent('redemrp_inventory:CreatePickup') -AddEventHandler('redemrp_inventory:CreatePickup', function(name, amount , meta, label, img) - local ped = PlayerPedId() - local coords = GetEntityCoords(ped) - local forward = GetEntityForwardVector(ped) - local x, y, z = table.unpack(coords + forward * 1.6) - while not HasModelLoaded( GetHashKey("P_COTTONBOX01X") ) do - Wait(500) - modelrequest( GetHashKey("P_COTTONBOX01X") ) - end - local obj = CreateObject("P_COTTONBOX01X", x, y, z, true, true, true) - PlaceObjectOnGroundProperly(obj) - SetEntityAsMissionEntity(obj, true, true) - FreezeEntityPosition(obj , true) - local _coords = GetEntityCoords(obj) - TriggerServerEvent("redemrp_inventory:AddPickupServer",name, amount, meta, label, img, _coords.x, _coords.y, _coords.z, obj) - PlaySoundFrontend("show_info", "Study_Sounds", true, 0) - SetModelAsNoLongerNeeded(GetHashKey("P_COTTONBOX01X")) -end) - -RegisterNetEvent('redemrp_inventory:removePickup') -AddEventHandler('redemrp_inventory:removePickup', function(obj) - SetEntityAsMissionEntity(obj, false, true) - NetworkRequestControlOfEntity(obj) - local timeout = 0 - while not NetworkHasControlOfEntity(obj) and timeout < 5000 do - timeout = timeout+100 - if timeout == 5000 then - print('Never got control of' ..obj) - end - Wait(100) - end - if NetworkHasControlOfEntity(obj) then - print("yeah we have control") - end - FreezeEntityPosition(obj , false) - DeleteEntity(obj) -end) - -RegisterNetEvent('redemrp_inventory:PickupAnim') -AddEventHandler('redemrp_inventory:PickupAnim', function() - local dict = "amb_work@world_human_box_pickup@1@male_a@stand_exit_withprop" - RequestAnimDict(dict) - while not HasAnimDictLoaded(dict) do - Citizen.Wait(10) - end - TaskPlayAnim(PlayerPedId(), dict, "exit_front", 1.0, 8.0, -1, 1, 0, false, false, false) - Wait(1200) - PlaySoundFrontend("CHECKPOINT_PERFECT", "HUD_MINI_GAME_SOUNDSET", true, 1) - Wait(1000) - ClearPedTasks(PlayerPedId()) -end) - -RegisterNetEvent('redemrp_inventory:UpdatePickups') -AddEventHandler('redemrp_inventory:UpdatePickups', function(pick) - DroppedItems = pick -end) - -local PickupPromptGroup = GetRandomIntInRange(0, 0xffffff) -print('PickupPromptGroup: ' .. PickupPromptGroup) -local PickupPrompt -local PromptActive = false - -function SetupPickPrompt() - Citizen.CreateThread(function() - local str = 'Pick Up' - PickupPrompt = Citizen.InvokeNative(0x04F97DE45A519419) - PromptSetControlAction(PickupPrompt, 0xF84FA74F) - str = CreateVarString(10, 'LITERAL_STRING', str) - PromptSetText(PickupPrompt, str) - PromptSetEnabled(PickupPrompt, true) - PromptSetVisible(PickupPrompt, true) - PromptSetHoldMode(PickupPrompt, true) - PromptSetGroup(PickupPrompt, PickupPromptGroup) - PromptRegisterEnd(PickupPrompt) - end) -end - - - -Citizen.CreateThread(function() - local wait = 1 - SetupPickPrompt() - while true do - Citizen.Wait(wait) - - local can_wait = true - local playerPed = PlayerPedId() - local coords = GetEntityCoords(playerPed) - - if next(DroppedItems) == nil then - Citizen.Wait(500) - end - - if DroppedItems ~= nil then - - for k,v in pairs(DroppedItems) do - local distance = Vdist(coords, v.coords.x, v.coords.y, v.coords.z) - if distance <= 15.0 then - can_wait = false - end - - if distance <= 5.0 then - DrawText3D(v.coords.x, v.coords.y, v.coords.z+0.5, v.label.." ".."["..v.amount.."]") - end - - if distance <= 1.2 then - if not PromptActive then - TaskLookAtEntity(playerPed, v.obj , 3000 ,2048 , 3) - local PromptGroupName = CreateVarString(10, 'LITERAL_STRING', v.label) - PromptSetActiveGroupThisFrame(PickupPromptGroup, PromptGroupName) - if PromptHasHoldModeCompleted(PickupPrompt) then - PromptActive = true - TriggerServerEvent("redemrp_inventory:onPickup",k) - - end - end - end - - end - end - if can_wait == true then - wait = 2000 - else - wait = 1 - end - end -end) - -RegisterNetEvent('redemrp_inventory:ReEnablePrompt') -AddEventHandler('redemrp_inventory:ReEnablePrompt', function() - PromptActive = false -end) - - -RegisterNetEvent('redemrp_inventory:OpenPrivateLocker') -AddEventHandler('redemrp_inventory:OpenPrivateLocker', function() - LockerZone = "private" - TriggerServerEvent("redemrp_inventory:GetLocker", LockerZone) -end) - -RegisterNetEvent('redemrp_inventory:OpenLocker') -AddEventHandler('redemrp_inventory:OpenLocker', function(id) - LockerZone = id - TriggerServerEvent("redemrp_inventory:GetLocker", LockerZone) -end) - ---==================== D R O P ======================================= - - - -RegisterNUICallback('useitem', function(data) - TriggerServerEvent("redemrp_inventory:use",data.data) -end) - -RegisterNUICallback('craft', function(data) - TriggerServerEvent("redemrp_inventory:craft",data , CurrentCraftingType) -end) - - - -RegisterNetEvent('redemrp_inventory:SendLockers') -AddEventHandler('redemrp_inventory:SendLockers', function(lock) - CreatedLockers = lock -end) - -RegisterNetEvent('redemrp_inventory:SendCraftings') -AddEventHandler('redemrp_inventory:SendCraftings', function(craft, job) - CreatedCraftings = craft - if job ~= nil then - PlayerJob = job - end -end) - - -Citizen.CreateThread(function() - local wait = 1 - while true do - Citizen.Wait(wait) - - local can_wait = true - local playerPed = PlayerPedId() - local coords = GetEntityCoords(playerPed) - - - if CreatedLockers ~= nil then - - for k,v in pairs(CreatedLockers) do - if v.coords.x ~= "empty" and v.coords ~= nil then - local distance = Vdist(coords, v.coords.x, v.coords.y, v.coords.z) - - if distance <= 15.0 then - can_wait = false - end - - if distance <= 2.0 and not LockerZone then - LockerZone = k - local str = Citizen.InvokeNative(0xFA925AC00EB830B9, 10, "LITERAL_STRING", "Press ~INPUT_JUMP~ to open locker", Citizen.ResultAsLong()) - Citizen.InvokeNative(0xFA233F8FE190514C, str) - Citizen.InvokeNative(0xE9990552DEC71600) - end - - if distance > 2 and k == LockerZone then - local blank = Citizen.InvokeNative(0xFA925AC00EB830B9, 10, "LITERAL_STRING", " ", Citizen.ResultAsLong()) - Citizen.InvokeNative(0xFA233F8FE190514C, blank) - Citizen.InvokeNative(0xE9990552DEC71600) - if isInventoryOpen then - SendNUIMessage({ - type = 2 - }) - SetNuiFocus(false, false) - isOtherOpen = false - LockerZone = nil - else - LockerZone = nil - end - end - if LockerZone then - if IsControlJustReleased(0, 0xD9D0E1C0) then - TriggerServerEvent("redemrp_inventory:GetLocker", LockerZone) - end - end - end - end - end - - if can_wait == true then - wait = 2000 - else - wait = 1 - end - end -end) - -local CraftingTarget -Citizen.CreateThread(function() - local wait = 1 - while true do - Citizen.Wait(wait) - - local can_wait = true - local playerPed = PlayerPedId() - local coords = GetEntityCoords(playerPed) - - - if CreatedCraftings ~= nil then - - for k,v in pairs(CreatedCraftings) do - local distance = Vdist(coords, v.coords.x, v.coords.y, v.coords.z) - - if distance <= 15.0 then - can_wait = false - end - - if distance <= 2.0 and not CraftingTarget and (v.requireJob == PlayerJob or v.requireJob == "empty") then - CraftingTarget = k - local str = Citizen.InvokeNative(0xFA925AC00EB830B9, 10, "LITERAL_STRING", "Press ~INPUT_JUMP~ to open crafting", Citizen.ResultAsLong()) - Citizen.InvokeNative(0xFA233F8FE190514C, str) - Citizen.InvokeNative(0xE9990552DEC71600) - end - - if distance > 2 and k == CraftingTarget then - local blank = Citizen.InvokeNative(0xFA925AC00EB830B9, 10, "LITERAL_STRING", " ", Citizen.ResultAsLong()) - Citizen.InvokeNative(0xFA233F8FE190514C, blank) - Citizen.InvokeNative(0xE9990552DEC71600) - if isInventoryOpen then - SendNUIMessage({ - type = 2 - }) - SetNuiFocus(false, false) - isOtherOpen = false - CraftingTarget = nil - else - CraftingTarget = nil - end - end - if CraftingTarget == k and (v.requireJob == PlayerJob or v.requireJob == "empty")then - - if IsControlJustReleased(0, 0xD9D0E1C0) then - CurrentCraftingType = v.type - isInventoryOpen = true - SendNUIMessage({ - type = 1, - inventory = isInventoryOpen, - otherinventory = isOtherOpen, - crafting = true, - items = InventoryItems, - otheritems = OtherItems, - money = PlayerMoney, - time = GetClockHours()..":"..GetClockMinutes(), - weight = InventoryWeight , - target = 0, - }) - SetNuiFocus(true, true) - end - end - end - - end - - if can_wait == true then - wait = 2000 - else - wait = 1 - end - end -end) - - - -RegisterNUICallback('close', function() - SetNuiFocus(false, false) - isInventoryOpen = false - isOtherOpen = false - LockerZone = nil -end) diff --git a/client/dataview.lua b/client/dataview.lua new file mode 100644 index 0000000..e7122eb --- /dev/null +++ b/client/dataview.lua @@ -0,0 +1,222 @@ + +------------------------------------------------------------------------------------------------------------- +------------------------------------------------------------------------------------------------------------- +----------------- DATAVIEW FUNCTIONS ------------- +----------------- ------------- +----------------- BIG THNKS to gottfriedleibniz for this DataView in LUA. ------------- +----------------- https://gist.github.com/gottfriedleibniz/8ff6e4f38f97dd43354a60f8494eedff ------------- +------------------------------------------------------------------------------------------------------------- +------------------------------------------------------------------------------------------------------------- + +local _strblob = string.blob or function(length) + return string.rep("\0", math.max(40 + 1, length)) +end + +DataView = { + EndBig = ">", + EndLittle = "<", + Types = { + Int8 = { code = "i1", size = 1 }, + Uint8 = { code = "I1", size = 1 }, + Int16 = { code = "i2", size = 2 }, + Uint16 = { code = "I2", size = 2 }, + Int32 = { code = "i4", size = 4 }, + Uint32 = { code = "I4", size = 4 }, + Int64 = { code = "i8", size = 8 }, + Uint64 = { code = "I8", size = 8 }, + + LuaInt = { code = "j", size = 8 }, + UluaInt = { code = "J", size = 8 }, + LuaNum = { code = "n", size = 8}, + Float32 = { code = "f", size = 4 }, + Float64 = { code = "d", size = 8 }, + String = { code = "z", size = -1, }, + }, + + FixedTypes = { + String = { code = "c", size = -1, }, + Int = { code = "i", size = -1, }, + Uint = { code = "I", size = -1, }, + }, +} +DataView.__index = DataView +local function _ib(o, l, t) return ((t.size < 0 and true) or (o + (t.size - 1) <= l)) end +local function _ef(big) return (big and DataView.EndBig) or DataView.EndLittle end +local SetFixed = nil +function DataView.ArrayBuffer(length) + return setmetatable({ + offset = 1, length = length, blob = _strblob(length) + }, DataView) +end +function DataView.Wrap(blob) + return setmetatable({ + offset = 1, blob = blob, length = blob:len(), + }, DataView) +end +function DataView:Buffer() return self.blob end +function DataView:ByteLength() return self.length end +function DataView:ByteOffset() return self.offset end +function DataView:SubView(offset) + return setmetatable({ + offset = offset, blob = self.blob, length = self.length, + }, DataView) +end +for label,datatype in pairs(DataView.Types) do + DataView["Get" .. label] = function(self, offset, endian) + local o = self.offset + offset + if _ib(o, self.length, datatype) then + local v,_ = string.unpack(_ef(endian) .. datatype.code, self.blob, o) + return v + end + return nil + end + + DataView["Set" .. label] = function(self, offset, value, endian) + local o = self.offset + offset + if _ib(o, self.length, datatype) then + return SetFixed(self, o, value, _ef(endian) .. datatype.code) + end + return self + end + if datatype.size >= 0 and string.packsize(datatype.code) ~= datatype.size then + local msg = "Pack size of %s (%d) does not match cached length: (%d)" + error(msg:format(label, string.packsize(fmt[#fmt]), datatype.size)) + return nil + end +end +for label,datatype in pairs(DataView.FixedTypes) do + DataView["GetFixed" .. label] = function(self, offset, typelen, endian) + local o = self.offset + offset + if o + (typelen - 1) <= self.length then + local code = _ef(endian) .. "c" .. tostring(typelen) + local v,_ = string.unpack(code, self.blob, o) + return v + end + return nil + end + DataView["SetFixed" .. label] = function(self, offset, typelen, value, endian) + local o = self.offset + offset + if o + (typelen - 1) <= self.length then + local code = _ef(endian) .. "c" .. tostring(typelen) + return SetFixed(self, o, value, code) + end + return self + end +end + +SetFixed = function(self, offset, value, code) + local fmt = { } + local values = { } + if self.offset < offset then + local size = offset - self.offset + fmt[#fmt + 1] = "c" .. tostring(size) + values[#values + 1] = self.blob:sub(self.offset, size) + end + fmt[#fmt + 1] = code + values[#values + 1] = value + local ps = string.packsize(fmt[#fmt]) + if (offset + ps) <= self.length then + local newoff = offset + ps + local size = self.length - newoff + 1 + + fmt[#fmt + 1] = "c" .. tostring(size) + values[#values + 1] = self.blob:sub(newoff, self.length) + end + self.blob = string.pack(table.concat(fmt, ""), table.unpack(values)) + self.length = self.blob:len() + return self +end + +DataStream = { } +DataStream.__index = DataStream + +function DataStream.New(view) + return setmetatable({ view = view, offset = 0, }, DataStream) +end + +for label,datatype in pairs(DataView.Types) do + DataStream[label] = function(self, endian, align) + local o = self.offset + self.view.offset + if not _ib(o, self.view.length, datatype) then + return nil + end + local v,no = string.unpack(_ef(endian) .. datatype.code, self.view:Buffer(), o) + if align then + self.offset = self.offset + math.max(no - o, align) + else + self.offset = no - self.view.offset + end + return v + end +end + +------------------------------------------------------------------------------------------------------------ +------------------------------------------------------------------------------------------------------------ +------------------------------------------------------------------------------------------------------------ +----------------- ------------ +----------------- END OF DATAVIEW FUNCTIONS ------------ +----------------- ------------ +------------------------------------------------------------------------------------------------------------ +------------------------------------------------------------------------------------------------------------ +------------------------------------------------------------------------------------------------------------ + +function getGuidFromItemId(inventoryId, itemData, category, slotId) + local outItem = DataView.ArrayBuffer(8 * 13) + + if not itemData then + itemData = 0 + end + + local success = Citizen.InvokeNative("0x886DFD3E185C8A89", inventoryId, itemData, category, slotId, outItem:Buffer()) --InventoryGetGuidFromItemid + if success then + return outItem:Buffer() --Seems to not return anythign diff. May need to pull from native above + else + return nil + end +end + +function addWardrobeInventoryItem(itemName, slotHash) + local itemHash = GetHashKey(itemName) + local addReason = GetHashKey("ADD_REASON_DEFAULT") + local inventoryId = 1 + + -- _ITEMDATABASE_IS_KEY_VALID + local isValid = Citizen.InvokeNative("0x6D5D51B188333FD1", itemHash, 0) --ItemdatabaseIsKeyValid + if not isValid then + return false + end + + local characterItem = getGuidFromItemId(inventoryId, nil, GetHashKey("CHARACTER"), 0xA1212100) + if not characterItem then + return false + end + + local wardrobeItem = getGuidFromItemId(inventoryId, characterItem, GetHashKey("WARDROBE"), 0x3DABBFA7) + if not wardrobeItem then + return false + end + + local itemData = DataView.ArrayBuffer(8 * 13) + + -- _INVENTORY_ADD_ITEM_WITH_GUID + local isAdded = Citizen.InvokeNative("0xCB5D11F9508A928D", inventoryId, itemData:Buffer(), wardrobeItem, itemHash, slotHash, 1, addReason); + if not isAdded then + return false + end + + -- _INVENTORY_EQUIP_ITEM_WITH_GUID + local equipped = Citizen.InvokeNative("0x734311E2852760D0", inventoryId, itemData:Buffer(), true); + return equipped; +end + +function givePlayerWeapon(weaponName, attachPoint) + local addReason = GetHashKey("ADD_REASON_DEFAULT"); + local weaponHash = weaponName; + local ammoCount = 0; + + -- RequestWeaponAsset + Citizen.InvokeNative(0x72D4CB5DB927009C, weaponHash, 0, true); + while not Citizen.InvokeNative(0xFF07CF465F48B830, weaponHash) do Wait(10) end + -- GIVE_WEAPON_TO_PED + Citizen.InvokeNative(0x5E3BDDBCB83F3D84, PlayerPedId(), weaponHash, ammoCount, true, false, attachPoint, true, 0.0, 0.0, addReason, true, 0.0, false); +end diff --git a/client/main.lua b/client/main.lua new file mode 100644 index 0000000..d414bb2 --- /dev/null +++ b/client/main.lua @@ -0,0 +1,923 @@ +RedEM = exports["redem_roleplay"]:GetCoreObject() + +local isInventoryOpen = false +local isOtherOpen = false +local InventoryItems = {} +local OtherItems = {} +local PlayerMoney = 0 +local InventoryWeight = 0.0 +local DroppedItems = {} +local OpenStash = nil +local UsedWeapons = {} +local PlayerJob = job +local CraftingId = nil +local IsCrafting = false + +local WeaponsWithoutAmmo = { + ["WEAPON_FISHINGROD"] = true, + + ["WEAPON_MELEE_KNIFE"] = true, + + ["WEAPON_MELEE_KNIFE_JAWBONE"] = true, + ["WEAPON_MELEE_KNIFE_TRADER"] = true, + ["WEAPON_MELEE_KNIFE_HORROR"] = true, + ["WEAPON_MELEE_KNIFE_RUSTIC"] = true, + ["WEAPON_MELEE_KNIFE_MINER"] = true, + ["WEAPON_MELEE_KNIFE_VAMPIRE"] = true, + + ["WEAPON_MELEE_MACHETE"] = true, + ["WEAPON_MELEE_MACHETE_COLLECTOR"] = true, + ["WEAPON_MELEE_MACHETE_HORROR"] = true, + + ["WEAPON_LASSO"] = true, + ["WEAPON_LASSO_IMPROVED"] = true, + + ["WEAPON_MELEE_CLEAVER"] = true, + ["WEAPON_MELEE_HATCHET"] = true, + ["WEAPON_MELEE_HATCHET_HUNTER"] = true, + ["WEAPON_MELEE_HATCHET_DOUBLE_BIT"] = true, + + ["WEAPON_MELEE_LANTERN"] = true, + ["WEAPON_MELEE_LANTERN_ELECTRIC"] = true, + ["WEAPON_MELEE_LANTERN_HALLOWEEN"] = true, + + ["WEAPON_MELEE_TORCH"] = true, + + ["WEAPON_KIT_BINOCULARS"] = true, +} + +RegisterNetEvent("redemrp_inventory:client:ResetWeapons", function() + UsedWeapons = {} +end) + +RegisterNetEvent("redemrp_inventory:client:OpenCrafting", function(id) + CraftingId = id + isInventoryOpen = true + IsCrafting = true + SendNUIMessage( + { + type = 1, + inventory = isInventoryOpen, + otherinventory = isOtherOpen, + crafting = true, + items = InventoryItems, + otheritems = OtherItems, + money = RedEM.GetPlayerData().money, + time = GetClockHours() .. ":" .. GetClockMinutes(), + weight = InventoryWeight, + target = 0 + } + ) + SetNuiFocus(true, true) +end) + +Citizen.CreateThread( + function() + TriggerServerEvent("redemrp_inventory:playerJoined") + while true do + Wait(1) + if IsControlJustReleased(0, 0x4CC0E2FE) then + isInventoryOpen = not isInventoryOpen + + if isInventoryOpen then + for i, k in pairs(InventoryItems) do + if k.type == "item_weapon" and not WeaponsWithoutAmmo[k.name] then + if HasPedGotWeapon(PlayerPedId(), tonumber(k.weaponHash)) then + if + UsedWeapons[tonumber(k.weaponHash)] and + UsedWeapons[tonumber(k.weaponHash)].meta.uid == k.meta.uid + then + InventoryItems[i].amount = + GetAmmoInPedWeapon(PlayerPedId(), tonumber(k.weaponHash)) + end + end + end + end + SendNUIMessage( + { + type = 1, + inventory = isInventoryOpen, + otherinventory = isOtherOpen, + crafting = false, + items = InventoryItems, + otheritems = OtherItems, + money = RedEM.GetPlayerData().money, + time = GetClockHours() .. ":" .. GetClockMinutes(), + weight = InventoryWeight, + target = 0 + } + ) + + SetNuiFocus(true, true) + else + SendNUIMessage( + { + type = 2 + } + ) + SetNuiFocus(false, false) + IsCrafting = false + isOtherOpen = false + SetNuiFocusKeepInput(false) + end + end + end + end +) + +RegisterNetEvent( + "redemrp_inventory:PlaySound", + function(soundID) + PlaySoundFrontend("HUD_SHOP_SOUNDSET", "PURCHASE", true, 0) + end +) + +RegisterNetEvent("redemrp_inventory:SearchPlayer") +AddEventHandler( + "redemrp_inventory:SearchPlayer", + function() + local closestPlayer, closestDistance = GetClosestPlayer() + if closestPlayer ~= -1 and closestDistance <= 1.5 then + TriggerServerEvent("redemrp_inventory:GetPlayer", GetPlayerServerId(closestPlayer), Citizen.InvokeNative(0x3AA24CCC0D451379, GetPlayerPed(closestPlayer))) + else + RedEM.Functions.NotifyLeft("Can't Find", "No players nearby!", "menu_textures", "menu_icon_alert", 4000) + end + end +) + +RegisterNetEvent("redemrp_inventory:PoliceSearchPlayer") +AddEventHandler( + "redemrp_inventory:PoliceSearchPlayer", + function() + local closestPlayer, closestDistance = GetClosestPlayer() + if closestPlayer ~= -1 and closestDistance <= 1.5 then + TriggerServerEvent("redemrp_inventory:GetPlayerAsPolice", GetPlayerServerId(closestPlayer)) + else + RedEM.Functions.NotifyLeft("Can't Find", "No players nearby!", "menu_textures", "menu_icon_alert", 4000) + end + end +) + +RegisterNetEvent("redemrp_inventory:removeWeapon") +AddEventHandler( + "redemrp_inventory:removeWeapon", + function(hash) + if UsedWeapons[tonumber(hash)] then + UsedWeapons[tonumber(hash)] = nil + ReloadWeapons() + end + end +) + +RegisterNetEvent('redemrp_inventory:getUsedWeapons') +AddEventHandler('redemrp_inventory:getUsedWeapons', function(hash) + TriggerServerEvent('redemrp_inventory:getUsedWeapons', UsedWeapons) +end) + +RegisterNetEvent('redemrp_inventory:getUsedWeapons') +AddEventHandler('redemrp_inventory:getUsedWeapons', function(hash) + TriggerServerEvent('redemrp_inventory:getUsedWeapons', UsedWeapons) +end) + + +local PistolsEquipped = 0 + +RegisterNetEvent("redemrp_inventory:UseWeapon") +AddEventHandler( + "redemrp_inventory:UseWeapon", + function(hash, ammoAmount, meta, name) + local id = false + local pweptype = Citizen.InvokeNative(0x5C2EA6C44F515F34, tonumber(hash)) + if (not UsedWeapons[tonumber(hash)]) or ((pweptype == 1681219929 or pweptype == 1950175060) and PistolsEquipped < 2) then + if pweptype == 1681219929 or pweptype == 1950175060 then + PistolsEquipped = PistolsEquipped + 1 + end + for i, k in pairs(UsedWeapons) do + if k.WeaponType == pweptype then + id = i + break + end + end + if id and pweptype ~= 1681219929 and pweptype ~= 1950175060 then + UsedWeapons[id] = nil + end + UsedWeapons[tonumber(hash)] = { + WeaponHash = tonumber(hash), + WeaponType = pweptype, + Ammo = tonumber(ammoAmount), + name = name, + meta = meta + } + else + if not WeaponsWithoutAmmo[UsedWeapons[tonumber(hash)].name] then + UsedWeapons[tonumber(hash)].Ammo = GetAmmoInPedWeapon(PlayerPedId(), tonumber(hash)) + end + TriggerServerEvent("redemrp_inventory:ChangeAmmoAmount", {UsedWeapons[tonumber(hash)]}) + UsedWeapons[tonumber(hash)] = nil + end + ReloadWeapons() + end +) + +local PistolsEquipping = 0 + +RegisterCommand("lanternbelt", function() + for i, k in pairs(UsedWeapons) do + if k.name == "WEAPON_MELEE_LANTERN" then + SetCurrentPedWeapon(PlayerPedId(), `WEAPON_MELEE_LANTERN`, true, 12, false, false) + if IsPedMale(PlayerPedId()) then + TriggerServerEvent('3dme:shareDisplay', "ATTACHES HIS LANTERN TO HIS BELT") + else + TriggerServerEvent('3dme:shareDisplay', "ATTACHES HER LANTERN TO HER BELT") + end + end + end +end) + +function ReloadWeapons() + Citizen.InvokeNative(0x1B83C0DEEBCBB214, PlayerPedId()) + RemoveAllPedWeapons(PlayerPedId(), true, true) + addWardrobeInventoryItem("CLOTHING_ITEM_M_OFFHAND_000_TINT_004", 0xF20B6B4A); + addWardrobeInventoryItem("UPGRADE_OFFHAND_HOLSTER", 0x39E57B01); + PistolsEquipping = 0 + for i, k in pairs(UsedWeapons) do + if k.name == "WEAPON_PISTOL_VOLCANIC" or + k.name == "WEAPON_PISTOL_M1899" or + k.name == "WEAPON_PISTOL_SEMIAUTO" or + k.name == "WEAPON_PISTOL_MAUSER" or + k.name == "WEAPON_REVOLVER_DOUBLEACTION" or + k.name == "WEAPON_REVOLVER_CATTLEMAN" or + k.name == "WEAPON_REVOLVER_LEMAT" or + k.name == "WEAPON_REVOLVER_SCHOFIELD" or + k.name == "WEAPON_REVOLVER_NAVY" then + PistolsEquipping = PistolsEquipping + 1 + if PistolsEquipping == 1 then + givePlayerWeapon(k.WeaponHash, 2) + elseif PistolsEquipping == 2 then + givePlayerWeapon(k.WeaponHash, 3) + else + Citizen.InvokeNative(0x5E3BDDBCB83F3D84, PlayerPedId(), k.WeaponHash, 0, false, true) -- GIVE_WEAPON_TO_PED + end + elseif k.name == "WEAPON_MELEE_LANTERN" then + GiveWeaponToPed_2(PlayerPedId(), `WEAPON_MELEE_LANTERN`, 0, true, true , 0, false, 0.5, 1.0, 752097756, false, 0, false) + SetCurrentPedWeapon(PlayerPedId(), `WEAPON_MELEE_LANTERN`, true, 0, false, false) + else + Citizen.InvokeNative(0x5E3BDDBCB83F3D84, PlayerPedId(), k.WeaponHash, 0, false, true) -- GIVE_WEAPON_TO_PED + end + --GiveWeaponToPed_2(v, `weapon_revolver_cattleman`, 500, false, true, 1, false, 0.5, 1.0, 1.0, true, 0, 0) + --print("Setting ammo for "..k.WeaponHash.." to "..k.Ammo) + SetPedAmmo(PlayerPedId(), k.WeaponHash, k.Ammo) + if k.meta.components ~= nil and k.meta.components["GLOBAL"] ~= nil then + TriggerEvent('darkk_weapon_customization:Apply', k.WeaponHash, k.meta.components) + end + + --[[ + Wait(100) + if k.meta.damage ~= nil and k.meta.dirt ~= nil then + local weapon = Citizen.InvokeNative(0x6CA484C9A7377E4F, PlayerPedId(), 1) -- _GET_PED_WEAPON_OBJECT + while not DoesEntityExist(weapon) do + Wait(10) + weapon = Citizen.InvokeNative(0x6CA484C9A7377E4F, PlayerPedId(), 1) -- _GET_PED_WEAPON_OBJECT + end + TriggerEvent('weapons:ApplyDamage', weapon, k.meta.damage, k.meta.dirt) + end]] + end +end + +RegisterNetEvent("weapons:ApplyDamage", function(weaponObject, damagelevel, dirtlevel) + if damagelevel == 1 then damagelevel = 1.0 end + if dirtlevel == 1 then dirtlevel = 1.0 end + if DoesEntityExist(weaponObject) then + --print("Applied damage of "..damagelevel.." and dirt level "..dirtlevel.." to weapon object "..weaponObject) + Citizen.InvokeNative(0xA7A57E89E965D839, weaponObject, damagelevel) -- _SET_WEAPON_DEGRADATION + Citizen.InvokeNative(0x812CE61DEBCAB948, weaponObject, dirtlevel, 0) -- _SET_WEAPON_DIRT + Citizen.InvokeNative(0xA9EF4AD10BDDDB57, weaponObject, dirtlevel, 0) + end +end) + +RegisterCommand('inspect', function(source, args, raw) + local ped = PlayerPedId() + local wep = GetCurrentPedWeaponEntityIndex(ped, 0) + local _, wepHash = GetCurrentPedWeapon(ped, true, 0, true) + local WeaponType = GetWeaponType(wepHash) + if wepHash == `WEAPON_UNARMED` then return end + ShowWeaponStats() + if WeaponType == "SHOTGUN" then WeaponType = "LONGARM" end + if WeaponType == "MELEE" then WeaponType = "SHORTARM" end + if WeaponType == "BOW" then WeaponType = "SHORTARM" end + Citizen.InvokeNative(0x72F52AA2D2B172CC, PlayerPedId(), wepHash, wep, 0, GetHashKey(WeaponType.."_HOLD_ENTER"), 0, 0, -1.0) +end) + +function GetWeaponType(hash) + if Citizen.InvokeNative(0x959383DCD42040DA, hash) or Citizen.InvokeNative(0x792E3EF76C911959, hash) then + return "MELEE" + elseif Citizen.InvokeNative(0x6AD66548840472E5, hash) or Citizen.InvokeNative(0x0A82317B7EBFC420, hash) or Citizen.InvokeNative(0xDDB2578E95EF7138, hash) then + return "LONGARM" + elseif Citizen.InvokeNative(0xC75386174ECE95D5, hash) then + return "SHOTGUN" + elseif Citizen.InvokeNative(0xDDC64F5E31EEDAB6, hash) or Citizen.InvokeNative(0xC212F1D05A8232BB, hash) then + return "SHORTARM" + end + return false +end + +function ShowWeaponStats() + local PlayerPed = PlayerPedId() + local WeaponObject = GetObjectIndexFromEntityIndex(GetCurrentPedWeaponEntityIndex(PlayerPed , 0)) + local _, WeaponHash = GetCurrentPedWeapon(PlayerPed, true, 0, true) + local Block = RequestFlowBlock(GetHashKey("PM_FLOW_WEAPON_INSPECT")) + local Container = DatabindingAddDataContainerFromPath("" , "ItemInspection") + exports["redemrp_weaponmods"]:GetWeaponStats(Container, WeaponHash) + DatabindingAddDataBool(Container, "Visible", true) + DatabindingAddDataString(Container, "tipText", GetLabelText(WeaponObject)) + DatabindingAddDataHash(Container, "itemLabel", WeaponHash) + Citizen.InvokeNative(0x10A93C057B6BD944 ,Block) + Citizen.InvokeNative(0x3B7519720C9DCB45 ,Block, 0) + Citizen.InvokeNative(0x4C6F2C4B7A03A266 ,-813354801, Block) + Citizen.CreateThread(function() + Wait(1000) + while true do + Wait(100) + if not Citizen.InvokeNative(0x6AA3DCA2C6F5EB6D, PlayerPedId()) then + Citizen.InvokeNative(0x4EB122210A90E2D8, -813354801) + break + end + end + end) +end + +function GetLabelText(WeaponObject) + local WeaponDegradation = Citizen.InvokeNative(0x0D78E1097F89E637 ,WeaponObject , Citizen.ResultAsFloat()) + local WeaponPernamentDegradation = Citizen.InvokeNative(0xD56E5F336C675EFA ,WeaponObject , Citizen.ResultAsFloat()) + if WeaponDegradation == 0.0 then + return GetLabelTextByHash(1803343570) + end + if WeaponPernamentDegradation > 0.0 and WeaponDegradation == WeaponPernamentDegradation then + return GetLabelTextByHash(-1933427003) + end + return GetLabelTextByHash(-54957657) +end + +Citizen.CreateThread(function() + while true do + Wait(2000) + local weaponObject = Citizen.InvokeNative(0x6CA484C9A7377E4F, PlayerPedId(), 1) -- _GET_PED_WEAPON_OBJECT + local _,pedWeapon = GetCurrentPedWeapon(PlayerPedId(), 1) + for i, k in pairs(UsedWeapons) do + if k.WeaponHash == pedWeapon then + TriggerEvent('weapons:ApplyDamage', weaponObject, UsedWeapons[i].meta.damage, UsedWeapons[i].meta.dirt) + break + end + end + end +end) + +Citizen.CreateThread(function() + while true do + Wait(50) + if IsPedShooting(PlayerPedId()) then + local weaponObject = Citizen.InvokeNative(0x6CA484C9A7377E4F, PlayerPedId(), 1) -- _GET_PED_WEAPON_OBJECT + local _,pedWeapon = GetCurrentPedWeapon(PlayerPedId(), 1) + for i, k in pairs(UsedWeapons) do + if k.WeaponHash == pedWeapon then + if not UsedWeapons[i].meta.damage then + UsedWeapons[i].meta.damage = 0.0 + end + if not UsedWeapons[i].meta.dirt then + UsedWeapons[i].meta.dirt = 0.0 + end + UsedWeapons[i].meta.damage = tonumber(math.format("%.2f", UsedWeapons[i].meta.damage + ((math.random(5, 9)/10) / 100))) + UsedWeapons[i].meta.dirt = tonumber(math.format("%.2f", UsedWeapons[i].meta.dirt + ((math.random(5, 9)/10) / 100))) + if UsedWeapons[i].meta.damage > 1.0 then + UsedWeapons[i].meta.damage = 1.0 + end + if UsedWeapons[i].meta.dirt > 1.0 then + UsedWeapons[i].meta.dirt = 1.0 + end + TriggerEvent('weapons:ApplyDamage', weaponObject, UsedWeapons[i].meta.damage, UsedWeapons[i].meta.dirt) + TriggerServerEvent('weapons:server:ApplyDamage', UsedWeapons) + --print("Damaged weapon "..k.name.." by 0.01 to ".. UsedWeapons[i].meta.damage) + --print("Dirtied weapon "..k.name.." by 0.02 to ".. UsedWeapons[i].meta.dirt) + break + end + end + end + end +end) + +--[[ +Citizen.CreateThread(function() + while true do + Wait(5000) + if next(UsedWeapons) ~= nil then + TriggerServerEvent('weapons:server:ApplyDamage', UsedWeapons) + --print("Saving weapon damage with server") + end + end +end)]] + +RegisterNetEvent("weapons:CleanAndRepairWeapon", function() + TriggerEvent("redemrp_inventory:closeinv") + local ped = PlayerPedId() + local retval, weaponHash = GetCurrentPedWeapon(PlayerPedId(), false, weaponHash, false) + if weaponHash ~= `WEAPON_UNARMED` then + local Cloth= CreateObject(GetHashKey('s_balledragcloth01x'), GetEntityCoords(PlayerPedId()), false, true, false, false, true) + local PropId = GetHashKey("CLOTH") + local actshort = GetHashKey("SHORTARM_CLEAN_ENTER") + local actlong = GetHashKey("LONGARM_CLEAN_ENTER") + local model = GetWeapontypeGroup(weaponHash) + local object = GetObjectIndexFromEntityIndex(GetCurrentPedWeaponEntityIndex(PlayerPedId(),0)) + -- print("Model --> "..model) + -- print("Weapon hash --> "..weaponHash) + -- print("NOmbre--> "..weaponName) + if model == 416676503 or model == -1101297303 then + Citizen.InvokeNative(0x72F52AA2D2B172CC, PlayerPedId(), 1242464081, Cloth, PropId, actshort, 1, 0, -1.0) + else + Citizen.InvokeNative(0x72F52AA2D2B172CC, PlayerPedId(), 1242464081, Cloth, PropId, actlong, 1, 0, -1.0) + end + RepairWeapon() + TriggerServerEvent("redemrp_weaponshop:server:RemoveGunOil") + end +end) + +RepairWeapon = function() + local weaponObject = Citizen.InvokeNative(0x6CA484C9A7377E4F, PlayerPedId(), 1) + local _,pedWeapon = GetCurrentPedWeapon(PlayerPedId(), 1) + for i, k in pairs(UsedWeapons) do + if k.WeaponHash == pedWeapon then + Citizen.InvokeNative(0xA7A57E89E965D839, weaponObject, 0.0) + Citizen.InvokeNative(0x812CE61DEBCAB948, weaponObject, 0.0, 0) + Citizen.InvokeNative(0xA9EF4AD10BDDDB57, weaponObject, 0.0, 0) + UsedWeapons[i].meta.damage = 0.0 + UsedWeapons[i].meta.dirt = 0.0 + TriggerServerEvent('weapons:server:ApplyDamage', UsedWeapons) + break + end + end +end + +RegisterNetEvent("weapons:BreakWeapon", function() + local weaponObject = Citizen.InvokeNative(0x6CA484C9A7377E4F, PlayerPedId(), 1) + local _,pedWeapon = GetCurrentPedWeapon(PlayerPedId(), 1) + for i, k in pairs(UsedWeapons) do + if k.WeaponHash == pedWeapon then + Citizen.InvokeNative(0xA7A57E89E965D839, weaponObject, 1.0) + Citizen.InvokeNative(0x812CE61DEBCAB948, weaponObject, 1.0, 0) + Citizen.InvokeNative(0xA9EF4AD10BDDDB57, weaponObject, 1.0, 0) + UsedWeapons[i].meta.damage = 1.0 + UsedWeapons[i].meta.dirt = 1.0 + TriggerServerEvent('weapons:server:ApplyDamage', UsedWeapons) + break + end + end +end) + +--[[ +RegisterCommand("weaponclean", function() + TriggerEvent("weapons:CleanAndRepairWeapon") +end) + +RegisterCommand("weaponbreak", function() + TriggerEvent("weapons:BreakWeapon") +end)]] + +Citizen.CreateThread( + function() + while true do + Wait(10000) + local Changed = false + if next(UsedWeapons) ~= nil then + for i, k in pairs(UsedWeapons) do + if HasPedGotWeapon(PlayerPedId(), i, 0, 0) then + if not WeaponsWithoutAmmo[k.name] then + Changed = true + UsedWeapons[i].Ammo = GetAmmoInPedWeapon(PlayerPedId(), i) + end + end + end + if Changed then + TriggerServerEvent("redemrp_inventory:ChangeAmmoAmount", UsedWeapons) + end + end + end + end +) + + +RegisterNetEvent( + "redemrp_inventory:SendItems", + function(data, data2, weight, other, target) + InventoryItems = data + OtherItems = data2 + InventoryWeight = weight + local _target = 0 + if other then + isOtherOpen = true + isInventoryOpen = true + end + if target then + _target = target + for i, k in pairs(InventoryItems) do + if k.type == "item_weapon" and not WeaponsWithoutAmmo[k.name] then + if HasPedGotWeapon(PlayerPedId(), tonumber(k.weaponHash)) then + if UsedWeapons[tonumber(k.weaponHash)].meta.uid == k.meta.uid then + InventoryItems[i].amount = GetAmmoInPedWeapon(PlayerPedId(), tonumber(k.weaponHash)) + end + end + end + end + end + if isInventoryOpen then + SendNUIMessage( + { + type = 1, + inventory = isInventoryOpen, + otherinventory = isOtherOpen, + crafting = IsCrafting, + items = InventoryItems, + otheritems = OtherItems, + money = RedEM.GetPlayerData().money, + time = GetClockHours() .. ":" .. GetClockMinutes(), + weight = InventoryWeight, + target = _target + } + ) + SetNuiFocus(true, true) + end + end +) + +RegisterNetEvent( + "redem:addMoney", + function(_money) + PlayerMoney = _money + end +) + +RegisterNetEvent( + "redem:activateMoney", + function(_money) + PlayerMoney = _money + end +) + +RegisterNUICallback( + "additem", + function(data) + TriggerServerEvent("redemrp_inventory:update", "add", data.data, data.target, nil, OpenStash) + end +) + +RegisterNUICallback( + "removeitem", + function(data) + TriggerServerEvent("redemrp_inventory:update", "delete", data.data, data.target, nil, OpenStash) + end +) + +local crafting = false + +RegisterNetEvent("redemrp_inventory:client:StartCraftingProgress", function(itemstoremove, outputItem, outputAmount) + if not crafting then + TriggerEvent("redemrp_inventory:closeinv") + crafting = true + TaskStartScenarioInPlace(PlayerPedId(), GetHashKey('WORLD_HUMAN_CROUCH_INSPECT'), -1, true, false, false, false) + exports['progressBars']:startUI(3000 * outputAmount, "Crafting Items...") + Wait(3000 * outputAmount) + ClearPedTasks(PlayerPedId()) + TriggerServerEvent("redemrp_inventory:server:FinishCraftingProgress", itemstoremove, outputItem, outputAmount) + crafting = false + end +end) + +--==================== D R O P ======================================= + +RegisterNetEvent("redemrp_inventory:closeinv") +AddEventHandler("redemrp_inventory:closeinv", function() + SendNUIMessage( + { + type = 2 + } + ) + SetNuiFocus(false, false) + IsCrafting = false + isInventoryOpen = false + isOtherOpen = false + SetNuiFocusKeepInput(false) +end) + +function GetClosestPlayer() + local players, closestDistance, closestPlayer = GetActivePlayers(), -1, -1 + local playerPed, playerId = PlayerPedId(), PlayerId() + local coords, usePlayerPed = coords, false + + if coords then + coords = vector3(coords.x, coords.y, coords.z) + else + usePlayerPed = true + coords = GetEntityCoords(playerPed) + end + + for i = 1, #players, 1 do + local tgt = GetPlayerPed(players[i]) + + if not usePlayerPed or (usePlayerPed and players[i] ~= playerId) then + local targetCoords = GetEntityCoords(tgt) + local distance = #(coords - targetCoords) + + if closestDistance == -1 or closestDistance > distance then + closestPlayer = players[i] + closestDistance = distance + end + end + end + return closestPlayer, closestDistance +end + +RegisterNUICallback( + "dropitem", + function(data) + TriggerServerEvent("redemrp_inventory:drop", data.data) + end +) + +RegisterNUICallback( + "giveitem", + function(data) + local closestPlayer, closestDistance = GetClosestPlayer() + if closestPlayer ~= -1 and closestDistance <= 1.5 then + --print(json.encode(data)) + TriggerServerEvent("redemrp_inventory:giveItem", data.data, GetPlayerServerId(closestPlayer)) + else + RedEM.Functions.NotifyLeft("Can't Find", "No players nearby!", "menu_textures", "menu_icon_alert", 4000) + end + end +) + +function modelrequest(model) + Citizen.CreateThread( + function() + RequestModel(model) + end + ) +end + +function DrawText3D(x, y, z, text) + local onScreen, _x, _y = GetScreenCoordFromWorldCoord(x, y, z) + local px, py, pz = table.unpack(GetGameplayCamCoord()) + SetTextScale(0.35, 0.35) + SetTextFontForCurrentCommand(1) + SetTextColor(255, 255, 255, 215) + local str = CreateVarString(10, "LITERAL_STRING", text, Citizen.ResultAsLong()) + SetTextCentre(1) + DisplayText(str, _x, _y) + local factor = (string.len(text)) / 150 + DrawSprite("generic_textures", "hud_menu_4a", _x, _y + 0.0125, 0.015 + factor, 0.03, 0.1, 100, 1, 1, 190, 0) +end + +RegisterNetEvent( + "redemrp_inventory:CreatePickup", + function(name, amount, meta, label, img) + local ped = PlayerPedId() + local coords = GetEntityCoords(ped) + local forward = GetEntityForwardVector(ped) + local x, y, z = table.unpack(coords + forward * 1.6) + while not HasModelLoaded(GetHashKey("P_COTTONBOX01X")) do + Wait(500) + modelrequest(GetHashKey("P_COTTONBOX01X")) + end + local obj = CreateObject("P_COTTONBOX01X", x, y, z, true, true, true) + PlaceObjectOnGroundProperly(obj) + SetEntityAsMissionEntity(obj, true, true) + FreezeEntityPosition(obj, true) + local _coords = GetEntityCoords(obj) + TriggerServerEvent( + "redemrp_inventory:AddPickupServer", + name, + amount, + meta, + label, + img, + _coords.x, + _coords.y, + _coords.z, + ObjToNet(obj) + ) + PlaySoundFrontend("show_info", "Study_Sounds", true, 0) + SetModelAsNoLongerNeeded(GetHashKey("P_COTTONBOX01X")) + end +) + +RegisterNetEvent( + "redemrp_inventory:CreateLetterPickup", + function(name, amount, meta, label, img) + local ped = PlayerPedId() + local coords = GetEntityCoords(ped) + local forward = GetEntityForwardVector(ped) + local x, y, z = table.unpack(coords + forward * 1.6) + while not HasModelLoaded(GetHashKey("p_uniqletterbundle01x")) do + Wait(500) + modelrequest(GetHashKey("p_uniqletterbundle01x")) + end + local obj = CreateObject("p_uniqletterbundle01x", x, y, z, true, true, true) + PlaceObjectOnGroundProperly(obj) + SetEntityAsMissionEntity(obj, true, true) + FreezeEntityPosition(obj, true) + local _coords = GetEntityCoords(obj) + TriggerServerEvent( + "redemrp_inventory:AddPickupServer", + name, + amount, + meta, + label, + img, + _coords.x, + _coords.y, + _coords.z, + ObjToNet(obj) + ) + PlaySoundFrontend("show_info", "Study_Sounds", true, 0) + SetModelAsNoLongerNeeded(GetHashKey("p_uniqletterbundle01x")) + end +) + +RegisterNetEvent( + "redemrp_inventory:removePickup", + function(netid) + local obj = NetToObj(netid) + SetEntityAsMissionEntity(obj, false, true) + NetworkRequestControlOfEntity(obj) + local timeout = 0 + while not NetworkHasControlOfEntity(obj) and timeout < 5000 do + timeout = timeout + 100 + Wait(100) + end + FreezeEntityPosition(obj, false) + DeleteEntity(obj) + end +) + +RegisterNetEvent( + "redemrp_inventory:PickupAnim", + function() + local dict = "amb_work@world_human_box_pickup@1@male_a@stand_exit_withprop" + RequestAnimDict(dict) + while not HasAnimDictLoaded(dict) do + Citizen.Wait(10) + end + TaskPlayAnim(PlayerPedId(), dict, "exit_front", 1.0, 8.0, -1, 1, 0, false, false, false) + Wait(1200) + PlaySoundFrontend("CHECKPOINT_PERFECT", "HUD_MINI_GAME_SOUNDSET", true, 1) + Wait(1000) + ClearPedTasks(PlayerPedId()) + end +) + +RegisterNetEvent( + "redemrp_inventory:UpdatePickups", + function(pick) + DroppedItems = pick + end +) + +local PickupPromptGroup = GetRandomIntInRange(0, 0xffffff) +print("PickupPromptGroup: " .. PickupPromptGroup) +local PickupPrompt +local PromptActive = false + +function SetupPickPrompt() + Citizen.CreateThread( + function() + local str = "Pick Up" + PickupPrompt = Citizen.InvokeNative(0x04F97DE45A519419) + PromptSetControlAction(PickupPrompt, 0xF84FA74F) + str = CreateVarString(10, "LITERAL_STRING", str) + PromptSetText(PickupPrompt, str) + PromptSetEnabled(PickupPrompt, true) + PromptSetVisible(PickupPrompt, true) + PromptSetHoldMode(PickupPrompt, true) + PromptSetGroup(PickupPrompt, PickupPromptGroup) + PromptRegisterEnd(PickupPrompt) + end + ) +end + +Citizen.CreateThread( + function() + local wait = 1 + SetupPickPrompt() + while true do + Citizen.Wait(wait) + + local can_wait = true + local playerPed = PlayerPedId() + local coords = GetEntityCoords(playerPed) + + if next(DroppedItems) == nil then + Citizen.Wait(500) + end + + if DroppedItems ~= nil then + for k, v in pairs(DroppedItems) do + local distance = Vdist(coords, v.coords.x, v.coords.y, v.coords.z) + if distance <= 15.0 then + can_wait = false + end + + if distance <= 5.0 then + DrawText3D(v.coords.x, v.coords.y, v.coords.z + 0.5, v.label .. " " .. "[" .. v.amount .. "]") + end + + if distance <= 1.2 then + if not PromptActive then + TaskLookAtEntity(playerPed, v.obj, 3000, 2048, 3) + local PromptGroupName = CreateVarString(10, "LITERAL_STRING", v.label) + PromptSetActiveGroupThisFrame(PickupPromptGroup, PromptGroupName) + if PromptHasHoldModeCompleted(PickupPrompt) then + PromptActive = true + TriggerServerEvent("redemrp_inventory:onPickup", k) + end + end + end + end + end + if can_wait == true then + wait = 2000 + else + wait = 1 + end + end + end +) + +RegisterNetEvent( + "redemrp_inventory:ReEnablePrompt", + function() + PromptActive = false + end +) + +RegisterNetEvent( + "redemrp_inventory:OpenStash", + function(id, weight) + OpenStash = id + CurrentMaxWeight = weight + --print(weight) + TriggerServerEvent("redemrp_inventory:GetStash", OpenStash, weight) + end +) + +local showingmsg = false + +RegisterNetEvent("redemrp_inventory:client:WeightNotif", function(txt, time) + ShowScreenMessage(txt, time) +end) + +ShowScreenMessage = function(message, time) + Citizen.CreateThread(function () + if not showingmsg then + showingmsg = true + local textTime = GetGameTimer() + while GetGameTimer() - textTime < time do + Citizen.Wait(0) + DrawTxt(message, 0.50, 0.87, 0.7, 0.7, true, 255, 255, 255, 255, true) + end + showingmsg = false + end + end) +end + +function DrawTxt(str, x, y, w, h, enableShadow, col1, col2, col3, a, centre) + local str = CreateVarString(10, "LITERAL_STRING", str) + SetTextScale(w, h) + SetTextColor(math.floor(col1), math.floor(col2), math.floor(col3), math.floor(a)) + SetTextCentre(centre) + if enableShadow then SetTextDropshadow(1, 0, 0, 0, 255) end + Citizen.InvokeNative(0xADA9255D, 9); + DisplayText(str, x, y) +end + + +--==================== D R O P ======================================= + +RegisterNUICallback( + "useitem", + function(data) + TriggerServerEvent("redemrp_inventory:use", data.data) + end +) + +RegisterNUICallback('craft', function(data) + TriggerServerEvent("redemrp_inventory:craft", data, CraftingId) +end) + +RegisterNUICallback( + "close", + function() + SetNuiFocus(false, false) + SetNuiFocusKeepInput(false) + IsCrafting = false + isInventoryOpen = false + isOtherOpen = false + end +) diff --git a/config.lua b/config.lua index 10902d6..e6de060 100644 --- a/config.lua +++ b/config.lua @@ -1,875 +1,522 @@ Config = {} -Config.MaxWeight = 24.0 - +Config.MaxWeight = 24.0 -- kg Config.Crafting = { + ["bandage"] = { + items = { + "empty","empty","empty", + "cotton,3","purealcohol,1","empty", + "empty","empty","empty" + }, + requireId = "cooking", + requireJob = { "doctor" }, + }, + ["mbandage"] = { + items = { + "empty","empty","empty", + "cotton,3","purealcohol,2","ginseng,1", + "empty","empty","empty" + }, + requireId = "cooking", + requireJob = { "doctor" }, + }, -["bread"] = { - -items = { - "empty","empty","empty", - "wheat","wheat, 2","wheat", - "empty","empty","empty" - }, -requireJob = "empty", -type = "cooking", -amount = 1, - - -}, - + -------- cooking + -- + -- + + + ["bread"] = { + items = { + "empty","flour","empty", + "empty","water","empty", + "empty","empty","empty" + }, + requireId = "cooking", + }, } Config.Items = { - - ["water"] = - { + ["water"] = { label = "Water", - description = "?????????", - weight = 0.3, + description = "Some refreshing water to keep you hydrated", + weight = 0.01, canBeDropped = true, canBeUsed = true, - requireLvl = 0, - limit = 32, + limit = 200, imgsrc = "items/water.png", - type = "item_standard", - + type = "item_standard" }, - - ["bread"] = - { - label = "Bread", - description = "?????????", - weight = 0.1, + ["bandage"] = { + label = "Bandage", + description = "A bandage to heal wounds and restore health", + weight = 0.2, canBeDropped = true, canBeUsed = true, - requireLvl = 0, - limit = 20, - imgsrc = "items/bread.png", - type = "item_standard", - - + limit = 100, + imgsrc = "items/bandage.png", + type = "item_standard" }, - - ["wheat"] = - { - label = "Wheat", - description = "?????????", - weight = 0.05, - canBeDropped = true, - canBeUsed = false, - requireLvl = 0, - limit = 64, - imgsrc = "items/wheat.png", - type = "item_standard", - - }, - - ["apple"] = - { - label = "Apple", - description = "?????????", - weight = 0.02, + ["mbandage"] = { + label = "Medicated Bandage", + description = "A medicated bandage to heal wounds and restore health faster", + weight = 0.2, canBeDropped = true, canBeUsed = true, - requireLvl = 0, - limit = 32, - imgsrc = "items/apple.png", - type = "item_standard", - - + limit = 100, + imgsrc = "items/mbandage.png", + type = "item_standard" }, - ["p_baitBread01x"] = - { - label = "Bread Bait", - description = "?????????", - weight = 0.01, + ["WEAPON_REVOLVER_CATTLEMAN"] = { + label = "Cattleman Revolver", + description = "Cattleman Revolver", + weight = 0.5, canBeDropped = true, - canBeUsed = true, - requireLvl = 0, - limit = 32, - imgsrc = "items/bread_bait.png", - type = "item_standard", - - + weaponHash = GetHashKey("WEAPON_REVOLVER_CATTLEMAN"), + imgsrc = "items/WEAPON_REVOLVER_CATTLEMAN.png", + type = "item_weapon" }, - - - - ["p_baitCheese01x"] = - { - label = "Cheese Bait", - description = "?????????", - weight = 0.01, + ["WEAPON_REVOLVER_DOUBLEACTION"] = { + label = "DoubleAction", + description = "DoubleAction", + weight = 0.5, canBeDropped = true, - canBeUsed = true, - requireLvl = 0, - limit = 48, - imgsrc = "items/cheese_bait.png", - type = "item_standard", - - + weaponHash = GetHashKey("WEAPON_REVOLVER_DOUBLEACTION"), + imgsrc = "items/WEAPON_REVOLVER_DOUBLEACTION.png", + type = "item_weapon" }, - - ["p_baitCorn01x"] = - { - label = "Corn Bait", - description = "?????????", - weight = 0.01, + ["WEAPON_REVOLVER_NAVY"] = { + label = "Navy Revolver", + description = "Navy Revolver", + weight = 0.5, canBeDropped = true, - canBeUsed = true, - requireLvl = 0, - limit = 48, - imgsrc = "items/corn_bait.png", - type = "item_standard", - - + weaponHash = GetHashKey("WEAPON_REVOLVER_NAVY"), + imgsrc = "items/weapon_revolver_navy.png", + type = "item_weapon", }, - ["p_baitCricket01x"] = - { - label = "Cricket Bait", - description = "?????????", - weight = 0.01, + ["WEAPON_PISTOL_VOLCANIC"] = { + label = "Volcanic", + description = "Volcanic", + weight = 0.5, canBeDropped = true, - canBeUsed = true, - requireLvl = 0, - limit = 32, - imgsrc = "items/cricket_bait.png", - type = "item_standard", - - + weaponHash = GetHashKey("WEAPON_PISTOL_VOLCANIC"), + imgsrc = "items/WEAPON_PISTOL_VOLCANIC.png", + type = "item_weapon" }, - - - - ["p_finishedragonfly01x"] = - { - label = "River Bait", - description = "?????????", - weight = 0.05, + ["WEAPON_PISTOL_SEMIAUTO"] = { + label = "SemiAuto", + description = "SemiAuto", + weight = 0.5, canBeDropped = true, - canBeUsed = true, - requireLvl = 0, - limit = 5, - imgsrc = "items/river_bait.png", - type = "item_standard", - - + weaponHash = GetHashKey("WEAPON_PISTOL_SEMIAUTO"), + imgsrc = "items/WEAPON_PISTOL_SEMIAUTO.png", + type = "item_weapon" }, - - - ["p_FinisdFishlure01x"] = - { - label = "Lake Bait", - description = "?????????", - weight = 0.05, + ["WEAPON_PISTOL_MAUSER"] ={ + label = "Mauser", + description = "Mauser", + weight = 0.5, canBeDropped = true, - canBeUsed = true, - requireLvl = 0, - limit = 5, - imgsrc = "items/lake_bait.png", - type = "item_standard", - - + weaponHash = GetHashKey("WEAPON_PISTOL_MAUSER"), + imgsrc = "items/WEAPON_PISTOL_MAUSER.png", + type = "item_weapon" }, - - ["p_finishdcrawd01x"] = - { - label = "Swamp Bait", - description = "?????????", - weight = 0.05, + ["WEAPON_PISTOL_M1899"] ={ + label = "M1899", + description = "M1899", + weight = 0.5, canBeDropped = true, - canBeUsed = true, - requireLvl = 0, - limit = 5, - imgsrc = "items/swamp_bait.png", - type = "item_standard", - - + weaponHash = GetHashKey("WEAPON_PISTOL_M1899"), + imgsrc = "items/m1899.png", + type = "item_weapon" }, - - ["smallfish"] = - { - label = "Small Fish", - description = "?????????", - weight = 0.3, - canBeDropped = true, - canBeUsed = false, - requireLvl = 0, - limit = 20, - imgsrc = "items/smallfish.png", - type = "item_standard", - - + ["WEAPON_REVOLVER_LEMAT"] ={ + label = "Lemat", + description = "Lemat", + weight = 0.5, + canBeDropped = true, + weaponHash = GetHashKey("WEAPON_REVOLVER_LEMAT"), + imgsrc = "items/WEAPON_REVOLVER_LEMAT.png", + type = "item_weapon" }, - - - ["mediumfish"] = - { - label = "Medium Fish", - description = "?????????", - weight = 2.3, - canBeDropped = true, - canBeUsed = false, - requireLvl = 0, - limit = 15, - imgsrc = "items/mediumfish.png", - type = "item_standard", - - + ["WEAPON_REVOLVER_SCHOFIELD"] = { + label = "Schofield", + description = "Schofield", + weight = 0.7, + canBeDropped = true, + weaponHash = GetHashKey("WEAPON_REVOLVER_SCHOFIELD"), + imgsrc = "items/WEAPON_REVOLVER_SCHOFIELD.png", + type = "item_weapon" }, - - ["largefish"] = - { - label = "Large Fish", - description = "?????????", - weight = 4.5, - canBeDropped = true, - canBeUsed = false, - requireLvl = 0, - limit = 10, - imgsrc = "items/largefish.png", - type = "item_standard", - + --REAPEATERS + ["WEAPON_REPEATER_CARBINE"] = { + label = "Carbine", + description = "Carbine", + weight = 0.9, + canBeDropped = true, + weaponHash = GetHashKey("WEAPON_REPEATER_CARBINE"), + imgsrc = "items/WEAPON_REPEATER_CARBINE.png", + type = "item_weapon" }, - - ["blueberry"] = - { - label = "Blueberry", - description = "?????????", - weight = 0.1, + ["WEAPON_REPEATER_EVANS"] = { + label = "Evans", + description = "Evans", + weight = 0.9, canBeDropped = true, - canBeUsed = true, - requireLvl = 0, - limit = 20, - imgsrc = "items/blueberry.png", - type = "item_standard", - - + weaponHash = GetHashKey("WEAPON_REPEATER_EVANS"), + imgsrc = "items/WEAPON_REPEATER_EVANS.png", + type = "item_weapon" }, - ["stick"] = - { - label = "Stick", - description = "?????????", - weight = 0.02, - canBeDropped = true, - canBeUsed = false, - requireLvl = 0, - limit = 64, - imgsrc = "items/stick.png", - type = "item_standard", - - + ["WEAPON_REPEATER_HENRY"] = { + label = "Henry", + description = "Henry", + weight = 0.9, + canBeDropped = true, + weaponHash = GetHashKey("WEAPON_REPEATER_HENRY"), + imgsrc = "items/WEAPON_REPEATER_HENRY.png", + type = "item_weapon" }, - - ["WEAPON_MELEE_LANTERN_ELECTRIC"] = - { - label = "Electric Lamp", - description = "A source of light, fire & fun", - weight = 0.5, - canBeDropped = true, - requireLvl = 12, - weaponHash = GetHashKey("weapon_melee_davy_lantern"), - imgsrc = "items/weapon_melee_electric_lantern.png", - type = "item_weapon", - }, - - - -["WEAPON_MELEE_TORCH"] = - { - label = "Torch", - description = "Great for travelers scared of the dark", - weight = 0.4, - canBeDropped = true, - requireLvl = 2, - weaponHash = GetHashKey("WEAPON_MELEE_TORCH"), - imgsrc = "items/WEAPON_MELEE_TORCH.png", - type = "item_weapon", - }, - - - -["WEAPON_FISHINGROD"] = + ["WEAPON_REPEATER_WINCHESTER"] = { + label = "Winchester", + description = "Winchester", + weight = 0.9, + canBeDropped = true, + weaponHash = GetHashKey("WEAPON_REPEATER_WINCHESTER"), + imgsrc = "items/WEAPON_REPEATER_LANCASTER.png", + type = "item_weapon" + }, + --RIFLES + ["WEAPON_RIFLE_VARMINT"] = { + label = "Varmint", + description = "Varmint", + weight = 0.9, + canBeDropped = true, + weaponHash = GetHashKey("WEAPON_RIFLE_VARMINT"), + imgsrc = "items/WEAPON_RIFLE_VARMINT.png", + type = "item_weapon" + }, + ["WEAPON_RIFLE_BOLTACTION"] = { + label = "Bolt action", + description = "Bolt action", + weight = 0.9, + canBeDropped = true, + weaponHash = GetHashKey("WEAPON_RIFLE_BOLTACTION"), + imgsrc = "items/WEAPON_RIFLE_BOLTACTION.png", + type = "item_weapon" + }, + ["WEAPON_SNIPERRIFLE_CARCANO"] = { + label = "Carcano", + description = "Carcano", + weight = 0.9, + canBeDropped = true, + weaponHash = GetHashKey("WEAPON_SNIPERRIFLE_CARCANO"), + imgsrc = "items/WEAPON_SNIPERRIFLE_CARCANO.png", + type = "item_weapon" + }, + ["WEAPON_SNIPERRIFLE_ROLLINGBLOCK"] = { + label = "Rolling block", + description = "Rolling block", + weight = 0.9, + canBeDropped = true, + weaponHash = GetHashKey("WEAPON_SNIPERRIFLE_ROLLINGBLOCK"), + imgsrc = "items/WEAPON_SNIPERRIFLE_ROLLINGBLOCK.png", + type = "item_weapon" + }, + ["WEAPON_RIFLE_SPRINGFIELD"] = { + label = "Springfield", + description = "Springfield", + weight = 0.9, + canBeDropped = true, + weaponHash = GetHashKey("WEAPON_RIFLE_SPRINGFIELD"), + imgsrc = "items/WEAPON_RIFLE_SPRINGFIELD.png", + type = "item_weapon" + }, + --SHOTGUNS + ["WEAPON_SHOTGUN_PUMP"] = { + label = "Pump", + description = "Pump", + weight = 0.9, + canBeDropped = true, + weaponHash = GetHashKey("WEAPON_SHOTGUN_PUMP"), + imgsrc = "items/WEAPON_SHOTGUN_PUMP.png", + type = "item_weapon" + }, + ["WEAPON_SHOTGUN_REPEATING"] = { + label = "Repeating shotgun", + description = "Repeating shotgun", + weight = 0.9, + canBeDropped = true, + weaponHash = GetHashKey("WEAPON_SHOTGUN_REPEATING"), + imgsrc = "items/WEAPON_SHOTGUN_REPEATING.png", + type = "item_weapon" + }, + ["WEAPON_SHOTGUN_DOUBLEBARREL"] = { + label = "Doublebarrel", + description = "Doublebarrel", + weight = 0.9, + canBeDropped = true, + weaponHash = GetHashKey("WEAPON_SHOTGUN_DOUBLEBARREL"), + imgsrc = "items/WEAPON_SHOTGUN_DOUBLEBARREL.png", + type = "item_weapon" + }, + ["WEAPON_SHOTGUN_SAWEDOFF"] = { + label = "Sawed off", + description = "Sawed off", + weight = 0.9, + canBeDropped = true, + weaponHash = GetHashKey("WEAPON_SHOTGUN_SAWEDOFF"), + imgsrc = "items/WEAPON_SHOTGUN_SAWEDOFF.png", + type = "item_weapon" + }, + ["WEAPON_SHOTGUN_SEMIAUTO"] = { + label = "Semiauto Shotgun", + description = "Semiauto Shotgun", + weight = 0.9, + canBeDropped = true, + weaponHash = GetHashKey("WEAPON_SHOTGUN_SEMIAUTO"), + imgsrc = "items/WEAPON_SHOTGUN_SEMIAUTO.png", + type = "item_weapon" + }, + --MELEE WEAPONS + ["WEAPON_MELEE_HATCHET_HUNTER"] = { - label = "Rod", - description = "A mans second best friend", - weight = 0.9, + label = "Hunter Hatchet", + description = "Hunting Wild Animals", + weight = 1.0, canBeDropped = true, requireLvl = 1, - weaponHash = GetHashKey("WEAPON_FISHINGROD"), - imgsrc = "items/WEAPON_FISHINGROD.png", + weaponHash = GetHashKey("WEAPON_MELEE_HATCHET_HUNTER"), + imgsrc = "items/WEAPON_MELEE_HATCHET_HUNTER.png", type = "item_weapon" }, - - -["WEAPON_MELEE_HATCHET"] = + ["WEAPON_MELEE_HATCHET_DOUBLE_BIT"] = { - label = "Hatchet", - description = "Uses include: Trees, Building, Fireplaces & Humans", + label = "Double Bit Hatchet", + description = "Hunting Wild Animals", weight = 1.0, canBeDropped = true, - requireLvl = 15, - weaponHash = GetHashKey("WEAPON_MELEE_HATCHET"), - imgsrc = "items/WEAPON_MELEE_HATCHET.png", + requireLvl = 1, + weaponHash = GetHashKey("WEAPON_MELEE_HATCHET_DOUBLE_BIT"), + imgsrc = "items/WEAPON_MELEE_HATCHET_DOUBLE_BIT.png", type = "item_weapon" }, - - -["WEAPON_MELEE_CLEAVER"] = + ["WEAPON_MELEE_CLEAVER"] = { label = "Cleaver", description = "Keep out of reach of kids", weight = 1.0, canBeDropped = true, - requireLvl = 15, + requireLvl = 1, weaponHash = GetHashKey("WEAPON_MELEE_CLEAVER"), imgsrc = "items/WEAPON_MELEE_CLEAVER.png", type = "item_weapon" }, - - -["WEAPON_MELEE_KNIFE"] = - { - label = "Knife", - description = "Thats not a knife, this is a knife.", - weight = 0.5, - canBeDropped = true, - requireLvl = 2, - weaponHash = GetHashKey("WEAPON_MELEE_KNIFE"), - imgsrc = "items/WEAPON_MELEE_KNIFE.png", - type = "item_weapon" - }, - - - -["WEAPON_THROWN_THROWING_KNIVES"] = + ["WEAPON_MELEE_KNIFE_JAWBONE"] = { - label = "Throwing Knives", - description = "Throw me, ill hurt.", - weight = 0.2, - canBeDropped = true, - requireLvl = 2, - weaponHash = GetHashKey("WEAPON_THROWN_THROWING_KNIVES"), - imgsrc = "items/WEAPON_THROWN_THROWING_KNIVES.png", - type = "item_weapon" - }, - - - -["WEAPON_MELEE_KNIFE_MINER"] = - { - label = "Mining Knife", - description = "An old mining knife, quite large and heavy", - weight = 0.7, - canBeDropped = true, - requireLvl = 5, - weaponHash = GetHashKey("WEAPON_MELEE_KNIFE_MINER"), - imgsrc = "items/WEAPON_MELEE_KNIFE_MINER.png", - type = "item_weapon" - }, - - -["WEAPON_MELEE_KNIFE_VAMPIRE"] = - { - label = "Decorated Dagger", + label = "Jawbone Knife", description = "A symbol of designer tastes", weight = 1.0, canBeDropped = true, - requireLvl = 20, - weaponHash = GetHashKey("WEAPON_MELEE_KNIFE_VAMPIRE"), - imgsrc = "items/WEAPON_MELEE_KNIFE_VAMPIRE.png", - type = "item_weapon" - }, - - - -["WEAPON_LASSO"] = - { - label = "Lasso", - description = "Capture, drag & bind.", - weight = 0.6, - canBeDropped = true, - requireLvl = 4, - weaponHash = GetHashKey("WEAPON_LASSO"), - imgsrc = "items/WEAPON_LASSO.png", - type = "item_weapon" - }, - - -["WEAPON_THROWN_TOMAHAWK"] = - { - label = "Tomahawk", - description = "The weapon of the Native tribes.", - weight = 0.4, - canBeDropped = true, - requireLvl = 18, - weaponHash = GetHashKey("WEAPON_THROWN_TOMAHAWK"), - imgsrc = "items/WEAPON_THROWN_TOMAHAWK.png", - type = "item_weapon" - }, - - - -["WEAPON_PISTOL_M1899"] = - { - label = "Pistol M1899", - description = "A standard cost effective killing machine", - weight = 0.8, - canBeDropped = true, - requireLvl = 30, - weaponHash = GetHashKey("WEAPON_PISTOL_M1899"), - imgsrc = "items/WEAPON_PISTOL_M1899.png", - type = "item_weapon" - }, - - -["WEAPON_PISTOL_MAUSER"] = - { - label = "Pistol Mauser", - description = "A must for any advanced warfare", - weight = 0.6, - canBeDropped = true, - requireLvl = 21, - weaponHash = GetHashKey("WEAPON_PISTOL_MAUSER"), - imgsrc = "items/WEAPON_PISTOL_MAUSER.png", - type = "item_weapon" - }, - - -["WEAPON_PISTOL_MAUSER_DRUNK"] = - { - label = "Decorated Mauser", - description = "Gold, silver & metal... what a treat", - weight = 0.8, - canBeDropped = true, - requireLvl = 20, - weaponHash = GetHashKey("WEAPON_PISTOL_MAUSER_DRUNK"), - imgsrc = "items/WEAPON_PISTOL_MAUSER.png", - type = "item_weapon" - }, - - - -["WEAPON_PISTOL_SEMIAUTO"] = - { - label = "Pistol Semi-Automatic", - description = "Goes bang more then once", - weight = 0.6, - canBeDropped = true, - requireLvl = 16, - weaponHash = GetHashKey("WEAPON_PISTOL_SEMIAUTO"), - imgsrc = "items/WEAPON_PISTOL_SEMIAUTO.png", - type = "item_weapon" - }, - - -["WEAPON_PISTOL_VOLCANIC"] = - { - label = "Pistol Volcanic", - description = "WARNING: Does not shoot lava", - weight = 0.7, - canBeDropped = true, - requireLvl = 14, - weaponHash = GetHashKey("WEAPON_PISTOL_VOLCANIC"), - imgsrc = "items/WEAPON_PISTOL_VOLCANIC.png", - type = "item_weapon" - }, - - -["WEAPON_REPEATER_CARBINE"] = - { - label = "Repeated Carbine", - description = "Medium range, high damage.", - weight = 2.0, - canBeDropped = true, - requireLvl = 6, - weaponHash = GetHashKey("WEAPON_REPEATER_CARBINE"), - imgsrc = "items/WEAPON_REPEATER_CARBINE.png", - type = "item_weapon" - }, - - -["WEAPON_REPEATER_EVANS"] = - { - label = "Repeater Evans", - description = "A feat in weapon mechanics", - weight = 2.5, - canBeDropped = true, - requireLvl = 20, - weaponHash = GetHashKey("WEAPON_REPEATER_EVANS"), - imgsrc = "items/WEAPON_REPEATER_CARBINE.png", - type = "item_weapon" - }, - - -["WEAPON_REPEATER_HENRY"] = - { - label = "Litchfield Bolt-Action Rifle", - description = "Great range & accuracy", - weight = 2.3, - canBeDropped = true, - requireLvl = 22, - weaponHash = GetHashKey("WEAPON_REPEATER_HENRY"), - imgsrc = "items/WEAPON_REPEATER_HENRY.png", - type = "item_weapon" - }, - - - -["WEAPON_RIFLE_VARMINT"] = - { - label = "Light Rifle", - description = "Ride & Shoot!", - weight = 1.5, - canBeDropped = true, - requireLvl = 14, - weaponHash = GetHashKey("WEAPON_RIFLE_VARMINT"), - imgsrc = "items/WEAPON_RIFLE_VARMINT.png", - type = "item_weapon" - }, - - - -["WEAPON_REPEATER_WINCHESTER"] = - { - label = "Lancaster Bolt-Action Rifle", - description = "The famous lancaster", - weight = 1.9, - canBeDropped = true, - requireLvl = 26, - weaponHash = GetHashKey("WEAPON_REPEATER_WINCHESTER"), - imgsrc = "items/weapon_repeater_lancaster.png", - type = "item_weapon" - }, - - -["WEAPON_REVOLVER_CATTLEMAN"] = - { - label = "Revolver Cattleman", - description = "Its high noon!", - weight = 0.4, - canBeDropped = true, - requireLvl = 2, - weaponHash = GetHashKey("WEAPON_REVOLVER_CATTLEMAN"), - imgsrc = "items/WEAPON_REVOLVER_CATTLEMAN.png", - type = "item_weapon" - }, - - - -["WEAPON_REVOLVER_CATTLEMAN_JOHN"] = - { - label = "Revolver Cattleman", - description = "Its high noon!", - weight = 0.5, - canBeDropped = true, - requireLvl = 2, - weaponHash = GetHashKey("WEAPON_REVOLVER_CATTLEMAN_JOHN"), - imgsrc = "items/WEAPON_REVOLVER_CATTLEMAN.png", - type = "item_weapon" - }, - - -["WEAPON_REVOLVER_CATTLEMAN_MEXICAN"] = - { - label = "Revolver Cattleman", - description = "Its high noon!", - weight = 0.5, - canBeDropped = true, - requireLvl = 2, - weaponHash = GetHashKey("WEAPON_REVOLVER_CATTLEMAN_MEXICAN"), - imgsrc = "items/WEAPON_REVOLVER_CATTLEMAN.png", - type = "item_weapon" - }, - - -["WEAPON_REVOLVER_DOUBLEACTION"] = - { - label = "Double Action Revolver", - description = "Double the action, same weight.", - weight = 0.8, - canBeDropped = true, - requireLvl = 25, - weaponHash = GetHashKey("WEAPON_REVOLVER_DOUBLEACTION"), - imgsrc = "items/WEAPON_REVOLVER_DOUBLEACTION.png", - type = "item_weapon" - }, - - - -["WEAPON_REVOLVER_DOUBLEACTION_EXOTIC"] = - { - label = "Exotic Double Action Revolver", - description = "Just a bit more exotic*", - weight = 0.8, - canBeDropped = true, - requireLvl = 12, - weaponHash = GetHashKey("WEAPON_REVOLVER_DOUBLEACTION_EXOTIC"), - imgsrc = "items/WEAPON_REVOLVER_DOUBLEACTION.png", - type = "item_weapon" - }, - - - -["WEAPON_REVOLVER_DOUBLEACTION_GAMBLER"] = - { - label = "Self-Locking Revolver", - description = "Dont forget to lock...", - weight = 0.8, - canBeDropped = true, - requireLvl = 12, - weaponHash = GetHashKey("WEAPON_REVOLVER_DOUBLEACTION_GAMBLER"), - imgsrc = "items/WEAPON_REVOLVER_DOUBLEACTION.png", - type = "item_weapon" - }, - - - -["WEAPON_REVOLVER_LEMAT"] = - { - label = "LeMat Revolver", - description = "I think its french, it does go bang!", - weight = 0.9, - canBeDropped = true, - requireLvl = 12, - weaponHash = GetHashKey("WEAPON_REVOLVER_LEMAT"), - imgsrc = "items/WEAPON_REVOLVER_LEMAT.png", - type = "item_weapon" - }, - - - -["WEAPON_REVOLVER_SCHOFIELD"] = - { - label = "Revolver Schofield", - description = "Great for prison breaks", - weight = 0.7, - canBeDropped = true, - requireLvl = 20, - weaponHash = GetHashKey("WEAPON_REVOLVER_SCHOFIELD"), - imgsrc = "items/WEAPON_REVOLVER_SCHOFIELD.png", - type = "item_weapon" - }, - - - -["WEAPON_REVOLVER_NAVY"] = - { - label = "Navy Revolver", - description = "Just a typical revolver that is Navy", - weight = 0.8, - canBeDropped = true, - requireLvl = 30, - weaponHash = GetHashKey("WEAPON_REVOLVER_NAVY"), - imgsrc = "items/WEAPON_REVOLVER_NAVY.png", - type = "item_weapon" - }, - - - -["WEAPON_REVOLVER_SCHOFIELD_CALLOWAY"] = - { - label = "Engraved Schofield", - description = "Unreadable engravings", - weight = 0.6, - canBeDropped = true, - requireLvl = 15, - weaponHash = GetHashKey("WEAPON_REVOLVER_SCHOFIELD_CALLOWAY"), - imgsrc = "items/WEAPON_REVOLVER_SCHOFIELD.png", - type = "item_weapon" - }, - - - -["WEAPON_RIFLE_BOLTACTION"] = - { - label = "Bolt Action Rifle", - description = "Jams a lot, but works well when it doesnt.", - weight = 2.3, - canBeDropped = true, - requireLvl = 30, - weaponHash = GetHashKey("WEAPON_RIFLE_BOLTACTION"), - imgsrc = "items/WEAPON_RIFLE_BOLTACTION.png", - type = "item_weapon" - }, - - -["WEAPON_SNIPERRIFLE_CARCANO"] = - { - label = "Carcano Rifle", - description = "Range is the key!", - weight = 4.0, - canBeDropped = true, - requireLvl = 60, - weaponHash = GetHashKey("WEAPON_SNIPERRIFLE_CARCANO"), - imgsrc = "items/WEAPON_SNIPERRIFLE_CARCANO.png", - type = "item_weapon" - }, - - -["WEAPON_SNIPERRIFLE_ROLLINGBLOCK"] = - { - label = "Rotary Rifle", - description = "Line em up 500 metres away!", - weight = 4.0, - canBeDropped = true, - requireLvl = 80, - weaponHash = GetHashKey("WEAPON_SNIPERRIFLE_ROLLINGBLOCK"), - imgsrc = "items/WEAPON_SNIPERRIFLE_ROLLINGBLOCK.png", - type = "item_weapon" - }, - - -["WEAPON_RIFLE_SPRINGFIELD"] = - { - label = "Springfield Rifle", - description = "Military standard", - weight = 2.0, - canBeDropped = true, - requireLvl = 32, - weaponHash = GetHashKey("WEAPON_RIFLE_SPRINGFIELD"), - imgsrc = "items/WEAPON_RIFLE_SPRINGFIELD.png", - type = "item_weapon" - }, - - - -["WEAPON_SHOTGUN_DOUBLEBARREL"] = - { - label = "Double Action Shotgun", - description = "Poorly designed, does the trick though.", - weight = 3.0, - canBeDropped = true, - requireLvl = 13, - weaponHash = GetHashKey("WEAPON_SHOTGUN_DOUBLEBARREL"), - imgsrc = "items/WEAPON_SHOTGUN_DOUBLEBARREL.png", - type = "item_weapon" - }, - - -["WEAPON_SHOTGUN_DOUBLEBARREL_EXOTIC"] = - { - label = "Decorated Gun", - description = "Close range death machine", - weight = 3.0, - canBeDropped = true, - requireLvl = 18, - weaponHash = GetHashKey("WEAPON_SHOTGUN_DOUBLEBARREL_EXOTIC"), - imgsrc = "items/WEAPON_SHOTGUN_DOUBLEBARREL.png", - type = "item_weapon" - }, - - -["WEAPON_SHOTGUN_PUMP"] = - { - label = "Pump Shotgun", - description = "WARNING: May mutilate", - weight = 2.5, - canBeDropped = true, - requireLvl = 40, - weaponHash = GetHashKey("WEAPON_SHOTGUN_PUMP"), - imgsrc = "items/WEAPON_SHOTGUN_PUMP.png", - type = "item_weapon" - }, - - -["WEAPON_SHOTGUN_REPEATING"] = - { - label = "Repeating Shotgun", - description = "Dont shoot too fast, you might jam it!", - weight = 2.0, - canBeDropped = true, - requireLvl = 80, - weaponHash = GetHashKey("WEAPON_SHOTGUN_REPEATING"), - imgsrc = "items/WEAPON_SHOTGUN_REPEATING.png", - type = "item_weapon" - }, - - - -["WEAPON_SHOTGUN_SAWEDOFF"] = - { - label = "Sawn-Off Shotgun", - description = "Compact, high damage & close range", - weight = 1.2, - canBeDropped = true, - requireLvl = 20, - weaponHash = GetHashKey("WEAPON_SHOTGUN_SAWEDOFF"), - imgsrc = "items/WEAPON_SHOTGUN_SAWEDOFF.png", - type = "item_weapon" - }, - - - -["WEAPON_SHOTGUN_SEMIAUTO"] = - { - label = "Semi-Automatic Shotgun", - description = "This may just save your life one day", - weight = 2.2, - canBeDropped = true, - requireLvl = 51, - weaponHash = GetHashKey("WEAPON_SHOTGUN_SEMIAUTO"), - imgsrc = "items/WEAPON_SHOTGUN_SEMIAUTO.png", + requireLvl = 1, + weaponHash = GetHashKey("WEAPON_MELEE_KNIFE_JAWBONE"), + imgsrc = "items/WEAPON_MELEE_KNIFE_JAWBONE.png", type = "item_weapon" }, - - - -["WEAPON_BOW"] = + ["WEAPON_MELEE_KNIFE_TRADER"] = { - label = "Simple Bow", - description = "A hunting bow", - weight = 0.7, + label = "Trader Knife", + description = "A symbol of designer tastes", + weight = 1.0, canBeDropped = true, requireLvl = 1, - weaponHash = GetHashKey("WEAPON_BOW"), - imgsrc = "items/WEAPON_BOW.png", + weaponHash = GetHashKey("WEAPON_MELEE_KNIFE_TRADER"), + imgsrc = "items/WEAPON_MELEE_KNIFE_TRADER.png", type = "item_weapon" }, - - -["WEAPON_THROWN_DYNAMITE"] = - { - label = "Dynamite", - description = "This baby will blow up in 3 seconds...", - weight = 0.3, - canBeDropped = true, - canBeUsed = false, - requireLvl = 35, - limit = 8, - imgsrc = "items/WEAPON_THROWN_DYNAMITE.png", - type = "item_standard" - }, - - - -["WEAPON_THROWN_MOLOTOV"] = + ["WEAPON_MELEE_KNIFE_HORROR"] = { - label = "Molotov", - description = "A poor mans grenade", - weight = 0.5, + label = "Horror Knife", + description = "A symbol of designer tastes", + weight = 1.0, canBeDropped = true, - requireLvl = 30, - weaponHash = GetHashKey("WEAPON_THROWN_MOLOTOV"), - imgsrc = "items/WEAPON_THROWN_MOLOTOV.png", + requireLvl = 1, + weaponHash = GetHashKey("WEAPON_MELEE_KNIFE_HORROR"), + imgsrc = "items/WEAPON_MELEE_KNIFE_HORROR.png", type = "item_weapon" }, - -["WEAPON_KIT_BINOCULARS"] = + ["WEAPON_MELEE_KNIFE_RUSTIC"] = { - label = "Binoculars", - description = "Left lens quite scratched...", - weight = 0.5, + label = "Rustic Knife", + description = "A symbol of designer tastes", + weight = 1.0, canBeDropped = true, - requireLvl = 30, - weaponHash = GetHashKey("WEAPON_KIT_BINOCULARS"), - imgsrc = "items/WEAPON_KIT_BINOCULARS.png", + requireLvl = 1, + weaponHash = GetHashKey("WEAPON_MELEE_KNIFE_RUSTIC"), + imgsrc = "items/WEAPON_MELEE_KNIFE_RUSTIC.png", type = "item_weapon" }, - - - + ["WEAPON_MELEE_MACHETE"] = + { + label = "Hunting Machete", + description = "A hunting machete", + weight = 1, + canBeDropped = true, + requireLvl = 1, + weaponHash = GetHashKey("WEAPON_MELEE_MACHETE"), + imgsrc = "items/WEAPON_MELEE_MACHETE.png", + type = "item_weapon" + }, + ["WEAPON_MELEE_MACHETE_HORROR"] = + { + label = "Horror Machete", + description = "A horror machete", + weight = 1, + canBeDropped = true, + requireLvl = 1, + weaponHash = GetHashKey("WEAPON_MELEE_MACHETE_HORROR"), + imgsrc = "items/WEAPON_MELEE_MACHETE_HORROR.png", + type = "item_weapon" + }, + ["WEAPON_MELEE_MACHETE_COLLECTOR"] = + { + label = "Collector Machete", + description = "A collector machete", + weight = 1, + canBeDropped = true, + requireLvl = 1, + weaponHash = GetHashKey("WEAPON_MELEE_MACHETE_COLLECTOR"), + imgsrc = "items/WEAPON_MELEE_MACHETE_COLLECTOR.png", + type = "item_weapon" + }, + ["WEAPON_FISHINGROD"] = { + label = "Fishing Rod", + description = "Fishing Rod", + weight = 0.5, + canBeDropped = true, + weaponHash = GetHashKey("WEAPON_FISHINGROD"), + imgsrc = "items/weapon_fishingrod.png", + type = "item_weapon" + }, + ["WEAPON_MELEE_KNIFE"] = { + label = "Knife", + description = "Knife", + weight = 0.5, + canBeDropped = true, + weaponHash = GetHashKey("WEAPON_MELEE_KNIFE"), + imgsrc = "items/WEAPON_MELEE_KNIFE.png", + type = "item_weapon" + }, + ["WEAPON_MELEE_LANTERN"] = { + label = "Lantern", + description = "Lantern", + weight = 0.5, + canBeDropped = true, + weaponHash = GetHashKey("WEAPON_MELEE_LANTERN"), + imgsrc = "items/generic_horse_equip_lantern.png", + type = "item_weapon" + }, + ["WEAPON_MELEE_TORCH"] = { + label = "Torch", + description = "Torch", + weight = 0.5, + canBeDropped = true, + weaponHash = GetHashKey("WEAPON_MELEE_TORCH"), + imgsrc = "items/WEAPON_MELEE_TORCH.png", + type = "item_weapon" + }, + ["WEAPON_LANTERN_ELECTRIC"] = { + label = "Electric Lantern", + description = "Electric Lantern", + weight = 0.5, + canBeDropped = true, + weaponHash = GetHashKey("WEAPON_MELEE_LANTERN_ELECTRIC"), + imgsrc = "items/weapon_melee_electric_lantern.png", + type = "item_weapon" + }, + ["WEAPON_BOW"] = { + label = "Bow", + description = "Bow", + weight = 0.25, + canBeDropped = true, + weaponHash = GetHashKey("WEAPON_BOW"), + imgsrc = "items/WEAPON_BOW.png", + type = "item_weapon" + }, + ["WEAPON_BOW_IMPROVED"] = { + label = "Improved Bow", + description = "Improved Bow", + weight = 0.25, + canBeDropped = true, + weaponHash = GetHashKey("WEAPON_BOW_IMPROVED"), + imgsrc = "items/T_Bow_01ca.png", + type = "item_weapon" + }, + ["WEAPON_LASSO"] = { + label = "Lasso", + description = "Lasso", + weight = 0.25, + canBeDropped = true, + weaponHash = GetHashKey("WEAPON_LASSO_REINFORCED"), + imgsrc = "items/WEAPON_LASSO.png", + type = "item_weapon" + }, + ["WEAPON_MELEE_HATCHET"] = { + label = "Hatchet", + description = "Hatchet", + weight = 0.5, + canBeDropped = true, + weaponHash = GetHashKey("WEAPON_MELEE_HATCHET"), + imgsrc = "items/WEAPON_MELEE_HATCHET.png", + type = "item_weapon" + }, + ["WEAPON_THROWN_THROWING_KNIVES"] = { + label = "Throwing knives", + description = "Throwing knives", + weight = 0.5, + canBeDropped = true, + weaponHash = GetHashKey("WEAPON_THROWN_THROWING_KNIVES"), + imgsrc = "items/WEAPON_THROWN_THROWING_KNIVES.png", + type = "item_weapon" + }, + ["WEAPON_THROWN_TOMAHAWK"] = { + label = "Tomahawk", + description = "Tomahawk", + weight = 0.5, + canBeDropped = true, + weaponHash = GetHashKey("WEAPON_THROWN_TOMAHAWK"), + imgsrc = "items/WEAPON_THROWN_TOMAHAWK.png", + type = "item_weapon" + }, + ["WEAPON_THROWN_DYNAMITE"] = { + label = "Dynamite stick", + description = "Dynamite stick", + weight = 0.5, + canBeDropped = true, + weaponHash = GetHashKey("WEAPON_THROWN_DYNAMITE"), + imgsrc = "items/WEAPON_THROWN_DYNAMITE.png", + type = "item_weapon" + }, + ["WEAPON_THROWN_MOLOTOV"] = { + label = "Molotov", + description = "Molotov", + weight = 0.25, + canBeDropped = true, + weaponHash = GetHashKey("WEAPON_THROWN_MOLOTOV"), + imgsrc = "items/WEAPON_THROWN_MOLOTOV.png", + type = "item_weapon" + }, + ["WEAPON_KIT_BINOCULARS"] = { + label = "Binoculars", + description = "Binoculars", + weight = 0.25, + canBeDropped = true, + weaponHash = GetHashKey("WEAPON_KIT_BINOCULARS"), + imgsrc = "items/WEAPON_KIT_BINOCULARS.png", + type = "item_weapon" + }, } +exports("GetItemsList", function() + return Config.Items +end) \ No newline at end of file diff --git a/fxmanifest.lua b/fxmanifest.lua index b22847c..4dacdc8 100644 --- a/fxmanifest.lua +++ b/fxmanifest.lua @@ -2,24 +2,32 @@ fx_version "adamant" games {"rdr3"} rdr3_warning 'I acknowledge that this is a prerelease build of RedM, and I am aware my resources *will* become incompatible once RedM ships.' client_scripts { - 'client/cl_main.lua', + 'client/dataview.lua', + 'config.lua', + 'client/main.lua', } server_scripts { 'config.lua', - '@mysql-async/lib/MySQL.lua', - 'server/Create_items.lua', - 'server/sv_main.lua', + '@oxmysql/lib/MySQL.lua', + 'server/items.lua', + 'server/main.lua', } + files{ -'html/inventory.html', -'html/crock.ttf', -'html/*.png', -'html/js/jquery-1.4.1.min.js', -'html/js/jquery.jcarousel.pack.js', -'html/js/listener.js', -'html/js/inventory.js', -'html/items/*.png', + 'html/css/*', + 'html/items/*', + 'html/js/*', + 'html/*', +} + +client_exports { + 'GetItemsList', +} + +server_exports { + 'GetStashWeight', + 'GetItemsList' } ui_page "html/inventory.html" \ No newline at end of file diff --git a/html/css/contextual.css b/html/css/contextual.css new file mode 100644 index 0000000..c3a62a2 --- /dev/null +++ b/html/css/contextual.css @@ -0,0 +1,144 @@ +/* Main context menu outer */ +.contextualMenu{ + font-size: 13px; + position: absolute; + padding: 8px 0; + background: var(--contextualMenuBg); + box-shadow: var(--contextualMenuShadow); + border-radius: var(--contextualMenuRadius); + margin:0; + list-style: none; + color: var(--contextualMenuText); +} + +/* Menu seperator item */ +.contextualMenuSeperator{ + display: block; + position: relative; + padding: 5px 5px; +} + .contextualMenuSeperator span{ + display: block; + width:100%; + height:1px; + background: var(--contextualSeperator); + } + +/* Default menu item */ +.contextualMenuItemOuter { + position: relative; +} +.contextualMenuItem{ + display: block; + padding: 5px 8px; + cursor: default; +} + .contextualMenuItem:hover{ + background: var(--contextualHover); + } + .contextualMenuItemIcon{ + float: left; + width:16px; + height: 16px; + } + .contextualMenuItemTitle{ + text-align: left; + line-height: 16px; + display: inline-block; + padding: 0px 0px 0px 7px; + } + .contextualMenuItemTip{ + float: right; + padding: 0px 0px 0px 50px; + text-align: right; + line-height: 16px; + } + .contextualMenuItemOverflow{ + float: right; + width:16px; + height: 16px; + padding: 1px 0px 0px 7px; + } + + .contextualMenuItemOverflow .contextualMenuItemOverflowLine{ + display: block; + height: 1px; + margin: 3px 2px; + background: var(--contextualOverflowIcon); + } + .contextualMenuItemOverflow.hidden{ + display: none; + } + + .contextualMenuItem.disabled{ + opacity: 0.4; + } + .contextualMenuItem.disabled:hover{ + background: none; + } + +/* Submenu item */ +.contextualSubMenu{ + padding: 0; + margin: 0; + background: var(--contextualSubMenuBg); + border-radius: var(--contextualMenuRadius); + width: 100%; + height: auto; + max-height: 1000px; + transition: max-height 0.5s; + overflow: hidden; +} + .contextualSubMenu .contextualMenuItem:hover{ + background: var(--contextualHover); + } + +.contextualMenuHidden{ + max-height: 0; +} + +/* Multi item button */ +.contextualMultiItem{ + display: flex; + position: relative; +} + .contextualMultiItem .contextualMenuItemOuter{ + flex: auto; + display: inline-block; + } + +/* Hover menu */ +.contextualHoverMenuOuter{ + position: relative; +} +.contextualHoverMenuItem{ + display: block; + padding: 5px 8px; + cursor: default; +} +.contextualHoverMenuItem.disabled{ + opacity: 0.4; +} +.contextualHoverMenuItem.disabled:hover{ + background: none; +} +.contextualHoverMenuItem:hover{ + background: var(--contextualHover); +} + +.contextualHoverMenuOuter > .contextualHoverMenu{ + display: none; +} +.contextualHoverMenuOuter:hover > .contextualHoverMenu{ + display: block; + position: absolute; + left: 100%; + top: 0; + background: var(--contextualMenuBg); + box-shadow: var(--contextualMenuShadow); + border-radius: var(--contextualMenuRadius); + padding: 8px 0; + width: 100%; + z-index: 1000; + list-style: none; +} diff --git a/html/counter_bg_1b.png b/html/css/counter_bg_1b.png similarity index 100% rename from html/counter_bg_1b.png rename to html/css/counter_bg_1b.png diff --git a/html/crock.ttf b/html/css/crock.ttf similarity index 100% rename from html/crock.ttf rename to html/css/crock.ttf diff --git a/html/css/inventory.css b/html/css/inventory.css new file mode 100644 index 0000000..1bb1897 --- /dev/null +++ b/html/css/inventory.css @@ -0,0 +1,402 @@ + +@font-face { + font-family: crock; + src: url(crock.ttf); +} + +* { + font-family: crock; + overflow: hidden; +} + +html, +body { + height: 100%; + margin: 0 !important; + overflow: hidden; + +} + +.game { + position: relative; + width: 90%; + height: 3%; + margin: 0 4%; +} +.invinfo { + position: relative; + width: 90%; + padding-top: 10px; + height: 4%; + margin: 0 5%; + color: white; + overflow-x: hidden; + padding-left:1.5%; + margin-bottom:1%; +} +.invCraft { + position: absolute; + width: 15vw; + height: 2vw; + top: 75%; + left: 50%; + transform: translate(-50%, 0%); + color: black; + overflow-x: hidden; + text-align:center; + font-size: 0.9vw; + background-image: url("selection_box_bg_1d.png"); + background-position: center; + background-repeat: no-repeat; + background-size: 100% 100%; +} + +.invSplit { + position:absolute; + left:50%; + top:50%; + transform:translate(-50%, -50%); + background-color:#00000077; + color:#eeeeee; +} + +#splitBox { + display: none; + width:10vw; +} + +.splitamount { + height: 5vh; + width: 5vw; + margin-top:2vh; + margin-left:50%; + transform:translate(-50%, 0); + font-size: 26pt; + text-align: center; +} + +.splitmsg { + top: 10px; + left: 50%; + transform: translate(-50%, 0); + position: absolute; +} + +.splitbutton { + padding:10px; + margin:10px; + background-color:#eeeeee66; + color:#eeeeee; + border:1px solid #444444; +} + +.splitbutton:hover { + background-color:#aaaaaa66; +} + +.invtext { + font-size: 1.1vw; + color: white; + float: left; + width: 25%; +} +.invweight { + font-size: 0.9vw; + color: black; + float: left; + width: 25%; + height:100%; + line-height:200%; + text-align:center; + background-image: url("selection_box_bg_1d.png"); + background-position: center; + background-repeat: no-repeat; + background-size: 100% 100%; +} + +.money { + font-size: 1.1vw; + color: black; + float: right; + width: 20%; + text-align:center; + background-image: url("selection_box_bg_1d.png"); + background-position: center; + background-repeat: no-repeat; + background-size: 100% 100%; + margin-left:5%; +} + +.clock { + font-size: 1.1vw; + color: black; + float: right; + width: 20%; + text-align:center; + background-image: url("selection_box_bg_1d.png"); + background-position: center; + background-repeat: no-repeat; + background-size: 100% 100%; + margin-left:5%; +} + +.info { + position: absolute; + bottom: 5%; + width: 90%; + height: 6%; + margin: 0 4%; + text-align: left; + color: white; + overflow-x: hidden; + margin-top: 1.5%; + font-size: 0.8vw; + padding-top: 1%; + /* background-image: url(selection_box_bg_1d.png); */ + background-position: center; + background-repeat: no-repeat; + background-size: 95% 100%; + padding-left: 5%; +} + +#info2 { + font-size: 1vw; + font-weight: 750; +} + +.main { + user-select: none; + position: relative; + left: 0; + right: 0; + top: 0; + bottom: 0; + padding: 0; + margin: 0; + width: 100vw; + height: 100vh; + background-image: linear-gradient(225deg, rgba(155, 155, 155, 0.2)40%, rgba(0, 0, 0, 0.10) 100%); +} + +.inventory { + position: absolute; + top: 50%; + right: 20%; + transform: translate(50%, -50%); + height: 80%; + width: 28%; + margin-left: 0; + padding-left: 0; + background: #151515cf; + padding: 40px; + background: url(../redm.png); + + background-size: contain; + background-repeat: no-repeat; + background-position: center; +} + +.grid { + position: absolute; + width: 15vw; + height: 15vw; + top: 50%; + left: 50%; + margin-right: -50%; + transform: translate(-50%, -20%); +} + +.cell { + position: relative; + left: 0; + right: 0; + bottom: 0; + width: 30%; + min-height: 30%; + max-height: 30%; + margin: 1%; + background: rgba(0, 0, 0, 0.6); + border-radius: 1px; + float: left; +} + +.column { + position: relative; + margin: 0 1.5%; + background: rgba(0, 0, 0, 0.6); + border-radius: 1px; + min-height: 13%; +} + +.scroll { + position: relative; + width: 90%; + height:40.5%; + margin-left: auto; + margin-right: auto; + overflow-x: hidden; + overflow-y: auto; +} + +.column.box0 { + position: relative; + width: 98%; + min-height: 100%; + overflow-x: hidden; +} + +.column.box1 { + position: relative; + width: 98%; + min-height: 100%; + overflow-x: hidden; +} + +.column.box2 { + margin: 1.5%; + max-width: 43.5%; + width: 43.5%; + float: left; + margin-left: 5%; + color: white; + text-align: center; + margin-bottom:5%; +} + +.column.box3 { + margin: 1.5%; + max-width: 43.5%; + width: 43.5%; + float: left; + color: white; + text-align: center; + margin-bottom:5%; +} + +.item { + position: absolute; + width: 16%; + height: 6vh; + max-height: 6vh; + min-width: 20px; + margin: 3px; + background-color: rgba(0, 0, 0, 0.60); + color: #fff; + display: grid; +} + +.item:hover { + /* + background-image: url("item_bg_selected.png"); + background-position: center; + background-repeat: no-repeat; + background-size: 100% 100%; + border: none;*/ + border: 1px solid red; + background-color:rgba(50, 50, 50, 0.60); + transform:scale(0.8); +} + +.item.muuri-item-dragging { + z-index: 9999; +} + +.item.muuri-item-releasing { + z-index: 9998; +} + +.item.muuri-item-hidden { + z-index: 0; +} + +.item-content { + position: relative; + width: 100%; + height: 100%; + text-align: center; +} + +.item-content-main { + width: 100%; + height: 100%; + padding-top: 6px; + font-size: 20px; + color: black; + background-position: center; + background-repeat: no-repeat; + background-size: cover; +} + +.item-content-footer { + border-radius: 25px; + position: absolute; + color: black; + height: 30%; + width: 50%; + text-align: center; + background: rgba(255,255,255,0.8); + background-size: cover; + top: 0; + right: 0; + font-size: 10pt; + transform: translate(0%, 10%); +} + +.item-content-amount-moved { + background-color: rgba(0, 0, 0, 0.6); + color: white; + font-size: 25px; + position: absolute; + top: 0; + text-align: center; + height: 100px; + width: 100px; + line-height: 100px; +} + +::-webkit-scrollbar { + width: 3px; + height: 3px; +} + +::-webkit-scrollbar-button { + width: 0px; + height: 0px; +} + +::-webkit-scrollbar-thumb { + background: #dfdfdf; + border: 0px none #ffffff; + border-radius: 50px; +} + +::-webkit-scrollbar-thumb:hover { + background: #ffffff; +} + +::-webkit-scrollbar-thumb:active { + background: #000000; +} + +::-webkit-scrollbar-track { + background: #666666; + border: 0px none #ffffff; + border-radius: 0px; +} + +::-webkit-scrollbar-track:hover { + background: #666666; +} + +::-webkit-scrollbar-track:active { + background: #333333; +} + +::-webkit-scrollbar-corner { + background: transparent; +} + + +.contextmenu-inventory { + min-width: 6em !important; +} \ No newline at end of file diff --git a/html/item_bg_selected.png b/html/css/item_bg_selected.png similarity index 100% rename from html/item_bg_selected.png rename to html/css/item_bg_selected.png diff --git a/html/selection_box_bg_1d.png b/html/css/selection_box_bg_1d.png similarity index 100% rename from html/selection_box_bg_1d.png rename to html/css/selection_box_bg_1d.png diff --git a/html/inventory.html b/html/inventory.html index 3a6a518..53403e6 100644 --- a/html/inventory.html +++ b/html/inventory.html @@ -1,392 +1,56 @@ - - - - - -
-
-
16.34$
16:34
-
DROP
-
USE
-
INVENTORY
15.0/24KG
-
-
-
-
-
-
-
-
-
+ + + + + RedEM:RP Inventory 2022 + + + + +
+
+
INVENTORY
16.34$
16:34
15.0/24KG
+
+
+ +
+
+

+
+
+
+
+
+
+
+
+ + +
+
+
+
+
+
+
+
+
+
+
+
CRAFT
+
+ Split by amount?
+
+ + +
-
CRAFT
-
- - -
-
-
-
-
-
-
-
-
-
-
- - - -
- - - - - - - + + + + + + + + \ No newline at end of file diff --git a/html/items/apple.png b/html/items/apple.png deleted file mode 100644 index 0e09bf1..0000000 Binary files a/html/items/apple.png and /dev/null differ diff --git a/html/items/bread_bait.png b/html/items/bread_bait.png deleted file mode 100644 index 08120f6..0000000 Binary files a/html/items/bread_bait.png and /dev/null differ diff --git a/html/items/character_exists.png b/html/items/character_exists.png new file mode 100644 index 0000000..60e58c3 Binary files /dev/null and b/html/items/character_exists.png differ diff --git a/html/items/character_new.png b/html/items/character_new.png new file mode 100644 index 0000000..fe3cb0f Binary files /dev/null and b/html/items/character_new.png differ diff --git a/html/items/charsel_cancel.png b/html/items/charsel_cancel.png new file mode 100644 index 0000000..bd15f44 Binary files /dev/null and b/html/items/charsel_cancel.png differ diff --git a/html/items/charsel_confirm.png b/html/items/charsel_confirm.png new file mode 100644 index 0000000..f021598 Binary files /dev/null and b/html/items/charsel_confirm.png differ diff --git a/html/items/charsel_delete.png b/html/items/charsel_delete.png new file mode 100644 index 0000000..3500f17 Binary files /dev/null and b/html/items/charsel_delete.png differ diff --git a/html/items/cheese_bait.png b/html/items/cheese_bait.png deleted file mode 100644 index 095f644..0000000 Binary files a/html/items/cheese_bait.png and /dev/null differ diff --git a/html/items/corn_bait.png b/html/items/corn_bait.png deleted file mode 100644 index e2c6898..0000000 Binary files a/html/items/corn_bait.png and /dev/null differ diff --git a/html/items/cricket_bait.png b/html/items/cricket_bait.png deleted file mode 100644 index 7ae86ee..0000000 Binary files a/html/items/cricket_bait.png and /dev/null differ diff --git a/html/items/lake_bait.png b/html/items/lake_bait.png deleted file mode 100644 index dfb478f..0000000 Binary files a/html/items/lake_bait.png and /dev/null differ diff --git a/html/items/swamp_bait.png b/html/items/swamp_bait.png deleted file mode 100644 index ef9d042..0000000 Binary files a/html/items/swamp_bait.png and /dev/null differ diff --git a/html/items/weapon_bow_improved.png b/html/items/weapon_bow_improved.png new file mode 100644 index 0000000..2296ee9 Binary files /dev/null and b/html/items/weapon_bow_improved.png differ diff --git a/html/items/weapon_kit_binoculars_improved.png b/html/items/weapon_kit_binoculars_improved.png new file mode 100644 index 0000000..165c8eb Binary files /dev/null and b/html/items/weapon_kit_binoculars_improved.png differ diff --git a/html/items/weapon_kit_camera.png b/html/items/weapon_kit_camera.png new file mode 100644 index 0000000..cb65dd7 Binary files /dev/null and b/html/items/weapon_kit_camera.png differ diff --git a/html/items/weapon_kit_camera_advanced.png b/html/items/weapon_kit_camera_advanced.png new file mode 100644 index 0000000..7324eee Binary files /dev/null and b/html/items/weapon_kit_camera_advanced.png differ diff --git a/html/items/weapon_kit_detector.png b/html/items/weapon_kit_detector.png new file mode 100644 index 0000000..cda06be Binary files /dev/null and b/html/items/weapon_kit_detector.png differ diff --git a/html/items/weapon_kit_generic_animal_sample.png b/html/items/weapon_kit_generic_animal_sample.png new file mode 100644 index 0000000..3e9e84d Binary files /dev/null and b/html/items/weapon_kit_generic_animal_sample.png differ diff --git a/html/items/weapon_kit_metal_detector.png b/html/items/weapon_kit_metal_detector.png new file mode 100644 index 0000000..9f7fe43 Binary files /dev/null and b/html/items/weapon_kit_metal_detector.png differ diff --git a/html/items/weapon_lasso_reinforced.png b/html/items/weapon_lasso_reinforced.png new file mode 100644 index 0000000..cf07565 Binary files /dev/null and b/html/items/weapon_lasso_reinforced.png differ diff --git a/html/items/weapon_melee_ancient_hatchet.png b/html/items/weapon_melee_ancient_hatchet.png new file mode 100644 index 0000000..8fb7841 Binary files /dev/null and b/html/items/weapon_melee_ancient_hatchet.png differ diff --git a/html/items/weapon_melee_broken_sword.png b/html/items/weapon_melee_broken_sword.png new file mode 100644 index 0000000..7d81c79 Binary files /dev/null and b/html/items/weapon_melee_broken_sword.png differ diff --git a/html/items/weapon_melee_cleaver.png b/html/items/weapon_melee_cleaver.png new file mode 100644 index 0000000..5b62f71 Binary files /dev/null and b/html/items/weapon_melee_cleaver.png differ diff --git a/html/items/weapon_melee_davy_lantern.png b/html/items/weapon_melee_davy_lantern.png new file mode 100644 index 0000000..b6bea26 Binary files /dev/null and b/html/items/weapon_melee_davy_lantern.png differ diff --git a/html/items/weapon_melee_hammer.png b/html/items/weapon_melee_hammer.png new file mode 100644 index 0000000..6bc56e9 Binary files /dev/null and b/html/items/weapon_melee_hammer.png differ diff --git a/html/items/weapon_melee_hatchet_double_bit.png b/html/items/weapon_melee_hatchet_double_bit.png new file mode 100644 index 0000000..467ef30 Binary files /dev/null and b/html/items/weapon_melee_hatchet_double_bit.png differ diff --git a/html/items/weapon_melee_hatchet_double_bit_rusted.png b/html/items/weapon_melee_hatchet_double_bit_rusted.png new file mode 100644 index 0000000..2d7cfb6 Binary files /dev/null and b/html/items/weapon_melee_hatchet_double_bit_rusted.png differ diff --git a/html/items/weapon_melee_hatchet_hewing.png b/html/items/weapon_melee_hatchet_hewing.png new file mode 100644 index 0000000..4bc28d4 Binary files /dev/null and b/html/items/weapon_melee_hatchet_hewing.png differ diff --git a/html/items/weapon_melee_hatchet_hunter.png b/html/items/weapon_melee_hatchet_hunter.png new file mode 100644 index 0000000..86ef408 Binary files /dev/null and b/html/items/weapon_melee_hatchet_hunter.png differ diff --git a/html/items/weapon_melee_hatchet_hunter_rusted.png b/html/items/weapon_melee_hatchet_hunter_rusted.png new file mode 100644 index 0000000..fd50c03 Binary files /dev/null and b/html/items/weapon_melee_hatchet_hunter_rusted.png differ diff --git a/html/items/weapon_melee_hatchet_viking.png b/html/items/weapon_melee_hatchet_viking.png new file mode 100644 index 0000000..1bc25c5 Binary files /dev/null and b/html/items/weapon_melee_hatchet_viking.png differ diff --git a/html/items/weapon_melee_knife_bear.png b/html/items/weapon_melee_knife_bear.png new file mode 100644 index 0000000..28ad660 Binary files /dev/null and b/html/items/weapon_melee_knife_bear.png differ diff --git a/html/items/weapon_melee_knife_civil_war.png b/html/items/weapon_melee_knife_civil_war.png new file mode 100644 index 0000000..f7a3ef0 Binary files /dev/null and b/html/items/weapon_melee_knife_civil_war.png differ diff --git a/html/items/weapon_melee_knife_horror.png b/html/items/weapon_melee_knife_horror.png new file mode 100644 index 0000000..acaacb6 Binary files /dev/null and b/html/items/weapon_melee_knife_horror.png differ diff --git a/html/items/weapon_melee_knife_jawbone.png b/html/items/weapon_melee_knife_jawbone.png new file mode 100644 index 0000000..f2389f4 Binary files /dev/null and b/html/items/weapon_melee_knife_jawbone.png differ diff --git a/html/items/weapon_melee_knife_rustic.png b/html/items/weapon_melee_knife_rustic.png new file mode 100644 index 0000000..13ca8eb Binary files /dev/null and b/html/items/weapon_melee_knife_rustic.png differ diff --git a/html/items/weapon_melee_knife_trader.png b/html/items/weapon_melee_knife_trader.png new file mode 100644 index 0000000..3bb9246 Binary files /dev/null and b/html/items/weapon_melee_knife_trader.png differ diff --git a/html/items/weapon_melee_lantern_halloween.png b/html/items/weapon_melee_lantern_halloween.png new file mode 100644 index 0000000..89e10b3 Binary files /dev/null and b/html/items/weapon_melee_lantern_halloween.png differ diff --git a/html/items/weapon_melee_machete.png b/html/items/weapon_melee_machete.png new file mode 100644 index 0000000..8d74346 Binary files /dev/null and b/html/items/weapon_melee_machete.png differ diff --git a/html/items/weapon_melee_machete_collector.png b/html/items/weapon_melee_machete_collector.png new file mode 100644 index 0000000..5f288c8 Binary files /dev/null and b/html/items/weapon_melee_machete_collector.png differ diff --git a/html/items/weapon_melee_machete_horror.png b/html/items/weapon_melee_machete_horror.png new file mode 100644 index 0000000..a2a6ab9 Binary files /dev/null and b/html/items/weapon_melee_machete_horror.png differ diff --git a/html/items/weapon_moonshinejug.png b/html/items/weapon_moonshinejug.png new file mode 100644 index 0000000..d55f822 Binary files /dev/null and b/html/items/weapon_moonshinejug.png differ diff --git a/html/items/weapon_moonshinejug_mp.png b/html/items/weapon_moonshinejug_mp.png new file mode 100644 index 0000000..ab9e131 Binary files /dev/null and b/html/items/weapon_moonshinejug_mp.png differ diff --git a/html/items/weapon_pistol_m1899.png b/html/items/weapon_pistol_m1899.png new file mode 100644 index 0000000..fc93e7e Binary files /dev/null and b/html/items/weapon_pistol_m1899.png differ diff --git a/html/items/weapon_repeater_evans.png b/html/items/weapon_repeater_evans.png new file mode 100644 index 0000000..86c5f14 Binary files /dev/null and b/html/items/weapon_repeater_evans.png differ diff --git a/html/items/weapon_revolver_doubleaction_exotic.png b/html/items/weapon_revolver_doubleaction_exotic.png new file mode 100644 index 0000000..b61f9f8 Binary files /dev/null and b/html/items/weapon_revolver_doubleaction_exotic.png differ diff --git a/html/items/weapon_revolver_doubleaction_gambler.png b/html/items/weapon_revolver_doubleaction_gambler.png new file mode 100644 index 0000000..ccb9e7d Binary files /dev/null and b/html/items/weapon_revolver_doubleaction_gambler.png differ diff --git a/html/items/weapon_revolver_lemat.png b/html/items/weapon_revolver_lemat.png new file mode 100644 index 0000000..e2bd214 Binary files /dev/null and b/html/items/weapon_revolver_lemat.png differ diff --git a/html/items/weapon_revolver_navy.png b/html/items/weapon_revolver_navy.png new file mode 100644 index 0000000..ce8cdf0 Binary files /dev/null and b/html/items/weapon_revolver_navy.png differ diff --git a/html/items/weapon_revolver_navy_crossover.png b/html/items/weapon_revolver_navy_crossover.png new file mode 100644 index 0000000..0f14e21 Binary files /dev/null and b/html/items/weapon_revolver_navy_crossover.png differ diff --git a/html/items/weapon_rifle_elephant.png b/html/items/weapon_rifle_elephant.png new file mode 100644 index 0000000..d0cf95f Binary files /dev/null and b/html/items/weapon_rifle_elephant.png differ diff --git a/html/items/weapon_shotgun_doublebarrel_exotic.png b/html/items/weapon_shotgun_doublebarrel_exotic.png new file mode 100644 index 0000000..2b93c66 Binary files /dev/null and b/html/items/weapon_shotgun_doublebarrel_exotic.png differ diff --git a/html/items/weapon_thrown_ancient_tomahawk.png b/html/items/weapon_thrown_ancient_tomahawk.png new file mode 100644 index 0000000..bc5e1b7 Binary files /dev/null and b/html/items/weapon_thrown_ancient_tomahawk.png differ diff --git a/html/items/weapon_thrown_bolas.png b/html/items/weapon_thrown_bolas.png new file mode 100644 index 0000000..48a8ab2 Binary files /dev/null and b/html/items/weapon_thrown_bolas.png differ diff --git a/html/items/weapon_thrown_bolas_hawkmoth.png b/html/items/weapon_thrown_bolas_hawkmoth.png new file mode 100644 index 0000000..49b8bdb Binary files /dev/null and b/html/items/weapon_thrown_bolas_hawkmoth.png differ diff --git a/html/items/weapon_thrown_bolas_intertwined.png b/html/items/weapon_thrown_bolas_intertwined.png new file mode 100644 index 0000000..b3f5239 Binary files /dev/null and b/html/items/weapon_thrown_bolas_intertwined.png differ diff --git a/html/items/weapon_thrown_bolas_ironspiked.png b/html/items/weapon_thrown_bolas_ironspiked.png new file mode 100644 index 0000000..77aa6be Binary files /dev/null and b/html/items/weapon_thrown_bolas_ironspiked.png differ diff --git a/html/items/weapon_thrown_homing_tomahawk.png b/html/items/weapon_thrown_homing_tomahawk.png new file mode 100644 index 0000000..3581255 Binary files /dev/null and b/html/items/weapon_thrown_homing_tomahawk.png differ diff --git a/html/items/weapon_thrown_improved_tomahawk.png b/html/items/weapon_thrown_improved_tomahawk.png new file mode 100644 index 0000000..22eaecc Binary files /dev/null and b/html/items/weapon_thrown_improved_tomahawk.png differ diff --git a/html/items/weapon_thrown_poisonbottle.png b/html/items/weapon_thrown_poisonbottle.png new file mode 100644 index 0000000..5b91794 Binary files /dev/null and b/html/items/weapon_thrown_poisonbottle.png differ diff --git a/html/items/weapon_thrown_throwing_knives_improved.png b/html/items/weapon_thrown_throwing_knives_improved.png new file mode 100644 index 0000000..ce754fd Binary files /dev/null and b/html/items/weapon_thrown_throwing_knives_improved.png differ diff --git a/html/items/weapon_unarmed.png b/html/items/weapon_unarmed.png new file mode 100644 index 0000000..7928c4b Binary files /dev/null and b/html/items/weapon_unarmed.png differ diff --git a/html/items/weapon_volatile_dynamite.png b/html/items/weapon_volatile_dynamite.png new file mode 100644 index 0000000..76b96dd Binary files /dev/null and b/html/items/weapon_volatile_dynamite.png differ diff --git a/html/items/weapon_volatile_fire_bottle.png b/html/items/weapon_volatile_fire_bottle.png new file mode 100644 index 0000000..0290125 Binary files /dev/null and b/html/items/weapon_volatile_fire_bottle.png differ diff --git a/html/items/wheat.png b/html/items/wheat.png deleted file mode 100644 index dfc70dd..0000000 Binary files a/html/items/wheat.png and /dev/null differ diff --git a/html/js/inventory.js b/html/js/inventory.js index ca95faa..acabb0e 100644 --- a/html/js/inventory.js +++ b/html/js/inventory.js @@ -1,247 +1,542 @@ var targetPlayerId = 0; +var SecondInventoryActive = false; +var SplittingObject = null; +var SplitMode = false; + +$(function(){ + window.onload = (e) => { + window.addEventListener('message', (event) => { + switch (event.data.type){ + case 1: { + show(event.data.inventory, event.data.otherinventory, event.data.crafting); + getItems(event.data.items, event.data.otheritems, event.data.target, event.data.weight); + $("#money").html(`$${event.data.money}`); + $("#clock").html(`${event.data.time}`); + break; + } + case 2: { + hide(); + break; + } + default: { + hide(); + } + } + }); + }; +}); + +$(function() { + $.contextMenu({ + selector: '.item-content', + className: 'contextmenu-inventory', + callback: function(key, options) { + var objectId = options.$trigger.attr('objectId'); + var nodrop = false; + var nouse = false; + var nogive = false; + var classname = $(options.$trigger).parent().parent().attr('class'); + //console.log(classname); + if (classname.includes("box0")) { + nodrop = true; + nouse = true; + nogive = true; + } + if(key == "use" && !nouse) { + var object = getObjectById(objectId); + $.post(`https://${GetParentResourceName()}/useitem`, JSON.stringify({ + data: object + })); + } else if(key == "split") { + SplittingObject = objectId; + ShowSplit(Math.floor(getObjectById(objectId).amount/2)); + } else if(key == "drop" && !nodrop) { + var object = getObjectById(objectId); + $.post(`https://${GetParentResourceName()}/dropitem`, JSON.stringify({ + data: object + })); + } else if(key == "give" && !nogive) { + var object = getObjectById(objectId); + $.post(`https://${GetParentResourceName()}/giveitem`, JSON.stringify({ + data: object + })); + } + else if(key == "transfer") { + //console.log(SecondInventoryActive) + if (SecondInventoryActive) { + if (classname.includes("box0")) { + var object = getObjectById(objectId); + $.post(`https://${GetParentResourceName()}/additem`, JSON.stringify({ + data: object, + target: targetPlayerId + })); + } else { + var object = getObjectById(objectId); + $.post(`https://${GetParentResourceName()}/removeitem`, JSON.stringify({ + data: object, + target: targetPlayerId + })); + } + } + } + }, + items: { + "use": {name: "Use"}, + "split": {name: "Split"}, + "drop": {name: "Drop"}, + "give": {name: "Give"}, + "transfer": {name: "Transfer"}, + } + }); +}); + +function ShowSplit(amt) { + SplitMode = true; + $("#splitBox").show(); + $("#splitamt").val(amt); + $(".inventory").css("pointer-events", "none"); + $(".inventory").css("opacity", "0.3"); + $(".grid").css("pointer-events", "none"); + $(".grid").css("opacity", "0.3"); + $("#splitamt").focus(); +} + +$("#splitConf").click(function() { + if(SplittingObject) { + var object = getObjectById(SplittingObject); + + if (object.amount <= 1 || object.box > 3 || object.type == "item_weapon") return; + var amount = $("#splitamt").val(); + if(amount > 0 && amount < object.amount) { + var val = Math.floor(object.amount - amount); + setObjectAmount(SplittingObject, val, false); + addObject({ + name: object.name, + description: object.description, + label: object.label, + type: object.type, + amount: amount, + imgsrc: object.imgsrc, + box: object.box, + meta: object.meta + }); + } + } + SplitMode = false; + $("#splitBox").hide(); + $(".inventory").css("pointer-events", "auto"); + $(".inventory").css("opacity", "1.0"); + $(".grid").css("pointer-events", "auto"); + $(".grid").css("opacity", "1.0"); +}); + +$("#splitamt").keyup(function(e) { + if(e.key == "Enter") { + if(SplittingObject) { + var object = getObjectById(SplittingObject); + + if (object.amount <= 1 || object.box > 3 || object.type == "item_weapon") return; + var amount = $("#splitamt").val(); + if(amount > 0 && amount < object.amount) { + var val = Math.floor(object.amount - amount); + setObjectAmount(SplittingObject, val, false); + addObject({ + name: object.name, + description: object.description, + label: object.label, + type: object.type, + amount: amount, + imgsrc: object.imgsrc, + box: object.box, + meta: object.meta + }); + } + } + SplitMode = false; + $("#splitBox").hide(); + $(".inventory").css("pointer-events", "auto"); + $(".inventory").css("opacity", "1.0"); + $(".grid").css("pointer-events", "auto"); + $(".grid").css("opacity", "1.0"); + } else if (e.key == "Escape") { + $("#splitBox").hide(); + $(".inventory").css("pointer-events", "auto"); + $(".inventory").css("opacity", "1.0"); + $(".grid").css("pointer-events", "auto"); + $(".grid").css("opacity", "1.0"); + setTimeout(() => { + SplitMode = false; + }, 500); + } +}); + +$("#splitCancel").click(function() { + SplitMode = false; + $("#splitBox").hide(); + $(".inventory").css("pointer-events", "auto"); + $(".inventory").css("opacity", "1.0"); + $(".grid").css("pointer-events", "auto"); + $(".grid").css("opacity", "1.0"); +}); + + function createObjectBox(object) { - const box = document.createElement("div"); - box.setAttribute('class', 'item'); - box.setAttribute('data-amount', object.amount); - if (object.box > 3) { - document.getElementsByClassName(`slot${object.box-3}`)[0].appendChild(box); - } else { - document.getElementsByClassName(`box${object.box}`)[0].appendChild(box); - } - - const boxContent = document.createElement("div"); - box.appendChild(boxContent); - boxContent.setAttribute('class', 'item-content'); - boxContent.setAttribute('objectId', object.id); - boxContent.setAttribute('oncontextmenu', `cloneBox(${object.id})`); - boxContent.setAttribute('ondblclick', `cloneBox2(${object.id})`); - boxContent.setAttribute('onmouseover', "Over(`" + object.label + "`, `" + object.description + "`) " ); - - - - const mainContent = document.createElement("div"); - mainContent.setAttribute('class', 'item-content-main'); - boxContent.appendChild(mainContent); - - const img = document.createElement("img"); - img.src = object.imgsrc; - img.style.position = 'absolute'; - img.style.left = '50%'; - img.style.height = '90%'; - img.style.marginRight = '-50%'; - img.style.transform = 'translate(-50%, 0%)'; - mainContent.appendChild(img); - - const sliderBox = document.createElement("div"); - sliderBox.setAttribute('class', 'item-content-footer'); - sliderBox.style.display = 'none'; - boxContent.appendChild(sliderBox); - - const amountBox = document.createElement("div"); - boxContent.appendChild(amountBox); - amountBox.setAttribute('class', 'item-content-footer'); - amountBox.innerHTML = object.amount; - - return box; + const box = document.createElement("div"); + box.setAttribute('class', 'item'); + box.setAttribute('data-amount', object.amount); + if (object.box > 3) { + document.getElementsByClassName(`slot${object.box-3}`)[0].appendChild(box); + } else { + document.getElementsByClassName(`box${object.box}`)[0].appendChild(box); + } + + const boxContent = document.createElement("div"); + box.appendChild(boxContent); + boxContent.setAttribute('class', 'item-content'); + boxContent.setAttribute('objectId', object.id); + //boxContent.setAttribute('oncontextmenu', `openContextMenu(${object.id})`); + //boxContent.setAttribute('ondblclick', `cloneBox(${object.id})`); + if (object.name == "letter") { + if (object.meta.name == "") { + boxContent.setAttribute('onmouseover', "Over(`" + object.label + "`, `A letter addressed to nobody`) "); + } else { + boxContent.setAttribute('onmouseover', "Over(`" + object.label + "`, `A letter addressed to " + object.meta.name + "`) "); + } + } else if(object.name == "newspaper") { + boxContent.setAttribute('onmouseover', "Over(`" + object.label + "`, `A newspaper (edition " + object.meta.edition + ")`) "); + } else if(object.name == "wateringcan") { + if(object.meta.water != undefined && object.meta.water != null) { + var waterdisp = object.meta.water * 10; + boxContent.setAttribute('onmouseover', "Over(`" + object.label + "`, `A watering can (" + waterdisp.toFixed(0) + "% Full)`) "); + } + } else if(object.name == "canteen") { + if(object.meta.water != undefined && object.meta.water != null) { + var waterdisp = object.meta.water * 10; + boxContent.setAttribute('onmouseover', "Over(`" + object.label + "`, `A canteen (" + waterdisp.toFixed(0) + "% Full)`) "); + } + } else if(object.type == "item_weapon") { + if((object.meta.damage != undefined && object.meta.damage != null) && + (object.meta.dirt != undefined && object.meta.dirt != null)) { + boxContent.setAttribute('onmouseover', "Over(`" + object.label + "`, `" + object.description + " (" + (object.meta.dirt*100).toFixed(2) + "% Dirt, "+(object.meta.damage*100).toFixed(2)+"% Damage)`) "); + } else { + boxContent.setAttribute('onmouseover', "Over(`" + object.label + "`, `" + object.description + "`) "); + } + } else { + boxContent.setAttribute('onmouseover', "Over(`" + object.label + "`, `" + object.description + "`) "); + } + + + /* + $(boxContent).mousedown(function(event) { + switch (event.which) { + case 1: { + if(event.shiftKey) { + console.log(JSON.stringify(object)); + if (object.box == 0) { + var object = getObjectById(object.id); + $.post(`https://${GetParentResourceName()}/additem`, JSON.stringify({ + data: object, + target: targetPlayerId + })); + } else { + var object = getObjectById(object.id); + $.post(`https://${GetParentResourceName()}/removeitem`, JSON.stringify({ + data: object, + target: targetPlayerId + })); + } + } + break; + } + case 3: { + if(event.shiftKey) { + $(boxContent).contextMenu(false); + cloneBox(object.id); + } else { + $(boxContent).contextMenu(true); + } + break; + } + } + });*/ + $(boxContent).mousedown(function(event) { + switch (event.which) { + case 3: { + if(event.shiftKey) { + //console.log(JSON.stringify(object)); + $(boxContent).contextMenu(false); + cloneBox(object.id); + } else { + $(boxContent).contextMenu(true); + } + break; + } + } + }); + const mainContent = document.createElement("div"); + mainContent.setAttribute('class', 'item-content-main'); + boxContent.appendChild(mainContent); + + const img = document.createElement("img"); + img.src = object.imgsrc; + img.style.position = 'absolute'; + img.style.left = '50%'; + img.style.height = '90%'; + img.style.marginRight = '-50%'; + img.style.transform = 'translate(-50%, 0%)'; + mainContent.appendChild(img); + + const sliderBox = document.createElement("div"); + sliderBox.setAttribute('class', 'item-content-footer'); + sliderBox.style.display = 'none'; + boxContent.appendChild(sliderBox); + + const amountBox = document.createElement("div"); + boxContent.appendChild(amountBox); + amountBox.setAttribute('class', 'item-content-footer'); + amountBox.innerHTML = object.amount; + + return box; } function cloneBox(id) { - object = getObjectById(id); - - if (object.amount <= 1 || object.box > 3 || object.type == "item_weapon") return; - - neighbour = getObjectsByNameAndMeta(object.name, object.meta).find(obj => obj.box == object.box && obj.id != id); - setObjectAmount(id, object.amount - 1, false); - - if (neighbour) setObjectAmount(neighbour.id, neighbour.amount + 1, false); - else return addObject({ - name: object.name, - description: object.description, - label : object.label, - type : object.type, - amount: 1, - imgsrc: object.imgsrc, - box: object.box, - meta: object.meta - }); + object = getObjectById(id); + + if (object.amount <= 1 || object.box > 3 || object.type == "item_weapon") return; + + neighbour = getObjectsByNameAndMeta(object.name, object.meta).find(obj => obj.box == object.box && obj.id != id); + setObjectAmount(id, object.amount - 1, false); + + if (neighbour) setObjectAmount(neighbour.id, neighbour.amount + 1, false); + else return addObject({ + name: object.name, + description: object.description, + label: object.label, + type: object.type, + amount: 1, + imgsrc: object.imgsrc, + box: object.box, + meta: object.meta + }); +} + + +function openContextMenu(id) { + object = getObjectById(id); + new Contextual({ + items: menuItems + }); + + + neighbour = getObjectsByNameAndMeta(object.name, object.meta).find(obj => obj.box == object.box && obj.id != id); + setObjectAmount(id, object.amount - 1, false); + + if (neighbour) setObjectAmount(neighbour.id, neighbour.amount + 1, false); + else return addObject({ + name: object.name, + description: object.description, + label: object.label, + type: object.type, + amount: 1, + imgsrc: object.imgsrc, + box: object.box, + meta: object.meta + }); } function cloneBox2(id) { - object = getObjectById(id); - - if (object.amount <= 1 || object.box > 3 || object.type == "item_weapon") return; - var val = Math.floor(object.amount / 2); - setObjectAmount(id, object.amount - val, false); - addObject({ - name: object.name, - description: object.description, - label : object.label, - type : object.type, - amount: val, - imgsrc: object.imgsrc, - box: object.box, - meta: object.meta - }); + object = getObjectById(id); + + if (object.amount <= 1 || object.box > 3 || object.type == "item_weapon") return; + var val = Math.floor(object.amount / 2); + setObjectAmount(id, object.amount - val, false); + addObject({ + name: object.name, + description: object.description, + label: object.label, + type: object.type, + amount: val, + imgsrc: object.imgsrc, + box: object.box, + meta: object.meta + }); +} + +function cloneBox2Amt(id, amt) { + object = getObjectById(id); + + if (object.amount <= 1 || object.box > 3 || object.type == "item_weapon") return; + var val = Math.floor(object.amount - amt); + setObjectAmount(id, object.amount - val, false); + addObject({ + name: object.name, + description: object.description, + label: object.label, + type: object.type, + amount: val, + imgsrc: object.imgsrc, + box: object.box, + meta: object.meta + }); } + function addObject(data) { - id = objects.length ? objects[objects.length - 1].id + 1 : 1; - obj = { - id: id, - name: data.name, - description: data.description, - label : data.label, - type : data.type, - meta: data.meta, - amount: data.amount, - imgsrc: data.imgsrc, - box: data.box, - }; - objects.push(obj); - grids[parseInt(data.box)].add(createObjectBox(obj))[0]._id = id; - return obj; + id = objects.length ? objects[objects.length - 1].id + 1 : 1; + obj = { + id: id, + name: data.name, + description: data.description, + label: data.label, + type: data.type, + meta: data.meta, + amount: data.amount, + imgsrc: data.imgsrc, + box: data.box, + }; + objects.push(obj); + grids[parseInt(data.box)].add(createObjectBox(obj))[0]._id = id; + return obj; } function getObjectById(id) { - return objects.find(obj => obj.id == id); + return objects.find(obj => obj.id == id); } function getObjectsByNameAndMeta(name, meta) { - return objects.filter(obj => obj.name == name && obj.meta == meta); + return objects.filter(obj => obj.name == name && obj.meta == meta); } function getAmountSum(name, meta) { - return getObjectsByNameAndMeta(name, meta).reduce((sum, { - amount - }) => sum + amount, 0); + return getObjectsByNameAndMeta(name, meta).reduce((sum, { + amount + }) => sum + amount, 0); } function getObjectHTML(objectId) { - return document.querySelector(`[objectId='${objectId}']`); + return document.querySelector(`[objectId='${objectId}']`); } function setObjectAmount(id, amount, affectOnOthers = true) { - if (amount <= 0) { - removeObjects([getObjectById(id)]); - return; - } - object = getObjectById(id); - difference = parseInt(amount) - object.amount; - - object.amount = parseInt(amount); - boxContent = getObjectHTML(id); - boxContent.lastChild.innerHTML = amount; - if (difference == 0 || !affectOnOthers) return; - if (getObjectsByNameAndMeta(object.name, object.meta).length == 1) { - addObject({ - name: object.name, - description: object.description, - label : object.label, - type : object.type, - meta: object.meta, - amount: -difference, - imgsrc: object.imgsrc, - box: object.box - }); - return; - } - - for (const destinationBox of objectsMoveDirections[object.box]) { - destinationObjects = getObjectsByNameAndMeta(object.name, object.meta).filter(obj => obj.box == destinationBox && obj.id != id); - - for (const destinationobject of destinationObjects) { - if (destinationobject.amount >= difference) { - setObjectAmount(destinationobject.id, destinationobject.amount - difference, false); - return; - } else { - difference -= destinationobject.amount; - setObjectAmount(destinationobject.id, 0, false); - } - } - } + if (amount <= 0) { + removeObjects([getObjectById(id)]); + return; + } + object = getObjectById(id); + difference = parseInt(amount) - object.amount; + + object.amount = parseInt(amount); + boxContent = getObjectHTML(id); + boxContent.lastChild.innerHTML = amount; + if (difference == 0 || !affectOnOthers) return; + if (getObjectsByNameAndMeta(object.name, object.meta).length == 1) { + addObject({ + name: object.name, + description: object.description, + label: object.label, + type: object.type, + meta: object.meta, + amount: -difference, + imgsrc: object.imgsrc, + box: object.box + }); + return; + } + + for (const destinationBox of objectsMoveDirections[object.box]) { + destinationObjects = getObjectsByNameAndMeta(object.name, object.meta).filter(obj => obj.box == destinationBox && obj.id != id); + + for (const destinationobject of destinationObjects) { + if (destinationobject.amount >= difference) { + setObjectAmount(destinationobject.id, destinationobject.amount - difference, false); + return; + } else { + difference -= destinationobject.amount; + setObjectAmount(destinationobject.id, 0, false); + } + } + } } function getObjectsFromBox(box_nr) { - return objects.filter(({ - box - }) => box == box_nr); + return objects.filter(({ + box + }) => box == box_nr); } function onDragFinished(data) { - // get dragged object - draggedObject = getObjectById(data.item._id); - // get all repeated elements - - repeats = getObjectsFromBox(data.toGrid._id - 1).filter(({ - name, - meta - }) => name == draggedObject.name && deepEqual(meta, draggedObject.meta)); - if (draggedObject.type == "item_standard" ) { - // add amount of objects from this box - repeatsAmount = repeats.reduce((sum, { - amount - }) => sum + amount, 0); - setObjectAmount(data.item._id, draggedObject.amount + repeatsAmount, false); - } - // set new box value to object - getObjectById(data.item._id).box = data.toGrid._id - 1; - // remove all repeats - - removeObjects(repeats); + // get dragged object + draggedObject = getObjectById(data.item._id); + // get all repeated elements + + repeats = getObjectsFromBox(data.toGrid._id - 1).filter(({ + name, + meta + }) => name == draggedObject.name && deepEqual(meta, draggedObject.meta)); + if (draggedObject.type == "item_standard") { + // add amount of objects from this box + repeatsAmount = repeats.reduce( (sum, {amount} ) => parseInt(sum) + parseInt(amount), 0 ); + setObjectAmount(data.item._id, parseInt(draggedObject.amount) + parseInt(repeatsAmount), false); + } + // set new box value to object + getObjectById(data.item._id).box = data.toGrid._id - 1; + // remove all repeats + + removeObjects(repeats); } function deepEqual(object1, object2) { - const keys1 = Object.keys(object1); - const keys2 = Object.keys(object2); - - if (keys1.length !== keys2.length) { - return false; - } - - for (const key of keys1) { - const val1 = object1[key]; - const val2 = object2[key]; - const areObjects = isObject(val1) && isObject(val2); - if ( - areObjects && !deepEqual(val1, val2) || - !areObjects && val1 !== val2 - ) { - return false; - } - } - - return true; + const keys1 = Object.keys(object1); + const keys2 = Object.keys(object2); + + if (keys1.length !== keys2.length) { + return false; + } + + for (const key of keys1) { + const val1 = object1[key]; + const val2 = object2[key]; + const areObjects = isObject(val1) && isObject(val2); + if ( + areObjects && !deepEqual(val1, val2) || + !areObjects && val1 !== val2 + ) { + return false; + } + } + + return true; } function isObject(object) { - return object != null && typeof object === 'object'; + return object != null && typeof object === 'object'; } function removeObjects(arrayOfObjects) { - arrayOfObjects.forEach(obj => { - //Remove from grid - grids[parseInt(obj.box)].remove(grids[parseInt(obj.box)].getItems().find(({ - _id - }) => _id == obj.id)); - //Delete HTML element - box = getObjectHTML(obj.id).parentElement; - box.parentElement.removeChild(box); - //Remove from objects array - objects = objects.filter(obj => !arrayOfObjects.find(el => el.id == obj.id)) - }) + arrayOfObjects.forEach(obj => { + //Remove from grid + grids[parseInt(obj.box)].remove(grids[parseInt(obj.box)].getItems().find(({ + _id + }) => _id == obj.id)); + //Delete HTML element + box = getObjectHTML(obj.id).parentElement; + box.parentElement.removeChild(box); + //Remove from objects array + objects = objects.filter(obj => !arrayOfObjects.find(el => el.id == obj.id)) + }) } const objectsMoveDirections = [ - [0, 1, 2], - [1, 0, 2], - [2, 1, 0] + [0, 1, 2], + [1, 0, 2], + [2, 1, 0] ]; let objects = []; @@ -250,489 +545,522 @@ let objectsIn = null; var secondInventoryId = -1 var grids = [ - new Muuri('.box0', { - dragEnabled: true, - dragContainer: document.body, - dragSort: () => grids, - sortData: { - amount: function (item, element) { - return parseFloat(element.getAttribute('data-amount')); - } - }, - dragStartPredicate: { - handle: '.item-content-main, .item-content-amount-moved' - } - }).on('send', data => onDragFinished(data)) - .on('dragStart', function(item) { - item.getElement().style.width = item.getWidth() + 'px'; - item.getElement().style.height = item.getHeight() + 'px'; - }) - .on('dragReleaseEnd', function(item) { - item.getElement().style.width = '15.2%'; - item.getElement().style.height = '8vh'; - grids.forEach(function(grid) { - grid.refreshItems(); - }); - }), - - - new Muuri('.box1', { - dragEnabled: true, - dragContainer: document.body, - dragSort: () => grids, - sortData: { - amount: function (item, element) { - return parseFloat(element.getAttribute('data-amount')); - } - }, - dragStartPredicate: { - handle: '.item-content-main, .item-content-amount-moved' - } - }) .on('send', function(data) { - if (data.toGrid._id == 1) { - var object = getObjectById(data.item._id); - $.post('http:/redemrp_inventory/removeitem', JSON.stringify({data:object, target:targetPlayerId}), ); - } - onDragFinished(data)} - ) - .on('beforeReceive', function(data) { - if (data.fromGrid._id == 1) { - var object = getObjectById(data.item._id); - $.post('http:/redemrp_inventory/additem', JSON.stringify({data:object , target:targetPlayerId}), ); - } - }) - .on('dragStart', function(item) { - item.getElement().style.width = item.getWidth() + 'px'; - item.getElement().style.height = item.getHeight() + 'px'; - }) - .on('dragReleaseEnd', function(item) { - item.getElement().style.width = '15.2%'; - item.getElement().style.height = '8vh'; - grids.forEach(function(grid) { - grid.refreshItems(); - }); - }), - - - new Muuri('.box2', { - dragEnabled: true, - dragSort: () => grids, - dragContainer: document.body, - dragStartPredicate: { - - handle: '.item-content-main, .item-content-amount-moved' - } - }) - .on('receive', function(data) { - if (data.fromGrid._id == 2) { - var object = getObjectById(data.item._id); - - $.post('http:/redemrp_inventory/dropitem', JSON.stringify({data:object}), ); - }else{ - ItemBack(data); - } - }) - .on('send', data => onDragFinished(data)) - .on('dragStart', function(item) { - item.getElement().style.width = item.getWidth() + 'px'; - item.getElement().style.height = item.getHeight() + 'px'; - }) - .on('dragReleaseEnd', function(item) { - item.getElement().style.width = '15.2%'; - item.getElement().style.height = '8vh'; - grids.forEach(function(grid) { - grid.refreshItems(); - }); - }), - - - new Muuri('.box3', { - dragEnabled: true, - dragSort: () => grids, - dragContainer: document.body, - dragStartPredicate: { - - handle: '.item-content-main, .item-content-amount-moved' - } - }) + new Muuri('.box0', { + dragEnabled: true, + dragContainer: document.body, + dragSort: () => grids, + sortData: { + amount: function(item, element) { + return parseFloat(element.getAttribute('data-amount')); + } + }, + dragStartPredicate: { + handle: '.item-content-main, .item-content-amount-moved' + } + }).on('send', data => onDragFinished(data)) + .on('dragStart', function(item) { + item.getElement().style.width = item.getWidth() + 'px'; + item.getElement().style.height = item.getHeight() + 'px'; + }) + .on('dragReleaseEnd', function(item) { + item.getElement().style.width = '16%'; + item.getElement().style.height = '6vh'; + grids.forEach(function(grid) { + grid.refreshItems(); + }); + }), + + + new Muuri('.box1', { + dragEnabled: true, + dragContainer: document.body, + dragSort: () => grids, + sortData: { + amount: function(item, element) { + return parseFloat(element.getAttribute('data-amount')); + } + }, + dragStartPredicate: { + handle: '.item-content-main, .item-content-amount-moved' + } + }).on('send', function(data) { + if (data.toGrid._id == 1) { + var object = getObjectById(data.item._id); + $.post(`https://${GetParentResourceName()}/removeitem`, JSON.stringify({ + data: object, + target: targetPlayerId + })); + } + onDragFinished(data) + }) + .on('beforeReceive', function(data) { + if (data.fromGrid._id == 1) { + var object = getObjectById(data.item._id); + $.post(`https://${GetParentResourceName()}/additem`, JSON.stringify({ + data: object, + target: targetPlayerId + })); + } + }) + .on('dragStart', function(item) { + item.getElement().style.width = item.getWidth() + 'px'; + item.getElement().style.height = item.getHeight() + 'px'; + }) + .on('dragReleaseEnd', function(item) { + item.getElement().style.width = '16%'; + item.getElement().style.height = '6vh'; + grids.forEach(function(grid) { + grid.refreshItems(); + }); + }), + + /* + new Muuri('.box2', { + dragEnabled: true, + dragSort: () => grids, + dragContainer: document.body, + dragStartPredicate: { + + handle: '.item-content-main, .item-content-amount-moved' + } + }) .on('receive', function(data) { + if (data.fromGrid._id == 2) { + var object = getObjectById(data.item._id); + + $.post(`https://${GetParentResourceName()}/dropitem`, JSON.stringify({ + data: object + }), ); + } else { + ItemBack(data); + } + }) + .on('send', data => onDragFinished(data)) + .on('dragStart', function(item) { + item.getElement().style.width = item.getWidth() + 'px'; + item.getElement().style.height = item.getHeight() + 'px'; + }) + .on('dragReleaseEnd', function(item) { + item.getElement().style.width = '15.2%'; + item.getElement().style.height = '8vh'; + grids.forEach(function(grid) { + grid.refreshItems(); + }); + }), + - if (data.fromGrid._id == 2) { - var object = getObjectById(data.item._id); - $.post('http:/redemrp_inventory/useitem', JSON.stringify({data:object}), ); - ItemBack(data); - }else{ - ItemBack(data); - } - }) - .on('send', data => onDragFinished(data)) - .on('dragStart', function(item) { - item.getElement().style.width = item.getWidth() + 'px'; - item.getElement().style.height = item.getHeight() + 'px'; - }) - .on('dragReleaseEnd', function(item) { - item.getElement().style.width = '15.2%'; - item.getElement().style.height = '8vh'; - grids.forEach(function(grid) { - grid.refreshItems(); - }); - }), - - new Muuri('.slot1', { - dragEnabled: true, - dragSort: () => grids, - dragContainer: document.body, - dragStartPredicate: { - handle: '.item-content-main, .item-content-amount-moved' - } - }).on('send', data => onDragFinished(data)) - .on('receive', function(data) { - if (GetNumberOfItems(data) > 1 || (data.fromGrid._id < 4 && data.fromGrid._id != 2)) { - ItemBack(data); - } - }) - .on('dragStart', function(item) { - item.getElement().style.width = item.getWidth() + 'px'; - item.getElement().style.height = item.getHeight() + 'px'; - }) - .on('dragReleaseEnd', function(item) { - item.getElement().style.width = '85%'; - item.getElement().style.height = '85%'; - }), - - new Muuri('.slot2', { - dragEnabled: true, - dragSort: () => grids, - dragContainer: document.body, - dragStartPredicate: { - handle: '.item-content-main, .item-content-amount-moved' - } - }).on('send', data => onDragFinished(data)).on('receive', function(data) { - if (GetNumberOfItems(data) > 1 || (data.fromGrid._id < 4 && data.fromGrid._id != 2)) { - ItemBack(data); - } - }) - .on('dragStart', function(item) { - item.getElement().style.width = item.getWidth() + 'px'; - item.getElement().style.height = item.getHeight() + 'px'; - }) - .on('dragReleaseEnd', function(item) { - item.getElement().style.width = '85%'; - item.getElement().style.height = '85%'; - - }), - - - new Muuri('.slot3', { - dragEnabled: true, - dragSort: () => grids, - dragContainer: document.body, - dragStartPredicate: { - handle: '.item-content-main, .item-content-amount-moved' - } - }).on('send', data => onDragFinished(data)).on('receive', function(data) { - if (GetNumberOfItems(data) > 1 || (data.fromGrid._id < 4 && data.fromGrid._id != 2)) { - ItemBack(data); - } - }) - .on('dragStart', function(item) { - item.getElement().style.width = item.getWidth() + 'px'; - item.getElement().style.height = item.getHeight() + 'px'; - }) - .on('dragReleaseEnd', function(item) { - item.getElement().style.width = '85%'; - item.getElement().style.height = '85%'; - - }), - - new Muuri('.slot4', { - dragEnabled: true, - dragSort: () => grids, - dragContainer: document.body, - dragStartPredicate: { - handle: '.item-content-main, .item-content-amount-moved' - } - }).on('send', data => onDragFinished(data)).on('receive', function(data) { - if (GetNumberOfItems(data) > 1 || (data.fromGrid._id < 4 && data.fromGrid._id != 2)) { - ItemBack(data); - } - }) - .on('dragStart', function(item) { - item.getElement().style.width = item.getWidth() + 'px'; - item.getElement().style.height = item.getHeight() + 'px'; - }) - .on('dragReleaseEnd', function(item) { - item.getElement().style.width = '85%'; - item.getElement().style.height = '85%'; - - }), - - new Muuri('.slot5', { - dragEnabled: true, - dragSort: () => grids, - dragContainer: document.body, - dragStartPredicate: { - handle: '.item-content-main, .item-content-amount-moved' - } - }).on('send', data => onDragFinished(data)).on('receive', function(data) { - if (GetNumberOfItems(data) > 1 || (data.fromGrid._id < 4 && data.fromGrid._id != 2)) { - ItemBack(data); - } - }) - .on('dragStart', function(item) { - item.getElement().style.width = item.getWidth() + 'px'; - item.getElement().style.height = item.getHeight() + 'px'; - }) - .on('dragReleaseEnd', function(item) { - item.getElement().style.width = '85%'; - item.getElement().style.height = '85%'; - - }), - - new Muuri('.slot6', { - dragEnabled: true, - dragSort: () => grids, - dragContainer: document.body, - dragStartPredicate: { - handle: '.item-content-main, .item-content-amount-moved' - } - }).on('send', data => onDragFinished(data)).on('receive', function(data) { - if (GetNumberOfItems(data) > 1 || (data.fromGrid._id < 4 && data.fromGrid._id != 2)) { - ItemBack(data); - } - }) - .on('dragStart', function(item) { - item.getElement().style.width = item.getWidth() + 'px'; - item.getElement().style.height = item.getHeight() + 'px'; - }) - .on('dragReleaseEnd', function(item) { - item.getElement().style.width = '85%'; - item.getElement().style.height = '85%'; - - }), - - new Muuri('.slot7', { - dragEnabled: true, - dragSort: () => grids, - dragContainer: document.body, - dragStartPredicate: { - handle: '.item-content-main, .item-content-amount-moved' - } - }).on('send', data => onDragFinished(data)).on('receive', function(data) { - if (GetNumberOfItems(data) > 1 || (data.fromGrid._id < 4 && data.fromGrid._id != 2)) { - ItemBack(data); - } - }) - .on('dragStart', function(item) { - item.getElement().style.width = item.getWidth() + 'px'; - item.getElement().style.height = item.getHeight() + 'px'; - }) - .on('dragReleaseEnd', function(item) { - item.getElement().style.width = '85%'; - item.getElement().style.height = '85%'; - - }), - - new Muuri('.slot8', { - dragEnabled: true, - dragSort: () => grids, - dragContainer: document.body, - dragStartPredicate: { - handle: '.item-content-main, .item-content-amount-moved' - } - }).on('send', data => onDragFinished(data)).on('receive', function(data) { - if (GetNumberOfItems(data) > 1 || (data.fromGrid._id < 4 && data.fromGrid._id != 2)) { - ItemBack(data); - } - }) - .on('dragStart', function(item) { - item.getElement().style.width = item.getWidth() + 'px'; - item.getElement().style.height = item.getHeight() + 'px'; - }) - .on('dragReleaseEnd', function(item) { - item.getElement().style.width = '85%'; - item.getElement().style.height = '85%'; - - }), - - new Muuri('.slot9', { - dragEnabled: true, - dragSort: () => grids, - dragContainer: document.body, - dragStartPredicate: { - handle: '.item-content-main, .item-content-amount-moved' - } - }).on('send', data => onDragFinished(data)).on('receive', function(data) { - if (GetNumberOfItems(data) > 1 || (data.fromGrid._id < 4 && data.fromGrid._id != 2)) { - ItemBack(data); - } - }) - .on('dragStart', function(item) { - item.getElement().style.width = item.getWidth() + 'px'; - item.getElement().style.height = item.getHeight() + 'px'; - }) - - .on('dragReleaseEnd', function(item) { - item.getElement().style.width = '85%'; - item.getElement().style.height = '85%'; - }), + new Muuri('.box3', { + dragEnabled: true, + dragSort: () => grids, + dragContainer: document.body, + dragStartPredicate: { + + handle: '.item-content-main, .item-content-amount-moved' + } + }) + .on('receive', function(data) { + + if (data.fromGrid._id == 2) { + var object = getObjectById(data.item._id); + $.post(`https://${GetParentResourceName()}/useitem`, JSON.stringify({ + data: object + }), ); + ItemBack(data); + } else { + ItemBack(data); + } + }) + .on('send', data => onDragFinished(data)) + .on('dragStart', function(item) { + item.getElement().style.width = item.getWidth() + 'px'; + item.getElement().style.height = item.getHeight() + 'px'; + }) + .on('dragReleaseEnd', function(item) { + item.getElement().style.width = '15.2%'; + item.getElement().style.height = '8vh'; + grids.forEach(function(grid) { + grid.refreshItems(); + }); + }),*/ + + new Muuri('.slot1', { + dragEnabled: true, + dragSort: () => grids, + dragContainer: document.body, + dragStartPredicate: { + handle: '.item-content-main, .item-content-amount-moved' + } + }).on('send', data => onDragFinished(data)) + .on('receive', function(data) { + if (GetNumberOfItems(data) > 1 || (data.fromGrid._id < 4 && data.fromGrid._id != 2)) { + ItemBack(data); + } + }) + .on('dragStart', function(item) { + item.getElement().style.width = item.getWidth() + 'px'; + item.getElement().style.height = item.getHeight() + 'px'; + }) + .on('dragReleaseEnd', function(item) { + item.getElement().style.width = '85%'; + item.getElement().style.height = '85%'; + }), + + new Muuri('.slot2', { + dragEnabled: true, + dragSort: () => grids, + dragContainer: document.body, + dragStartPredicate: { + handle: '.item-content-main, .item-content-amount-moved' + } + }).on('send', data => onDragFinished(data)).on('receive', function(data) { + if (GetNumberOfItems(data) > 1 || (data.fromGrid._id < 4 && data.fromGrid._id != 2)) { + ItemBack(data); + } + }) + .on('dragStart', function(item) { + item.getElement().style.width = item.getWidth() + 'px'; + item.getElement().style.height = item.getHeight() + 'px'; + }) + .on('dragReleaseEnd', function(item) { + item.getElement().style.width = '85%'; + item.getElement().style.height = '85%'; + + }), + + + new Muuri('.slot3', { + dragEnabled: true, + dragSort: () => grids, + dragContainer: document.body, + dragStartPredicate: { + handle: '.item-content-main, .item-content-amount-moved' + } + }).on('send', data => onDragFinished(data)).on('receive', function(data) { + if (GetNumberOfItems(data) > 1 || (data.fromGrid._id < 4 && data.fromGrid._id != 2)) { + ItemBack(data); + } + }) + .on('dragStart', function(item) { + item.getElement().style.width = item.getWidth() + 'px'; + item.getElement().style.height = item.getHeight() + 'px'; + }) + .on('dragReleaseEnd', function(item) { + item.getElement().style.width = '85%'; + item.getElement().style.height = '85%'; + + }), + + new Muuri('.slot4', { + dragEnabled: true, + dragSort: () => grids, + dragContainer: document.body, + dragStartPredicate: { + handle: '.item-content-main, .item-content-amount-moved' + } + }).on('send', data => onDragFinished(data)).on('receive', function(data) { + if (GetNumberOfItems(data) > 1 || (data.fromGrid._id < 4 && data.fromGrid._id != 2)) { + ItemBack(data); + } + }) + .on('dragStart', function(item) { + item.getElement().style.width = item.getWidth() + 'px'; + item.getElement().style.height = item.getHeight() + 'px'; + }) + .on('dragReleaseEnd', function(item) { + item.getElement().style.width = '85%'; + item.getElement().style.height = '85%'; + + }), + + new Muuri('.slot5', { + dragEnabled: true, + dragSort: () => grids, + dragContainer: document.body, + dragStartPredicate: { + handle: '.item-content-main, .item-content-amount-moved' + } + }).on('send', data => onDragFinished(data)).on('receive', function(data) { + if (GetNumberOfItems(data) > 1 || (data.fromGrid._id < 4 && data.fromGrid._id != 2)) { + ItemBack(data); + } + }) + .on('dragStart', function(item) { + item.getElement().style.width = item.getWidth() + 'px'; + item.getElement().style.height = item.getHeight() + 'px'; + }) + .on('dragReleaseEnd', function(item) { + item.getElement().style.width = '85%'; + item.getElement().style.height = '85%'; + + }), + + new Muuri('.slot6', { + dragEnabled: true, + dragSort: () => grids, + dragContainer: document.body, + dragStartPredicate: { + handle: '.item-content-main, .item-content-amount-moved' + } + }).on('send', data => onDragFinished(data)).on('receive', function(data) { + if (GetNumberOfItems(data) > 1 || (data.fromGrid._id < 4 && data.fromGrid._id != 2)) { + ItemBack(data); + } + }) + .on('dragStart', function(item) { + item.getElement().style.width = item.getWidth() + 'px'; + item.getElement().style.height = item.getHeight() + 'px'; + }) + .on('dragReleaseEnd', function(item) { + item.getElement().style.width = '85%'; + item.getElement().style.height = '85%'; + + }), + + new Muuri('.slot7', { + dragEnabled: true, + dragSort: () => grids, + dragContainer: document.body, + dragStartPredicate: { + handle: '.item-content-main, .item-content-amount-moved' + } + }).on('send', data => onDragFinished(data)).on('receive', function(data) { + if (GetNumberOfItems(data) > 1 || (data.fromGrid._id < 4 && data.fromGrid._id != 2)) { + ItemBack(data); + } + }) + .on('dragStart', function(item) { + item.getElement().style.width = item.getWidth() + 'px'; + item.getElement().style.height = item.getHeight() + 'px'; + }) + .on('dragReleaseEnd', function(item) { + item.getElement().style.width = '85%'; + item.getElement().style.height = '85%'; + + }), + + new Muuri('.slot8', { + dragEnabled: true, + dragSort: () => grids, + dragContainer: document.body, + dragStartPredicate: { + handle: '.item-content-main, .item-content-amount-moved' + } + }).on('send', data => onDragFinished(data)).on('receive', function(data) { + if (GetNumberOfItems(data) > 1 || (data.fromGrid._id < 4 && data.fromGrid._id != 2)) { + ItemBack(data); + } + }) + .on('dragStart', function(item) { + item.getElement().style.width = item.getWidth() + 'px'; + item.getElement().style.height = item.getHeight() + 'px'; + }) + .on('dragReleaseEnd', function(item) { + item.getElement().style.width = '85%'; + item.getElement().style.height = '85%'; + + }), + + new Muuri('.slot9', { + dragEnabled: true, + dragSort: () => grids, + dragContainer: document.body, + dragStartPredicate: { + handle: '.item-content-main, .item-content-amount-moved' + } + }).on('send', data => onDragFinished(data)).on('receive', function(data) { + if (GetNumberOfItems(data) > 1 || (data.fromGrid._id < 4 && data.fromGrid._id != 2)) { + ItemBack(data); + } + }) + .on('dragStart', function(item) { + item.getElement().style.width = item.getWidth() + 'px'; + item.getElement().style.height = item.getHeight() + 'px'; + }) + + .on('dragReleaseEnd', function(item) { + item.getElement().style.width = '85%'; + item.getElement().style.height = '85%'; + }), ]; function hide() { - document.body.style.display = 'none'; + SplitMode = false; + $("body").css("display", "none"); + $("#splitBox").hide(); + $(".inventory").css("pointer-events", "auto"); + $(".inventory").css("opacity", "1.0"); + $(".grid").css("pointer-events", "auto"); + $(".grid").css("opacity", "1.0"); } function GetNumberOfItems(data) { - return grids[data.toGrid._id - 1]._items.length; + return grids[data.toGrid._id - 1]._items.length; } -$( "#craftButton" ).click(function() { - const message = []; +$("#craftButton").click(function() { + const message = []; - for (i = 4; i <= 12; i++) { - message.push(GetCraftingSlotData(i)); - } + for (i = 2; i <= 10; i++) { + message.push(GetCraftingSlotData(i)); + } - $.post('http:/redemrp_inventory/craft', JSON.stringify(message)); + $.post(`https://${GetParentResourceName()}/craft`, JSON.stringify(message)); }); -function GetCraftingSlotData(id) -{ - var name = "empty"; - var amount = 0; - var meta = []; - - if (grids[id]._items[0] != null) { - var itemId = grids[id]._items[0]._id - var object = getObjectById(itemId); - name = object.name; - amount = object.amount; - meta = object.meta; - } +function GetCraftingSlotData(id) { + var name = "empty"; + var amount = 0; + var meta = []; + + if (grids[id]._items[0] != null) { + var itemId = grids[id]._items[0]._id + var object = getObjectById(itemId); + name = object.name; + amount = object.amount; + meta = object.meta; + } - return [name, amount, meta] + return [name, amount, meta] } function ItemBack(data) { - var object = getObjectById(data.item._id); - if (data.fromGrid._id > 4) { - addObject({ - name: object.name, - meta: object.meta, - label : object.label, - type : object.type, - amount: object.amount, - imgsrc: object.imgsrc, - box: 1, - }); - }else{ - addObject({ - name: object.name, - meta: object.meta, - label : object.label, - type : object.type, - amount: object.amount, - imgsrc: object.imgsrc, - box: data.fromGrid._id - 1 - }); - } -removeObjects([object]); -grids[0].sort('amount:desc',{layout: 'instant'}); -grids[1].sort('amount:desc',{layout: 'instant'}); + var object = getObjectById(data.item._id); + if (data.fromGrid._id > 4) { + addObject({ + name: object.name, + meta: object.meta, + label: object.label, + type: object.type, + amount: object.amount, + imgsrc: object.imgsrc, + box: 1, + }); + } else { + addObject({ + name: object.name, + meta: object.meta, + label: object.label, + type: object.type, + amount: object.amount, + imgsrc: object.imgsrc, + box: data.fromGrid._id - 1 + }); + } + removeObjects([object]); + grids[0].sort('amount:desc', { + layout: 'instant' + }); + grids[1].sort('amount:desc', { + layout: 'instant' + }); } function show(playerInventory, otherInventory, crafting) { - document.body.style.display = 'block'; + $("body").css("display", 'block'); + + if(otherInventory){ + //console.log("Other inventory") + $("#selfinv").css("height", "40.5%"); + SecondInventoryActive = true; + } else { + //console.log("NO Other inventory") + $("#selfinv").css("height", "80.5%"); + SecondInventoryActive = false; + } - document.getElementsByClassName('box0')[0].style.display = (otherInventory) ? 'block' : 'none'; - document.getElementsByClassName('box1')[0].style.display = (playerInventory) ? 'block' : 'none'; - document.getElementsByClassName('grid')[0].style.display = (crafting) ? 'block' : 'none'; - document.getElementsByClassName('invCraft')[0].style.display = (crafting) ? 'block' : 'none'; + $(".box0").css("display", (otherInventory) ? 'block' : 'none'); + $(".box1").css("display", (playerInventory) ? 'block' : 'none'); + $(".grid").css("display", (crafting) ? 'block' : 'none'); + $('.invCraft').css("display", (crafting) ? 'block' : 'none'); + //$(".grid").css("display", 'none'); + //$(".invCraft").css("display", 'none'); } + var shiftactive = false; $(document).keydown(function(e) { - if (e.keyCode == 16) { - shiftactive = true; - } + if (e.keyCode == 16) { + shiftactive = true; + } }); - grids[1].on('dragMove', function(item, event) { +grids[1].on('dragMove', function(item, event) { var i; - if (shiftactive){ - for (i = 0; i < objects.length; i++) { - - if (parseInt(item._id) !== parseInt(objects[i].id)) { - if (getObjectHTML(item._id) != null) { - var coords = getObjectHTML(item._id).getBoundingClientRect(); - var coords2 = getObjectHTML(objects[i].id).getBoundingClientRect(); - var a = coords.top - coords2.top; - var b = coords.left - coords2.left; - var c = Math.sqrt(a * a + b * b); - - if (c < 40) { - var object = getObjectById(objects[i].id); - var object2 = getObjectById(item._id); - if (object2.name == object.name && deepEqual(object2.meta, object.meta)) { - - boxContent = getObjectHTML(item._id); - boxContent.lastChild.innerHTML = parseInt(object2.amount + object.amount); - object2.amount = parseInt(object2.amount + object.amount); - removeObjects([object]); - } - } - } - } - shiftactive = false; - } + if (shiftactive) { + for (i = 0; i < objects.length; i++) { + + if (parseInt(item._id) !== parseInt(objects[i].id)) { + if (getObjectHTML(item._id) != null) { + var coords = getObjectHTML(item._id).getBoundingClientRect(); + var coords2 = getObjectHTML(objects[i].id).getBoundingClientRect(); + var a = coords.top - coords2.top; + var b = coords.left - coords2.left; + var c = Math.sqrt(a * a + b * b); + + if (c < 40) { + var object = getObjectById(objects[i].id); + var object2 = getObjectById(item._id); + if (object2.name == object.name && deepEqual(object2.meta, object.meta)) { + + boxContent = getObjectHTML(item._id); + boxContent.lastChild.innerHTML = parseInt(object2.amount + object.amount); + object2.amount = parseInt(object2.amount + object.amount); + removeObjects([object]); + } + } + } + } + shiftactive = false; + } } - }); +}); function Over(item, desc) { - var name = document.getElementById("info2"); - var opis = document.getElementById("info3"); - if (item == null) { - name.innerHTML = ""; - opis.innerHTML = ""; - } else { - name.innerHTML = item; - opis.innerHTML = desc; - } + var name = document.getElementById("info2"); + var opis = document.getElementById("info3"); + if (item == null) { + name.innerHTML = ""; + opis.innerHTML = ""; + } else { + name.innerHTML = item; + opis.innerHTML = desc; + } } -async function getItems(data, secondInventory, targetPlayer , weight) { - objectsIn = data; - targetPlayerId = targetPlayer; - removeObjects(objects); -for (x in data) { - data[x].box = 1; - addObject(data[x]); - } - if (secondInventory){ - for (x in secondInventory) { - secondInventory[x].box = 0; - addObject(secondInventory[x]); - } - } - var weight_object = document.getElementById("weight"); -weight_object.innerHTML = Math.round(weight * 100) / 100+" / 24 KG"; -grids[0].sort('amount:desc',{layout: 'instant'}); -grids[1].sort('amount:desc',{layout: 'instant'}); +async function getItems(data, secondInventory, targetPlayer, weight) { + objectsIn = data; + targetPlayerId = targetPlayer; + removeObjects(objects); + for (x in data) { + data[x].box = 1; + addObject(data[x]); + } + if (secondInventory) { + for (x in secondInventory) { + secondInventory[x].box = 0; + addObject(secondInventory[x]); + } + } + var weight_object = document.getElementById("weight"); + weight_object.innerHTML = Math.round(weight * 100) / 100 + " / 24 KG"; + grids[0].sort('amount:desc', { + layout: 'instant' + }); + grids[1].sort('amount:desc', { + layout: 'instant' + }); } $(document).keyup(function(e) { - if (e.keyCode == 27 || e.keyCode == 66 || e.keyCode == 8) { //hide eq - - hide(); - $.post('http:/redemrp_inventory/close'); - } -}); - - - + if ((e.keyCode == 27 || e.keyCode == 66) && !SplitMode) { //hide eq + console.log("SplitMode = " + SplitMode); + hide(); + $.post(`https://${GetParentResourceName()}/close`); + } +}); \ No newline at end of file diff --git a/html/js/jquery-1.4.1.min.js b/html/js/jquery-1.4.1.min.js deleted file mode 100644 index 0c7294c..0000000 --- a/html/js/jquery-1.4.1.min.js +++ /dev/null @@ -1,152 +0,0 @@ -/*! - * jQuery JavaScript Library v1.4.1 - * http://jquery.com/ - * - * Copyright 2010, John Resig - * Dual licensed under the MIT or GPL Version 2 licenses. - * http://jquery.org/license - * - * Includes Sizzle.js - * http://sizzlejs.com/ - * Copyright 2010, The Dojo Foundation - * Released under the MIT, BSD, and GPL Licenses. - * - * Date: Mon Jan 25 19:43:33 2010 -0500 - */ -(function(z,v){function la(){if(!c.isReady){try{r.documentElement.doScroll("left")}catch(a){setTimeout(la,1);return}c.ready()}}function Ma(a,b){b.src?c.ajax({url:b.src,async:false,dataType:"script"}):c.globalEval(b.text||b.textContent||b.innerHTML||"");b.parentNode&&b.parentNode.removeChild(b)}function X(a,b,d,f,e,i){var j=a.length;if(typeof b==="object"){for(var n in b)X(a,n,b[n],f,e,d);return a}if(d!==v){f=!i&&f&&c.isFunction(d);for(n=0;n-1){i=j.data;i.beforeFilter&&i.beforeFilter[a.type]&&!i.beforeFilter[a.type](a)||f.push(j.selector)}else delete x[o]}i=c(a.target).closest(f, -a.currentTarget);m=0;for(s=i.length;m)[^>]*$|^#([\w-]+)$/,Qa=/^.[^:#\[\.,]*$/,Ra=/\S/,Sa=/^(\s|\u00A0)+|(\s|\u00A0)+$/g,Ta=/^<(\w+)\s*\/?>(?:<\/\1>)?$/,O=navigator.userAgent, -va=false,P=[],L,$=Object.prototype.toString,aa=Object.prototype.hasOwnProperty,ba=Array.prototype.push,Q=Array.prototype.slice,wa=Array.prototype.indexOf;c.fn=c.prototype={init:function(a,b){var d,f;if(!a)return this;if(a.nodeType){this.context=this[0]=a;this.length=1;return this}if(typeof a==="string")if((d=Pa.exec(a))&&(d[1]||!b))if(d[1]){f=b?b.ownerDocument||b:r;if(a=Ta.exec(a))if(c.isPlainObject(b)){a=[r.createElement(a[1])];c.fn.attr.call(a,b,true)}else a=[f.createElement(a[1])];else{a=ra([d[1]], -[f]);a=(a.cacheable?a.fragment.cloneNode(true):a.fragment).childNodes}}else{if(b=r.getElementById(d[2])){if(b.id!==d[2])return S.find(a);this.length=1;this[0]=b}this.context=r;this.selector=a;return this}else if(!b&&/^\w+$/.test(a)){this.selector=a;this.context=r;a=r.getElementsByTagName(a)}else return!b||b.jquery?(b||S).find(a):c(b).find(a);else if(c.isFunction(a))return S.ready(a);if(a.selector!==v){this.selector=a.selector;this.context=a.context}return c.isArray(a)?this.setArray(a):c.makeArray(a, -this)},selector:"",jquery:"1.4.1",length:0,size:function(){return this.length},toArray:function(){return Q.call(this,0)},get:function(a){return a==null?this.toArray():a<0?this.slice(a)[0]:this[a]},pushStack:function(a,b,d){a=c(a||null);a.prevObject=this;a.context=this.context;if(b==="find")a.selector=this.selector+(this.selector?" ":"")+d;else if(b)a.selector=this.selector+"."+b+"("+d+")";return a},setArray:function(a){this.length=0;ba.apply(this,a);return this},each:function(a,b){return c.each(this, -a,b)},ready:function(a){c.bindReady();if(c.isReady)a.call(r,c);else P&&P.push(a);return this},eq:function(a){return a===-1?this.slice(a):this.slice(a,+a+1)},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},slice:function(){return this.pushStack(Q.apply(this,arguments),"slice",Q.call(arguments).join(","))},map:function(a){return this.pushStack(c.map(this,function(b,d){return a.call(b,d,b)}))},end:function(){return this.prevObject||c(null)},push:ba,sort:[].sort,splice:[].splice}; -c.fn.init.prototype=c.fn;c.extend=c.fn.extend=function(){var a=arguments[0]||{},b=1,d=arguments.length,f=false,e,i,j,n;if(typeof a==="boolean"){f=a;a=arguments[1]||{};b=2}if(typeof a!=="object"&&!c.isFunction(a))a={};if(d===b){a=this;--b}for(;b
a";var e=d.getElementsByTagName("*"),i=d.getElementsByTagName("a")[0];if(!(!e||!e.length||!i)){c.support= -{leadingWhitespace:d.firstChild.nodeType===3,tbody:!d.getElementsByTagName("tbody").length,htmlSerialize:!!d.getElementsByTagName("link").length,style:/red/.test(i.getAttribute("style")),hrefNormalized:i.getAttribute("href")==="/a",opacity:/^0.55$/.test(i.style.opacity),cssFloat:!!i.style.cssFloat,checkOn:d.getElementsByTagName("input")[0].value==="on",optSelected:r.createElement("select").appendChild(r.createElement("option")).selected,checkClone:false,scriptEval:false,noCloneEvent:true,boxModel:null}; -b.type="text/javascript";try{b.appendChild(r.createTextNode("window."+f+"=1;"))}catch(j){}a.insertBefore(b,a.firstChild);if(z[f]){c.support.scriptEval=true;delete z[f]}a.removeChild(b);if(d.attachEvent&&d.fireEvent){d.attachEvent("onclick",function n(){c.support.noCloneEvent=false;d.detachEvent("onclick",n)});d.cloneNode(true).fireEvent("onclick")}d=r.createElement("div");d.innerHTML="";a=r.createDocumentFragment();a.appendChild(d.firstChild); -c.support.checkClone=a.cloneNode(true).cloneNode(true).lastChild.checked;c(function(){var n=r.createElement("div");n.style.width=n.style.paddingLeft="1px";r.body.appendChild(n);c.boxModel=c.support.boxModel=n.offsetWidth===2;r.body.removeChild(n).style.display="none"});a=function(n){var o=r.createElement("div");n="on"+n;var m=n in o;if(!m){o.setAttribute(n,"return;");m=typeof o[n]==="function"}return m};c.support.submitBubbles=a("submit");c.support.changeBubbles=a("change");a=b=d=e=i=null}})();c.props= -{"for":"htmlFor","class":"className",readonly:"readOnly",maxlength:"maxLength",cellspacing:"cellSpacing",rowspan:"rowSpan",colspan:"colSpan",tabindex:"tabIndex",usemap:"useMap",frameborder:"frameBorder"};var G="jQuery"+J(),Ua=0,xa={},Va={};c.extend({cache:{},expando:G,noData:{embed:true,object:true,applet:true},data:function(a,b,d){if(!(a.nodeName&&c.noData[a.nodeName.toLowerCase()])){a=a==z?xa:a;var f=a[G],e=c.cache;if(!b&&!f)return null;f||(f=++Ua);if(typeof b==="object"){a[G]=f;e=e[f]=c.extend(true, -{},b)}else e=e[f]?e[f]:typeof d==="undefined"?Va:(e[f]={});if(d!==v){a[G]=f;e[b]=d}return typeof b==="string"?e[b]:e}},removeData:function(a,b){if(!(a.nodeName&&c.noData[a.nodeName.toLowerCase()])){a=a==z?xa:a;var d=a[G],f=c.cache,e=f[d];if(b){if(e){delete e[b];c.isEmptyObject(e)&&c.removeData(a)}}else{try{delete a[G]}catch(i){a.removeAttribute&&a.removeAttribute(G)}delete f[d]}}}});c.fn.extend({data:function(a,b){if(typeof a==="undefined"&&this.length)return c.data(this[0]);else if(typeof a==="object")return this.each(function(){c.data(this, -a)});var d=a.split(".");d[1]=d[1]?"."+d[1]:"";if(b===v){var f=this.triggerHandler("getData"+d[1]+"!",[d[0]]);if(f===v&&this.length)f=c.data(this[0],a);return f===v&&d[1]?this.data(d[0]):f}else return this.trigger("setData"+d[1]+"!",[d[0],b]).each(function(){c.data(this,a,b)})},removeData:function(a){return this.each(function(){c.removeData(this,a)})}});c.extend({queue:function(a,b,d){if(a){b=(b||"fx")+"queue";var f=c.data(a,b);if(!d)return f||[];if(!f||c.isArray(d))f=c.data(a,b,c.makeArray(d));else f.push(d); -return f}},dequeue:function(a,b){b=b||"fx";var d=c.queue(a,b),f=d.shift();if(f==="inprogress")f=d.shift();if(f){b==="fx"&&d.unshift("inprogress");f.call(a,function(){c.dequeue(a,b)})}}});c.fn.extend({queue:function(a,b){if(typeof a!=="string"){b=a;a="fx"}if(b===v)return c.queue(this[0],a);return this.each(function(){var d=c.queue(this,a,b);a==="fx"&&d[0]!=="inprogress"&&c.dequeue(this,a)})},dequeue:function(a){return this.each(function(){c.dequeue(this,a)})},delay:function(a,b){a=c.fx?c.fx.speeds[a]|| -a:a;b=b||"fx";return this.queue(b,function(){var d=this;setTimeout(function(){c.dequeue(d,b)},a)})},clearQueue:function(a){return this.queue(a||"fx",[])}});var ya=/[\n\t]/g,ca=/\s+/,Wa=/\r/g,Xa=/href|src|style/,Ya=/(button|input)/i,Za=/(button|input|object|select|textarea)/i,$a=/^(a|area)$/i,za=/radio|checkbox/;c.fn.extend({attr:function(a,b){return X(this,a,b,true,c.attr)},removeAttr:function(a){return this.each(function(){c.attr(this,a,"");this.nodeType===1&&this.removeAttribute(a)})},addClass:function(a){if(c.isFunction(a))return this.each(function(o){var m= -c(this);m.addClass(a.call(this,o,m.attr("class")))});if(a&&typeof a==="string")for(var b=(a||"").split(ca),d=0,f=this.length;d-1)return true;return false},val:function(a){if(a===v){var b=this[0];if(b){if(c.nodeName(b,"option"))return(b.attributes.value|| -{}).specified?b.value:b.text;if(c.nodeName(b,"select")){var d=b.selectedIndex,f=[],e=b.options;b=b.type==="select-one";if(d<0)return null;var i=b?d:0;for(d=b?d+1:e.length;i=0;else if(c.nodeName(this,"select")){var x=c.makeArray(s);c("option",this).each(function(){this.selected=c.inArray(c(this).val(),x)>=0});if(!x.length)this.selectedIndex=-1}else this.value=s}})}});c.extend({attrFn:{val:true,css:true,html:true,text:true,data:true,width:true,height:true,offset:true},attr:function(a,b,d,f){if(!a||a.nodeType===3||a.nodeType===8)return v;if(f&&b in c.attrFn)return c(a)[b](d); -f=a.nodeType!==1||!c.isXMLDoc(a);var e=d!==v;b=f&&c.props[b]||b;if(a.nodeType===1){var i=Xa.test(b);if(b in a&&f&&!i){if(e){b==="type"&&Ya.test(a.nodeName)&&a.parentNode&&c.error("type property can't be changed");a[b]=d}if(c.nodeName(a,"form")&&a.getAttributeNode(b))return a.getAttributeNode(b).nodeValue;if(b==="tabIndex")return(b=a.getAttributeNode("tabIndex"))&&b.specified?b.value:Za.test(a.nodeName)||$a.test(a.nodeName)&&a.href?0:v;return a[b]}if(!c.support.style&&f&&b==="style"){if(e)a.style.cssText= -""+d;return a.style.cssText}e&&a.setAttribute(b,""+d);a=!c.support.hrefNormalized&&f&&i?a.getAttribute(b,2):a.getAttribute(b);return a===null?v:a}return c.style(a,b,d)}});var ab=function(a){return a.replace(/[^\w\s\.\|`]/g,function(b){return"\\"+b})};c.event={add:function(a,b,d,f){if(!(a.nodeType===3||a.nodeType===8)){if(a.setInterval&&a!==z&&!a.frameElement)a=z;if(!d.guid)d.guid=c.guid++;if(f!==v){d=c.proxy(d);d.data=f}var e=c.data(a,"events")||c.data(a,"events",{}),i=c.data(a,"handle"),j;if(!i){j= -function(){return typeof c!=="undefined"&&!c.event.triggered?c.event.handle.apply(j.elem,arguments):v};i=c.data(a,"handle",j)}if(i){i.elem=a;b=b.split(/\s+/);for(var n,o=0;n=b[o++];){var m=n.split(".");n=m.shift();if(o>1){d=c.proxy(d);if(f!==v)d.data=f}d.type=m.slice(0).sort().join(".");var s=e[n],x=this.special[n]||{};if(!s){s=e[n]={};if(!x.setup||x.setup.call(a,f,m,d)===false)if(a.addEventListener)a.addEventListener(n,i,false);else a.attachEvent&&a.attachEvent("on"+n,i)}if(x.add)if((m=x.add.call(a, -d,f,m,s))&&c.isFunction(m)){m.guid=m.guid||d.guid;m.data=m.data||d.data;m.type=m.type||d.type;d=m}s[d.guid]=d;this.global[n]=true}a=null}}},global:{},remove:function(a,b,d){if(!(a.nodeType===3||a.nodeType===8)){var f=c.data(a,"events"),e,i,j;if(f){if(b===v||typeof b==="string"&&b.charAt(0)===".")for(i in f)this.remove(a,i+(b||""));else{if(b.type){d=b.handler;b=b.type}b=b.split(/\s+/);for(var n=0;i=b[n++];){var o=i.split(".");i=o.shift();var m=!o.length,s=c.map(o.slice(0).sort(),ab);s=new RegExp("(^|\\.)"+ -s.join("\\.(?:.*\\.)?")+"(\\.|$)");var x=this.special[i]||{};if(f[i]){if(d){j=f[i][d.guid];delete f[i][d.guid]}else for(var A in f[i])if(m||s.test(f[i][A].type))delete f[i][A];x.remove&&x.remove.call(a,o,j);for(e in f[i])break;if(!e){if(!x.teardown||x.teardown.call(a,o)===false)if(a.removeEventListener)a.removeEventListener(i,c.data(a,"handle"),false);else a.detachEvent&&a.detachEvent("on"+i,c.data(a,"handle"));e=null;delete f[i]}}}}for(e in f)break;if(!e){if(A=c.data(a,"handle"))A.elem=null;c.removeData(a, -"events");c.removeData(a,"handle")}}}},trigger:function(a,b,d,f){var e=a.type||a;if(!f){a=typeof a==="object"?a[G]?a:c.extend(c.Event(e),a):c.Event(e);if(e.indexOf("!")>=0){a.type=e=e.slice(0,-1);a.exclusive=true}if(!d){a.stopPropagation();this.global[e]&&c.each(c.cache,function(){this.events&&this.events[e]&&c.event.trigger(a,b,this.handle.elem)})}if(!d||d.nodeType===3||d.nodeType===8)return v;a.result=v;a.target=d;b=c.makeArray(b);b.unshift(a)}a.currentTarget=d;(f=c.data(d,"handle"))&&f.apply(d, -b);f=d.parentNode||d.ownerDocument;try{if(!(d&&d.nodeName&&c.noData[d.nodeName.toLowerCase()]))if(d["on"+e]&&d["on"+e].apply(d,b)===false)a.result=false}catch(i){}if(!a.isPropagationStopped()&&f)c.event.trigger(a,b,f,true);else if(!a.isDefaultPrevented()){d=a.target;var j;if(!(c.nodeName(d,"a")&&e==="click")&&!(d&&d.nodeName&&c.noData[d.nodeName.toLowerCase()])){try{if(d[e]){if(j=d["on"+e])d["on"+e]=null;this.triggered=true;d[e]()}}catch(n){}if(j)d["on"+e]=j;this.triggered=false}}},handle:function(a){var b, -d;a=arguments[0]=c.event.fix(a||z.event);a.currentTarget=this;d=a.type.split(".");a.type=d.shift();b=!d.length&&!a.exclusive;var f=new RegExp("(^|\\.)"+d.slice(0).sort().join("\\.(?:.*\\.)?")+"(\\.|$)");d=(c.data(this,"events")||{})[a.type];for(var e in d){var i=d[e];if(b||f.test(i.type)){a.handler=i;a.data=i.data;i=i.apply(this,arguments);if(i!==v){a.result=i;if(i===false){a.preventDefault();a.stopPropagation()}}if(a.isImmediatePropagationStopped())break}}return a.result},props:"altKey attrChange attrName bubbles button cancelable charCode clientX clientY ctrlKey currentTarget data detail eventPhase fromElement handler keyCode layerX layerY metaKey newValue offsetX offsetY originalTarget pageX pageY prevValue relatedNode relatedTarget screenX screenY shiftKey srcElement target toElement view wheelDelta which".split(" "), -fix:function(a){if(a[G])return a;var b=a;a=c.Event(b);for(var d=this.props.length,f;d;){f=this.props[--d];a[f]=b[f]}if(!a.target)a.target=a.srcElement||r;if(a.target.nodeType===3)a.target=a.target.parentNode;if(!a.relatedTarget&&a.fromElement)a.relatedTarget=a.fromElement===a.target?a.toElement:a.fromElement;if(a.pageX==null&&a.clientX!=null){b=r.documentElement;d=r.body;a.pageX=a.clientX+(b&&b.scrollLeft||d&&d.scrollLeft||0)-(b&&b.clientLeft||d&&d.clientLeft||0);a.pageY=a.clientY+(b&&b.scrollTop|| -d&&d.scrollTop||0)-(b&&b.clientTop||d&&d.clientTop||0)}if(!a.which&&(a.charCode||a.charCode===0?a.charCode:a.keyCode))a.which=a.charCode||a.keyCode;if(!a.metaKey&&a.ctrlKey)a.metaKey=a.ctrlKey;if(!a.which&&a.button!==v)a.which=a.button&1?1:a.button&2?3:a.button&4?2:0;return a},guid:1E8,proxy:c.proxy,special:{ready:{setup:c.bindReady,teardown:c.noop},live:{add:function(a,b){c.extend(a,b||{});a.guid+=b.selector+b.live;b.liveProxy=a;c.event.add(this,b.live,na,b)},remove:function(a){if(a.length){var b= -0,d=new RegExp("(^|\\.)"+a[0]+"(\\.|$)");c.each(c.data(this,"events").live||{},function(){d.test(this.type)&&b++});b<1&&c.event.remove(this,a[0],na)}},special:{}},beforeunload:{setup:function(a,b,d){if(this.setInterval)this.onbeforeunload=d;return false},teardown:function(a,b){if(this.onbeforeunload===b)this.onbeforeunload=null}}}};c.Event=function(a){if(!this.preventDefault)return new c.Event(a);if(a&&a.type){this.originalEvent=a;this.type=a.type}else this.type=a;this.timeStamp=J();this[G]=true}; -c.Event.prototype={preventDefault:function(){this.isDefaultPrevented=Z;var a=this.originalEvent;if(a){a.preventDefault&&a.preventDefault();a.returnValue=false}},stopPropagation:function(){this.isPropagationStopped=Z;var a=this.originalEvent;if(a){a.stopPropagation&&a.stopPropagation();a.cancelBubble=true}},stopImmediatePropagation:function(){this.isImmediatePropagationStopped=Z;this.stopPropagation()},isDefaultPrevented:Y,isPropagationStopped:Y,isImmediatePropagationStopped:Y};var Aa=function(a){for(var b= -a.relatedTarget;b&&b!==this;)try{b=b.parentNode}catch(d){break}if(b!==this){a.type=a.data;c.event.handle.apply(this,arguments)}},Ba=function(a){a.type=a.data;c.event.handle.apply(this,arguments)};c.each({mouseenter:"mouseover",mouseleave:"mouseout"},function(a,b){c.event.special[a]={setup:function(d){c.event.add(this,b,d&&d.selector?Ba:Aa,a)},teardown:function(d){c.event.remove(this,b,d&&d.selector?Ba:Aa)}}});if(!c.support.submitBubbles)c.event.special.submit={setup:function(a,b,d){if(this.nodeName.toLowerCase()!== -"form"){c.event.add(this,"click.specialSubmit."+d.guid,function(f){var e=f.target,i=e.type;if((i==="submit"||i==="image")&&c(e).closest("form").length)return ma("submit",this,arguments)});c.event.add(this,"keypress.specialSubmit."+d.guid,function(f){var e=f.target,i=e.type;if((i==="text"||i==="password")&&c(e).closest("form").length&&f.keyCode===13)return ma("submit",this,arguments)})}else return false},remove:function(a,b){c.event.remove(this,"click.specialSubmit"+(b?"."+b.guid:""));c.event.remove(this, -"keypress.specialSubmit"+(b?"."+b.guid:""))}};if(!c.support.changeBubbles){var da=/textarea|input|select/i;function Ca(a){var b=a.type,d=a.value;if(b==="radio"||b==="checkbox")d=a.checked;else if(b==="select-multiple")d=a.selectedIndex>-1?c.map(a.options,function(f){return f.selected}).join("-"):"";else if(a.nodeName.toLowerCase()==="select")d=a.selectedIndex;return d}function ea(a,b){var d=a.target,f,e;if(!(!da.test(d.nodeName)||d.readOnly)){f=c.data(d,"_change_data");e=Ca(d);if(a.type!=="focusout"|| -d.type!=="radio")c.data(d,"_change_data",e);if(!(f===v||e===f))if(f!=null||e){a.type="change";return c.event.trigger(a,b,d)}}}c.event.special.change={filters:{focusout:ea,click:function(a){var b=a.target,d=b.type;if(d==="radio"||d==="checkbox"||b.nodeName.toLowerCase()==="select")return ea.call(this,a)},keydown:function(a){var b=a.target,d=b.type;if(a.keyCode===13&&b.nodeName.toLowerCase()!=="textarea"||a.keyCode===32&&(d==="checkbox"||d==="radio")||d==="select-multiple")return ea.call(this,a)},beforeactivate:function(a){a= -a.target;a.nodeName.toLowerCase()==="input"&&a.type==="radio"&&c.data(a,"_change_data",Ca(a))}},setup:function(a,b,d){for(var f in T)c.event.add(this,f+".specialChange."+d.guid,T[f]);return da.test(this.nodeName)},remove:function(a,b){for(var d in T)c.event.remove(this,d+".specialChange"+(b?"."+b.guid:""),T[d]);return da.test(this.nodeName)}};var T=c.event.special.change.filters}r.addEventListener&&c.each({focus:"focusin",blur:"focusout"},function(a,b){function d(f){f=c.event.fix(f);f.type=b;return c.event.handle.call(this, -f)}c.event.special[b]={setup:function(){this.addEventListener(a,d,true)},teardown:function(){this.removeEventListener(a,d,true)}}});c.each(["bind","one"],function(a,b){c.fn[b]=function(d,f,e){if(typeof d==="object"){for(var i in d)this[b](i,f,d[i],e);return this}if(c.isFunction(f)){e=f;f=v}var j=b==="one"?c.proxy(e,function(n){c(this).unbind(n,j);return e.apply(this,arguments)}):e;return d==="unload"&&b!=="one"?this.one(d,f,e):this.each(function(){c.event.add(this,d,j,f)})}});c.fn.extend({unbind:function(a, -b){if(typeof a==="object"&&!a.preventDefault){for(var d in a)this.unbind(d,a[d]);return this}return this.each(function(){c.event.remove(this,a,b)})},trigger:function(a,b){return this.each(function(){c.event.trigger(a,b,this)})},triggerHandler:function(a,b){if(this[0]){a=c.Event(a);a.preventDefault();a.stopPropagation();c.event.trigger(a,b,this[0]);return a.result}},toggle:function(a){for(var b=arguments,d=1;d0){y=t;break}}t=t[g]}l[q]=y}}}var f=/((?:\((?:\([^()]+\)|[^()]+)+\)|\[(?:\[[^[\]]*\]|['"][^'"]*['"]|[^[\]'"]+)+\]|\\.|[^ >+~,(\[\\]+)+|[>+~])(\s*,\s*)?((?:.|\r|\n)*)/g,e=0,i=Object.prototype.toString,j=false,n=true;[0,0].sort(function(){n=false;return 0});var o=function(g,h,k,l){k=k||[];var q=h=h||r;if(h.nodeType!==1&&h.nodeType!==9)return[];if(!g|| -typeof g!=="string")return k;for(var p=[],u,t,y,R,H=true,M=w(h),I=g;(f.exec(""),u=f.exec(I))!==null;){I=u[3];p.push(u[1]);if(u[2]){R=u[3];break}}if(p.length>1&&s.exec(g))if(p.length===2&&m.relative[p[0]])t=fa(p[0]+p[1],h);else for(t=m.relative[p[0]]?[h]:o(p.shift(),h);p.length;){g=p.shift();if(m.relative[g])g+=p.shift();t=fa(g,t)}else{if(!l&&p.length>1&&h.nodeType===9&&!M&&m.match.ID.test(p[0])&&!m.match.ID.test(p[p.length-1])){u=o.find(p.shift(),h,M);h=u.expr?o.filter(u.expr,u.set)[0]:u.set[0]}if(h){u= -l?{expr:p.pop(),set:A(l)}:o.find(p.pop(),p.length===1&&(p[0]==="~"||p[0]==="+")&&h.parentNode?h.parentNode:h,M);t=u.expr?o.filter(u.expr,u.set):u.set;if(p.length>0)y=A(t);else H=false;for(;p.length;){var D=p.pop();u=D;if(m.relative[D])u=p.pop();else D="";if(u==null)u=h;m.relative[D](y,u,M)}}else y=[]}y||(y=t);y||o.error(D||g);if(i.call(y)==="[object Array]")if(H)if(h&&h.nodeType===1)for(g=0;y[g]!=null;g++){if(y[g]&&(y[g]===true||y[g].nodeType===1&&E(h,y[g])))k.push(t[g])}else for(g=0;y[g]!=null;g++)y[g]&& -y[g].nodeType===1&&k.push(t[g]);else k.push.apply(k,y);else A(y,k);if(R){o(R,q,k,l);o.uniqueSort(k)}return k};o.uniqueSort=function(g){if(C){j=n;g.sort(C);if(j)for(var h=1;h":function(g,h){var k=typeof h==="string";if(k&&!/\W/.test(h)){h=h.toLowerCase();for(var l=0,q=g.length;l=0))k||l.push(u);else if(k)h[p]=false;return false},ID:function(g){return g[1].replace(/\\/g,"")},TAG:function(g){return g[1].toLowerCase()},CHILD:function(g){if(g[1]==="nth"){var h=/(-?)(\d*)n((?:\+|-)?\d*)/.exec(g[2]==="even"&&"2n"||g[2]==="odd"&& -"2n+1"||!/\D/.test(g[2])&&"0n+"+g[2]||g[2]);g[2]=h[1]+(h[2]||1)-0;g[3]=h[3]-0}g[0]=e++;return g},ATTR:function(g,h,k,l,q,p){h=g[1].replace(/\\/g,"");if(!p&&m.attrMap[h])g[1]=m.attrMap[h];if(g[2]==="~=")g[4]=" "+g[4]+" ";return g},PSEUDO:function(g,h,k,l,q){if(g[1]==="not")if((f.exec(g[3])||"").length>1||/^\w/.test(g[3]))g[3]=o(g[3],null,null,h);else{g=o.filter(g[3],h,k,true^q);k||l.push.apply(l,g);return false}else if(m.match.POS.test(g[0])||m.match.CHILD.test(g[0]))return true;return g},POS:function(g){g.unshift(true); -return g}},filters:{enabled:function(g){return g.disabled===false&&g.type!=="hidden"},disabled:function(g){return g.disabled===true},checked:function(g){return g.checked===true},selected:function(g){return g.selected===true},parent:function(g){return!!g.firstChild},empty:function(g){return!g.firstChild},has:function(g,h,k){return!!o(k[3],g).length},header:function(g){return/h\d/i.test(g.nodeName)},text:function(g){return"text"===g.type},radio:function(g){return"radio"===g.type},checkbox:function(g){return"checkbox"=== -g.type},file:function(g){return"file"===g.type},password:function(g){return"password"===g.type},submit:function(g){return"submit"===g.type},image:function(g){return"image"===g.type},reset:function(g){return"reset"===g.type},button:function(g){return"button"===g.type||g.nodeName.toLowerCase()==="button"},input:function(g){return/input|select|textarea|button/i.test(g.nodeName)}},setFilters:{first:function(g,h){return h===0},last:function(g,h,k,l){return h===l.length-1},even:function(g,h){return h%2=== -0},odd:function(g,h){return h%2===1},lt:function(g,h,k){return hk[3]-0},nth:function(g,h,k){return k[3]-0===h},eq:function(g,h,k){return k[3]-0===h}},filter:{PSEUDO:function(g,h,k,l){var q=h[1],p=m.filters[q];if(p)return p(g,k,h,l);else if(q==="contains")return(g.textContent||g.innerText||a([g])||"").indexOf(h[3])>=0;else if(q==="not"){h=h[3];k=0;for(l=h.length;k= -0}},ID:function(g,h){return g.nodeType===1&&g.getAttribute("id")===h},TAG:function(g,h){return h==="*"&&g.nodeType===1||g.nodeName.toLowerCase()===h},CLASS:function(g,h){return(" "+(g.className||g.getAttribute("class"))+" ").indexOf(h)>-1},ATTR:function(g,h){var k=h[1];g=m.attrHandle[k]?m.attrHandle[k](g):g[k]!=null?g[k]:g.getAttribute(k);k=g+"";var l=h[2];h=h[4];return g==null?l==="!=":l==="="?k===h:l==="*="?k.indexOf(h)>=0:l==="~="?(" "+k+" ").indexOf(h)>=0:!h?k&&g!==false:l==="!="?k!==h:l==="^="? -k.indexOf(h)===0:l==="$="?k.substr(k.length-h.length)===h:l==="|="?k===h||k.substr(0,h.length+1)===h+"-":false},POS:function(g,h,k,l){var q=m.setFilters[h[2]];if(q)return q(g,k,h,l)}}},s=m.match.POS;for(var x in m.match){m.match[x]=new RegExp(m.match[x].source+/(?![^\[]*\])(?![^\(]*\))/.source);m.leftMatch[x]=new RegExp(/(^(?:.|\r|\n)*?)/.source+m.match[x].source.replace(/\\(\d+)/g,function(g,h){return"\\"+(h-0+1)}))}var A=function(g,h){g=Array.prototype.slice.call(g,0);if(h){h.push.apply(h,g);return h}return g}; -try{Array.prototype.slice.call(r.documentElement.childNodes,0)}catch(B){A=function(g,h){h=h||[];if(i.call(g)==="[object Array]")Array.prototype.push.apply(h,g);else if(typeof g.length==="number")for(var k=0,l=g.length;k";var k=r.documentElement;k.insertBefore(g,k.firstChild);if(r.getElementById(h)){m.find.ID=function(l,q,p){if(typeof q.getElementById!=="undefined"&&!p)return(q=q.getElementById(l[1]))?q.id===l[1]||typeof q.getAttributeNode!=="undefined"&&q.getAttributeNode("id").nodeValue===l[1]?[q]:v:[]};m.filter.ID=function(l,q){var p=typeof l.getAttributeNode!=="undefined"&&l.getAttributeNode("id"); -return l.nodeType===1&&p&&p.nodeValue===q}}k.removeChild(g);k=g=null})();(function(){var g=r.createElement("div");g.appendChild(r.createComment(""));if(g.getElementsByTagName("*").length>0)m.find.TAG=function(h,k){k=k.getElementsByTagName(h[1]);if(h[1]==="*"){h=[];for(var l=0;k[l];l++)k[l].nodeType===1&&h.push(k[l]);k=h}return k};g.innerHTML="";if(g.firstChild&&typeof g.firstChild.getAttribute!=="undefined"&&g.firstChild.getAttribute("href")!=="#")m.attrHandle.href=function(h){return h.getAttribute("href", -2)};g=null})();r.querySelectorAll&&function(){var g=o,h=r.createElement("div");h.innerHTML="

";if(!(h.querySelectorAll&&h.querySelectorAll(".TEST").length===0)){o=function(l,q,p,u){q=q||r;if(!u&&q.nodeType===9&&!w(q))try{return A(q.querySelectorAll(l),p)}catch(t){}return g(l,q,p,u)};for(var k in g)o[k]=g[k];h=null}}();(function(){var g=r.createElement("div");g.innerHTML="
";if(!(!g.getElementsByClassName||g.getElementsByClassName("e").length=== -0)){g.lastChild.className="e";if(g.getElementsByClassName("e").length!==1){m.order.splice(1,0,"CLASS");m.find.CLASS=function(h,k,l){if(typeof k.getElementsByClassName!=="undefined"&&!l)return k.getElementsByClassName(h[1])};g=null}}})();var E=r.compareDocumentPosition?function(g,h){return g.compareDocumentPosition(h)&16}:function(g,h){return g!==h&&(g.contains?g.contains(h):true)},w=function(g){return(g=(g?g.ownerDocument||g:0).documentElement)?g.nodeName!=="HTML":false},fa=function(g,h){var k=[], -l="",q;for(h=h.nodeType?[h]:h;q=m.match.PSEUDO.exec(g);){l+=q[0];g=g.replace(m.match.PSEUDO,"")}g=m.relative[g]?g+"*":g;q=0;for(var p=h.length;q=0===d})};c.fn.extend({find:function(a){for(var b=this.pushStack("","find",a),d=0,f=0,e=this.length;f0)for(var i=d;i0},closest:function(a,b){if(c.isArray(a)){var d=[],f=this[0],e,i={},j;if(f&&a.length){e=0;for(var n=a.length;e --1:c(f).is(e)){d.push({selector:j,elem:f});delete i[j]}}f=f.parentNode}}return d}var o=c.expr.match.POS.test(a)?c(a,b||this.context):null;return this.map(function(m,s){for(;s&&s.ownerDocument&&s!==b;){if(o?o.index(s)>-1:c(s).is(a))return s;s=s.parentNode}return null})},index:function(a){if(!a||typeof a==="string")return c.inArray(this[0],a?c(a):this.parent().children());return c.inArray(a.jquery?a[0]:a,this)},add:function(a,b){a=typeof a==="string"?c(a,b||this.context):c.makeArray(a);b=c.merge(this.get(), -a);return this.pushStack(pa(a[0])||pa(b[0])?b:c.unique(b))},andSelf:function(){return this.add(this.prevObject)}});c.each({parent:function(a){return(a=a.parentNode)&&a.nodeType!==11?a:null},parents:function(a){return c.dir(a,"parentNode")},parentsUntil:function(a,b,d){return c.dir(a,"parentNode",d)},next:function(a){return c.nth(a,2,"nextSibling")},prev:function(a){return c.nth(a,2,"previousSibling")},nextAll:function(a){return c.dir(a,"nextSibling")},prevAll:function(a){return c.dir(a,"previousSibling")}, -nextUntil:function(a,b,d){return c.dir(a,"nextSibling",d)},prevUntil:function(a,b,d){return c.dir(a,"previousSibling",d)},siblings:function(a){return c.sibling(a.parentNode.firstChild,a)},children:function(a){return c.sibling(a.firstChild)},contents:function(a){return c.nodeName(a,"iframe")?a.contentDocument||a.contentWindow.document:c.makeArray(a.childNodes)}},function(a,b){c.fn[a]=function(d,f){var e=c.map(this,b,d);bb.test(a)||(f=d);if(f&&typeof f==="string")e=c.filter(f,e);e=this.length>1?c.unique(e): -e;if((this.length>1||db.test(f))&&cb.test(a))e=e.reverse();return this.pushStack(e,a,Q.call(arguments).join(","))}});c.extend({filter:function(a,b,d){if(d)a=":not("+a+")";return c.find.matches(a,b)},dir:function(a,b,d){var f=[];for(a=a[b];a&&a.nodeType!==9&&(d===v||a.nodeType!==1||!c(a).is(d));){a.nodeType===1&&f.push(a);a=a[b]}return f},nth:function(a,b,d){b=b||1;for(var f=0;a;a=a[d])if(a.nodeType===1&&++f===b)break;return a},sibling:function(a,b){for(var d=[];a;a=a.nextSibling)a.nodeType===1&&a!== -b&&d.push(a);return d}});var Fa=/ jQuery\d+="(?:\d+|null)"/g,V=/^\s+/,Ga=/(<([\w:]+)[^>]*?)\/>/g,eb=/^(?:area|br|col|embed|hr|img|input|link|meta|param)$/i,Ha=/<([\w:]+)/,fb=/"},F={option:[1,""],legend:[1,"
","
"],thead:[1,"","
"],tr:[2,"","
"],td:[3,"","
"], -col:[2,"","
"],area:[1,"",""],_default:[0,"",""]};F.optgroup=F.option;F.tbody=F.tfoot=F.colgroup=F.caption=F.thead;F.th=F.td;if(!c.support.htmlSerialize)F._default=[1,"div
","
"];c.fn.extend({text:function(a){if(c.isFunction(a))return this.each(function(b){var d=c(this);d.text(a.call(this,b,d.text()))});if(typeof a!=="object"&&a!==v)return this.empty().append((this[0]&&this[0].ownerDocument||r).createTextNode(a));return c.getText(this)}, -wrapAll:function(a){if(c.isFunction(a))return this.each(function(d){c(this).wrapAll(a.call(this,d))});if(this[0]){var b=c(a,this[0].ownerDocument).eq(0).clone(true);this[0].parentNode&&b.insertBefore(this[0]);b.map(function(){for(var d=this;d.firstChild&&d.firstChild.nodeType===1;)d=d.firstChild;return d}).append(this)}return this},wrapInner:function(a){if(c.isFunction(a))return this.each(function(b){c(this).wrapInner(a.call(this,b))});return this.each(function(){var b=c(this),d=b.contents();d.length? -d.wrapAll(a):b.append(a)})},wrap:function(a){return this.each(function(){c(this).wrapAll(a)})},unwrap:function(){return this.parent().each(function(){c.nodeName(this,"body")||c(this).replaceWith(this.childNodes)}).end()},append:function(){return this.domManip(arguments,true,function(a){this.nodeType===1&&this.appendChild(a)})},prepend:function(){return this.domManip(arguments,true,function(a){this.nodeType===1&&this.insertBefore(a,this.firstChild)})},before:function(){if(this[0]&&this[0].parentNode)return this.domManip(arguments, -false,function(b){this.parentNode.insertBefore(b,this)});else if(arguments.length){var a=c(arguments[0]);a.push.apply(a,this.toArray());return this.pushStack(a,"before",arguments)}},after:function(){if(this[0]&&this[0].parentNode)return this.domManip(arguments,false,function(b){this.parentNode.insertBefore(b,this.nextSibling)});else if(arguments.length){var a=this.pushStack(this,"after",arguments);a.push.apply(a,c(arguments[0]).toArray());return a}},clone:function(a){var b=this.map(function(){if(!c.support.noCloneEvent&& -!c.isXMLDoc(this)){var d=this.outerHTML,f=this.ownerDocument;if(!d){d=f.createElement("div");d.appendChild(this.cloneNode(true));d=d.innerHTML}return c.clean([d.replace(Fa,"").replace(V,"")],f)[0]}else return this.cloneNode(true)});if(a===true){qa(this,b);qa(this.find("*"),b.find("*"))}return b},html:function(a){if(a===v)return this[0]&&this[0].nodeType===1?this[0].innerHTML.replace(Fa,""):null;else if(typeof a==="string"&&!/