https://github.com/ardelan869/fivem-statebag-eventsystem
Uses FiveM's built-in StateBags to route events.
https://github.com/ardelan869/fivem-statebag-eventsystem
cfx-resource fivem fivem-lua fivem-script lua
Last synced: about 1 year ago
JSON representation
Uses FiveM's built-in StateBags to route events.
- Host: GitHub
- URL: https://github.com/ardelan869/fivem-statebag-eventsystem
- Owner: ardelan869
- License: cc-by-4.0
- Created: 2024-07-20T21:26:10.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2024-07-22T15:12:19.000Z (almost 2 years ago)
- Last Synced: 2024-07-23T00:38:27.511Z (almost 2 years ago)
- Topics: cfx-resource, fivem, fivem-lua, fivem-script, lua
- Language: Lua
- Homepage:
- Size: 16.6 KB
- Stars: 4
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
> [!WARNING]
> It has been tested, but it still could be unreliable or buggy. Use it at your own risk.
> [!NOTE]
>This is just a fun little project I whipped up in about 10-20 minutes.\
>It might be safer than the normal event system, but I do not promise anything.\
>Executors like Eulen or RedEngine should still be able to trigger the "StateBag-Events" if the user knows the structure.
# fivem-statebag-eventsystem
Uses FiveM's built-in StateBags to route events.\
\
This script/file overwrites `RegisterNetEvent`, `AddEventHandler`, `TriggerEvent`, `TriggerServerEvent`, `TriggerClientEvent`.\
You can use everything like you did before, the only difference is that it "*uses a different routing*".
# Usage
Add the file `@resourceName/import.lua` into the `shared_scripts` section of your desired `fxmanifest.lua`.\
`@resourceName` refers to the name of the resource, name the resource as you desire.
## Example
- fxmanifest.lua
```lua
fx_version 'cerulean'
game 'gta5'
lua54 'yes'
shared_script '@fivem-statebag-eventsystem/import.lua'
client_script 'client.lua'
```
- client.lua
```lua
RegisterNetEvent('test', function(value1, value2)
print('value1', value1)
print('value2', value2)
end)
RegisterCommand('test', function()
TriggerEvent('test', '🐈', '🗣️')
end)
```