📜  Fivem esx init (1)

📅  最后修改于: 2023-12-03 15:30:46.829000             🧑  作者: Mango

Fivem Esx Init

Introduction

Fivem Esx Init is a resource for FiveM servers that allows developers to easily create and manage custom ESX scripts. It includes a set of pre-configured functions that handle common ESX events and server interactions, making it easy to get started with creating your own custom scripts.

Features
  • Pre-configured function sets for common ESX events and server interactions
  • Configurable settings for customizing your scripts
  • Easy to use syntax and API for creating custom scripts
Installation
  1. Download the latest release from the GitHub repository.
  2. Extract the files from the downloaded archive to the resources folder of your FiveM server.
  3. Add start fivem-esx-init to your server server.cfg file.
Usage
Creating a new script

To create a new script using Fivem Esx Init, simply create a new file in the resources folder of your FiveM server with a .lua extension. Then, start the file with the following code:

ESX = nil

TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end)

ESX.RegisterServerCallback('yourCallbackName', function(source, cb, ...)
  -- Insert your callback logic here
end)

AddEventHandler('yourEventName', function(...)
  -- Insert your event logic here
end)

This code sets up the ESX global variable, registers a server callback, and adds an event handler for your custom script.

Using the pre-configured functions

Fivem Esx Init includes a set of pre-configured functions for common ESX events and server interactions, which you can use in your custom scripts.

For example, to give a player a weapon using the pre-configured ESX.PlayerData function, you can use the following code:

ESX = nil

TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end)

ESX.RegisterServerCallback('yourCallbackName', function(source, cb, ...)
  -- Insert your callback logic here
end)

AddEventHandler('yourEventName', function(source)
  ESX.PlayerData(source).addWeapon('weapon_pistol')
end)
Configuration

Fivem Esx Init includes a config.lua file where you can customize the settings for your custom scripts. This includes settings for the currency symbol, job names, and more.

The following settings are available:

  • CurrencySymbol: The currency symbol to use for display purposes.
  • JobNames: An array of job names to display in the job selector menu.
  • DefaultJob: The default job to give to new players.
  • MenuTitle: The title to display at the top of the job selector menu.
Conclusion

Fivem Esx Init is a powerful and easy-to-use resource for creating custom ESX scripts for FiveM servers. With its pre-configured functions and easy-to-use API, it's the perfect tool for developers looking to create their own custom scripts.