Setup
Checking the framework of a script on FiveM is essential to ensure its compatibility with the server environment and to avoid execution errors. This allows the code to be adapted to the correct methods for the framework used, guaranteeing stability and optimising performance. In addition, this check facilitates the integration and maintenance of the script while reducing the risk of conflicts between resources.
Steps to fllow ensure the script works properly
Learn in account if you put standalone
If you are using standalone mode, you will need to adapt the script
Go to shared/config.lua
Please make the line where you are asked to select the framework standalone
Then you have a piece of code for the notifications, as shown below:
Where you'll find ‘Use your custom notify’, you'll need to set your notification system to warn you of the actions you've just taken.
It's just a notification that it's being used on the client side and not the server side, so you don't need to use TriggerServerEvent or server-side triggers.
Now go to server/framework/Standalone.lua
You should adapt the content of the functions to ensure correct operation
On the right-hand side, you have a function called GetIdPlayer_STANDALONE, which retrieves the player id, which is mandatory for it to work.
First of all, you have a function called GetIdPlayer_STANDALONE
, which is responsible for retrieving player data, a mandatory step for its proper functioning. Based on the player's ID, you should receive a response containing their data, such as their job, rank, etc.
Example
Next, you have another function called HasJob_STANDALONE
, which allows you to check if the player has the correct job and rank. You need to adapt its content so that it returns whether the player has the job or not, using return true
or return false
to indicate the result. Additionally, you should implement a condition so that if the player has a specific job, such as "police," the function directly returns true
when used.
Example
Next, you have another function called GetHasGroupPlayer, which lets you check whether the player has the right group (e.g. ‘admin’). You need to adapt its content so that it indicates whether or not the player has a group, using return true or return false to indicate the result.
Example
Last updated