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
#Inv save and load help
1 messages Β· Page 1 of 1 (latest)
For Armor and Offhand items you need to use this.
Thanks for replying, actually I am a beginner in scripting so can you please tell me exactly what I need to do? π
are you a complete beginner or you know the basics?
I understand the code but I can't make it myself
So ig I know something
But I think I am a complete beginner
So please guide me π
Ok I'll go through it
But can you help me making that addon? Like what I exactly need to do
yeah but you need the base to learn the rest
Okay bro thanks I'll read that now
Hey @dim drift, now I know the basics you gave in that pdf.
Let's continue for the rest
ok so you got what events are?
Yes when a specific thing happens in the world, that's Event right?
yes, you can use interactWithEntity event to catch when the player wants to get the kit
I want that player get kit by interacting with the npc
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?
yes
So what i would have to do
you can setup an inventory with an array of itemstacks and give them to the player when the scriptEvent is triggered
I have this script I got somewhere from this server
But this script doesn't have commands to save and load kits in-game
you can just setup a scriptEvent to create the command
system.afterEvent.scriptEventRecieve
and the command will be /scriptevent myEvent kitName
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
Oh
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
you can but its 10 times more complex and not something you can do it as first thing
Yes you are right
So I would have to make a second script connected with this or I can edit inside this script?
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
Ahm alright
see the examples and you get the rule
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);
}
});
Should I add this in the bottom of that script?
Yes
The kit I want to save should be saved by
/scriptevent myEvent:save:kit1
And loaded by
/scriptevent myEvent:load:kit1
Right?
but system.afterEvents not world
Does it have any errors?
Ok
try to run it and look at the log
Ok
for checking for errors you need to test
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
look again at the manifest setup in the file
I added entry in manifest now there is some error in script file
I am trying to fix it
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
change the syntax to make the command have 2 parameters
/scriptevent save:kit kit1
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
you also have to change the syntax from the script
What do I have to change π
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
π€¨
Hey @dim drift , in that simple kits addon, full inventory gets saved but not Armor and offhand slots, so I think it's better to change in that addon rather than making this script. And I think I need to understand and use server.EntityEquippableComponent Class for that so please help me with that.
Its a component.
If you do
equippable = player.getComponent("minecraft:equippable");
You can do something like
equippable.getEquipment(EquipmentSlot.Chest);
Anf it will either return undefined or the ItemStack of my current chestplate
Ok understood
Yoo dude it worked I am getting the items and it's loading the inventory correctly but the only problem is that it's not saving and loading enchantments of items i tried to fix that but it's not giving me enchanted items
To get the enchantments, you need to get the Enchatable Component
With it you can get and set enchantments
Oh alright lemme see
Bro I can't make that, the addon completely breaks or the enchantments does not gets saved and loaded can you tell me what I can do
@dim drift can you help me with that
This is the pack which loads full inventory and Armor and offhand slots but it does not save and load enchantments
@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 π
Sorry right now I neither got time nor the needed motivation fot coding.
Busy with Wachthing animes :(
):
@dim drift can QIDB cause lag by any means?the server resources are not utilised to its max still the server lags idk why
What do you mean by lag. A script spike, or what?
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π
tps arre around 15
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
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
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
Optimize them, set tick interval to higher, turn off command feedback, its useless overhead
Or even better: dont use command blocks
i have 100 or more than that
Theres the issue
wait i will try setting the tick interval to higher value
but in the first 2 days it was fine
Wont help you if you have like 100...
okk
Hmm
Still, Connect a debugger
You can download a mcbe debugger
In the VScode extensions
It will give you an instruction on how to connect it
And then you check whats the issue
ok
ok
Youre welcome
Brother you re making something that needs above average skills to do and you found out yesterday about system how do you think you re going to make it?
depends on what save rate are you using and how many items are you saving each tick
1 as saverate and if you got enough ram use more cache possible
100 should be fine if you got like 32gb
i have 16 gb ram
then do 30
np
I am taking help from chat gpt
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?
Read the docs, it will help you alot
Then do a new chat
Check the error message or debug the script
There could be mutliple issues, try debugging to check which oart is not working
Okay got it! Thanks!
Yoo indian
Hi
first time seeing indian scripting lolol
Still it says you can do data analysis after 1 day
Hehe
then dont send him files, send him the script as a plain txt..
@atomic basalt can you help me
Yeah kya help chayiye tumhe
mereko scripting acchi aati hai
Mera ek addon hai jisme puri inventory save hojati hai /tag @s add save_kit:kitname command se and load hojati hai /tag @<playername> add give_kit:kitname
Bas ek problem hai ki items ki enchantments nahi aa rahi hain
Kya aap isme enchantments ko save and load krne ka bhi add kr skte ho?
instead of the whole addon, send the lines that are not workin
it will make evrything lots easier
Ok Mai tumhe fix karke deta hu
Oh yeah you are right
Oh ok bro
π
@unkempt tartan do you understand Hindi? Where are you from?
I don't, I just used a translator
I am from germany
Ok ππ»
nothing
π
what
@keen plume change your saveinventory and loadinventory functions with the functions inside this file
Apna script ka functions iss file se change karo
2 step verification
what
public server mei ek addon mei help chaiye thi isiliye aaya tha
its very useful tbh
Oh bhai mai to so gya tha
Wait abhi dekhta hu
Dusro se help maangte rehte ho mai help maangta hu to mana krdete ho
Yahi dosti yahi pyaar
Aam ka achaar
maine sikhi thi aadhe se jyada
ahm
kaam hogya sayad aapka
Haa to mai bhi seekh Raha hu thoda thoda (:
u guys know json
Hmm
Ya
addons banana tum logon ko aati hain
mainly js havent used json files
i have average js knowledge
Yes
i dont think i can help u but if i can then i will do
Thoda sa only a little bit π€π»
I thought about I wanted to have a group of ppl
To make addons together
Remained a dream π₯
Oh yeah I also thought this some months ago π₯
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
i am out
ah ok
I can help
@keen plumevc?
Nahi
Kal school se aane k baad aaunga vc 3 bje k baad
ok
Kuch kaam hai kya important?
aise hi ek baat bolni thi
mereko 2 din baaad math exams Haiπ
2 min vc aajao general
Chat me hi boldo
Nhii aa skta ):
π½
mute reh lena
Ican
Abe yaar earphones nhi hain mere pass
@atomic basalt ahm bro I am having some confusion. Maybe i would break the addon so can you please do that for me
This is my script please edit this bro
USNE
what
actually I need experienced guys for adon help
Ahm
Tumko block permutations aati hai
yes isiliye maine pehle hi maana krdiyaπ
Mujhe bilkul 1% bhi nhi pta hoga shayad sorry bhai agar mai aapki help na kr pau to π
chalo gn guys
Gn
You shouldn't do hard things at first which you don't understand.
Maine tumhe full code diya tha tum toh add hi nhi Kar sakte, atleast u should do that yourself bro I can't make the whole script for you
gn
Matlab full script hi change krdu? Like isko rename krke daaldu pack me
nooo
Yes you are right, mai in sab chizo me naya hu isiliye thoda dar lgta hai π₯²
he told u to replace the function he gave you in your script
Tumko thoda sa javascript basic knowledge chahiye, agar tum apna khud ka script khud banao, tab tum Sikh sakte ho
Ok mai krta hu try
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
yayyy
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
Sorry i dont feel well rny kindof depressed again
Ill help you when i feel better
Thats something I would like to know too, potions are separated by data values, but I dont know how to give or save a data value using script API
Ohk get well soon bro β€οΈβπ©Ή
Hmm
Potions do have an own component as far as i know
that is even more advanced you should use to save all the data, but again its hard even for experienced scripters#1252014916496527380
doesnt work well
I tried to find but only found some pre release components :'v
To read/set items data value:
#1365770249835909272
To save ALL data without needing dynamic properties or reading data values:
#1252014916496527380
yeah but its inefficient and stupid do do
Wait
Thank you sir
no problem
Why tho ? Im a beginner sorry
Carchi's QIDB repositry has the entity JSON file
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 ?
that's not the same thing
AGAIN its something not for beginners
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.
Bro I think you are a experienced and above average coder so can you help me π
you dont know anything that's not helping thats doing free work
Oh ok sorry bro π
if you find someone that will do the addon for you
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
Okay bro got it thanks for correcting me
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?
Bro the addon has only one script file
also dont ping me randomly
Ok bro
(: ok
Can you help me in saving potions data? If you want something from me to send then i can
Yes
Hmm
This one
To save ALL data without needing dynamic properties or reading data values:
#1252014916496527380
Ok
Ok
Got it
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
Hey @atomic basalt I want to talk something important can you come vc? Anytime you are free you can tell me we would talk
i have parents now , can't vc
text me
Okay bro whenever you can you can tell me
Okay can I make group with you me and my one other friend?