Skip to content

Environment

Shiva code runs in three environments. Understanding which environment your code runs in is critical.

The Three Environments

EnvironmentWhereWhat's Available
ServerFiveM server processDatabase, all player data, economy, jobs
ClientPlayer's FiveM gamePed manipulation, cameras, NUI, local state
SharedBothPure Lua utilities, models, validation schemas

Directory Convention

my-module/
├── server/     -- runs only on the server
├── client/     -- runs only on each player's game
└── shared/     -- runs in both, no side effects

What Goes Where

Server:

  • Database reads/writes
  • Player authentication and trust
  • Economy, inventory mutations
  • Authoritative game state

Client:

  • Ped / entity manipulation
  • Camera control
  • NUI rendering
  • Local caching for display

Shared:

  • Data models (validation schemas)
  • Locale strings
  • Config defaults
  • Pure utility functions

The Golden Rule

Never trust the client.

The client can send anything. All state mutations must happen on the server after validation. The client only ever receives display data or triggers server-side actions.

fxmanifest.lua

Every module has an fxmanifest.lua that declares which files go to which environment:

lua
fx_version 'cerulean'
game 'gta5'

name 'my-module'
version '1.0.0'

shared_scripts {
    'shared/**/*.lua',
}

server_scripts {
    '@oxmysql/lib/MySQL.lua',
    'server/**/*.lua',
}

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

See Also

Released under the MIT License.