💡How we code

National War's structure aims to be optimised and developer friendly as much as possible, therefore you must follow specific layouts and uses

Events

As any developer knows, events are crucial in the FiveM enviroment, therefore you must follow the following in the following cases

Client to client // Server to server

In these cases there is no need of using RegisterNetEvent , therefore use only AddEventHandler

Server to client

In the client side you must set up an event that is similar to this structure

-- Example usage of event in the client-side
RegisterNetEvent("nw:cl:{module}:{action}", function(args)
    print(args)
end)

-- Example fill for {module} and {action}
RegisterNetEvent("nw:cl:chat:sendMessage", function(player, message)
    print(("Player %s has said %s."):format(player, message))
end)

Client to server

The structure is similar for "Server to client", but instead of starting with "nw:cl" we start with "nw:sv"

The server events must be secured in order to protect the server from exploiters

A check must be made for what ever the event is for

Built in

There's a lot of built in inside the development environment, and the most important is the following:

No use of CreateThread, Wait, etc... , when you code make sure to include Citizen. where it should be

Last updated