[How-to] Have multiple scripts in one resource

So hello guys so I saw someone that asked about how to have multiple scripts in one script. It is really easy and I’m going to show you guys an example:

So first you need to make a loadout as you can see I have 3 scripts in my pack: Script1, Script2, Script3,

script1

When you have made that, then we can move to the fxmanifest

So here is the fxmanifest code

-- Script pack by godgutten

fx_version 'cerulean'
game { 'gta5' }

client_scripts {
    '/**/client.lua'
}

server_scripts {
    '/**/server.lua'
}

Doing it this way will allow all files with the names client.lua or server.lua to be started without having to list everyone individually. (Note: Only works if your client and server files have the same names)


I’m going to give a download for those of you who like to do it that way:

Download: ScriptPack.rar

If your client or server files aren’t the same you can use arrays to declare them in the fxmanifest

fx_version 'cerulean'
game { 'gta5' }

client_scripts {
     "'script1/client.lua",
      'script2/client.lua',
      'script3/server.lua'
}

server_scripts {
     'script1/server.lua',
     'script2/server.lua',
     'script3/server.lua'
}

Another way to do it is to declare each file seperately

-- Script pack by godgutten

fx_version 'cerulean'
game { 'gta5' }

-- Script 1 
client_script 'script1/client.lua'
server_script 'script1/server.lua'

-- Script 2
client_script 'script2/client.lua'
server_script 'script2/server.lua'

-- Script 3
client_script 'script3/client.lua'
server_script 'script3/server.lua'

This is a wiki post if you want to contribute you have permission

29 Likes

Can this reduce resources?

3 Likes

You are looking for a way to restrict resources with car addons??

3 Likes

What do you mean?

1 Like

I believe he was saying he wants to take all his Car mod files , and place them all into one directory such as [gtr, m3, m4] - all within /vehicleaddons/ rather than ensure gtr , ensure m3 , ensure m4.

you need merge meta file.

1 Like

__resource.lua is no longer supported check out
https://docs.fivem.net/docs/scripting-reference/resource-manifest/resource-manifest/

1 Like

and what happens with the various configs that you put?

In the manifesto, I propose this:

resource_manifest_version '77731fab-63ca-442c-a67b-abc70f28dfa5'

-- For multiple client scripts (adding on to the example above)
client_scripts {
     '/**/client.lua'
}

server_scripts {
     '/**/server.lua'
}

It will go through all folders and run client and server, you can give unlimited number of script folders

2 Likes

Can someone explain why is this worth the effort? why not just leave them with their own manifests?

1 Like

is this also included the config setup?>

In my experience, as a developer they would be useful to start multiple resources at the same time. During testing if i have to restart a resource that is a dependency for maybe 3,4, or even more other resources, then you would have start all of those resources again one at a time. This make it so instead of doing:
“start some_resource1”
“start some_resource2”
“start some_resource3”

Now I can just do
“start some_resource”

This loads all 3 of the other resources and I dont have to reload each and every one manually.

Also, this would likely not provide any real performance boost. This would be more for simplicity of starting all the resources together that need to be together. It cant work in every case. Such as 2 resources with their own ui.html will likely have problems because the fxmanifest uses “ui_page” in it to set the resources UI. So, I could be wrong, and someone correct me if I am, But you would likely run into issues if 2 resources are using a UI page.

What about scripts that have configs?

2 Likes

It works the same way.
You just have to add script1/config.lua as a client script :slight_smile:

In the manifesto, I propose this:

resource_manifest_version '77731fab-63ca-442c-a67b-abc70f28dfa5'

-- For multiple client scripts (adding on to the example above)
client_scripts {
     '/**/client.lua'
}

server_scripts {
     '/**/server.lua'
}

It will go through all folders and run client and server, you can give unlimited number of script folders

thanks pepe

i have error with this


how to fix this?

Not here buddy. Go to the resources page for support.

1 Like

So if i try to merge all the esx scripts would i go by keeping es_extended alone and merging all the other scripts

i would not recommend u to try this… ESX files are difficult to merge, u have (locales folder, client,servber) and many times HTML…