#Inv save and load help

1 messages Β· Page 1 of 1 (latest)

keen plume
#

I want an add-on in which i can make a kit/inv which loads to a player when he interacts with the npc, and enchantments, Armor slots, offhand also gets saved and loaded, i found an add-on named "Simple kits" which loads the whole inventory by /tag @initiator add give_kit:name but Armor and offhand slots were not saving in that addon please help me

unkempt tartan
#

For Armor and Offhand items you need to use this.

keen plume
dim drift
keen plume
#

So ig I know something

#

But I think I am a complete beginner

#

So please guide me πŸ˜„

keen plume
#

But can you help me making that addon? Like what I exactly need to do

dim drift
keen plume
#

Okay bro thanks I'll read that now

keen plume
#

Hey @dim drift, now I know the basics you gave in that pdf.

#

Let's continue for the rest

dim drift
keen plume
dim drift
keen plume
#

So I can set a command in npc with @initiator
I now need to know how can I save and load inventory

#

I need to make a script for that

#

Right?

dim drift
keen plume
#

So what i would have to do

dim drift
#

you can setup an inventory with an array of itemstacks and give them to the player when the scriptEvent is triggered

keen plume
#

But this script doesn't have commands to save and load kits in-game

dim drift
#

you can just setup a scriptEvent to create the command

#

system.afterEvent.scriptEventRecieve

#

and the command will be /scriptevent myEvent kitName

keen plume
#

So, if i want that my inventory gets saved by
/kit save <kitname>
And load to a player by
/kit load <kitname> <playername>
What can I do

keen plume
#

I am understanding only a little bit

#

So ig we can't directly add slash commands to the server/world

#

We need to use scriptevent command

dim drift
keen plume
dim drift
# keen plume I have this script I got somewhere from this server

you can recicle that, you see that there are 2 functions that are called
saveInventory with player, invName, storage
and
loadInventorywith also player, invName, storage

you just need to do the system scriptEvent and run the function using the player as the player you want to save/load the inv to, the invName that will be the kit name, and the storage that will be the world since its global

keen plume
#

Ahm alright

dim drift
#

see the examples and you get the rule

keen plume
#

system.afterEvent.scriptEventRecieve
I can't understand what to do after this

#

@dim drift
system.afterEvents.scriptEventReceive.subscribe((event) => {
const player = event.sourceEntity;
if (!player || !player.isValid()) return;

const id = event.id;
if (!id.startsWith("myEvent:")) return;

const [_, action, invName] = id.split(":");

if (action === "save") {
    saveInventory(player, invName, world);
} else if (action === "load") {
    loadInventory(player, invName, world);
}

});

keen plume
dim drift
#

Yes

keen plume
#

The kit I want to save should be saved by
/scriptevent myEvent:save:kit1
And loaded by
/scriptevent myEvent:load:kit1
Right?

dim drift
#

but system.afterEvents not world

keen plume
#

Does it have any errors?

keen plume
dim drift
keen plume
dim drift
#

for checking for errors you need to test

keen plume
#

Ok now I will go in game and test it

#

Ig there is error in manifest

#

And when I type in chat
/scriptevent myEvent:save:kit1
It's that error you can see in second image

dim drift
keen plume
#

I am trying to fix it

dim drift
keen plume
#

Yes I know I forgot to add this I am adding this rn

#

Identifier must have a namespace that is not "minecraft"
I am getting this error in chat when I run /scriptevent myEvent:save:kit1

#

And nothing in log

dim drift
#

change the syntax to make the command have 2 parameters
/scriptevent save:kit kit1

keen plume
#

I used this command it worked then when I used
/scriptevent load:kit kit1
Nothing happened

#

I didn't got the kit but the commands are working somewhere

dim drift
keen plume
dim drift
#
import { world, system } from "@minecraft/server"

system.afterEvents.scriptEventReceive.subscribe((e) => {
    const { sourceEntity: player, id, message } = e;

    if (id == "save:kit") {
        saveInventory(player, message, world)
    }
    if (id == "load:kit") {
        saveInventory(player, message, world)
    }
})

just simple as that

keen plume
#

Still I am not getting the kit

#

This is the behaviour pack

#

You can also try

urban robin
#

Why do I get deja vu

#

Ah

keen plume
#

🀨

keen plume
unkempt tartan
keen plume
unkempt tartan
#

With it you can get and set enchantments

keen plume
#

Oh alright lemme see

keen plume
#

@dim drift can you help me with that

#

@unkempt tartan bro it would be a great help for me if you can do that for me or tell me how I can do that 😐

unkempt tartan
urban robin
#

@dim drift can QIDB cause lag by any means?the server resources are not utilised to its max still the server lags idk why

unkempt tartan
urban robin
#

i dont know the server is lagging,i.e,game lag

#

the resources of the server are not used to the max so i just wanted to ask that can that addon cause lag

#

i am using 4-5 addons

#

out of which 3 contains only 1 script

#

other 2 are addons made by different creator

#

i dont know whats causing the lag so i am just so confusedπŸ˜“

urban robin
unkempt tartan
#

Try this

#

Remove all addons > check if thr lag is still there

#

If not, add on addon and recheck

#

Then continue it

#

Your server can also lag roughly of you have alot of commands

#

Or entities

urban robin
#

okk

#

there are actually many command blocks in the server

#

but i cant do anything

#

and i have killed all the entities then checked still it lagged

#

actually in the first 2 days the server was very lag free

#

idk what happened after that

unkempt tartan
#

Connect a debugger and check how many commands are executen

#

I had 9 fill commands in my world and it went down to 15-18 tps

unkempt tartan
#

Or even better: dont use command blocks

urban robin
unkempt tartan
urban robin
urban robin
unkempt tartan
urban robin
#

okk

unkempt tartan
#

Still, Connect a debugger

#

You can download a mcbe debugger

#

In the VScode extensions

urban robin
#

ok

#

what it does?

unkempt tartan
#

It will give you an instruction on how to connect it

#

And then you check whats the issue

urban robin
#

ok

unkempt tartan
#

It shows you the stats of the world

#

A resource monitor

#

Like:

urban robin
#

wait

#

imma see

unkempt tartan
#

How many commands are executen every tick

#

Or how many entities are loaded

urban robin
#

ok

unkempt tartan
#

Or how many RAM is being used

#

Its pretty good for debugging

urban robin
#

ok

#

thanks for the help

unkempt tartan
#

Youre welcome

dim drift
dim drift
urban robin
#

ok

#

how much should i set

dim drift
#

1 as saverate and if you got enough ram use more cache possible

#

100 should be fine if you got like 32gb

urban robin
#

i have 16 gb ram

dim drift
#

then do 30

urban robin
#

what shouid i set for th at

#

ok

#

thanks

dim drift
#

np

keen plume
#

The only problem left is the enchantments are not saving and loading

#

If I try to use enchantable component then the addon somehow stops working

#

And when I tried to ask gpt, limit has been reached.

#

I can use it after 1 day

#

Could you help me with using enchantable component?

unkempt tartan
unkempt tartan
unkempt tartan
unkempt tartan
keen plume
#

Okay got it! Thanks!

atomic basalt
keen plume
atomic basalt
#

first time seeing indian scripting lolol

keen plume
keen plume
unkempt tartan
keen plume
#

@atomic basalt can you help me

atomic basalt
#

mereko scripting acchi aati hai

unkempt tartan
#

just joking

keen plume
#

Kya aap isme enchantments ko save and load krne ka bhi add kr skte ho?

unkempt tartan
#

it will make evrything lots easier

atomic basalt
keen plume
keen plume
unkempt tartan
#

nvm forget it

#

@atomic basalt got time to help you

keen plume
#

@unkempt tartan do you understand Hindi? Where are you from?

unkempt tartan
#

I am from germany

keen plume
#

Ok πŸ‘ŒπŸ»

unkempt tartan
#

YOOO

#

I WILL FIND YOU

atomic basalt
#

nothing

keen plume
#

πŸ’€

atomic basalt
#

what

unkempt tartan
#

Are you sure about that

#

We will invade you

atomic basalt
#

@keen plume change your saveinventory and loadinventory functions with the functions inside this file

#

Apna script ka functions iss file se change karo

urban robin
atomic basalt
#

what

urban robin
#

kuch nhi english mei bola fir hindi mei bhi

#

wahi kehra tha

atomic basalt
#

nah Indians gonna invade the server

#

didn't know ur indian tko

urban robin
#

its very useful tbh

keen plume
#

Wait abhi dekhta hu

keen plume
#

Yahi dosti yahi pyaar

#

Aam ka achaar

urban robin
#

ahm

urban robin
keen plume
atomic basalt
#

u guys know json

urban robin
#

thanks me later issi bahane aap sikhre ho

#

future mei addons kaam aayegi

keen plume
atomic basalt
#

addons banana tum logon ko aati hain

urban robin
atomic basalt
#

hmm

#

I wanted to make a addon wanna help along guys

urban robin
urban robin
keen plume
atomic basalt
#

I thought about I wanted to have a group of ppl

#

To make addons together

#

Remained a dream πŸ₯€

keen plume
#

Oh yeah I also thought this some months ago πŸ₯€

urban robin
#

pata nhi mera main stream addon banana nhi hai,youtube is my dream and usme public server complete krne ke liye maine scripting sikhi thori bahot

atomic basalt
#

u guys know anyone who creates addon like us

#

Let's create a group

urban robin
#

i am out

atomic basalt
#

ah ok

keen plume
#

I can help

urban robin
#

@keen plumevc?

keen plume
#

Kal school se aane k baad aaunga vc 3 bje k baad

urban robin
#

ok

keen plume
#

Kuch kaam hai kya important?

urban robin
#

aise hi ek baat bolni thi

atomic basalt
#

mereko 2 din baaad math exams HaiπŸ’€

urban robin
#

2 min vc aajao general

keen plume
keen plume
keen plume
urban robin
atomic basalt
keen plume
urban robin
#

choro hogya

keen plume
keen plume
urban robin
#

USNE

atomic basalt
#

actually I need experienced guys for adon help

atomic basalt
#

Tumko block permutations aati hai

urban robin
keen plume
urban robin
#

chalo gn guys

keen plume
atomic basalt
atomic basalt
keen plume
atomic basalt
#

nooo

keen plume
urban robin
atomic basalt
#

Tumko thoda sa javascript basic knowledge chahiye, agar tum apna khud ka script khud banao, tab tum Sikh sakte ho

keen plume
#

Ok mai krta hu try

keen plume
#

Yoooooooooooooooooooooooooooooooooooo
Thanks a lot dude I don't know how can I thank you bro you really helped me a lot, I know it's only a small thing for you but it's really a very big help for me @atomic basalt

#

Bro the addon worked

#

And thank you for being strict on me so that I tried that myself and overcome the difficulties

#

Thanks @urban robin @unkempt tartan @dim drift you all helped me a lot

urban robin
#

yayyy

keen plume
#

Hey @atomic basalt there is a problem, when I am saving the inventory with potions, and when I load, I am getting water bottles or splash water bottles, i tried to fix but I was not able to do that please help me.

#

@unkempt tartan @dim drift

unkempt tartan
#

Ill help you when i feel better

prime dirge
keen plume
unkempt tartan
dim drift
dim drift
atomic basalt
#

yea you need to use a entity file

#

Potion component doesn't work weell

prime dirge
atomic basalt
#

Carchi provide him Superstack

#

Superstack can get potions data isn't it

dim drift
dim drift
prime dirge
#

Wait

dim drift
prime dirge
atomic basalt
keen plume
#

In the simple kits addon full inventory with every data gets saved and loads correctly but it doesn't load Armor and offhand slots and the advance kit addon which is made by your help, it's not loading potions, so is there any way we can merge or copy paste some code and do something to save all inventory data or potions data ?

dim drift
dim drift
manic cargoBOT
#
Free Work

If you want an add-on made for you for free, you're most likely out of luck. The best thing you can do is watch tutorials and read guides so you can learn how to develop it yourself.

People won't work for free, but you can always offer to pay them to make something for you.

keen plume
dim drift
#

you dont know anything that's not helping thats doing free work

keen plume
#

Oh ok sorry bro 😐

dim drift
#

if you find someone that will do the addon for you

atomic basalt
#

context; this server is for getting help when u get stuck when coding..
But if you ask ppl to do the work and send the whole addon, that's just him working for you, not helping. You can also find someone tho that can do that, who has time, some ppl do commissions who ask for money and do it

keen plume
atomic basalt
#

I swear I could help if he sent me JUST the script file.

But bro why are you wasting our time, sending the WHOLE addon?

keen plume
dim drift
#

also dont ping me randomly

keen plume
atomic basalt
#

xd u can ping me anytime

#

For small help

keen plume
keen plume
atomic basalt
#

hm so firstly

#

Let me guide you

keen plume
#

Yes

atomic basalt
#

Carchi sent you a link

#

QIDB

keen plume
#

Hmm

atomic basalt
atomic basalt
#

U can save all data using his

#

Enchantment and potions

keen plume
#

Ok

atomic basalt
#

Put his script

#

Into your scripts folder

#

And import it to your script

keen plume
#

Got it

atomic basalt
#

Then as he shows in his post, you save the item

#

using the method

#

In his class

#

you'll have to import that in ur script like that (pseudo-code not actual code I sent)

import { QIDB } from "./.."
new QIDB().saveItemStack()
#

Just follow his post

keen plume
#

Okay bro

#

Thanks

#

I'll try that now

unkempt tartan
#

Hello there

#

I feel much better now

keen plume
#

Hey @atomic basalt I want to talk something important can you come vc? Anytime you are free you can tell me we would talk

atomic basalt
#

text me

keen plume
#

Okay can I make group with you me and my one other friend?