diff --git a/resources/[ps]/ps-inventory/html/ammo_images/pistol_ammo.png b/resources/[ps]/ps-inventory/html/ammo_images/pistol_ammo.png new file mode 100644 index 0000000..12766a5 Binary files /dev/null and b/resources/[ps]/ps-inventory/html/ammo_images/pistol_ammo.png differ diff --git a/resources/[ps]/ps-inventory/html/ammo_images/rifle_ammo.png b/resources/[ps]/ps-inventory/html/ammo_images/rifle_ammo.png new file mode 100644 index 0000000..f71fd3d Binary files /dev/null and b/resources/[ps]/ps-inventory/html/ammo_images/rifle_ammo.png differ diff --git a/resources/[ps]/ps-inventory/html/ammo_images/shotgun_ammo.png b/resources/[ps]/ps-inventory/html/ammo_images/shotgun_ammo.png new file mode 100644 index 0000000..f33ea22 Binary files /dev/null and b/resources/[ps]/ps-inventory/html/ammo_images/shotgun_ammo.png differ diff --git a/resources/[ps]/ps-inventory/html/ammo_images/smg_ammo.png b/resources/[ps]/ps-inventory/html/ammo_images/smg_ammo.png new file mode 100644 index 0000000..12786ba Binary files /dev/null and b/resources/[ps]/ps-inventory/html/ammo_images/smg_ammo.png differ diff --git a/resources/[ps]/ps-inventory/html/attachment_images/weapon_assaultrifle.png b/resources/[ps]/ps-inventory/html/attachment_images/weapon_assaultrifle.png new file mode 100644 index 0000000..1bbccca Binary files /dev/null and b/resources/[ps]/ps-inventory/html/attachment_images/weapon_assaultrifle.png differ diff --git a/resources/[ps]/ps-inventory/html/attachment_images/weapon_carbinerifle.png b/resources/[ps]/ps-inventory/html/attachment_images/weapon_carbinerifle.png new file mode 100644 index 0000000..a220b95 Binary files /dev/null and b/resources/[ps]/ps-inventory/html/attachment_images/weapon_carbinerifle.png differ diff --git a/resources/[ps]/ps-inventory/html/attachment_images/weapon_compactrifle.png b/resources/[ps]/ps-inventory/html/attachment_images/weapon_compactrifle.png new file mode 100644 index 0000000..48f57a4 Binary files /dev/null and b/resources/[ps]/ps-inventory/html/attachment_images/weapon_compactrifle.png differ diff --git a/resources/[ps]/ps-inventory/html/attachment_images/weapon_microsmg.png b/resources/[ps]/ps-inventory/html/attachment_images/weapon_microsmg.png new file mode 100644 index 0000000..2ac3868 Binary files /dev/null and b/resources/[ps]/ps-inventory/html/attachment_images/weapon_microsmg.png differ diff --git a/resources/[ps]/ps-inventory/html/attachment_images/weapon_minismg.png b/resources/[ps]/ps-inventory/html/attachment_images/weapon_minismg.png new file mode 100644 index 0000000..4a93078 Binary files /dev/null and b/resources/[ps]/ps-inventory/html/attachment_images/weapon_minismg.png differ diff --git a/resources/[ps]/ps-inventory/html/attachment_images/weapon_pistol.png b/resources/[ps]/ps-inventory/html/attachment_images/weapon_pistol.png new file mode 100644 index 0000000..4d69e62 Binary files /dev/null and b/resources/[ps]/ps-inventory/html/attachment_images/weapon_pistol.png differ diff --git a/resources/[ps]/ps-inventory/html/attachment_images/weapon_pistol_mk2.png b/resources/[ps]/ps-inventory/html/attachment_images/weapon_pistol_mk2.png new file mode 100644 index 0000000..1900441 Binary files /dev/null and b/resources/[ps]/ps-inventory/html/attachment_images/weapon_pistol_mk2.png differ diff --git a/resources/[ps]/ps-inventory/html/attachment_images/weapon_pumpshotgun.png b/resources/[ps]/ps-inventory/html/attachment_images/weapon_pumpshotgun.png new file mode 100644 index 0000000..6f1f3b4 Binary files /dev/null and b/resources/[ps]/ps-inventory/html/attachment_images/weapon_pumpshotgun.png differ diff --git a/resources/[ps]/ps-inventory/html/attachment_images/weapon_smg.png b/resources/[ps]/ps-inventory/html/attachment_images/weapon_smg.png new file mode 100644 index 0000000..6a4c57f Binary files /dev/null and b/resources/[ps]/ps-inventory/html/attachment_images/weapon_smg.png differ diff --git a/resources/[ps]/ps-inventory/html/attachment_images/weapon_snspistol.png b/resources/[ps]/ps-inventory/html/attachment_images/weapon_snspistol.png new file mode 100644 index 0000000..1e5d477 Binary files /dev/null and b/resources/[ps]/ps-inventory/html/attachment_images/weapon_snspistol.png differ diff --git a/resources/[ps]/ps-inventory/html/attachment_images/weapon_stungun.png b/resources/[ps]/ps-inventory/html/attachment_images/weapon_stungun.png new file mode 100644 index 0000000..86a5210 Binary files /dev/null and b/resources/[ps]/ps-inventory/html/attachment_images/weapon_stungun.png differ diff --git a/resources/[ps]/ps-inventory/html/attachment_images/weapon_vintagepistol.png b/resources/[ps]/ps-inventory/html/attachment_images/weapon_vintagepistol.png new file mode 100644 index 0000000..37c14e7 Binary files /dev/null and b/resources/[ps]/ps-inventory/html/attachment_images/weapon_vintagepistol.png differ diff --git a/resources/[ps]/ps-inventory/html/css/main.css b/resources/[ps]/ps-inventory/html/css/main.css new file mode 100644 index 0000000..ef5f2d5 --- /dev/null +++ b/resources/[ps]/ps-inventory/html/css/main.css @@ -0,0 +1,1386 @@ +@import url('https://fonts.googleapis.com/css2?family=Roboto:ital,wght@0,100;0,300;0,400;0,500;0,700;0,900;1,100;1,300;1,400;1,500;1,700;1,900&display=swap'); + +.bg-button { background: var(--color-primary)!important; box-shadow: none!important; } +.text-check { color: rgba(255, 255, 255, 0.8)!important; } +.text-checkbox { color: #0fffd5!important; } +.q-checkbox__svg { color: #000!important; } +div#q-loading-bar { display: none!important; } +.q-card { background: var(--color-primary)!important; } +p { margin: 0 !important; } +.q-btn { align-items: center!important; box-shadow: none!important;} +.text-h6 { color: #fff; } +.q-card__section.q-card__section--vert.q-pt-none { color: #fff; } + +@media screen and (min-width: 2540px) { + #itembox-label { + min-height: 1.8vh; + } +} + +.row { + display: flex; + flex-wrap: wrap; + margin-right: 0px!important; + margin-left: 0px!important; +} + +:root { + --color-primary: #23242e; + --color-secondary: #383942; + --color-accent: rgb(65, 199, 165); +} + +.fas.fa-lock { + font-size: 22px; + top: -82px; + right: 0px; + position: relative; +} + +.brand-logo { + position: relative; + left: 50%; + transform: translateX(-50%); + padding-top: 3px; + padding-bottom: 10px; + width: 45%; +} + +::placeholder { + color: white; + text-align: center; + line-height: 48px; + text-transform: normal; + font-size: 1.5vh; + font-family: 'Roboto', sans-serif !important; + } + +/* rgb() */ + +input[type=number]::-webkit-inner-spin-button, +input[type=number]::-webkit-outer-spin-button { + -webkit-appearance: none; + margin: 0; +} + +::-webkit-scrollbar { + width: 12px; + background: var(--color-secondary); + border-radius: 15px; +} + +::-webkit-scrollbar-thumb { + background: #191b1f; + border-radius: 15px; +} + +#progressbar { + width: 112%; + margin-left: 65.8%; + margin-top: 1.8%; + border-radius: 15px; + background-color: var(--color-secondary); +} + +#progressbar-other { + width: 77.6%; + margin-left: 2.2%; + margin-top: 1.8%; + border-radius: 15px; + background-color: var(--color-secondary); +} + +.pro { + background: linear-gradient(to right, var(--color-accent), var(--color-accent) 500px); + height: 6px; + max-width: 100%; + border-radius: 15px; + transition: width 1s, background-color 1s; +} + +.pro1 { + background: linear-gradient(to right, var(--color-accent), var(--color-accent) 500px); + height: 6px; + max-width: 100%; + border-radius: 15px; + transition: width 1s, background-color 1s; +} + +.weight-img { + margin-top: 0.6%; + width: 4%; + right: -14%; + position: absolute; +} + +.weight-img-other { + margin-top: 0.6%; + width:4%; + right: -12%; + position:absolute; +} + +body { + overflow-x: hidden; +} + +#qbcore-inventory { + position: absolute; + width: 100%; + height: 100%; + left: 0vw; + display: none; + user-select: none; +} + +.inv-background { + width: 100%; + height: 100%; + position: absolute; + top: 0; + left: 0; + z-index: -1; +} + +.inv-container { + position: absolute; + width: 100%; + height: 100%; +} + +.player-inventory-bg { + position: absolute; + float: left; + top: 15%; + left: 21.2%; + width: 45.7%; + max-width: 35.7%; + height: 64.17%; + max-height: 64.17%; + background: var(--color-primary); + border-bottom-left-radius: 10px; + border-top-left-radius: 10px; +} + +.player-inventory { + position: absolute; + top: 8%; + left: 2.3%; + width: 100.22%; + max-width: 102.22%; + height: 100%; + max-height: 132%; + float: right; + z-index: 100; +} + +.player-inventory-first { + position: absolute; + margin-top: -0.6rem; + margin-left: -19%; + width: 19%; + height: 78.2%; + background-color: var(--color-primary); + padding: 10px; + border-bottom-left-radius: 10px; + border-top-left-radius: 10px; + z-index: 10; +} + +.other-inventory-bg { + position: absolute; + top: 15%; + float: right; + right: 18.2%; + margin: 0 auto; + width: 25.26%; + max-width: 25.26%; + height: 64.17%; + max-height: 64.17%; + background: var(--color-primary); + border-bottom-right-radius: 10px; + border-top-right-radius: 10px; +} + +.other-inventory { + position: absolute; + top: 8%; + right: 1.5%; + width: 89%; + max-width: 102.22%; + height: 90%; + max-height: 132%; + float: right; + overflow-x: hidden; + overflow-y: scroll; + z-index: 100; +} + +.ply-hotbar-inventory { + position: absolute; + bottom: 10%; + left: 35.5%; + z-index: 105; +} + +.player-inventory > .item-slot > .item-slot-key > p { + position: absolute; + font-weight: 400; + color: #20202062; + padding-top: 4vh; + padding-bottom: 0px; + padding-left: 2.35vh; + text-align: center; + font-size: 7vh; + line-height: 1.8vh; + font-family: 'Roboto', sans-serif !important; +} + +.player-inventory-first > .item-slot > .item-slot-key > p { + position: absolute; + font-weight: 400; + color: #20202062; + padding-top: 4vh; + padding-bottom: 0px; + padding-left: 2.35vh; + text-align: center; + font-size: 7vh; + line-height: 1.8vh; + font-family: 'Roboto', sans-serif !important; +} + +.inv-options { + position: absolute; + margin: 11.5% auto; + right: -12.6%; + height: 4rem; + width: 4.3rem; + left: 1vh; + cursor: pointer; /* Can also be 'none' however, as these are the buttons I feel as the pointer fits better */ + z-index: 200; +} + +.inv-help-options { + background: var(--color-primary); + height: 2.8rem; + width: 2.8rem; + display: flex; + justify-content: center; + flex-direction: column; + align-items: center; + cursor: pointer; + border-radius: 5px; + box-shadow: none; + text-shadow: none; + margin-left: 18%; + margin-top: 40%; + z-index: 9999; +} + +.inv-help-options button { + background-color: transparent; + width: 2.8rem; + height: 2.8rem; + color: white; + border: none; + box-shadow: none; + text-shadow: none; + font-size: large; +} + +.btn { + box-shadow: none; + } + + +.combine-option-container { + display: none; + position: relative; + right: 0px; + width: auto; + left: 0vh; + margin: 0px auto; +} + +.item-slot { + position: relative; + width: 98px; + height: 98px; + float: left; + border: 2px solid #41414b; + background-color: #33343d !important; + margin: 3px; + transition: opacity 0.2s ease 0s; + border-radius: 9px; + opacity: 90%; +} + +.item-slot:hover { + background-color: #292932 !important; + opacity: 90%; +} + +.inv-option-item { + margin-top: 10%; +} + +.btn-inv { + width: 100%!important; + max-width: 100%!important; + padding: 10%!important; + background-color: var(--color-secondary); +} + +#item-amount { + color: white; + text-align: center; + font-size: 1.5vh; + font-weight: 300; + font-family: 'Roboto', sans-serif !important; + outline: none; +} + +.ammo-info-block { + position: absolute; + margin: 0 auto; + left: 0; + right: 0; + width: 22vh; + height: 11vh; + background-color: rgba(235, 235, 235, 0.08); + border: 1px solid rgba(255, 255, 255, 0.01); + top: 2vh; +} +.ammo-info-header { + /* background-color: rgba(5, 5, 5, 0.5); */ + width: 100%; + color: white; + font-family: 'Roboto', sans-serif !important; + background-color: rgba(0, 0, 0, 0.192); + font-size: 1.vh; + padding: .4vh; + text-align: center; +} +.ammo-info { + position: relative; + color: white; + font-family: 'Roboto', sans-serif !important; + font-weight: 200; + font-size: 1.vh; + margin-left: .8vh; + margin-top: .4vh; + margin-bottom: .25vh; + top: .6vh; +} +.ammo-info span { + margin-right: 1vh; + float: right; +} + +.inv-option-item > p { + color: white; + text-align: center; + line-height: 48px; + text-transform: normal; + font-size: 1.5vh; + font-weight: 300; + font-family: 'Roboto', sans-serif !important; +} +.inv-option-item > label { + color: white; + text-align: center; + line-height: 48px; + text-transform: normal; + font-size: 1.5vh; + font-weight: 300; + font-family: 'Roboto', sans-serif !important; + margin-right: 10px; + margin-bottom: auto; + margin-top: auto; +} + +.inv-option-item { + margin-top: 10%; + height: 3rem; + width: 4.5rem; + margin-left: 0%; + background: var(--color-secondary)!important; + border: none; + color: white; + transition: background-color .1s linear; + border-radius: 5px!important; + opacity: 70%; +} +.inv-option-hand { + margin-top: 20%; +/* width: 80%; */ + height: 100px; + margin-left: 10%; + transition: background-color .1s linear; +} + +.inv-option-item:hover { + background-color: #5c5c6c; +} + +.btn-combine { + position: relative; + margin-top: 6px; + height: 3rem; + width: 4.5rem; + top: 0px; + left: 0px; + background: var(--color-secondary)!important; + text-align: center; + line-height: 48px; + font-size: 1.1vh; + font-weight: 900; + font-family: Roboto, sans-serif !important; + border-radius: 0px; + border-width: 1px; + border-style: solid; + border-image: initial; + transition: background-color 0.1s linear 0s; + border-radius: 5px!important; + opacity: 70%; +} + +.btn-combine > p { + color: white; + text-align: center; + font-size: 1.5vh; + font-weight: 300; + font-family: 'Roboto', sans-serif !important; + outline: none; + +} + +.item-slot-amount { + position: absolute; + top: 0.3%; + left: 0.15vw; + background-color: #41414b; + padding-right: 4px; + padding-left: 4px; + border-radius: 50px; +} + +.item-slot-amount > p { + color: #ffffff; + text-align: right; + font-size: 1.25vh; + font-weight: 400; + cursor: none; +} + +.item-slot-name { + position: absolute; + top: 0.3%; + right: 0.15vw; + background-color: #41414b; + padding-right: 4px; + padding-left: 4px; + border-radius: 50px; +} + +.item-slot-name > p { + color: #ffffff; + text-align: right; + font-size: 1.25vh; + font-weight: 400; + cursor: none; +} + +.item-slot-label { + position: absolute; + bottom: 0vh; + width: 100%; + background-color: transparent; +} + +.item-slot-label > p { + font-weight: 400; + padding: 2.5px; + padding-left: 5px; + color: white; + font-size: 1.15vh; + text-align: left; + letter-spacing: 0px; + font-family: 'Roboto', sans-serif !important; + white-space: pre; + text-overflow: ellipsis; + overflow: hidden; + cursor: none; +} + +.item-slot-quality { + position: absolute; + bottom: 0.2vh; + width: 100%; + height: 0.4vh; + border-radius: 25px; + background-color: rgba(32, 6, 6, 0.15); + border-bottom-left-radius: 9px; + border-bottom-right-radius: 9px; +} + +.item-slot-quality-bar { + position: absolute; + width: 0%; + height: 150%; + background-color: var(--color-accent); + z-index: 1; + border-bottom-left-radius: 9px; + border-bottom-right-radius: 9px; +} + +.item-slot-quality p { + color: transparent; +} + +.item-slot-img { + max-width: 100%; + max-height: 100%; + padding: 0.5vw; +} + +.item-slot-img img { + display: block; + position: relative; + margin: 0 auto; + margin-top: 9%; + width: auto; + height: auto; + max-width: 92%; + max-height: 100%; +} + +.item-slot-img-itembox img { + display: block; + position: relative; + margin: 0 auto; + margin-top: 2vh; + width: auto; + height: auto; + max-width: 75%; + max-height: 100%; +} + +.item-slot-img2 img { + display:block; +} + +.ui-draggable-dragging { + background: rgba(0, 0, 0, 0.3); + z-index: 9999; +} + +.player-inv-info { + position: absolute; + left: 3.3%; + top: 15.6%; + width: 28.8%; + z-index: 1000; + cursor: none; +} + +#player-inv-label { + position: relative; + color: white; + font-size: 20px; + font-family: 'Roboto', sans-serif !important; + font-weight: 600; + letter-spacing: 0.01vh; + right: -66%; + float: left; + text-transform: normal; + cursor: none; +} + +#player-inv-weight { + position: relative; + color: rgb(255, 255, 255); + font-size: 16px; + font-weight: 900; + font-family: 'Roboto', sans-serif !important; + letter-spacing: 0.1vh; + bottom: 30px; + right: -77%; + float: right; +} + +#other-inv-label { + position: relative; + color: white; + font-size: 20px; + font-family: 'Roboto', sans-serif !important; + font-weight: 600; + letter-spacing: 0.01vh; + left: 3%; + float: left; + text-transform: normal; + cursor: none; +} + + +#other-inv-weight { + position: relative; + color: rgb(255, 255, 255); + font-size: 16px; + font-weight: 900; + font-family: 'Roboto', sans-serif !important; + letter-spacing: 0.1vh; + bottom: 30px; + right: 20.5%; + float: right; + cursor: none; +} + +.player-inv-weight { + position: absolute; + left: 38%; + top: 10%; +} + +.player-inv-weight > p { + color: white; + font-size: 12px; + font-family: 'Roboto', sans-serif !important; +} + +.other-inv-info { + position: absolute; + left: 58.3%; + top: 15.6%; + width: 28.8%; + z-index: 1000; +} + +.ply-iteminfo-container { + background: var(--color-primary); + opacity: 50%; + border-radius: 3px; + color: rgba(220, 220, 220, 1); + border: 1px solid rgba(255, 255, 255, 0.02); + font-size: 1.35vh; + font-weight: 0; + left: 41%; + max-height: 25%; + min-height: 50px; + overflow: hidden; + padding: 1%; + pointer-events: none; + position: absolute; + text-decoration: none; + top: 50%; + transition: opacity 0.6s ease; + width: 13%; + z-index: 10000; +} + +.item-info-title { + text-transform: normal; + font-weight: 900; + font-family: sans-serif; + font-size: 2.4vh; + letter-spacing: 0.3px; + line-height: 1; + color: white; + font-family: 'Roboto', sans-serif !important; + padding-top: 5px; + padding-left: 5px; +} + +.item-info-line { + position: absolute; + font-family: 'Roboto', sans-serif !important; + width: 85%; + background-color: #6d6d6d96; + height: 0.13vh; +} + +.item-info-description { + text-transform: normal; + font-size: 1.4vh; + font-weight: 400; + line-height: 1.1; + letter-spacing: 0.3px; + font-family: 'Roboto', sans-serif !important; + color: white; + padding-left: 5px; + padding-top: .5vh; +} + +.itemboxes-container { + display: flex; + gap: 1rem; + width: 100vw; + position: absolute; + bottom: 18%; + overflow: hidden; + flex-direction: row; + justify-content: center; +} + +.template { + display: none !important; +} + +.itembox-container { + display: flex; + flex-direction: column; + position: relative; + width: 10vh; + height: 11vh; + border: 2px solid #41414b; + background-color: #33343d !important; + border-radius: 9px; +} + +#itembox-action { + position: absolute; + color: white; + border-top-left-radius: 1px; + padding: 4px; + top: 0; + left: 0; +} + +#itembox-action > p { + font-size: 14px; + font-weight: 400; + font-family: 'Roboto', sans-serif !important; + white-space: pre; + text-overflow: ellipsis; + overflow: hidden; +} + +#itembox-label { + height: 4rem; + display: flex; + align-items: center; +} + +.itembox-image { + max-width: 10%; + max-height: 100%; + padding: 0.10vw; +} + +#itembox-label > p { + padding: 0 15px; + color: #ffffff; + font-size: 13px; + text-align: center; + top: -10px; + position: relative; + left: 50%; + transform: translateX(-50%); + text-overflow: ellipsis; + overflow: hidden; +} + +.requiredItem-container { + display: none; + position: absolute; + height: 100vh; + width: 100vw; + display: flex; +} + +.requiredItem-box { + position: relative; + top: 79%; + left: 42%; + width: 10vh; + height: 11vh; + float: left; + margin-left: 20px; + background: rgba(54, 54, 54, 0.233); +} + +#requiredItem-action { + position: absolute; + left: 0; + top: 0; + color: white; + padding: 3px; + font-size: 14px; + font-family: 'Roboto', sans-serif !important; +} + +#requiredItem-label { + position: absolute; + bottom: 0; + width: 100%; + height: 0.3vh; +} + +#requiredItem-label > p { + color: #ffffff; + font-size: 14px; + text-align: center; + top: -25px; + position: relative; + left: 50%; + transform: translateX(-50%); + white-space: pre; + text-overflow: ellipsis; + overflow: hidden; +} + +.item-slot-img-itembox-test img { + display: block; + position: relative; + margin: 0 auto; + margin-top: 1.3vh; + width: 80px; + height: 80px; + max-width: 100%; + max-height: 100%; +} + +.z-hotbar-inventory { + display: none; + position: absolute; + bottom: 1%; + margin: 0 auto; + left: 0; + right: 0; + width: fit-content; + z-index: 105; + padding: 4px; + background-color: var(--color-primary); + border-radius: 9px; +} + +.z-hotbar-inventory > .z-hotbar-item-slot > .z-hotbar-item-slot-key > p { + position: absolute; + font-weight: 400; + color: #20202062; + padding-top: 42%; + padding-bottom: 0px; + padding-left: 29%; + text-align: center; + font-size: 4rem; + line-height: 1.8vh; + font-family: 'Roboto', sans-serif !important; + z-index: -1; +} + +.z-hotbar-item-slot { + margin-left: 2px; + margin-bottom: 2px; + position: relative; + width: 6.15rem; + height: 6.15rem; + float: left; + border: 2px solid #41414b; + background-color: #33343d !important; + margin: 3px; + transition: opacity 0.2s ease 0s; + border-radius: 9px; + opacity: 90%; + z-index: 9999; +} + +.z-hotbar-item-slot-amount { + position: absolute; + top: 0.5%; + left: 0.15vw; + background-color: #41414b; + padding-right: 4px; + padding-left: 4px; + border-radius: 50px; +} + +.z-hotbar-item-slot-amount > p { + color: #ffffff; + text-align: right; + font-size: 1.25vh; + font-weight: 400; + cursor: none; +} + +.z-hotbar-item-slot-amount-name { + position: absolute; + top: 0.5%; + right: 0.15vw; + background-color: #41414b; + padding-right: 4px; + padding-left: 4px; + border-radius: 50px; +} + +.z-hotbar-item-slot-amount-name > p { + color: #ffffff; + text-align: right; + font-size: 1.25vh; + font-weight: 400; + cursor: none; +} + +.z-hotbar-item-slot-label { + position: absolute; + bottom: 0vh; + width: 100%; + background-color: transparent; +} + +.z-hotbar-item-slot-label > p { + font-weight: 400; + padding: 2.5px; + padding-left: 5px; + color: white; + font-size: 1.15vh; + text-align: left; + letter-spacing: 0px; + font-family: 'Roboto', sans-serif !important; + white-space: pre; + text-overflow: ellipsis; + overflow: hidden; + cursor: none; +} + +.z-hotbar-item-slot-img { + max-width: 100%; + max-height: 100%; + padding: 0.8vw; +} + +.z-hotbar-item-slot-img img { + display: block; + position: relative; + margin: 0 auto; + margin-top: -12%; + left: -18%; + width: auto; + height: auto; + max-width: 120%; + max-height: 120%; +} + +.ammo-container { + position: absolute; + background-color: rgba(20, 18, 32, 0.2); + width: 3.25%; + height: 44.16%; + top: 26%; + left: 6%; +} + +.ammo-container-header { + position: absolute; + top: 0; + width: 100%; + height: 5vh; + background-color: rgba(120, 10, 20, 0.5); + text-align: center; + color: rgba(216, 216, 216, 0.897); +} + +.ammo-container-header > i { + line-height: 5vh; + font-size: 1.8vh; +} + +.ammo-box { + position: relative; + width: 100%; + height: 6vh; + top: 5vh; + background-color: rgba(0, 0, 0, .4); + margin-bottom: .5vh; + margin-top: .5vh; +} + +.ammo-box > img { + position: absolute; + top: .15vh; + left: .2vh; + width: 5.25vh; + opacity: .25; +} + +.ammo-box > span { + position: absolute; + color: rgba(255, 255, 255, 0.95); + font-size: .93vh; + bottom: 0; + right: 0; + margin: .3vh; + font-family: 'Roboto', sans-serif !important; +} + +.ammo-box-amount { + position: absolute; + width: 100%; + background-color: rgba(36, 36, 36, 0.4); + bottom: 0; + max-height: 100%; +} + +#pistol_ammo > .ammo-box-amount { + height: 0%; +} + +#smg_ammo > .ammo-box-amount { + height: 0%; +} + +#shotgun_ammo > .ammo-box-amount { + height: 0%; +} + +#rifle_ammo > .ammo-box-amount { + height: 0%; +} + +/* Weapon Attachments */ + +.weapon-attachments-container { + position: absolute; + left: -100vw; + width: 100%; + height: 100%; + background-color: rgba(0, 0, 0, 0.5); +} + +.weapon-attachments-container-title { + position: absolute; + margin: 5vh; + font-size: 3vh; + color: rgb(255, 255, 255); + font-family: 'Roboto', sans-serif !important; +} + +.weapon-attachments-container-description { + position: absolute; + margin: 5vh; + top: 5vh; + font-size: 1.7vh; + color: rgba(255, 255, 255, 0.8); + font-family: 'Roboto', sans-serif !important; +} + +.weapon-attachments-container-details { + position: absolute; + margin: 5vh; + top: 9vh; + font-size: 1.4vh; + color: rgba(255, 255, 255, 0.8); + font-family: 'Roboto', sans-serif !important; +} + +.weapon-attachments-container-detail-durability { + height: 1.5vh; + width: 10vh; + background-color: rgba(0, 0, 0, 0.3); + border-radius: 1px; +} + +.weapon-attachments-container-detail-durability-total { + height: 100%; + width: 50%; + background-color: var(--color-accent); +} + +.weapon-attachments-container-image { + position: absolute; + margin: 0 auto; + left: 0; + right: 0; + top: 32%; + width: 30%; +} + +.weapon-attachments { + position: absolute; + bottom: 0; + left: 0; + margin: 5vh; + width: 50vh; + height: 12.5vh; +} + +.weapon-attachments-title { + position: absolute; + bottom: 14vh; + left: 0; + margin: 5vh; + color: rgba(255, 255, 255, 0.8); + font-family: 'Roboto', sans-serif !important; + font-size: 1.4vh +} + +.weapon-attachment { + position: relative; + height: 12.5vh; + width: 10.5vh; + background-color: rgba(0, 0, 0, 0.3); + border: 1px solid rgb(75, 75, 75); + margin-right: 1vh; + float: left; + transition: .05s linear; + z-index: 9888; +} + +.weapon-attachment:hover { + background-color: rgba(0, 0, 0, 0.4); + border: 1px solid rgb(29, 29, 29); + transition: .05s linear; +} + +.weapon-attachment-label { + position: absolute; + bottom: 0; + width: 100%; + background-color: rgba(38, 41, 60, 0.3); + padding: 2.1%; +} + +.weapon-attachment-label > p { + color: #ffffff; + font-size: 1.1vh; + text-align: center; + text-transform: uppercase; + line-height: 1.9vh; + font-family: 'Roboto', sans-serif !important; + font-weight: 100; +} + +.weapon-attachment-img { + max-width: 100%; + max-height: 100%; + padding: 0.5vw; +} + +.weapon-attachment-img > img { + display:block; + position: relative; + margin: 0 auto; + margin-top: 10%; + width: auto; + height: auto; + max-width: 100%; + max-height: 100%; +} + +.weapon-attachments-remove { + position: absolute; + width: 6.5vh; + height: 6.5vh; + background-color: rgb(15, 15, 15); + border-radius: 1px; + margin: 0 auto; + left: 0; + right: 0; + bottom: 20vh; + text-align: center; + color: white; + font-size: 2vh; + transition: background-color .05s linear; + z-index: 9888; +} + +.weapon-attachments-remove:hover { + background-color: rgb(18, 18, 18); +} + +.weapon-attachments-remove > i { + line-height: 6.5vh; +} + +.weapon-attachments-remove-hover { + background-color: var(--color-accent); +} + +.weapon-dragging-class { + animation: ShakeEffect .75s; + animation-iteration-count: infinite; +} + +@keyframes ShakeEffect { + 0% { transform: translate(1px, 1px) rotate(0deg); } + 10% { transform: translate(-1px, -2px) rotate(-1deg); } + 20% { transform: translate(-3px, 0px) rotate(1deg); } + 30% { transform: translate(3px, 2px) rotate(0deg); } + 40% { transform: translate(1px, -1px) rotate(1deg); } + 50% { transform: translate(-1px, 2px) rotate(-1deg); } + 60% { transform: translate(-3px, 1px) rotate(0deg); } + 70% { transform: translate(3px, 1px) rotate(-1deg); } + 80% { transform: translate(-1px, -1px) rotate(1deg); } + 90% { transform: translate(1px, 2px) rotate(0deg); } + 100% { transform: translate(1px, -2px) rotate(-1deg); } +} + +.weapon-attachments-back { + position: absolute; + bottom: 0; + right: 0; + width: 10vh; + height: 6vh; + margin: 5vh; + background-color: rgb(15, 15, 15); + border-radius: 1px; + text-align: center; + line-height: 6vh; + color: white; + font-family: 'Roboto', sans-serif !important; + transition: .05s linear; + z-index: 9999; +} + +.weapon-attachments-back:hover { + background-color: var(--color-primary); +} + +.color-picker-container { + display: flex; + flex-direction: row; + align-items: center; + justify-content: center; +} + +@media (width: 2560px) and (height: 1440px) { + .item-slot { + position: relative; + width: 133px; + height: 133px; + float: left; + border: 2px solid #41414b; + background-color: #33343d !important; + margin: 3px; + transition: opacity 0.2s ease 0s; + border-radius: 9px; + opacity: 90%; + } +} + +@media (width: 3360px) and (height: 1440px) { + .item-slot { + position: relative; + width: 133px; + height: 133px; + float: left; + border: 2px solid #41414b; + background-color: #33343d !important; + margin: 3px; + transition: opacity 0.2s ease 0s; + border-radius: 9px; + opacity: 90%; + } + .player-inventory-bg { + position: absolute; + float: left; + top: 15%; + left: 29.2%; + width: 26%; + max-width: 25.7%; + height: 64.17%; + max-height: 64.17%; + background: var(--color-primary); + border-bottom-left-radius: 10px; + border-top-left-radius: 10px; + } + .other-inventory-bg { + position: absolute; + top: 15%; + float: right; + right: 26%; + margin: 0 auto; + width: 19.26%; + max-width: 19.26%; + height: 64.17%; + max-height: 64.17%; + background: var(--color-primary); + border-bottom-right-radius: 10px; + border-top-right-radius: 10px; + } + + #progressbar { + width: 85%; + margin-left: 92.8%; + margin-top: 1.8%; + border-radius: 15px; + background-color: var(--color-secondary); + } + + #progressbar-other { + width: 57.2%; + margin-left: -6.2%; + margin-top: 1.8%; + border-radius: 15px; + background-color: var(--color-secondary); + } + + .inv-options { + position: absolute; + margin: 8.7% auto; + right: -10.6%; + height: 4rem; + width: 4.3rem; + left: 1vh; + cursor: pointer; /* Can also be 'none' however, as these are the buttons I feel as the pointer fits better */ + z-index: 200; + } + + .inv-option-item { + margin-top: 10%; + height: 3rem; + width: 4rem; + margin-left: 6%; + background: var(--color-secondary)!important; + border: none; + color: white; + transition: background-color .1s linear; + border-radius: 5px!important; + opacity: 70%; + } + + #player-inv-label { + position: relative; + color: white; + font-size: 20px; + font-family: 'Roboto', sans-serif !important; + font-weight: 600; + letter-spacing: 0.01vh; + right: -93%; + float: left; + text-transform: normal; + cursor: none; + } + + #other-inv-label { + position: relative; + color: white; + font-size: 20px; + font-family: 'Roboto', sans-serif !important; + font-weight: 600; + letter-spacing: 0.01vh; + left: -6%; + float: left; + text-transform: normal; + cursor: none; + } + + #other-inv-weight { + position: relative; + color: rgb(255, 255, 255); + font-size: 16px; + font-weight: 900; + font-family: 'Roboto', sans-serif !important; + letter-spacing: 0.1vh; + bottom: 30px; + right: 49.5%; + float: right; + cursor: none; + } + +} + +.craft-item-slot { + width: 30%; + height: 30%; + background: #0fffd5; +} diff --git a/resources/[ps]/ps-inventory/html/js/app.js b/resources/[ps]/ps-inventory/html/js/app.js new file mode 100644 index 0000000..01578ab --- /dev/null +++ b/resources/[ps]/ps-inventory/html/js/app.js @@ -0,0 +1,3151 @@ +const { useQuasar } = Quasar +const { ref } = Vue + +const app = Vue.createApp({ + setup() { + return { + options: ref(false), + help: ref(false), + showblur: ref(true), + } + }, + methods: { + select: function (event) { + targetId = event.currentTarget.id; + showBlur() + } + } +}) + +app.use(Quasar, { config: {} }) +app.mount('#inventory-menus') + +function showBlur() { + $.post('https://ps-inventory/showBlur'); +} + +var InventoryOption = "0, 0, 0"; + +var totalWeight = 0; +var totalWeightOther = 0; + +var playerMaxWeight = 0; +var otherMaxWeight = 0; + +var otherLabel = ""; + +var ClickedItemData = {}; + +var SelectedAttachment = null; +var AttachmentScreenActive = false; +var ControlPressed = false; +var disableRightMouse = false; +var selectedItem = null; + +var IsDragging = false; + +$(document).on("keydown", function () { + if (event.repeat) { + return; + } + switch (event.keyCode) { + case 27: // ESC + Inventory.Close(); + break; + case 9: // TAB + Inventory.Close(); + break; + case 17: // TAB + ControlPressed = true; + break; + } +}); + +$(document).on("dblclick", ".item-slot", function (e) { + var ItemData = $(this).data("item"); + var ItemInventory = $(this).parent().attr("data-inventory"); + if (ItemData) { + Inventory.Close(); + $.post( + "https://ps-inventory/UseItem", + JSON.stringify({ + inventory: ItemInventory, + item: ItemData, + }) + ); + } +}); + +$(document).on("keyup", function () { + switch (event.keyCode) { + case 17: // TAB + ControlPressed = false; + break; + } +}); + +$(document).on("mouseenter", ".item-slot", function (e) { + e.preventDefault(); + $(".ply-iteminfo-container").css("opacity", "0.0"); + if ($(this).data("item") != null) { + $(".ply-iteminfo-container").css("opacity", "1.0"); + $(".ply-iteminfo-container").fadeIn(150); + // FormatItemInfo($(this).data("item")); + FormatItemInfo($(this).data("item"), $(this)); + } else { + $(".ply-iteminfo-container").fadeOut(100); + } +}); + +$(document).on("mouseleave", ".item-slot", function (e) { + $(".ply-iteminfo-container").css("opacity", "0.0"); +}); + +// Autostack Quickmove +function GetFirstFreeSlot($toInv, $fromSlot) { + var retval = null; + $.each($toInv.find(".item-slot"), function (i, slot) { + if ($(slot).data("item") === undefined) { + if (retval === null) { + retval = i + 1; + } + } + }); + return retval; +} + +function CanQuickMove() { + var otherinventory = otherLabel.toLowerCase(); + var retval = true; + // if (otherinventory == "grond") { + // retval = false + // } else if (otherinventory.split("-")[0] == "dropped") { + // retval = false; + // } + if (otherinventory.split("-")[0] == "player") { + retval = false; + } + return retval; +} + +$(document).on("mousedown", ".item-slot", function (event) { + switch (event.which) { + case 3: + fromSlot = $(this).attr("data-slot"); + fromInventory = $(this).parent(); + + if ($(fromInventory).attr("data-inventory") == "player") { + toInventory = $(".other-inventory"); + } else { + toInventory = $(".player-inventory"); + } + toSlot = GetFirstFreeSlot(toInventory, $(this)); + if ($(this).data("item") === undefined) { + return; + } + toAmount = $(this).data("item").amount; + if (toAmount > 1) { + toAmount = 1; + } + if (CanQuickMove()) { + if (toSlot === null) { + InventoryError(fromInventory, fromSlot); + return; + } + if (fromSlot == toSlot && fromInventory == toInventory) { + return; + } + if (toAmount >= 0) { + if ( + updateweights( + fromSlot, + toSlot, + fromInventory, + toInventory, + toAmount + ) + ) { + swap(fromSlot, toSlot, fromInventory, toInventory, toAmount); + } + } + } else { + InventoryError(fromInventory, fromSlot); + } + break; + } +}); + +// $(document).on("click", ".item-slot", function(e) { +// e.preventDefault(); +// var ItemData = $(this).data("item"); + +// if (ItemData !== null && ItemData !== undefined) { +// if (ItemData.name !== undefined) { +// if (ItemData.name.split("_")[0] == "weapon") { +// if (!$("#weapon-attachments").length) { +// // if (ItemData.info.attachments !== null && ItemData.info.attachments !== undefined && ItemData.info.attachments.length > 0) { +// $(".inv-options-list").append( +// '

' +// ); +// $("#weapon-attachments").hide().fadeIn(250); +// ClickedItemData = ItemData; +// // } +// } else if (ClickedItemData == ItemData) { +// $("#weapon-attachments").fadeOut(250, function() { +// $("#weapon-attachments").remove(); +// }); +// ClickedItemData = {}; +// } else { +// ClickedItemData = ItemData; +// } +// } else { +// ClickedItemData = {}; +// if ($("#weapon-attachments").length) { +// $("#weapon-attachments").fadeOut(250, function() { +// $("#weapon-attachments").remove(); +// }); +// } +// } +// } else { +// ClickedItemData = {}; +// if ($("#weapon-attachments").length) { +// $("#weapon-attachments").fadeOut(250, function() { +// $("#weapon-attachments").remove(); +// }); +// } +// } +// } else { +// ClickedItemData = {}; +// if ($("#weapon-attachments").length) { +// $("#weapon-attachments").fadeOut(250, function() { +// $("#weapon-attachments").remove(); +// }); +// } +// } +// }); + +$(document).on("click", "#inv-close", function (e) { + e.preventDefault(); + Inventory.Close(); +}); + +$(document).on("click", ".weapon-attachments-back", function (e) { + e.preventDefault(); + $("#qbcore-inventory").css({ display: "block" }); + $("#qbcore-inventory").animate({ + left: 0 + "vw", + }, + 200 + ); + $(".weapon-attachments-container").animate({ + left: -100 + "vw", + }, + 200, + function () { + $(".weapon-attachments-container").css({ display: "none" }); + } + ); + AttachmentScreenActive = false; +}); + +// function changeInventoryColor(color) { +// $( ".player-inventory-bg" ).css( "background-color", color); +// $( ".other-inventory-bg" ).css( "background-color", color); +// $( ".inv-options" ).css( "background-color", color); +// localStorage.setItem('ps-inventory-color', color); +// } + +// const savedColor = localStorage.getItem('ps-inventory-color'); + +// if (savedColor) { +// changeInventoryColor(savedColor) +// } + +// $('#favcolor').change(function(){ +// let color = $(this).val(); +// let hexOpacity = "CC"; +// let finalColor = color+hexOpacity; +// changeInventoryColor(finalColor); +// }); + +function FormatAttachmentInfo(data) { + $.post( + "https://ps-inventory/GetWeaponData", + JSON.stringify({ + weapon: data.name, + ItemData: ClickedItemData, + }), + function (data) { + console.log(data); + var AmmoLabel = "9mm"; + var Durability = 100; + if (data.WeaponData.ammotype == "AMMO_RIFLE") { + AmmoLabel = "7.62mm"; + } else if (data.WeaponData.ammotype == "AMMO_SHOTGUN") { + AmmoLabel = "12 Gauge"; + } + if (ClickedItemData.info.quality !== undefined) { + Durability = ClickedItemData.info.quality; + } + + $(".weapon-attachments-container-title").html( + data.WeaponData.label + " | " + AmmoLabel + ); + $(".weapon-attachments-container-description").html( + data.WeaponData.description + ); + $(".weapon-attachments-container-details").html( + 'Serienummer
' + + ClickedItemData.info.serie + + '

Holdbarhed - ' + + Durability.toFixed() + + '%
' + ); + $(".weapon-attachments-container-detail-durability-total").css({ + width: Durability + "%", + }); + $(".weapon-attachments-container-image").attr( + "src", + "./attachment_images/" + data.WeaponData.name + ".png" + ); + $(".weapon-attachments").html(""); + + if (data.AttachmentData !== null && data.AttachmentData !== undefined) { + if (data.AttachmentData.length > 0) { + $(".weapon-attachments-title").html( + 'Tilføjelser' + ); + $.each(data.AttachmentData, function (i, attachment) { + var WeaponType = data.WeaponData.ammotype + .split("_")[1] + .toLowerCase(); + $(".weapon-attachments").append( + '

' + + attachment.label + + '

' + ); + attachment.id = i; + $("#weapon-attachment-" + i).data("AttachmentData", attachment); + }); + } else { + $(".weapon-attachments-title").html( + 'Våbnet har ingen tilføjelser' + ); + } + } else { + $(".weapon-attachments-title").html( + 'Våbnet har ingen tilføjelser' + ); + } + + handleAttachmentDrag(); + } + ); +} + +var AttachmentDraggingData = {}; + +function handleAttachmentDrag() { + $(".weapon-attachment").draggable({ + helper: "clone", + appendTo: "body", + scroll: true, + revertDuration: 0, + revert: "invalid", + start: function (event, ui) { + var ItemData = $(this).data("AttachmentData"); + $(this).addClass("weapon-dragging-class"); + AttachmentDraggingData = ItemData; + }, + stop: function () { + $(this).removeClass("weapon-dragging-class"); + }, + }); + $(".weapon-attachments-remove").droppable({ + accept: ".weapon-attachment", + hoverClass: "weapon-attachments-remove-hover", + drop: function (event, ui) { + $.post( + "https://ps-inventory/RemoveAttachment", + JSON.stringify({ + AttachmentData: AttachmentDraggingData, + WeaponData: ClickedItemData, + }), + function (data) { + if (data.Attachments !== null && data.Attachments !== undefined) { + if (data.Attachments.length > 0) { + $("#weapon-attachment-" + AttachmentDraggingData.id).fadeOut( + 150, + function () { + $("#weapon-attachment-" + AttachmentDraggingData.id).remove(); + AttachmentDraggingData = null; + } + ); + } else { + $("#weapon-attachment-" + AttachmentDraggingData.id).fadeOut( + 150, + function () { + $("#weapon-attachment-" + AttachmentDraggingData.id).remove(); + AttachmentDraggingData = null; + $(".weapon-attachments").html(""); + } + ); + $(".weapon-attachments-title").html( + 'Våbnet har ingen tilføjelser' + ); + } + } else { + $("#weapon-attachment-" + AttachmentDraggingData.id).fadeOut( + 150, + function () { + $("#weapon-attachment-" + AttachmentDraggingData.id).remove(); + AttachmentDraggingData = null; + $(".weapon-attachments").html(""); + } + ); + $(".weapon-attachments-title").html( + 'Våbnet har ingen tilføjelser' + ); + } + } + ); + }, + }); +} + +$(document).on("click", "#weapon-attachments", function (e) { + e.preventDefault(); + if (!Inventory.IsWeaponBlocked(ClickedItemData.name)) { + $(".weapon-attachments-container").css({ display: "block" }); + $("#qbcore-inventory").animate({ + left: 100 + "vw", + }, + 200, + function () { + $("#qbcore-inventory").css({ display: "none" }); + } + ); + $(".weapon-attachments-container").animate({ + left: 0 + "vw", + }, + 200 + ); + AttachmentScreenActive = true; + FormatAttachmentInfo(ClickedItemData); + } else { + $.post( + "https://ps-inventory/Notify", + JSON.stringify({ + message: "Ingen tilføjelser tilgængelig for dette våben", + type: "error", + }) + ); + } +}); + +function FormatItemInfo(itemData, dom) { + + let element = $('.ply-iteminfo-container'); + let itemOffset = $(dom).offset(); + element.css('top', itemOffset.top - element.height()); + let leftOffset = itemOffset.left + 92; + if (leftOffset + element.width() > $(window).width()) { + leftOffset = $(window).width() - element.width() - 20; + } + element.css('left', leftOffset); + + if (itemData != null && itemData.info != "") { + if (itemData.name == "id_card") { + var gender = "Mand"; + if (itemData.info.gender == 1) { + gender = "Kvinde"; + } + $(".item-info-title").html("

" + itemData.label + "

"); + $(".item-info-description").html( + "

CPR: " + + itemData.info.citizenid + + "

Fornavn: " + + itemData.info.firstname + + "

Efternavn: " + + itemData.info.lastname + + "

Fødselsdato: " + + itemData.info.birthdate + + "

Køn: " + + gender + + "

Nationalitet: " + + itemData.info.nationality + + "

Vægt: " + itemData.weight + " | Antal: " + itemData.amount + " | Kvalitet: " + "" + Math.floor(itemData.info.quality) + "" + + ); + } else if (itemData.name == "driver_license") { + $(".item-info-title").html("

" + itemData.label + "

"); + $(".item-info-description").html( + "

Fornavn: " + + itemData.info.firstname + + "

Efternavn: " + + itemData.info.lastname + + "

Fødselsdato: " + + itemData.info.birthdate + + "

Tilladelser: " + + itemData.info.type + + "

" + ); + } else if (itemData.name == "weaponlicense") { + $(".item-info-title").html("

" + itemData.label + "

"); + $(".item-info-description").html( + "

Fornavn: " + + itemData.info.firstname + + "

Efternavn: " + + itemData.info.lastname + + "

Fødselsdato: " + + itemData.info.birthdate + + "

" + ); + } else if (itemData.name == "lawyerpass") { + $(".item-info-title").html("

" + itemData.label + "

"); + $(".item-info-description").html( + "

Tilladelses-ID: " + + itemData.info.id + + "

Fornavn: " + + itemData.info.firstname + + "

Efternavn: " + + itemData.info.lastname + + "

CPR: " + + itemData.info.citizenid + + "

" + ); + } else if (itemData.name == "harness") { + $(".item-info-title").html("

" + itemData.label + "

"); + $(".item-info-description").html( + "

" + itemData.info.uses + " brug tilbage.

" + ); + } else if (itemData.type == "weapon") { + $(".item-info-title").html("

" + itemData.label + "

"); + if (itemData.info.ammo == undefined) { + itemData.info.ammo = 0; + } else { + itemData.info.ammo != null ? itemData.info.ammo : 0; + } + if (itemData.info.attachments != null) { + var attachmentString = ""; + $.each(itemData.info.attachments, function (i, attachment) { + if (i == itemData.info.attachments.length - 1) { + attachmentString += attachment.label; + } else { + attachmentString += attachment.label + ", "; + } + }); + $(".item-info-description").html( + "

Serienummer: " + + itemData.info.serie + + "

Ammo: " + + itemData.info.ammo + + "

Tilføjelser: " + + attachmentString + + "

" + ); + } else { + $(".item-info-description").html( + "

Serienummer: " + + itemData.info.serie + + "

Ammo: " + + itemData.info.ammo + + "

" + + itemData.description + + "

" + ); + } + } else if (itemData.name == "filled_evidence_bag") { + $(".item-info-title").html("

" + itemData.label + "

"); + if (itemData.info.type == "casing") { + $(".item-info-description").html( + "

Bevismateriale: " + + itemData.info.label + + "

Typenummer: " + + itemData.info.ammotype + + "

Kaliber: " + + itemData.info.ammolabel + + "

Serienummer: " + + itemData.info.serie + + "

Gerningssted: " + + itemData.info.street + + "


" + + itemData.description + + "

" + ); + } else if (itemData.info.type == "blood") { + $(".item-info-description").html( + "

Bevismateriale: " + + itemData.info.label + + "

Blodtype: " + + itemData.info.bloodtype + + "

DNA kode: " + + itemData.info.dnalabel + + "

Gerningssted: " + + itemData.info.street + + "


" + + itemData.description + + "

Vægt: " + itemData.weight + " | Mængde: " + itemData.amount + " | Kvalitet: " + "" + Math.floor(itemData.info.quality) + "" + ); + } else if (itemData.info.type == "fingerprint") { + $(".item-info-description").html( + "

Bevismateriale: " + + itemData.info.label + + "

Fingeraftryk: " + + itemData.info.fingerprint + + "

Gerningssted: " + + itemData.info.street + + "


" + + itemData.description + + "

Vægt: " + itemData.weight + " | Mængde: " + itemData.amount + " | Kvalitet: " + "" + Math.floor(itemData.info.quality) + "" + ); + } else if (itemData.info.type == "dna") { + $(".item-info-description").html( + "

Bevismateriale: " + + itemData.info.label + + "

DNA kode: " + + itemData.info.dnalabel + + "


" + + itemData.description + + "

Vægt: " + itemData.weight + " | Mængde: " + itemData.amount + " | Kvalitet: " + "" + Math.floor(itemData.info.quality) + "" + ); + } + } else if ( + itemData.info.costs != undefined && + itemData.info.costs != null + ) { + $(".item-info-title").html("

" + itemData.label + "

"); + $(".item-info-description").html("

" + itemData.info.costs + "

Vægt: " + itemData.weight + " | Mængde: " + itemData.amount + " | Kvalitet: " + "" + Math.floor(itemData.info.quality) + ""); + } else if (itemData.name == "stickynote") { + $(".item-info-title").html("

" + itemData.label + "

"); + $(".item-info-description").html("

" + itemData.info.label + "

Vægt: " + itemData.weight + " | Mængde: " + itemData.amount + " | Kvalitet: " + "" + Math.floor(itemData.info.quality) + ""); + } else if (itemData.name == "moneybag") { + $(".item-info-title").html("

" + itemData.label + "

"); + $(".item-info-description").html( + "

Pengemændge: " + + itemData.info.cash + + ",-

Vægt: " + itemData.weight + " | Mængde: " + itemData.amount + " | Kvalitet: " + "" + Math.floor(itemData.info.quality) + "" + ); + } else if (itemData.name == "markedbills") { + $(".item-info-title").html("

" + itemData.label + "

"); + $(".item-info-description").html( + "

Værdi: " + + itemData.info.worth + + ",-

Vægt: " + itemData.weight + " | Mængde: " + itemData.amount + " | Kvalitet: " + "" + Math.floor(itemData.info.quality) + "" + ); + } else if (itemData.name == "mdtcitation") { + $(".item-info-title").html("

" + itemData.label + "

"); + $(".item-info-description").html( + '

Borger ID: ' + itemData.info.citizenId + '

' + + '

Bøde: ' + itemData.info.fine + '

' + + '

Dato: ' + itemData.info.date + '

' + + '

Hændelses ID: ' + itemData.info.incidentId + '

' + + '

Betjente: ' + itemData.info.officer + '

' + ); + } else if (itemData.name == "visa" || itemData.name == "mastercard") { + $(".item-info-title").html('

' + itemData.label + '

') + var str = "" + itemData.info.cardNumber + ""; + var res = str.slice(12); + var cardNumber = "************" + res; + $(".item-info-description").html('

Kortholder: ' + itemData.info.name + '

Borger ID: ' + itemData.info.citizenid + '

Kortnummer: ' + cardNumber + '

Vægt: ' + itemData.weight + " | Mængde: " + itemData.amount + " | Kvalitet: " + "" + Math.floor(itemData.info.quality) + ""); + } else if (itemData.name == "labkey") { + $(".item-info-title").html("

" + itemData.label + "

"); + $(".item-info-description").html("

Lab: " + itemData.info.lab + "

Vægt: " + itemData.weight + " | Mængde: " + itemData.amount + " | Kvalitet: " + "" + Math.floor(itemData.info.quality) + ""); + } else { + $(".item-info-title").html("

" + itemData.label + "

"); + $(".item-info-description").html("

" + itemData.description + "

Vægt: " + itemData.weight + " | Mængde: " + itemData.amount + " | Kvalitet: " + "" + Math.floor(itemData.info.quality) + ""); + } + } else { + $(".item-info-title").html("

" + itemData.label + "

"); + $(".item-info-description").html("

" + itemData.description + "

Vægt: " + itemData.weight + " | Mængde: " + itemData.amount + " | Kvalitet: " + "" + Math.floor(itemData.info.quality) + ""); + } +} + +function handleDragDrop() { + $(".item-drag").draggable({ + helper: "clone", + appendTo: "body", + scroll: true, + revertDuration: 0, + revert: "invalid", + cancel: ".item-nodrag", + start: function (event, ui) { + IsDragging = true; + // $(this).css("background", "rgba(20,20,20,1.0)"); + $(this).find("img").css("filter", "brightness(50%)"); + + // $(".item-slot").css("border", "1px solid rgba(255, 255, 255, 0.1)"); + + var itemData = $(this).data("item"); + var dragAmount = $("#item-amount").val(); + if (!itemData.useable) { + // $("#item-use").css("background", "rgba(35,35,35, 0.5"); + } + + if (dragAmount == 0) { + if (itemData.price != null) { + $(this).find(".item-slot-amount p").html("0"); + $(".ui-draggable-dragging") + .find(".item-slot-amount p") + .html(" " + itemData.amount + " - " + itemData.price+",-"); + $(".ui-draggable-dragging").find(".item-slot-key").remove(); + if ($(this).parent().attr("data-inventory") == "hotbar") { + // $(".ui-draggable-dragging").find(".item-slot-key").remove(); + } + } else { + $(this).find(".item-slot-amount p").html("0"); + $(".ui-draggable-dragging") + .find(".item-slot-amount p") + .html( + itemData.amount + + " " + + + " " + ); + $(".ui-draggable-dragging").find(".item-slot-key").remove(); + if ($(this).parent().attr("data-inventory") == "hotbar") { + // $(".ui-draggable-dragging").find(".item-slot-key").remove(); + } + } + } else if (dragAmount > itemData.amount) { + if (itemData.price != null) { + $(this) + .find(".item-slot-amount p") + .html(" " + itemData.amount + " - " + itemData.price+",-"); + if ($(this).parent().attr("data-inventory") == "hotbar") { + // $(".ui-draggable-dragging").find(".item-slot-key").remove(); + } + } else { + $(this) + .find(".item-slot-amount p") + .html( + itemData.amount + + " " + + + " " + ); + if ($(this).parent().attr("data-inventory") == "hotbar") { + // $(".ui-draggable-dragging").find(".item-slot-key").remove(); + } + } + InventoryError($(this).parent(), $(this).attr("data-slot")); + } else if (dragAmount > 0) { + if (itemData.price != null) { + $(this) + .find(".item-slot-amount p") + .html(" " + itemData.amount + " - " + itemData.price+",-"); + $(".ui-draggable-dragging") + .find(".item-slot-amount p") + .html(" " + itemData.amount + " - " + itemData.price+",-"); + $(".ui-draggable-dragging").find(".item-slot-key").remove(); + if ($(this).parent().attr("data-inventory") == "hotbar") { + // $(".ui-draggable-dragging").find(".item-slot-key").remove(); + } + } else { + $(this) + .find(".item-slot-amount p") + .html( + itemData.amount - + dragAmount + + " " + + ( + (itemData.weight * (itemData.amount - dragAmount)) / + 1000 + ).toFixed(1) + + " " + ); + $(".ui-draggable-dragging") + .find(".item-slot-amount p") + .html( + dragAmount + + " " + + + " " + ); + $(".ui-draggable-dragging").find(".item-slot-key").remove(); + if ($(this).parent().attr("data-inventory") == "hotbar") { + // $(".ui-draggable-dragging").find(".item-slot-key").remove(); + } + } + } else { + if ($(this).parent().attr("data-inventory") == "hotbar") { + // $(".ui-draggable-dragging").find(".item-slot-key").remove(); + } + $(".ui-draggable-dragging").find(".item-slot-key").remove(); + $(this) + .find(".item-slot-amount p") + .html( + itemData.amount + + " " + + + " " + ); + InventoryError($(this).parent(), $(this).attr("data-slot")); + } + }, + stop: function () { + setTimeout(function () { + IsDragging = false; + }, 300); + $(this).css("background", "rgba(0, 0, 0, 0.3)"); + $(this).find("img").css("filter", "brightness(100%)"); + // $("#item-use").css("background", "rgba(" + InventoryOption + ", 0.3)"); + }, + }); + + $(".item-slot").droppable({ + hoverClass: "item-slot-hoverClass", + drop: function (event, ui) { + setTimeout(function () { + IsDragging = false; + }, 300); + fromSlot = ui.draggable.attr("data-slot"); + fromInventory = ui.draggable.parent(); + toSlot = $(this).attr("data-slot"); + toInventory = $(this).parent(); + toAmount = $("#item-amount").val(); + + var toDataUnique = toInventory.find("[data-slot=" + toSlot + "]").data("item"); + var fromDataUnique = fromInventory.find("[data-slot=" + fromSlot + "]").data("item"); + + if (fromSlot == toSlot && fromInventory == toInventory) { + return; + } + if (toAmount >= 0) { + if (!toDataUnique) { + if ( + updateweights(fromSlot, toSlot, fromInventory, toInventory, toAmount) + ) { + swap(fromSlot, toSlot, fromInventory, toInventory, toAmount); + } + } else { + if (fromDataUnique.unique == toDataUnique.unique) { + if (!toDataUnique.combinable) { + if ( + updateweights(fromSlot, toSlot, fromInventory, toInventory, toAmount) + ) { + swap(fromSlot, toSlot, fromInventory, toInventory, toAmount); + } + } else { + swap(fromSlot, toSlot, fromInventory, toInventory, toAmount); + } + } else { + if ( + updateweights(fromSlot, toSlot, fromInventory, toInventory, toAmount) + ) { + swap(fromSlot, toSlot, fromInventory, toInventory, toAmount); + } + } + } + } + }, + }); + + $("#item-use").droppable({ + hoverClass: "button-hover", + drop: function (event, ui) { + setTimeout(function () { + IsDragging = false; + }, 300); + fromData = ui.draggable.data("item"); + fromInventory = ui.draggable.parent().attr("data-inventory"); + if (fromData.useable) { + if (fromData.shouldClose) { + Inventory.Close(); + } + $.post( + "https://ps-inventory/UseItem", + JSON.stringify({ + inventory: fromInventory, + item: fromData, + }) + ); + } + }, + }); + + $("#item-drop").droppable({ + hoverClass: "item-slot-hoverClass", + drop: function (event, ui) { + setTimeout(function () { + IsDragging = false; + }, 300); + fromData = ui.draggable.data("item"); + fromInventory = ui.draggable.parent().attr("data-inventory"); + amount = $("#item-amount").val(); + if (amount == 0) { + amount = fromData.amount; + } + $(this).css("background", "rgba(35,35,35, 0.7"); + $.post( + "https://ps-inventory/DropItem", + JSON.stringify({ + inventory: fromInventory, + item: fromData, + amount: parseInt(amount), + }) + ); + }, + }); +} + +function updateweights($fromSlot, $toSlot, $fromInv, $toInv, $toAmount) { + var otherinventory = otherLabel.toLowerCase(); + if (otherinventory.split("-")[0] == "dropped") { + toData = $toInv.find("[data-slot=" + $toSlot + "]").data("item"); + if (toData !== null && toData !== undefined) { + InventoryError($fromInv, $fromSlot); + return false; + } + } + + if ( + ($fromInv.attr("data-inventory") == "hotbar" && + $toInv.attr("data-inventory") == "player") || + ($fromInv.attr("data-inventory") == "player" && + $toInv.attr("data-inventory") == "hotbar") || + ($fromInv.attr("data-inventory") == "player" && + $toInv.attr("data-inventory") == "player") || + ($fromInv.attr("data-inventory") == "hotbar" && + $toInv.attr("data-inventory") == "hotbar") + ) { + return true; + } + + if ( + ($fromInv.attr("data-inventory").split("-")[0] == "itemshop" && + $toInv.attr("data-inventory").split("-")[0] == "itemshop") || + ($fromInv.attr("data-inventory") == "crafting" && + $toInv.attr("data-inventory") == "crafting") + ) { + itemData = $fromInv.find("[data-slot=" + $fromSlot + "]").data("item"); + if ($fromInv.attr("data-inventory").split("-")[0] == "itemshop") { + $fromInv + .find("[data-slot=" + $fromSlot + "]") + .html( + '

' +
+                    itemData.name +
+                    '

' + + itemData.amount + + '

' + + " $" + + itemData.price + + '

' + + itemData.label + + "

" + ); + } else { + $fromInv + .find("[data-slot=" + $fromSlot + "]") + .html( + '
' +
+                    itemData.name +
+                    '

' + + itemData.amount + + '

' + + " " + + ((itemData.weight * itemData.amount) / 1000).toFixed(1) + + '

' + + itemData.label + + "

" + ); + } + + InventoryError($fromInv, $fromSlot); + return false; + } + + if ( + $toAmount == 0 && + ($fromInv.attr("data-inventory").split("-")[0] == "itemshop" || + $fromInv.attr("data-inventory") == "crafting") + ) { + itemData = $fromInv.find("[data-slot=" + $fromSlot + "]").data("item"); + if ($fromInv.attr("data-inventory").split("-")[0] == "itemshop") { + $fromInv + .find("[data-slot=" + $fromSlot + "]") + .html( + '
' +
+                    itemData.name +
+                    '

' + + itemData.amount + + '

' + + " $" + + itemData.price + + '

' + + itemData.label + + "

" + ); + } else { + $fromInv + .find("[data-slot=" + $fromSlot + "]") + .html( + '
' +
+                    itemData.name +
+                    '

' + + itemData.amount + + '

' + + " " + + ((itemData.weight * itemData.amount) / 1000).toFixed(1) + + '

' + + itemData.label + + "

" + ); + } + + InventoryError($fromInv, $fromSlot); + return false; + } + + if ( + $toInv.attr("data-inventory").split("-")[0] == "itemshop" || + $toInv.attr("data-inventory") == "crafting" + ) { + itemData = $toInv.find("[data-slot=" + $toSlot + "]").data("item"); + if ($toInv.attr("data-inventory").split("-")[0] == "itemshop") { + $toInv + .find("[data-slot=" + $toSlot + "]") + .html( + '
' +
+                    itemData.name +
+                    '

' + + itemData.amount + + '

' + + " $" + + itemData.price + + '

' + + itemData.label + + "

" + ); + } else { + $toInv + .find("[data-slot=" + $toSlot + "]") + .html( + '
' +
+                    itemData.name +
+                    '

' + + itemData.amount + + '

' + + " " + + ((itemData.weight * itemData.amount) / 1000).toFixed(1) + + '

' + + itemData.label + + "

" + ); + } + + InventoryError($fromInv, $fromSlot); + return false; + } + + if ($fromInv.attr("data-inventory") != $toInv.attr("data-inventory")) { + fromData = $fromInv.find("[data-slot=" + $fromSlot + "]").data("item"); + toData = $toInv.find("[data-slot=" + $toSlot + "]").data("item"); + if ($toAmount == 0) { + $toAmount = fromData.amount; + } + if (toData == null || fromData.name == toData.name) { + if ( + $fromInv.attr("data-inventory") == "player" || + $fromInv.attr("data-inventory") == "hotbar" + ) { + totalWeight = totalWeight - fromData.weight * $toAmount; + totalWeightOther = totalWeightOther + fromData.weight * $toAmount; + } else { + totalWeight = totalWeight + fromData.weight * $toAmount; + totalWeightOther = totalWeightOther - fromData.weight * $toAmount; + } + } else { + if ( + $fromInv.attr("data-inventory") == "player" || + $fromInv.attr("data-inventory") == "hotbar" + ) { + totalWeight = totalWeight - fromData.weight * $toAmount; + totalWeight = totalWeight + toData.weight * toData.amount; + + totalWeightOther = totalWeightOther + fromData.weight * $toAmount; + totalWeightOther = totalWeightOther - toData.weight * toData.amount; + } else { + totalWeight = totalWeight + fromData.weight * $toAmount; + totalWeight = totalWeight - toData.weight * toData.amount; + + totalWeightOther = totalWeightOther - fromData.weight * $toAmount; + totalWeightOther = totalWeightOther + toData.weight * toData.amount; + } + } + } + + if ( + totalWeight > playerMaxWeight || + (totalWeightOther > otherMaxWeight && + $fromInv.attr("data-inventory").split("-")[0] != "itemshop" && + $fromInv.attr("data-inventory") != "crafting") + ) { + InventoryError($fromInv, $fromSlot); + return false; + } + + var per = (totalWeight / 1000) / (playerMaxWeight / 100000) + $(".pro").css("width", per + "%") + $("#player-inv-weight").html( + // ' ' + + (parseInt(totalWeight) / 1000).toFixed(2) + + "/" + + (playerMaxWeight / 1000).toFixed(2) + ); + if ( + $fromInv.attr("data-inventory").split("-")[0] != "itemshop" && + $toInv.attr("data-inventory").split("-")[0] != "itemshop" && + $fromInv.attr("data-inventory") != "crafting" && + $toInv.attr("data-inventory") != "crafting" + ) { + $("#other-inv-label").html(otherLabel); + $("#other-inv-weight").html( + // ' ' + + (parseInt(totalWeightOther) / 1000).toFixed(2) + + "/" + + (otherMaxWeight / 1000).toFixed(2) + ); + var per1 = (totalWeightOther / 1000) / (otherMaxWeight / 100000) + $(".pro1").css("width", per1 + "%"); + } + + return true; +} + +var combineslotData = null; + +$(document).on("click", ".CombineItem", function (e) { + e.preventDefault(); + if (combineslotData.toData.combinable.anim != null) { + $.post( + "https://ps-inventory/combineWithAnim", + JSON.stringify({ + combineData: combineslotData.toData.combinable, + usedItem: combineslotData.toData.name, + requiredItem: combineslotData.fromData.name, + }) + ); + } else { + $.post( + "https://ps-inventory/combineItem", + JSON.stringify({ + reward: combineslotData.toData.combinable.reward, + toItem: combineslotData.toData.name, + fromItem: combineslotData.fromData.name, + }) + ); + } + Inventory.Close(); +}); + +$(document).on("click", ".SwitchItem", function (e) { + e.preventDefault(); + $(".combine-option-container").hide(); + + optionSwitch( + combineslotData.fromSlot, + combineslotData.toSlot, + combineslotData.fromInv, + combineslotData.toInv, + combineslotData.toAmount, + combineslotData.toData, + combineslotData.fromData + ); +}); + +function optionSwitch( + $fromSlot, + $toSlot, + $fromInv, + $toInv, + $toAmount, + toData, + fromData +) { + fromData.slot = parseInt($toSlot); + + $toInv.find("[data-slot=" + $toSlot + "]").data("item", fromData); + + $toInv.find("[data-slot=" + $toSlot + "]").addClass("item-drag"); + $toInv.find("[data-slot=" + $toSlot + "]").removeClass("item-nodrag"); + + if ($toSlot < 6) { + $toInv + .find("[data-slot=" + $toSlot + "]") + .html( + '

' + + $toSlot + + '

' +
+                fromData.name +
+                '

' + + fromData.amount + + '

' + + " " + + ((fromData.weight * fromData.amount) / 1000).toFixed(1) + + '

' + + fromData.label + + "

" + ); + } else { + $toInv + .find("[data-slot=" + $toSlot + "]") + .html( + '
' +
+                fromData.name +
+                '

' + + fromData.amount + + '

' + + " " + + ((fromData.weight * fromData.amount) / 1000).toFixed(1) + + '

' + + fromData.label + + "

" + ); + } + + toData.slot = parseInt($fromSlot); + + $fromInv.find("[data-slot=" + $fromSlot + "]").addClass("item-drag"); + $fromInv.find("[data-slot=" + $fromSlot + "]").removeClass("item-nodrag"); + + $fromInv.find("[data-slot=" + $fromSlot + "]").data("item", toData); + + if ($fromSlot < 6) { + $fromInv + .find("[data-slot=" + $fromSlot + "]") + .html( + '

' + + $fromSlot + + '

' +
+                toData.name +
+                '

' + + toData.amount + + '

' + + " " + + ((toData.weight * toData.amount) / 1000).toFixed(1) + + '

' + + toData.label + + "

" + ); + } else { + $fromInv + .find("[data-slot=" + $fromSlot + "]") + .html( + '
' +
+                toData.name +
+                '

' + + toData.amount + + '

' + + " " + + ((toData.weight * toData.amount) / 1000).toFixed(1) + + '

' + + toData.label + + "

" + ); + } + + $.post( + "https://ps-inventory/SetInventoryData", + JSON.stringify({ + fromInventory: $fromInv.attr("data-inventory"), + toInventory: $toInv.attr("data-inventory"), + fromSlot: $fromSlot, + toSlot: $toSlot, + fromAmount: $toAmount, + toAmount: toData.amount, + }) + ); +} + +function swap($fromSlot, $toSlot, $fromInv, $toInv, $toAmount) { + fromData = $fromInv.find("[data-slot=" + $fromSlot + "]").data("item"); + toData = $toInv.find("[data-slot=" + $toSlot + "]").data("item"); + var otherinventory = otherLabel.toLowerCase(); + + if (otherinventory.split("-")[0] == "dropped") { + if (toData !== null && toData !== undefined) { + InventoryError($fromInv, $fromSlot); + return; + } + } + + if (fromData !== undefined && fromData.amount >= $toAmount) { + if (fromData.unique && $toAmount > 1) { + InventoryError($fromInv, $fromSlot); + return; + } + + if ( + ($fromInv.attr("data-inventory") == "player" || + $fromInv.attr("data-inventory") == "hotbar") && + $toInv.attr("data-inventory").split("-")[0] == "itemshop" && + $toInv.attr("data-inventory") == "crafting" + ) { + InventoryError($fromInv, $fromSlot); + return; + } + + if ( + $toAmount == 0 && + $fromInv.attr("data-inventory").split("-")[0] == "itemshop" && + $fromInv.attr("data-inventory") == "crafting" + ) { + InventoryError($fromInv, $fromSlot); + return; + } else if ($toAmount == 0) { + $toAmount = fromData.amount; + } + if ( + (toData != undefined || toData != null) && + toData.name == fromData.name && + !fromData.unique + ) { + var newData = []; + newData.name = toData.name; + newData.label = toData.label; + newData.amount = parseInt($toAmount) + parseInt(toData.amount); + newData.type = toData.type; + newData.description = toData.description; + newData.image = toData.image; + newData.weight = toData.weight; + newData.info = toData.info; + newData.useable = toData.useable; + newData.unique = toData.unique; + newData.slot = parseInt($toSlot); + + if (newData.name == fromData.name) { + if (newData.info.quality !== fromData.info.quality) { + InventoryError($fromInv, $fromSlot); + $.post( + "https://ps-inventory/Notify", + JSON.stringify({ + message: "Du kan ikke stacke ting med forskellige kvalitet.", + type: "error", + }) + ); + return; + + } + } + + if (fromData.amount == $toAmount) { + $toInv.find("[data-slot=" + $toSlot + "]").data("item", newData); + + $toInv.find("[data-slot=" + $toSlot + "]").addClass("item-drag"); + $toInv.find("[data-slot=" + $toSlot + "]").removeClass("item-nodrag"); + + var ItemLabel = + '

' + newData.label + "

"; + // if (newData.name.split("_")[0] == "weapon") { + // if (!Inventory.IsWeaponBlocked(newData.name)) { + ItemLabel = + '

100

' + + newData.label + + "

"; + // } + // } + + if ($toSlot < 6 && $toInv.attr("data-inventory") == "player") { + $toInv + .find("[data-slot=" + $toSlot + "]") + .html( + '

' + + $toSlot + + '

' +
+                            newData.name +
+                            '

' + + newData.amount + + '

' + + " " + + ((newData.weight * newData.amount) / 1000).toFixed(1) + + "

" + + ItemLabel + ); + } else if ($toSlot == 43 && $toInv.attr("data-inventory") == "player") { + $toInv + .find("[data-slot=" + $toSlot + "]") + .html( + '

6

' +
+                            newData.name +
+                            '

' + + newData.amount + + '

' + + " " + + ((newData.weight * newData.amount) / 1000).toFixed(1) + + "

" + + ItemLabel + ); + } else { + $toInv + .find("[data-slot=" + $toSlot + "]") + .html( + '
' +
+                            newData.name +
+                            '

' + + newData.amount + + '

' + + " " + + ((newData.weight * newData.amount) / 1000).toFixed(1) + + "

" + + ItemLabel + ); + } + + // if (newData.name.split("_")[0] == "weapon") { + // if (!Inventory.IsWeaponBlocked(newData.name)) { + if (newData.info.quality == undefined) { + newData.info.quality = 100.0; + } + var QualityColor = "rgb(15, 255, 213)"; + if (newData.info.quality < 25) { + QualityColor = "rgb(192, 57, 43)"; + } else if (newData.info.quality > 25 && newData.info.quality < 50) { + QualityColor = "rgb(230, 126, 34)"; + } else if (newData.info.quality >= 50) { + QualityColor = "rgb(15, 255, 213)"; + } + if (newData.info.quality !== undefined) { + qualityLabel = newData.info.quality.toFixed(); + } else { + qualityLabel = newData.info.quality; + } + if (newData.info.quality == 0) { + qualityLabel = "ØDELAGT"; + } + $toInv + .find("[data-slot=" + $toSlot + "]") + .find(".item-slot-quality-bar") + .css({ + width: qualityLabel + "%", + "background-color": QualityColor, + }) + .find("p") + .html(qualityLabel); + // } + // } + + $fromInv.find("[data-slot=" + $fromSlot + "]").removeClass("item-drag"); + $fromInv.find("[data-slot=" + $fromSlot + "]").addClass("item-nodrag"); + + $fromInv.find("[data-slot=" + $fromSlot + "]").removeData("item"); + $fromInv + .find("[data-slot=" + $fromSlot + "]") + .html( + '

 

' + ); + } else if (fromData.amount > $toAmount) { + var newDataFrom = []; + newDataFrom.name = fromData.name; + newDataFrom.label = fromData.label; + newDataFrom.amount = parseInt(fromData.amount - $toAmount); + newDataFrom.type = fromData.type; + newDataFrom.description = fromData.description; + newDataFrom.image = fromData.image; + newDataFrom.weight = fromData.weight; + newDataFrom.price = fromData.price; + newDataFrom.info = fromData.info; + newDataFrom.useable = fromData.useable; + newDataFrom.unique = fromData.unique; + newDataFrom.slot = parseInt($fromSlot); + + $toInv.find("[data-slot=" + $toSlot + "]").data("item", newData); + + $toInv.find("[data-slot=" + $toSlot + "]").addClass("item-drag"); + $toInv.find("[data-slot=" + $toSlot + "]").removeClass("item-nodrag"); + + var ItemLabel = + '

' + newData.label + "

"; + // if (newData.name.split("_")[0] == "weapon") { + // if (!Inventory.IsWeaponBlocked(newData.name)) { + ItemLabel = + '

100

' + + newData.label + + "

"; + // } + // } + + if ($toSlot < 6 && $toInv.attr("data-inventory") == "player") { + $toInv + .find("[data-slot=" + $toSlot + "]") + .html( + '

' + + $toSlot + + '

' +
+                            newData.name +
+                            '

' + + newData.amount + + '

' + + " " + + ((newData.weight * newData.amount) / 1000).toFixed(1) + + "

" + + ItemLabel + ); + } else if ($toSlot == 43 && $toInv.attr("data-inventory") == "player") { + $toInv + .find("[data-slot=" + $toSlot + "]") + .html( + '

6

' +
+                            newData.name +
+                            '

' + + newData.amount + + '

' + + " " + + ((newData.weight * newData.amount) / 1000).toFixed(1) + + "

" + + ItemLabel + ); + } else { + $toInv + .find("[data-slot=" + $toSlot + "]") + .html( + '
' +
+                            newData.name +
+                            '

' + + newData.amount + + '

' + + " " + + ((newData.weight * newData.amount) / 1000).toFixed(1) + + "

" + + ItemLabel + ); + } + + // if (newData.name.split("_")[0] == "weapon") { + // if (!Inventory.IsWeaponBlocked(newData.name)) { + if (newData.info.quality == undefined) { + newData.info.quality = 100.0; + } + var QualityColor = "rgb(15, 255, 213)"; + if (newData.info.quality < 25) { + QualityColor = "rgb(192, 57, 43)"; + } else if (newData.info.quality > 25 && newData.info.quality < 50) { + QualityColor = "rgb(230, 126, 34)"; + } else if (newData.info.quality >= 50) { + QualityColor = "rgb(15, 255, 213)"; + } + if (newData.info.quality !== undefined) { + qualityLabel = newData.info.quality.toFixed(); + } else { + qualityLabel = newData.info.quality; + } + if (newData.info.quality == 0) { + qualityLabel = "ØDELAGT"; + } + $toInv + .find("[data-slot=" + $toSlot + "]") + .find(".item-slot-quality-bar") + .css({ + width: qualityLabel + "%", + "background-color": QualityColor, + }) + .find("p") + .html(qualityLabel); + // } + // } + + // From Data zooi + $fromInv + .find("[data-slot=" + $fromSlot + "]") + .data("item", newDataFrom); + + $fromInv.find("[data-slot=" + $fromSlot + "]").addClass("item-drag"); + $fromInv + .find("[data-slot=" + $fromSlot + "]") + .removeClass("item-nodrag"); + + if ($fromInv.attr("data-inventory").split("-")[0] == "itemshop") { + $fromInv + .find("[data-slot=" + $fromSlot + "]") + .html( + '
' +
+                            newDataFrom.name +
+                            '

' + + newDataFrom.amount + + '

' + + " $" + + newDataFrom.price + + '

' + + newDataFrom.label + + "

" + ); + } else { + var ItemLabel = + '

' + + newDataFrom.label + + "

"; + // if (newDataFrom.name.split("_")[0] == "weapon") { + // if (!Inventory.IsWeaponBlocked(newDataFrom.name)) { + ItemLabel = + '

100

' + + newDataFrom.label + + "

"; + // } + // } + + if ($fromSlot < 6 && $fromInv.attr("data-inventory") == "player") { + $fromInv + .find("[data-slot=" + $fromSlot + "]") + .html( + '

' + + $fromSlot + + '

' +
+                                newDataFrom.name +
+                                '

' + + newDataFrom.amount + + '

' + + " " + + ((newDataFrom.weight * newDataFrom.amount) / 1000).toFixed( + 1 + ) + + "

" + + ItemLabel + ); + } else if ( + $fromSlot == 43 && + $fromInv.attr("data-inventory") == "player" + ) { + $fromInv + .find("[data-slot=" + $fromSlot + "]") + .html( + '

6

' +
+                                newDataFrom.name +
+                                '

' + + newDataFrom.amount + + '

' + + " " + + ((newDataFrom.weight * newDataFrom.amount) / 1000).toFixed( + 1 + ) + + "

" + + ItemLabel + ); + } else { + $fromInv + .find("[data-slot=" + $fromSlot + "]") + .html( + '
' +
+                                newDataFrom.name +
+                                '

' + + newDataFrom.amount + + '

' + + " " + + ((newDataFrom.weight * newDataFrom.amount) / 1000).toFixed( + 1 + ) + + "

" + + ItemLabel + ); + } + + // if (newDataFrom.name.split("_")[0] == "weapon") { + // if (!Inventory.IsWeaponBlocked(newDataFrom.name)) { + if (newDataFrom.info.quality == undefined) { + newDataFrom.info.quality = 100.0; + } + var QualityColor = "rgb(15, 255, 213)"; + if (newDataFrom.info.quality < 25) { + QualityColor = "rgb(192, 57, 43)"; + } else if ( + newDataFrom.info.quality > 25 && + newDataFrom.info.quality < 50 + ) { + QualityColor = "rgb(230, 126, 34)"; + } else if (newDataFrom.info.quality >= 50) { + QualityColor = "rgb(15, 255, 213)"; + } + if (newDataFrom.info.quality !== undefined) { + qualityLabel = newDataFrom.info.quality.toFixed(); + } else { + qualityLabel = newDataFrom.info.quality; + } + if (newDataFrom.info.quality == 0) { + qualityLabel = "ØDELAGT"; + } + $fromInv + .find("[data-slot=" + $fromSlot + "]") + .find(".item-slot-quality-bar") + .css({ + width: qualityLabel + "%", + "background-color": QualityColor, + }) + .find("p") + .html(qualityLabel); + // } + // } + } + } + $.post("https://ps-inventory/PlayDropSound", JSON.stringify({})); + $.post( + "https://ps-inventory/SetInventoryData", + JSON.stringify({ + fromInventory: $fromInv.attr("data-inventory"), + toInventory: $toInv.attr("data-inventory"), + fromSlot: $fromSlot, + toSlot: $toSlot, + fromAmount: $toAmount, + }) + ); + } else { + if (fromData.amount == $toAmount) { + if (toData && toData.unique) { + InventoryError($fromInv, $fromSlot); + return; + } + if ( + toData != undefined && + toData.combinable != null && + isItemAllowed(fromData.name, toData.combinable.accept) + ) { + $.post( + "https://ps-inventory/getCombineItem", + JSON.stringify({ item: toData.combinable.reward }), + function (item) { + $(".combine-option-text").html( + "

Kombineringen af de to ting giver: " + + item.label + + "

" + ); + } + ); + $(".combine-option-container").fadeIn(100); + combineslotData = []; + combineslotData.fromData = fromData; + combineslotData.toData = toData; + combineslotData.fromSlot = $fromSlot; + combineslotData.toSlot = $toSlot; + combineslotData.fromInv = $fromInv; + combineslotData.toInv = $toInv; + combineslotData.toAmount = $toAmount; + return; + } + + fromData.slot = parseInt($toSlot); + + $toInv.find("[data-slot=" + $toSlot + "]").data("item", fromData); + + $toInv.find("[data-slot=" + $toSlot + "]").addClass("item-drag"); + $toInv.find("[data-slot=" + $toSlot + "]").removeClass("item-nodrag"); + + var ItemLabel = + '

' + fromData.label + "

"; + // if (fromData.name.split("_")[0] == "weapon") { + // if (!Inventory.IsWeaponBlocked(fromData.name)) { + ItemLabel = + '

100

' + + fromData.label + + "

"; + // } + // } + + if ($toSlot < 6 && $toInv.attr("data-inventory") == "player") { + $toInv + .find("[data-slot=" + $toSlot + "]") + .html( + '

' + + $toSlot + + '

' +
+                            fromData.name +
+                            '

' + + fromData.amount + + '

' + + " " + + ((fromData.weight * fromData.amount) / 1000).toFixed(1) + + "

" + + ItemLabel + ); + } else if ($toSlot == 43 && $toInv.attr("data-inventory") == "player") { + $toInv + .find("[data-slot=" + $toSlot + "]") + .html( + '

6

' +
+                            fromData.name +
+                            '

' + + fromData.amount + + '

' + + " " + + ((fromData.weight * fromData.amount) / 1000).toFixed(1) + + "

" + + ItemLabel + ); + } else { + $toInv + .find("[data-slot=" + $toSlot + "]") + .html( + '
' +
+                            fromData.name +
+                            '

' + + fromData.amount + + '

' + + " " + + ((fromData.weight * fromData.amount) / 1000).toFixed(1) + + "

" + + ItemLabel + ); + } + + // if (fromData.name.split("_")[0] == "weapon") { + // if (!Inventory.IsWeaponBlocked(fromData.name)) { + if (fromData.info.quality == undefined) { + fromData.info.quality = 100.0; + } + var QualityColor = "rgb(15, 255, 213)"; + if (fromData.info.quality < 25) { + QualityColor = "rgb(192, 57, 43)"; + } else if ( + fromData.info.quality > 25 && + fromData.info.quality < 50 + ) { + QualityColor = "rgb(230, 126, 34)"; + } else if (fromData.info.quality >= 50) { + QualityColor = "rgb(15, 255, 213)"; + } + if (fromData.info.quality !== undefined) { + qualityLabel = fromData.info.quality.toFixed(); + } else { + qualityLabel = fromData.info.quality; + } + if (fromData.info.quality == 0) { + qualityLabel = "ØDELAGT"; + } + $toInv + .find("[data-slot=" + $toSlot + "]") + .find(".item-slot-quality-bar") + .css({ + width: qualityLabel + "%", + "background-color": QualityColor, + }) + .find("p") + .html(qualityLabel); + // } + // } + + if (toData != undefined) { + toData.slot = parseInt($fromSlot); + + $fromInv.find("[data-slot=" + $fromSlot + "]").addClass("item-drag"); + $fromInv + .find("[data-slot=" + $fromSlot + "]") + .removeClass("item-nodrag"); + + $fromInv.find("[data-slot=" + $fromSlot + "]").data("item", toData); + + var ItemLabel = + '

' + toData.label + "

"; + // if (toData.name.split("_")[0] == "weapon") { + // if (!Inventory.IsWeaponBlocked(toData.name)) { + ItemLabel = + '

100

' + + toData.label + + "

"; + // } + // } + + if ($fromSlot < 6 && $fromInv.attr("data-inventory") == "player") { + $fromInv + .find("[data-slot=" + $fromSlot + "]") + .html( + '

' + + $fromSlot + + '

' +
+                                toData.name +
+                                '

' + + toData.amount + + '

' + + " " + + ((toData.weight * toData.amount) / 1000).toFixed(1) + + "

" + + ItemLabel + ); + } else if ( + $fromSlot == 43 && + $fromInv.attr("data-inventory") == "player" + ) { + $fromInv + .find("[data-slot=" + $fromSlot + "]") + .html( + '

6

' +
+                                toData.name +
+                                '

' + + toData.amount + + '

' + + " " + + ((toData.weight * toData.amount) / 1000).toFixed(1) + + "

" + + ItemLabel + ); + } else { + $fromInv + .find("[data-slot=" + $fromSlot + "]") + .html( + '
' +
+                                toData.name +
+                                '

' + + toData.amount + + '

' + + " " + + ((toData.weight * toData.amount) / 1000).toFixed(1) + + "

" + + ItemLabel + ); + } + + // if (toData.name.split("_")[0] == "weapon") { + // if (!Inventory.IsWeaponBlocked(toData.name)) { + if (toData.info.quality == undefined) { + toData.info.quality = 100.0; + } + var QualityColor = "rgb(15, 255, 213)"; + if (toData.info.quality < 25) { + QualityColor = "rgb(192, 57, 43)"; + } else if (toData.info.quality > 25 && toData.info.quality < 50) { + QualityColor = "rgb(230, 126, 34)"; + } else if (toData.info.quality >= 50) { + QualityColor = "rgb(15, 255, 213)"; + } + if (toData.info.quality !== undefined) { + qualityLabel = toData.info.quality.toFixed(); + } else { + qualityLabel = toData.info.quality; + } + if (toData.info.quality == 0) { + qualityLabel = "ØDELAGT"; + } + $fromInv + .find("[data-slot=" + $fromSlot + "]") + .find(".item-slot-quality-bar") + .css({ + width: qualityLabel + "%", + "background-color": QualityColor, + }) + .find("p") + .html(qualityLabel); + // } + // } + + $.post( + "https://ps-inventory/SetInventoryData", + JSON.stringify({ + fromInventory: $fromInv.attr("data-inventory"), + toInventory: $toInv.attr("data-inventory"), + fromSlot: $fromSlot, + toSlot: $toSlot, + fromAmount: $toAmount, + toAmount: toData.amount, + }) + ); + } else { + $fromInv + .find("[data-slot=" + $fromSlot + "]") + .removeClass("item-drag"); + $fromInv + .find("[data-slot=" + $fromSlot + "]") + .addClass("item-nodrag"); + + $fromInv.find("[data-slot=" + $fromSlot + "]").removeData("item"); + + if ($fromSlot < 6 && $fromInv.attr("data-inventory") == "player") { + $fromInv + .find("[data-slot=" + $fromSlot + "]") + .html( + '

' + + $fromSlot + + '

 

' + ); + } else if ( + $fromSlot == 43 && + $fromInv.attr("data-inventory") == "player" + ) { + $fromInv + .find("[data-slot=" + $fromSlot + "]") + .html( + '

6

 

' + ); + } else { + $fromInv + .find("[data-slot=" + $fromSlot + "]") + .html( + '

 

' + ); + } + + $.post( + "https://ps-inventory/SetInventoryData", + JSON.stringify({ + fromInventory: $fromInv.attr("data-inventory"), + toInventory: $toInv.attr("data-inventory"), + fromSlot: $fromSlot, + toSlot: $toSlot, + fromAmount: $toAmount, + }) + ); + } + $.post("https://ps-inventory/PlayDropSound", JSON.stringify({})); + } else if ( + fromData.amount > $toAmount && + (toData == undefined || toData == null) + ) { + var newDataTo = []; + newDataTo.name = fromData.name; + newDataTo.label = fromData.label; + newDataTo.amount = parseInt($toAmount); + newDataTo.type = fromData.type; + newDataTo.description = fromData.description; + newDataTo.image = fromData.image; + newDataTo.weight = fromData.weight; + newDataTo.info = fromData.info; + newDataTo.useable = fromData.useable; + newDataTo.unique = fromData.unique; + newDataTo.slot = parseInt($toSlot); + + $toInv.find("[data-slot=" + $toSlot + "]").data("item", newDataTo); + + $toInv.find("[data-slot=" + $toSlot + "]").addClass("item-drag"); + $toInv.find("[data-slot=" + $toSlot + "]").removeClass("item-nodrag"); + + var ItemLabel = + '

' + newDataTo.label + "

"; + // if (newDataTo.name.split("_")[0] == "weapon") { + // if (!Inventory.IsWeaponBlocked(newDataTo.name)) { + ItemLabel = + '

100

' + + newDataTo.label + + "

"; + // } + // } + + if ($toSlot < 6 && $toInv.attr("data-inventory") == "player") { + $toInv + .find("[data-slot=" + $toSlot + "]") + .html( + '

' + + $toSlot + + '

' +
+                            newDataTo.name +
+                            '

' + + newDataTo.amount + + '

' + + " " + + ((newDataTo.weight * newDataTo.amount) / 1000).toFixed(1) + + "

" + + ItemLabel + ); + } else if ($toSlot == 43 && $toInv.attr("data-inventory") == "player") { + $toInv + .find("[data-slot=" + $toSlot + "]") + .html( + '

6

' +
+                            newDataTo.name +
+                            '

' + + newDataTo.amount + + '

' + + " " + + ((newDataTo.weight * newDataTo.amount) / 1000).toFixed(1) + + "

" + + ItemLabel + ); + } else { + $toInv + .find("[data-slot=" + $toSlot + "]") + .html( + '
' +
+                            newDataTo.name +
+                            '

' + + newDataTo.amount + + '

' + + " " + + ((newDataTo.weight * newDataTo.amount) / 1000).toFixed(1) + + "

" + + ItemLabel + ); + } + + // if (newDataTo.name.split("_")[0] == "weapon") { + // if (!Inventory.IsWeaponBlocked(newDataTo.name)) { + if (newDataTo.info.quality == undefined) { + newDataTo.info.quality = 100.0; + } + var QualityColor = "rgb(15, 255, 213)"; + if (newDataTo.info.quality < 25) { + QualityColor = "rgb(192, 57, 43)"; + } else if ( + newDataTo.info.quality > 25 && + newDataTo.info.quality < 50 + ) { + QualityColor = "rgb(230, 126, 34)"; + } else if (newDataTo.info.quality >= 50) { + QualityColor = "rgb(15, 255, 213)"; + } + if (newDataTo.info.quality !== undefined) { + qualityLabel = newDataTo.info.quality.toFixed(); + } else { + qualityLabel = newDataTo.info.quality; + } + if (newDataTo.info.quality == 0) { + qualityLabel = "ØDELAGT"; + } + $toInv + .find("[data-slot=" + $toSlot + "]") + .find(".item-slot-quality-bar") + .css({ + width: qualityLabel + "%", + "background-color": QualityColor, + }) + .find("p") + .html(qualityLabel); + // } + // } + + var newDataFrom = []; + newDataFrom.name = fromData.name; + newDataFrom.label = fromData.label; + newDataFrom.amount = parseInt(fromData.amount - $toAmount); + newDataFrom.type = fromData.type; + newDataFrom.description = fromData.description; + newDataFrom.image = fromData.image; + newDataFrom.weight = fromData.weight; + newDataFrom.price = fromData.price; + newDataFrom.info = fromData.info; + newDataFrom.useable = fromData.useable; + newDataFrom.unique = fromData.unique; + newDataFrom.slot = parseInt($fromSlot); + + $fromInv + .find("[data-slot=" + $fromSlot + "]") + .data("item", newDataFrom); + + $fromInv.find("[data-slot=" + $fromSlot + "]").addClass("item-drag"); + $fromInv + .find("[data-slot=" + $fromSlot + "]") + .removeClass("item-nodrag"); + + if ($fromInv.attr("data-inventory").split("-")[0] == "itemshop") { + $fromInv + .find("[data-slot=" + $fromSlot + "]") + .html( + '
' +
+                            newDataFrom.name +
+                            '

' + + newDataFrom.amount + + '

' + + " $" + + newDataFrom.price + + '

' + + newDataFrom.label + + "

" + ); + } else { + var ItemLabel = + '

' + + newDataFrom.label + + "

"; + // if (newDataFrom.name.split("_")[0] == "weapon") { + // if (!Inventory.IsWeaponBlocked(newDataFrom.name)) { + ItemLabel = + '

100

' + + newDataFrom.label + + "

"; + // } + // } + + if ($fromSlot < 6 && $fromInv.attr("data-inventory") == "player") { + $fromInv + .find("[data-slot=" + $fromSlot + "]") + .html( + '

' + + $fromSlot + + '

' +
+                                newDataFrom.name +
+                                '

' + + newDataFrom.amount + + '

' + + " " + + ((newDataFrom.weight * newDataFrom.amount) / 1000).toFixed( + 1 + ) + + "

" + + ItemLabel + ); + } else if ( + $fromSlot == 43 && + $fromInv.attr("data-inventory") == "player" + ) { + $fromInv + .find("[data-slot=" + $fromSlot + "]") + .html( + '

6

' +
+                                newDataFrom.name +
+                                '

' + + newDataFrom.amount + + '

' + + " " + + ((newDataFrom.weight * newDataFrom.amount) / 1000).toFixed( + 1 + ) + + "

" + + ItemLabel + ); + } else { + $fromInv + .find("[data-slot=" + $fromSlot + "]") + .html( + '
' +
+                                newDataFrom.name +
+                                '

' + + newDataFrom.amount + + '

' + + " " + + ((newDataFrom.weight * newDataFrom.amount) / 1000).toFixed( + 1 + ) + + "

" + + ItemLabel + ); + } + + // if (newDataFrom.name.split("_")[0] == "weapon") { + // if (!Inventory.IsWeaponBlocked(newDataFrom.name)) { + if (newDataFrom.info.quality == undefined) { + newDataFrom.info.quality = 100.0; + } + var QualityColor = "rgb(15, 255, 213)"; + if (newDataFrom.info.quality < 25) { + QualityColor = "rgb(192, 57, 43)"; + } else if ( + newDataFrom.info.quality > 25 && + newDataFrom.info.quality < 50 + ) { + QualityColor = "rgb(230, 126, 34)"; + } else if (newDataFrom.info.quality >= 50) { + QualityColor = "rgb(15, 255, 213)"; + } + if (newDataFrom.info.quality !== undefined) { + qualityLabel = newDataFrom.info.quality.toFixed(); + } else { + qualityLabel = newDataFrom.info.quality; + } + if (newDataFrom.info.quality == 0) { + qualityLabel = "ØDELAGT"; + } + $fromInv + .find("[data-slot=" + $fromSlot + "]") + .find(".item-slot-quality-bar") + .css({ + width: qualityLabel + "%", + "background-color": QualityColor, + }) + .find("p") + .html(qualityLabel); + // } + // } + } + $.post("https://ps-inventory/PlayDropSound", JSON.stringify({})); + $.post( + "https://ps-inventory/SetInventoryData", + JSON.stringify({ + fromInventory: $fromInv.attr("data-inventory"), + toInventory: $toInv.attr("data-inventory"), + fromSlot: $fromSlot, + toSlot: $toSlot, + fromAmount: $toAmount, + }) + ); + } else { + InventoryError($fromInv, $fromSlot); + } + } + } else { + //InventoryError($fromInv, $fromSlot); + } + handleDragDrop(); +} + +function isItemAllowed(item, allowedItems) { + var retval = false; + $.each(allowedItems, function (index, i) { + if (i == item) { + retval = true; + } + }); + return retval; +} + +function InventoryError($elinv, $elslot) { + $elinv + .find("[data-slot=" + $elslot + "]") + .css("background", "rgba(156, 20, 20, 0.5)") + .css("transition", "background 500ms"); + setTimeout(function () { + $elinv + .find("[data-slot=" + $elslot + "]") + .css("background", "rgba(255, 255, 255, 0.3)"); + }, 500); + $.post("https://ps-inventory/PlayDropFail", JSON.stringify({})); +} + +var requiredItemOpen = false; + +(() => { + Inventory = {}; + + Inventory.slots = 40; + + Inventory.dropslots = 32; + Inventory.droplabel = "Drop"; + Inventory.dropmaxweight = 100000; + + Inventory.Error = function () { + $.post("https://ps-inventory/PlayDropFail", JSON.stringify({})); + }; + + Inventory.IsWeaponBlocked = function (WeaponName) { + var DurabilityBlockedWeapons = [ + "weapon_unarmed", + "weapon_stickybomb", + ]; + + var retval = false; + $.each(DurabilityBlockedWeapons, function (i, name) { + if (name == WeaponName) { + retval = true; + } + }); + return retval; + }; + + Inventory.QualityCheck = function (item, IsHotbar, IsOtherInventory) { + // if (!Inventory.IsWeaponBlocked(item.name)) { + // if (item.name.split("_")[0] == "weapon") { + if (item.info.quality == undefined) { + item.info.quality = 100; + } + var QualityColor = "rgb(15, 255, 213)"; + if (item.info.quality < 25) { + QualityColor = "rgb(192, 57, 43)"; + } else if (item.info.quality > 25 && item.info.quality < 50) { + QualityColor = "rgb(230, 126, 34)"; + } else if (item.info.quality >= 50) { + QualityColor = "rgb(15, 255, 213)"; + } + if (item.info.quality !== undefined) { + qualityLabel = item.info.quality.toFixed(); + } else { + qualityLabel = item.info.quality; + } + if (item.info.quality == 0) { + qualityLabel = "ØDELAGT"; + if (!IsOtherInventory) { + if (!IsHotbar) { + $(".player-inventory") + .find("[data-slot=" + item.slot + "]") + .find(".item-slot-quality-bar") + .css({ + width: "100%", + "background-color": QualityColor, + }) + .find("p") + .html(qualityLabel); + } else { + $(".z-hotbar-inventory") + .find("[data-zhotbarslot=" + item.slot + "]") + .find(".item-slot-quality-bar") + .css({ + width: "100%", + "background-color": QualityColor, + }) + .find("p") + .html(qualityLabel); + } + } else { + $(".other-inventory") + .find("[data-slot=" + item.slot + "]") + .find(".item-slot-quality-bar") + .css({ + width: "100%", + "background-color": QualityColor, + }) + .find("p") + .html(qualityLabel); + } + } else { + if (!IsOtherInventory) { + if (!IsHotbar) { + $(".player-inventory") + .find("[data-slot=" + item.slot + "]") + .find(".item-slot-quality-bar") + .css({ + width: qualityLabel + "%", + "background-color": QualityColor, + }) + .find("p") + .html(qualityLabel); + } else { + $(".z-hotbar-inventory") + .find("[data-zhotbarslot=" + item.slot + "]") + .find(".item-slot-quality-bar") + .css({ + width: qualityLabel + "%", + "background-color": QualityColor, + }) + .find("p") + .html(qualityLabel); + } + } else { + $(".other-inventory") + .find("[data-slot=" + item.slot + "]") + .find(".item-slot-quality-bar") + .css({ + width: qualityLabel + "%", + "background-color": QualityColor, + }) + .find("p") + .html(qualityLabel); + } + } + // } + // } + }; + + Inventory.Open = function (data) { + totalWeight = 0; + totalWeightOther = 0; + + $(".player-inv-label").html(data.Name); + $(".player-inventory").find(".item-slot").remove(); + $(".ply-hotbar-inventory").find(".item-slot").remove(); + $(".ply-iteminfo-container").css("opacity", "0.0"); + + if (requiredItemOpen) { + $(".requiredItem-container").hide(); + requiredItemOpen = false; + } + + $("#qbcore-inventory").fadeIn(300); + if (data.other != null && data.other != "") { + $(".other-inventory").attr("data-inventory", data.other.name); + } else { + $(".other-inventory").attr("data-inventory", 0); + } + + var firstSlots = $(".player-inventory-first"); + for (i = 1; i < 6; i++) { + firstSlots.append( + '

' + + i + + '

 

' + ); + } + $(".player-inventory").append(firstSlots); + + var remainingSlots = $(".player-inventory"); + for (i = 6; i < data.slots + 1; i++) { + if (i == 43) { + remainingSlots.append( + '

6

 

' + ); + } else { + remainingSlots.append( + '

 

' + ); + } + } + $(".player-inventory").append(remainingSlots); + + if (data.other != null && data.other != "") { + for (i = 1; i < data.other.slots + 1; i++) { + $(".other-inventory").append( + '

 

' + ); + } + } else { + for (i = 1; i < Inventory.dropslots + 1; i++) { + $(".other-inventory").append( + '

 

' + ); + } + $(".other-inventory .item-slot").css({ + "background-color": "rgba(0, 0, 0, 0.3)", + }); + } + + if (data.inventory !== null) { + $.each(data.inventory, function (i, item) { + if (item != null) { + totalWeight += item.weight * item.amount; + var ItemLabel = + '

' + item.label + "

"; + // if (item.name.split("_")[0] == "weapon") { + // if (!Inventory.IsWeaponBlocked(item.name)) { + ItemLabel = + '

100

' + + item.label + + "

"; + // } + // } + if (item.slot < 6) { + $(".player-inventory") + .find("[data-slot=" + item.slot + "]") + .addClass("item-drag"); + $(".player-inventory") + .find("[data-slot=" + item.slot + "]") + .html( + '

' + + item.slot + + '

' +
+                                item.name +
+                                '

' + + item.amount + + '

' + + " " + + ((item.weight * item.amount) / 1000).toFixed(1) + + "

" + + ItemLabel + ); + $(".player-inventory") + .find("[data-slot=" + item.slot + "]") + .data("item", item); + } else if (item.slot == 43) { + $(".player-inventory") + .find("[data-slot=" + item.slot + "]") + .addClass("item-drag"); + $(".player-inventory") + .find("[data-slot=" + item.slot + "]") + .html( + '

6

' +
+                                item.name +
+                                '

' + + item.amount + + '

' + + " " + + ((item.weight * item.amount) / 1000).toFixed(1) + + "

" + + ItemLabel + ); + $(".player-inventory") + .find("[data-slot=" + item.slot + "]") + .data("item", item); + } else { + $(".player-inventory") + .find("[data-slot=" + item.slot + "]") + .addClass("item-drag"); + $(".player-inventory") + .find("[data-slot=" + item.slot + "]") + .html( + '
' +
+                                item.name +
+                                '

' + + item.amount + + '

' + + " " + + ((item.weight * item.amount) / 1000).toFixed(1) + + "

" + + ItemLabel + ); + $(".player-inventory") + .find("[data-slot=" + item.slot + "]") + .data("item", item); + } + Inventory.QualityCheck(item, false, false); + } + }); + } + + if ( + data.other != null && + data.other != "" && + data.other.inventory != null + ) { + $.each(data.other.inventory, function (i, item) { + if (item != null) { + totalWeightOther += item.weight * item.amount; + var ItemLabel = + '

' + item.label + "

"; + // if (item.name.split("_")[0] == "weapon") { + // if (!Inventory.IsWeaponBlocked(item.name)) { + ItemLabel = + '

100

' + + item.label + + "

"; + // } + // } + $(".other-inventory") + .find("[data-slot=" + item.slot + "]") + .addClass("item-drag"); + if (item.price != null) { + $(".other-inventory") + .find("[data-slot=" + item.slot + "]") + .html( + '
' +
+                                item.name +
+                                '

' + + item.amount + + '

' + + " $" + + item.price + + "

" + + ItemLabel + ); + } else { + $(".other-inventory") + .find("[data-slot=" + item.slot + "]") + .html( + '
' +
+                                item.name +
+                                '

' + + item.amount + + '

' + + " " + + ((item.weight * item.amount) / 1000).toFixed(1) + + "

" + + ItemLabel + ); + } + $(".other-inventory") + .find("[data-slot=" + item.slot + "]") + .data("item", item); + Inventory.QualityCheck(item, false, true); + } + }); + } + + var per = (totalWeight / 1000) / (data.maxweight / 100000) + $(".pro").css("width", per + "%"); + $("#player-inv-weight").html( + // ' ' + + (totalWeight / 1000).toFixed(2) + + "/" + + (data.maxweight / 1000).toFixed(2) + ); + playerMaxWeight = data.maxweight; + if (data.other != null) { + var name = data.other.name.toString(); + if ( + name != null && + (name.split("-")[0] == "itemshop" || name == "crafting") + ) { + $("#other-inv-label").html(data.other.label); + } else { + $("#other-inv-label").html(data.other.label); + $("#other-inv-weight").html( + // ' ' + + (totalWeightOther / 1000).toFixed(2) + + "/" + + (data.other.maxweight / 1000).toFixed(2) + ); + } + otherMaxWeight = data.other.maxweight; + otherLabel = data.other.label; + var per1 = (totalWeightOther / 1000) / (otherMaxWeight / 100000) + $(".pro1").css("width", per1 + "%"); + } else { + $("#other-inv-label").html(Inventory.droplabel); + $("#other-inv-weight").html( + // ' ' + + (totalWeightOther / 1000).toFixed(2) + + "/" + + (Inventory.dropmaxweight / 1000).toFixed(2) + ); + otherMaxWeight = Inventory.dropmaxweight; + otherLabel = Inventory.droplabel; + var per1 = (totalWeightOther / 1000) / (otherMaxWeight / 100000) + $(".pro1").css("width", per1 + "%"); + } + + $.each(data.maxammo, function (index, ammotype) { + $("#" + index + "_ammo") + .find(".ammo-box-amount") + .css({ height: "0%" }); + }); + + if (data.Ammo !== null) { + $.each(data.Ammo, function (i, amount) { + var Handler = i.split("_"); + var Type = Handler[1].toLowerCase(); + if (amount > data.maxammo[Type]) { + amount = data.maxammo[Type]; + } + var Percentage = (amount / data.maxammo[Type]) * 100; + + $("#" + Type + "_ammo") + .find(".ammo-box-amount") + .css({ height: Percentage + "%" }); + $("#" + Type + "_ammo") + .find("span") + .html(amount); + }); + } + + handleDragDrop(); + }; + + Inventory.Close = function () { + // $(".item-slot").css("border", "1px solid rgba(255, 255, 255, 0.1)"); + $(".ply-hotbar-inventory").css("display", "block"); + // $(".ply-iteminfo-container").css("display", "none"); + $(".ply-iteminfo-container").css("opacity", "0.0"); + $("#qbcore-inventory").fadeOut(300); + $(".combine-option-container").hide(); + $(".item-slot").remove(); + if ($("#rob-money").length) { + $("#rob-money").remove(); + } + $.post("https://ps-inventory/CloseInventory", JSON.stringify({})); + + if (AttachmentScreenActive) { + $("#qbcore-inventory").css({ left: "0vw" }); + $(".weapon-attachments-container").css({ left: "-100vw" }); + AttachmentScreenActive = false; + } + + if (ClickedItemData !== null) { + $("#weapon-attachments").fadeOut(250, function () { + $("#weapon-attachments").remove(); + ClickedItemData = {}; + }); + } + }; + + Inventory.Update = function (data) { + totalWeight = 0; + totalWeightOther = 0; + $(".player-inventory").find(".item-slot").remove(); + $(".player-inventory-first").find(".item-slot").remove(); + $(".ply-hotbar-inventory").find(".item-slot").remove(); + if (data.error) { + Inventory.Error(); + } + var firstSlots = $(".player-inventory-first"); + for (i = 1; i < 6; i++) { + firstSlots.append( + '

' + + i + + '

 

' + ); + } + $(".player-inventory").append(firstSlots); + + var remainingSlots = $(".player-inventory"); + for (i = 6; i < data.slots + 1; i++) { + if (i == 43) { + remainingSlots.append( + '

6

 

' + ); + } else { + remainingSlots.append( + '

 

' + ); + } + } + $(".player-inventory").append(remainingSlots); + + $.each(data.inventory, function (i, item) { + if (item != null) { + totalWeight += item.weight * item.amount; + if (item.slot < 6) { + $(".player-inventory") + .find("[data-slot=" + item.slot + "]") + .addClass("item-drag"); + $(".player-inventory") + .find("[data-slot=" + item.slot + "]") + .html( + '

' + + item.slot + + '

' +
+                            item.name +
+                            '

' + + item.amount + + '

' + + " " + + ((item.weight * item.amount) / 1000).toFixed(1) + + '

' + + item.label + + "

" + ); + $(".player-inventory") + .find("[data-slot=" + item.slot + "]") + .data("item", item); + } else if (item.slot == 43) { + $(".player-inventory") + .find("[data-slot=" + item.slot + "]") + .addClass("item-drag"); + $(".player-inventory") + .find("[data-slot=" + item.slot + "]") + .html( + '

6

' +
+                            item.name +
+                            '

' + + item.amount + + '

' + + " " + + ((item.weight * item.amount) / 1000).toFixed(1) + + '

' + + item.label + + "

" + ); + $(".player-inventory") + .find("[data-slot=" + item.slot + "]") + .data("item", item); + } else { + $(".player-inventory") + .find("[data-slot=" + item.slot + "]") + .addClass("item-drag"); + $(".player-inventory") + .find("[data-slot=" + item.slot + "]") + .html( + '
' +
+                            item.name +
+                            '

' + + item.amount + + '

' + + " " + + ((item.weight * item.amount) / 1000).toFixed(1) + + '

' + + item.label + + "

" + ); + $(".player-inventory") + .find("[data-slot=" + item.slot + "]") + .data("item", item); + } + } + }); + + var per = (totalWeight / 1000) / (data.maxweight / 100000) + $(".pro").css("width", per + "%"); + $("#player-inv-weight").html( + // ' ' + + (totalWeight / 1000).toFixed(2) + + "/" + + (data.maxweight / 1000).toFixed(2) + ); + + handleDragDrop(); + }; + + Inventory.ToggleHotbar = function (data) { + if (data.open) { + $(".z-hotbar-inventory").html(""); + for (i = 1; i < 6; i++) { + var elem = + '

' + + i + + '

 

'; + $(".z-hotbar-inventory").append(elem); + } + // var elem = + // '

6

 

'; + // $(".z-hotbar-inventory").append(elem); + $.each(data.items, function (i, item) { + if (item != null) { + var ItemLabel = + '

' + item.label + "

"; + // if (item.name.split("_")[0] == "weapon") { + // if (!Inventory.IsWeaponBlocked(item.name)) { + ItemLabel = + '

100

' + + item.label + + "

"; + // } + // } + if (item.slot == 43) { + $(".z-hotbar-inventory") + .find("[data-zhotbarslot=" + item.slot + "]") + .html( + '

6

' +
+                                item.name +
+                                '

' + + item.amount + + '

' + + " " + + ((item.weight * item.amount) / 1000).toFixed(1) + + "

" + + ItemLabel + ); + } else { + $(".z-hotbar-inventory") + .find("[data-zhotbarslot=" + item.slot + "]") + .html( + '

' + + item.slot + + '

' +
+                                item.name +
+                                '

' + + item.amount + + '

' + + " " + + ((item.weight * item.amount) / 1000).toFixed(1) + + "

" + + ItemLabel + ); + } + Inventory.QualityCheck(item, true, false); + } + }); + $(".z-hotbar-inventory").fadeIn(150); + } else { + $(".z-hotbar-inventory").fadeOut(150, function () { + $(".z-hotbar-inventory").html(""); + }); + } + }; + + Inventory.UseItem = function (data) { + $(".itembox-container").hide(); + $(".itembox-container").fadeIn(250); + $("#itembox-action").html("

Brugte

"); + $("#itembox-label").html("

" + data.item.label + "

"); + $("#itembox-image").html( + '
' +
+            data.item.name +
+            '
' + ); + setTimeout(function () { + $(".itembox-container").fadeOut(250); + }, 2000); + }; + + var itemBoxtimer = null; + var requiredTimeout = null; + + Inventory.itemBox = function (data) { + if (itemBoxtimer !== null) { + clearTimeout(itemBoxtimer); + } + var type = "Brugte " + data.itemAmount; + if (data.type == "add") { + type = "Modtog " + data.itemAmount; + } else if (data.type == "remove") { + type = "Fjernede " + data.itemAmount; + } + + var $itembox = $(".itembox-container.template").clone(); + $itembox.removeClass("template"); + $itembox.html( + '

' + + type + + '

' +
+            data.item.name +
+            '

' + + data.item.label + + '

' + ); + + $(".itemboxes-container").prepend($itembox); + $itembox.fadeIn(250); + setTimeout(function () { + $.when($itembox.fadeOut(300)).done(function () { + $itembox.remove(); + }); + }, 3000); + }; + + Inventory.RequiredItem = function (data) { + if (requiredTimeout !== null) { + clearTimeout(requiredTimeout); + } + if (data.toggle) { + if (!requiredItemOpen) { + $(".requiredItem-container").html(""); + $.each(data.items, function (index, item) { + var element = + '
Required

' + + item.label + + '

' +
+                        item.name +
+                        '
'; + $(".requiredItem-container").hide(); + $(".requiredItem-container").append(element); + $(".requiredItem-container").fadeIn(100); + }); + requiredItemOpen = true; + } + } else { + $(".requiredItem-container").fadeOut(100); + requiredTimeout = setTimeout(function () { + $(".requiredItem-container").html(""); + requiredItemOpen = false; + }, 100); + } + }; + + window.onload = function (e) { + window.addEventListener("message", function (event) { + switch (event.data.action) { + case "open": + Inventory.Open(event.data); + break; + case "close": + Inventory.Close(); + break; + case "update": + Inventory.Update(event.data); + break; + case "itemBox": + Inventory.itemBox(event.data); + break; + case "requiredItem": + Inventory.RequiredItem(event.data); + break; + case "toggleHotbar": + Inventory.ToggleHotbar(event.data); + break; + case "RobMoney": + $(".inv-options-list").append( + '

' + ); + $("#rob-money").data("TargetId", event.data.TargetId); + break; + } + }); + }; +})(); + +$(document).on("click", "#rob-money", function (e) { + e.preventDefault(); + var TargetId = $(this).data("TargetId"); + $.post( + "https://ps-inventory/RobMoney", + JSON.stringify({ + TargetId: TargetId, + }) + ); + $("#rob-money").remove(); +}); + +// Give + +$("#item-give").droppable({ + hoverClass: "button-hover", + drop: function (event, ui) { + setTimeout(function () { + IsDragging = false; + }, 300); + fromData = ui.draggable.data("item"); + fromInventory = ui.draggable.parent().attr("data-inventory"); + amount = $("#item-amount").val(); + if (amount == 0) { + amount = fromData.amount; + } + $.post( + "https://ps-inventory/GiveItem", + JSON.stringify({ + inventory: fromInventory, + item: fromData, + amount: parseInt(amount), + }) + ); + }, +}); diff --git a/resources/[ps]/ps-inventory/html/ui.html b/resources/[ps]/ps-inventory/html/ui.html new file mode 100644 index 0000000..f3152fe --- /dev/null +++ b/resources/[ps]/ps-inventory/html/ui.html @@ -0,0 +1,201 @@ + + + + + + + + + + + + + + + + + + + + + + +
+
+
+ Spiller
+ +
+
+
+
+
+ +
+
+
+ +
+
+
+
+
+ +
+
+
+
+
+
+
+
+
+
+ + + +

Brug

+ +

Giv

+
+

Kombiner

+ +
+
+
+
+
+
+
+ +
+
+
+
+
+ +
+
+
+
+
+ +
+
+
+
+
+
+ +
+ + +
+ + + +
Indstillinger
+
+ + +
+ + + + + + Vis baggrunds-sløring + Slår du dette fra, fjerner du baggrunds-sløringen når du er i dit inventar. + + +
+
+ + + + +
+
+ + + + +
Hjælp:
+
+ + + For at flytte en fuld stak, skal du sørge for at antal-feltet er tomt. Du kan indtaste det specifikke antal du ønsker at flytte. For at bruge en genstand, skal du trække den ind i den midterste mulighed kaldet "BRUG", eller du kan dobbeltklikke. Antal-feltet nulstilles ikke, når du lukker dit inventar, så sørg for at få en vane med at rydde nummeret! + + + +
Middle Options:
+
+ + +
    +
  • Use: Drag item to this button to use that item
  • +
  • Give: Give item to other citizens around you
  • +
  • Combine: Combine certain items together
  • +
  • Switch: Switch current item
  • +
  • Attachments: When you have items you can attach to your weapons
  • +
  • Close: Another way to close the inventory
  • +
+
+ + +
Keybinds (default):
+
+ + +
    +
  • Left Click: Normal drag
  • +
  • Right Click: Drop item or move single item storage
  • +
  • Double Click: Use Item
  • +
  • Number 0-9: Will input the typed number
  • +
  • BACKSPACE Key: Will set AMOUNT to blank/move entire item stack
  • +
+
+ + +
Shops:
+
+ + + Put in the AMOUNT you want to buy in the AMOUNT FIELD and then drag the shop item into your inventory + +
+
+
+
+
+
+
+
Pistol | 9mm
+
This is a water gun yaay ...
+
Serial Number
12345678

Durability
+ + +
Attachments
+
+
+ +
+ +

RETURN

+
+
+
+
+
+
+ +
+ + + + +