I need some help with my system

Hello! I’ve recently been active again in the development community, and I am trying to improve my skills as a scripter.
I am currently working on a little project trying to test my skills out but I am not sure which data storing method I should be using for this project.

Details about the project:
The player will be able to create his own military base and train up npcs to fight against hordes of enemies, so far I’ve got an idea of how the data for each individual npc could be stored, I cannot show right now because I am writing this this from my phone, but this is an example…
A folder will be placed inside the dedicated npc, for example a Private rank NPC, this npc will be doing push-ups in order to gain exp, furthermore a Sergeant rank NPC can be added to the equation to multiply the speed of which the Private is training at, in the folder inside the npcs I have added a variation of values,

  • Level of the Npc
  • Exp of the Npc
  • Exp needed to lvl to the npc
  • the Rank of the npc
    I wanted to have a maximum of 30 privates npc slots per each player, I thought it would be a good idea to load all of the npcs into the game using tables, but unfortunately I’m stuck when it comes to loading each individual npc data and saving it whenever a player leaves the game. From my knowledge I have a slight idea of how I can combat this problem.
    Can anyone give me a hand with this and suggest me a method of storing all of this data please?

You can use tables like you mentioned, maybe saving all of the players data into one big table, to then put into a data store,

local playerData = {
[“Cash”] = 234,
[“NPCs”] = {
[1] = {
[“Name”] = “Private Rank NPC”,
[“Level”] = 3,
[“XP”] = 10
},
[2] = {
[“Name”] = “Sergeant Rank NPC”,
[“Level”] = 2,
[“XP”] = 6
}
}
}

Sorry the formatting isn’t good but you get the idea, you can then loop the NPCs data and parent where you need each thing.

For the “Exp needed to lvl up the NPC”, I suggest having default values for the first ever level up, then halfing it, times it by the level, and add it ontop of the default value, for example;

Level 1 → Level 2 - 50 XP
Level 4 → Level 5 - 150XP

(Halfing 50, times it by 4, add it ontop of the default value) you can always mess with this differently.

I hope this somewhat helped.

1 Like

Thank you! I tried your method and it works great for what I had envisioned!

No problem! Glad I could be of help

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.