Secure your server

Handle citizen files on your server

In order to protect your server from players who are playing with citizen files, the best solution is to use pure level 1. Use the following server command in your server.cfg file:
sv_pureLevel 1 # disable citizen files

Handle entity creation on your server

circle-info

The anticheat resource is not the only resource responsible of spawning entities on the server from external sources. As the anticheat resource is a standalone resource, the anticheat resource does everything that is possible. It is important to design your server resources carefully in order to ensure security for your server. In order to protect your server, you can practice the following security measures.

In order to protect your server from spawning entities from external sources, it is recommended to shift the entity spawn from client side to server side directly from your server resources by creating a server side function in your framework that spawns the entity and use it instead the client side natives or directly use server side native for spawning entities and add to your server.cfg one of the lines below at your choice
sv_entityLockdown relaxed #Blocks only client-created entities that are not owned by scripts.
sv_entityLockdown strict #Prevents clients from creating any entities.
It is recommended to make tests before launching this shift.

Create Vehicle (https://docs.fivem.net/natives/?_0xDD75460Aarrow-up-right)

triangle-exclamation
Client side
local vehicle = CreateVehicle(GetHashKey("adder"), coords[1], coords[2], coords[3], 200.0, true, false)
TaskWarpPedIntoVehicle(PlayerPedId(), vehicle, -1)
circle-check
Server side
function tvRP.CreateVehicle(hash, x, y, z, heading, isNetwork, netMissionEntity)
    local source = source
    local user_id = vRP.getUserId(source)
    if source and user_id then
        local vehicle = CreateVehicle(hash, x, y, z, heading, isNetwork, netMissionEntity)
        Wait(100)
        if DoesEntityExist(vehicle) then
            SetPedIntoVehicle(GetPlayerPed(source), vehicle, -1)
            return NetworkGetNetworkIdFromEntity(vehicle)
        end
    end
    return nil
end

If you do not use any native on the spawned vehicle you can use:

If you use any native on the spawned vehicle you can use:

circle-exclamation

Create Ped (https://docs.fivem.net/natives/?_0x389EF71arrow-up-right)

triangle-exclamation
circle-check

If you do not use any native on the spawned ped you can use:

If you use any native on the spawned ped you can use:

circle-exclamation

Create Object (https://docs.fivem.net/natives/?_0x2F7AA05Carrow-up-right)

triangle-exclamation
circle-check

If you do not use any native on the spawned object you can use:

If you use any native on the spawned object you can use:

circle-exclamation
circle-info

The content from above is just an example of a solution to create vehicles, peds and objects on server side. You can create your own functionality, such as a server event that will spawn vehicles, peds and objects on server side which is used in client side and then protect it with the anticheat event protection.

circle-info

The server side functions for spawning entities have been provided as an example for the vRP framework. To use these functions within a resource, you also need to include the following tunnel in client side:

circle-info

Our recommendation is to use server natives CreateVehicle, CreatePed or CreateObject only, instead of above functions, but in order to make a faster tranistion you can also use the functions showed as an example above.

circle-info

Another solution to prevent spawning entities is through server side checks based on the entity coordinates. For example, the vehicles can be spawned only in specific areas (garage, job) or by permission (admin), the peds can be spawned only in specific areas (job), the objects can be spawned only in specific areas (jobs) depending on how your server has been created.

Handle weapons on your server

circle-info

In order to protect your server from spawning weapons from external sources there are two ways that can prevent such functions, more than anticheat resource can already do

Weapons from weapon wheel

Weapons from server inventory

Handle functions and events

circle-info

If you use functions from server side to client side through tunnels, every function will generate an event in network event logger, so you can protect the generated event.

Last updated