Jump to content

Question about datas and perfomance


Spakye

Recommended Posts

Hello!
Im currently working on an npc system similar to npcs in bethesda games like elder scrolls or fallout.

Basicly if you are close enough to a character, you get an option to talk with him. For each line that the character has, you have few possible answers, each answer will lead you to an other line with new answers, ...

Right now all the npcs's datas are saved in a client file like this :

npcsData = {
	{
		32.359825134277, --x
		39.314876556396, --y
		3.1171875, --z
		67.613670349121, --rotation
		249, --skin
		30, --weapon id
		0, --interior
		0, -- dimension
		"Spakye", -- npc's name
		{
              --Lines : {animation, the line}
              {"wave","What a lovely day isn't it ?"},
              {"talklong","My creator named me Spakye! Im a bot and my job is to answer to your questions.\nWell i don't know many lines but i do my best!"},
              {"tired","Nothing really, im bored...\nIf only there was more people on this server..."},
              {"talklong","You are in The Mist! A Survival/RPG server!\nWell I don't know if we can call it a server... Nobody ever joins and there is absolutly nothing to do at the moment...\nBut you can be sure my creator is working to make this place unique!"},
              },
		{
      		-- answers : { line index, theAnswer, the line index it leads to }
			{1, "Who are you ?", 2},
			{2, "Oh ok", 1},
			{1, "What are you doing ?", 3},
			{3, "What else?", 1},
			{1, "Where are we ?", 4},
			{4, "Sounds sad..", 1},
		},
	},
	
	{
		21.6,
		50.9,
		3.12,
		170,
		141,
		0,
		0,
		0,
		"Trinity",
		{
			{"wave","Hello my name is Trinity!\nWhat can i do for you ?"},
			{"talk","Ah then you probably have met me in the UVA server before! I also hangout here at times."},
			{"vomit","Nothing much, just chilling arround."},
		},
		{
			{1, "Trinity ? i know that name!", 2},
			{1, "What are you doing ?", 3},
			{2, "Oh ok", 1},
			{3, "Oh ok", 1},
		},
	}
}

animations = {
	["wave"] = {"ped", "endchat_03"},
	["disagree1"] = {"ped", "endchat_02"},
	["disagree2"] = {"GANGS", "Invite_No"},
	["agree"] = {"GANGS", "Invite_Yes"},
	["calmdown"] = {"ped", "endchat_01"},
	[":Oyou"] = {"ped", ":Ou"},
	["tired"] = {"ped", "IDLE_tired"},
	["suspicious"] = {"ped", "roadcross"},
	["whisper"] = {"BAR", "Barser_veorder"},
	["armscrossed"] = {"COP_AMBIENT", "Coplook_in"},
	["time"] = {"COP_AMBIENT", "Coplook_watch"},
	["give"] = {"DEALER", "shop_pay"},
	["vomit"] = {"FOOD", "EAT_Vomit_P"},
	["check"] = {"GANGS", "hndshkfa"},
	["shakehand"] = {"GANGS", "prtial_hndshk_biz_01"},
	["sign"] = {"GHANDS", "gsign2LH"},
	["cry"] = {"GRAVEYARD", "mrnF_loop"},
	["talk"] = {"PED", "idle_chat"},
	["talklong"] = {"MISC", "Idle_Chat_02"},
	["scaredhide"] = {"ON_LOOKERS", "panic_hide"},
}

So all informations about npcs are saved in this file and the player downloads the file when joining.

So i have a few questions,

For now i only have 2npcs so the file is quite light, but what if i had like 1000 npcs with complex dialogues and a lot of lines?

if instead i  was to store all this data into a server file for instance, and then send it to the client when he joins, would that be heavier  or lighter on performance?

Is it there any difference (in performance) between a table written in a client file and a table that has been sent by the server to the client?

What do you think would be the best way of storing this data, knowing that the end goal is to have a serious ammount of npcs arround, and all of them will have a lot of possible lines and answers?

Edited by Spakye
typo
Link to comment
  • Moderators
1 hour ago, Spakye said:

For now i only have 2npcs so the file is quite light, but what if i had like 1000 npcs with complex dialogues and a lot of lines?

I don't think that would be an issue.

You can always optimise it later if it doesn't work as intended:

  • Use multiple files instead.
  • Or downloading only the ones of the peds in range.

 

You can compile the file, (without obfuscation!), to speed up the downloading and loading time of the file.

https://luac.multitheftauto.com/

 

 

  • Like 1
Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...