EndCore Framework

World and death

How en-core empties the world of ambient peds, traffic and police, sets player movement rules, and tracks death and revival.

An apocalypse should feel empty. en-core removes GTA's ambient pedestrians, traffic and emergency services, so the only people in the world are players and the things scripts spawn on purpose: zombies, traders and EndCore vehicles. It also tracks when a player dies or is revived, so other resources can react.

Ambient population

Three switches in config/client.lua control the world. The server reads them too.

KeyDefaultWhat it does
world.disablePedestrianstrueNo ambient peds
world.disableTraffictrueNo moving or parked vehicles, trains, boats or planes
world.disableDispatchtrueNo police, ambulance or fire services and no wanted level

On the server

If disablePedestrians or disableTraffic is not false, en-core turns off population in routing bucket 0. Every 5 seconds it does the same for any routing bucket a player is in, so instanced interiors stay empty as well.

ExportReturns
IsPopulationDisabled()boolean

On the client

Every frame, while enabled:

  • Ped, scenario, vehicle, parked vehicle and ambient density multipliers are held at 0.
  • Garbage trucks, boats, trains, distant cars, parked vehicles and vehicle, military and police scenarios are disabled.

When disableDispatch is set:

  • Dispatch services 1–15 are disabled.
  • The maximum wanted level is 0 and random cops are off.
  • Police ignore the player and the police scanner is muted.

These settings are reapplied every 10 seconds in case something else changes them.

Note

Script-spawned entities are not affected. Zombies from en-zombies, traders and vehicles created by EndCore resources appear as normal.

Player movement and health

config/client.lua also sets a few player rules, applied every second while logged in.

KeyDefaultWhat it does
player.runSpeed1.0Sprint speed multiplier
player.fastSwimfalseTurns on the swim speed multiplier
player.fastSwimSpeed1.2Swim speed multiplier when fastSwim is on
player.infiniteStaminafalseRestores stamina every second

The game's own health regeneration is always switched off. Healing is the job of items and resources, not the game.

The client reports health and armour to the server every 10 seconds when they change. They are stored in metadata as health (0–200) and armor (0–100).

Death and revive

en-core notices death by checking the local ped every 500 ms while the player is logged in. It does not need baseevents.

  1. The player dies. The client sends encore:server:onPlayerDeath(killerServerId, cause) and fires the local event encore:client:playerDied(killerServerId, cause).
  2. The server records it. It sets metadata.isdead = true and metadata.inlaststand = false, logs to the death webhook, and fires encore:server:playerDied(source, killerServerId, cause).
  3. The player is alive again. When the ped is no longer dead, for example after a medic or respawn script resurrects it, the client sends encore:server:onPlayerRevive and fires the local event encore:client:playerRevived.
  4. The server clears the flags. It sets isdead and inlaststand back to false in one update.

While isdead or inlaststand is true, the survival tick skips that player.

Last stand

The net event encore:server:onPlayerLastStand sets inlaststand = true. en-core has no last stand system of its own, and no EndCore resource currently sends this event. It is there for a downed-state resource to use.

Respawning

en-core has no respawn logic. The death screen, the wait timer and choosing where to spawn are handled by en-respawn. A revive or respawn resource only has to bring the ped back to life; en-core notices and clears the dead state.

Events

SideEventPayload
Client sendsencore:server:onPlayerDeathkillerServerId, cause
Client sendsencore:server:onPlayerRevivenone
Client sendsencore:server:onPlayerLastStandnone
Client sendsencore:server:syncHealthhealth, armor
Serverencore:server:playerDiedsource, killerServerId, cause
Client (local)encore:client:playerDiedkillerServerId, cause
Client (local)encore:client:playerRevivednone

Revive and last stand changes go through metadata, so they also fire encore:server:onSetMetaData for isdead and inlaststand.

Examples

Reward kills between players who are not in the same group:

lua
AddEventHandler('encore:server:playerDied', function(source, killerServerId, cause)
    local killer = tonumber(killerServerId)
    if not killer or killer == source or not exports['en-core']:IsPlayerLoaded(killer) then
        return
    end

    if not exports['en-core']:AreInSameGroup(killer, source) then
        exports['en-core']:AddXP(killer, 50, 'Player kill')
    end
end)

Check whether a player is down before letting them use something:

lua
if exports['en-core']:GetPlayerMetadata(source, 'isdead') then
    return
end

Show a message on the client when you die:

lua
AddEventHandler('encore:client:playerDied', function(killerServerId, cause)
    encore.notify({ description = 'You died.', type = 'error' })
end)