Browse docsns-crew

ns-crew

Crew system for FiveM: players create crews, invite members, climb a crew leaderboard and fight other crews in round-based Crew vs Crew (CvC) wars.

Cross-framework: ESX / QBCore / Qbox. The framework is detected at runtime (qbx_core → qb-core → es_extended); the script body never calls a framework directly.

Features

Crews

  • Create / delete a crew (name, 1–3 letter tag, banner). Deleting asks for the crew name typed exactly.
  • Join policy per crew: Private (invite only), Applications (players apply, officers approve) or Open (join from the leaderboard).
  • Invites with a 15 s popup, answered with Y / N or the on-screen buttons.
  • Custom roles with nine switchable permissions (invite, kick, banner, Discord link, post announcements, delete announcements, CvC, roles, join policy). Default roles: leader, manager, member.
  • Kick, leave, transfer leadership.
  • Announcements: chat message plus a top-of-screen alert to every online member, with history.
  • Crew map: live positions of crew members.
  • Kill / death tracking per member and per crew, K/D computed on the fly.
  • Leaderboard with podium, sortable by kills, deaths, K/D and wins.
  • Crew mates get nametags and map blips (only in the same routing bucket). Friendly fire between crew mates is off by default.
  • Personal display settings (nametags, distance, colour, blips) in the gear menu, saved per player.

Crew vs Crew

  • A leader (or a role with the CvC permission) declares war on another crew: mode, best-of, team size, map and weapon class bans.
  • The invite waits in the other crew's CvC › Invites tab. Unanswered invites are declined automatically after 10 minutes.
  • When accepted, both crews see a Join war bar in the crew menu for 5 minutes. A side that nobody joins cancels the war.
  • Matches run in their own routing bucket. Players are restored (position, weapons) when they leave or the war ends.
  • Modes — every mode is round-based. Classic and Capture the flag have no respawn, and wiping out the other crew wins the round:
    • Classic — elimination only.
    • Capture the flag — bring the enemy flag to your base. A dropped flag returns home when its owners touch it, or after 15 s.
    • Hold the zone — hold a zone alone for a total of 30 s. A map can have up to four zones, and each zone a crew holds alone adds to its timer. Both crews inside a zone pauses that zone. Dead players respawn at their team spawn after 3 s, so the round ends only when a crew takes the zone (safety limit: 15 minutes, the crew that held longer wins).
  • Before each round players pick one primary, one pistol and their attachments. Every weapon comes with maximum ammo, and a slot left alone gets a random allowed weapon.
  • Own weapons (optional, Config.CvC.ownWeapons): the declaring crew can make everyone fight with the weapons and ammo they carry instead. No pick screen, the inventory stays usable, weapon bans still apply.
  • Vehicles (optional): on a map with vehicle points, the declaring crew can turn on vehicles and pick the model from a list. Each side gets the same cars at its spawn every round, with the upgrades set in the config at max level; they are removed after the round.
  • Dead players spectate their alive teammates until the round ends (LMB / RMB to switch).
  • Forfeit rules for players who leave mid-war (Config.CvC.punishFirstRoundQuit).
  • The final score and the winner are posted in chat to the whole server.
  • Head-to-head history and recent matches per crew.

Requirements

ResourceRequired
oxmysqlYes
es_extended / qb-core / qbx_coreOne of them
OneSyncYes (routing buckets and server-side positions for CvC)

Installation

  1. Put the folder in resources/ as ns-crew. The NUI calls https://ns-crew/..., so the folder name must not change.
  2. Run crew.sql on your database. It creates three tables: ns_crew (crews, with their roles and join requests), ns_crew_log (activity feed, announcements) and ns_crew_wars (war results). Updating from an older version? Nothing to run: on start the resource moves the data of the old tables into these three and keeps the old tables as <name>_old.
  3. Add to server.cfg, after oxmysql and your framework:
    ensure ns-crew
    

Commands

CommandWhoWhat
/crewEveryoneOpen the crew menu (name set by Config.CrewCommand)
/crewnotify <message>Roles with the announcement permissionAnnounce to your crew
/allcrewnotify <message>Admin / modSystem message to every crew
/cvcleavePlayers in a warLeave the current war (same rules as the Leave button)
/cvcmapsAdmin / modOpen the CvC map editor

Adding a CvC map

With the map editor

  1. Run /cvcmaps, then pick a map or press New map. A top-down camera opens: W A S D move it and the mouse wheel zooms.
  2. Click the ground to place Team A spawn, then Team B spawn.
  3. Type a name and press Save map. The map is playable at once, with no restart.

For vehicles, set Team A vehicles and Team B vehicles (both or neither); the cars face the center. For Hold the zone, set Zone 1, then Zone 2 to Zone 4 appear one by one. Two spawns are all a map needs: the teams face each other, the center goes to the middle of the spawns, the lobby to the center, and the play area grows to fit every point. To change a point, click its row on the panel and click the ground. Flags and the zone show up when their mode is on.

  • A click lands on the top surface, so a point under a roof must be added in Config.CvC.maps.
  • Maps are stored in cvc_maps.json in the resource and override Config.CvC.maps entries with the same key. Reset on an edited map brings the config version back.
  • A map that a war or an invite is using cannot be changed.

In the config

Maps live in Config.CvC.maps; the comments there list every key. Each map needs lobbycoords, mapcenter, radius and spawnPoints (attacker, defender; vec4 sets the heading). Optional keys: flags (CTF bases), zone / zones, vehicles (attacker, defender as vec4), modes (offer the map in these modes only).

Players who leave the radius are put back where they left it, so every point the round uses must sit inside it. Without flags the spawn points are the CTF bases; without zone the map centre is used. For more than one zone, replace zone with zones = { { center = vec3(...), radius = 8.0 }, ... }.

Configuration

Everything is in config.lua:

SectionWhat it controls
Config.Locale'en' or 'tr' (strings in Config.Strings)
Config.DefaultDiscordInviteDiscord button target for crews without their own link ('' hides it)
Config.FriendlyFireEnabledCrew mates can hurt each other
Config.Permissions, Config.DefaultRolesPermission list and the roles every new crew starts with
Config.LeaderboardCrews listed, crews per page, K/D shown green from goodKD
Config.AnnounceAnnouncement spam guard: maxActive per crew, expireHours, per-player cooldown
Config.AvatarsProfile pictures: 'both' (player picks), 'steam', 'discord' (forced) or false. Discord needs set ns_crew_discord_token "..." in server.cfg
Config.InviteKeysAccept / decline keys for crew and war invites: { control = <GTA control index>, label = "Y" }. Defaults Y (246) / N (306)
Config.ServerName/tag limits, member limit (maxMember, applies to every crew), default banner, join policy, save interval, banner validation
Config.ClientNametag and blip defaults. NametagColor is a HUD colour index (1 white, 12 yellow, 6 red, 18 green, 9 blue, 21 purple, 15 orange, 24 pink). DistantBlipPollSec (default 2, 1–60) is how often blips of members out of streaming range move
Config.AmbulanceCompatAmbulance jobs to reset when CvC revives a player
Config.CvCModes, timings, best-of and team sizes, weapon categories, loadout, maps
Config.CvC.zoneholdTime to win a round, respawnTime after a death, roundTime safety limit
Config.CvC.defaultPlayersPlayers per side preselected on the war setup screen (1 = 1v1)
Config.CvC.pickTimeSeconds players stand frozen at spawn picking one primary (classes that are not banned) and one pistol; the pick carries over, a slot left alone gets a random allowed weapon each round. 0 gives defaultLoadout instead
Config.CvC.ownWeaponsenabled = true offers Own weapons on the war invite. keepOnDeath = true (default): a death in the war loses nothing and drops no loot. false: the inventory's normal death rules apply
Config.CvC.vehiclesVehicles on maps with vehicle points: enabled, perSide (1–8), models (the list the declaring crew picks from: model, label, type = CreateVehicleServerSetter type) and upgrades (engine, brakes, transmission, suspension, armor, turbo: true = max level, false = stock; put on as the vehicle spawns)
Config.CvC.soundsGame sounds for a received crew or war invite and an accepted war invite (false = silent)
Config.CvC.pistolsPistols on the pick screen (a class the war setup can ban like any other). Every picked weapon gets the game's maximum ammo. Players also pick attachments there; each weapon keeps its attachments for the next time (saved on the client)
Config.CvC.blockInventoryNo inventory and no death drop while in a war: ns-inventory through its game-mode exports, ox_inventory / qb-inventory through the invBusy / inv_busy statebags. Other inventories hook the war events (see Integration)

Exports

Server

Lua
exports['ns-crew']:GetAllCrew()                -- { [lowername] = crew, ... }
exports['ns-crew']:isInCrew(identifier)        -- crew name or nil
exports['ns-crew']:GetCrewData(name)           -- crew or nil
exports['ns-crew']:GetCrewAndRank(identifier)  -- { name, rank, banner } or nil
exports['ns-crew']:GetCrewTag(identifier)      -- tag or nil
exports['ns-crew']:GetCrewPlayers(identifier)  -- { src, ... } online members
exports['ns-crew']:getBanner(name)             -- banner path / URL
exports['ns-crew']:AreCrewMates(a, b)          -- boolean; a/b = server id or identifier
exports['ns-crew']:IsInWar(source)             -- boolean; skip these players in a lootbag / drop script

Client

Lua
exports['ns-crew']:openCrew(true)       -- open / close the menu
exports['ns-crew']:GetPlayerCrew()      -- local player's crew data
exports['ns-crew']:IsCrewMate(serverId) -- boolean

Events

Server-side, local only (TriggerEvent from another server script — they are not net events, so clients cannot fire them):

Lua
TriggerEvent('ns-crew:server:updateNickname', identifier, newName)  -- character renamed
TriggerEvent('ns-crew:server:WipePlayer', identifier)               -- remove a player from crews

Client event fired on a player whose crew membership changes (create, join, kick, leave, delete):

Lua
RegisterNetEvent('ns-crew:client:crewUpdated', function() --[[ refresh your UI ]] end)

Integration: inventory and loot

ns-inventory, ox_inventory, qs-inventory and qb-inventory with qb-weapons need no setup: ns-crew uses their own switches, so they leave war weapons alone and the player's items stay as they are. If any other inventory strips a picked weapon, ns-crew gives it back within 500 ms with the same rounds; add ns-crew:server:warWeapons below to stop the strip itself. Anticheats need their own exception: see Integration: anticheat.

For any other inventory, lootbag or death-drop script, ns-crew fires these events during a war; the script listens and blocks itself.

Lua
-- server: player entered (true) or left (false) a war.
-- false comes ~12 s after the war ends, after the last revive.
-- info is nil, or { ownWeapons = true, keepOnDeath = bool } in an own-weapons war.
AddEventHandler('ns-crew:server:warState', function(src, inWar, info)
    -- e.g. block the inventory, keep items on death, no lootbag
    -- own weapons: keep the inventory open; keepOnDeath false = normal death rules
end)

-- server: the weapons ns-crew gave this round (nil = none any more).
-- Do not strip these as "not in the inventory".
AddEventHandler('ns-crew:server:warWeapons', function(src, primary, sidearm) end)

-- client: same war state on the player's own client
AddEventHandler('ns-crew:client:warState', function(inWar, info) end)

In an own-weapons war ns-inventory is not blocked, and setKeepOnDeath follows Config.CvC.ownWeapons.keepOnDeath. LocalPlayer.state.nsCrewWar stays on in every war, so a lootbag script that only checks it drops nothing; use the info argument to follow keepOnDeath.

You can also poll: exports['ns-crew']:IsInWar(source) (server) or LocalPlayer.state.nsCrewWar (client).

Integration: anticheat

War weapons are ped weapons given with GiveWeaponToPed; they are not inventory items. An anticheat that removes weapons a player does not own, such as qb-anticheat, also removes war weapons. ns-crew gives them back within 500 ms, so the weapon disappears and returns during the round, and the anticheat can log or punish the player each time.

Make the anticheat skip players in a war:

Lua
-- client side of the anticheat, at the top of its weapon check
if LocalPlayer.state.nsCrewWar then return end

-- server side of the anticheat
if GetResourceState('ns-crew') == 'started' and exports['ns-crew']:IsInWar(source) then return end

Inside a loop, use goto continue or an if block in place of return, so the check still runs for other players and later ticks.

  • LocalPlayer.state.nsCrewWar is set only while Config.CvC.blockInventory is on (the default). With it off, use the ns-crew:client:warState event.
  • Add the same skip to teleport, revive and health checks: a war teleports and revives players every round.
  • Check weapon blacklists too. Config.BlacklistedWeapons in qb-smallresources lists WEAPON_RAILGUN by default, which is in the heavy class. Remove it there, or remove it from Config.CvC.weaponCategories.
  • For a closed anticheat, ask its author for an exception and give them the checks above.

War vehicles. The server creates them (CreateVehicleServerSetter) inside the war's routing bucket, so an anticheat that only cancels client-created entities (entityCreating) leaves them alone. Three checks can still remove or flag them:

  • A vehicle model whitelist or blacklist: allow every model in Config.CvC.vehicles.models.
  • Vehicle mod or handling detection: the upgrades are put on by a war player's client as the vehicle spawns.
  • An entity spawn rate limit: each round start creates up to perSide × 2 vehicles at once (4 by default).

Every war vehicle carries the state bag nsCrewWarVeh, so the anticheat can skip it:

Lua
-- server side, e.g. in an entityCreated or vehicle check
if Entity(vehicle).state.nsCrewWarVeh then return end

Death, ambulance jobs and items

A player who dies in a round is revived at once and sent to the lobby to spectate; the next round and the end of the war revive them again. ns-crew clears the ambulance job's own death state too (Config.AmbulanceCompat: qb-ambulancejob, qbx_medical, esx_ambulancejob, wasabi_ambulance, ars_ambulancejob). So the job's bleed-out timer never ends during a war, the player cannot respawn at the hospital, and the job's hospital rules (Config.WipeInventoryOnRespawn in qb-ambulancejob, the respawn bill) never run.

What a death costs in a war depends on the war type:

WarInventory itemsWeapons
Pick screenKept: the inventory is blocked and set to keep items on deathWar weapons only; the player's own weapons come back when the war ends
Own weapons, keepOnDeath = trueKept, no loot dropsKept; used ammo stays used
Own weapons, keepOnDeath = falseThe inventory's own death rules. ns-inventory drops its lootbag; qb-inventory and ox_inventory lose nothing on death by themselvesSame as items

An ambulance job that is not in Config.AmbulanceCompat can still show its death screen after a revive. Add it there with its revive event and death state bags.

Security notes

  • Kill stats take the killer from source, never from client data.
  • Every crew action re-checks the player's crew and permission on the server.
  • Invites expire on the server even if the client never answers.
  • Banners are validated (extension whitelist, length limit, no markup characters).
  • Crew deletion needs the leader check; typing the crew name only guards against mistakes.
  • Announcements have a per-player cooldown and a per-crew cap; posts are serialised per crew so the cap holds when members post at once.
  • The Discord bot token is read from a server convar, never from config.lua (which is sent to clients).
  • CvC objectives (flags, zone) are decided on the server from server-side positions.

Instant delivery

Scripts land in your Cfx.re Keymaster account right after checkout.

Support on Discord

Ask the team in our Discord, before or after you buy.

Open Source or Escrowed

Most scripts come in both plans: readable code to edit, or an escrowed build with the config open.

Your Cart

· 0
Your cart is empty
Add a script from the store and it shows up here.
Browse scripts