# API Reference

Every function below is called via the global `Core` table from any Rynex script's shared, server, or client context.

### Detection

```lua
Core.GetFramework()       -- Returns 'esx', 'qbcore', 'qbox', 'oxcore', 'standalone', or nil
Core.GetInventorySystem() -- Returns 'ox_inventory', 'esx', 'qb', or nil
Core.IsLoaded()           -- Returns true once framework detection has completed
Core.Version              -- The current rx-core version string
```

### Identity

```lua
Core.GetPlayer(src)                -- Returns a player table (or nil)
Core.GetPlayers()                  -- Returns an array of online player sources
Core.GetPlayerFromIdentifier(id)   -- Lookup by citizenid/identifier
Core.GetIdentifier(src)            -- Returns the player's primary identifier
Core.GetCitizenId(src)             -- Returns the citizen ID
Core.GetName(src)                  -- Returns the character's display name
Core.GetCoords(src)                -- Returns the player's coords as vector3
Core.GetPed(src)                   -- Returns the player's ped entity
Core.GetPlayerData(src)            -- Returns a normalized player data table
```

### Money

```lua
Core.GetMoney(src, account)        -- account = 'cash', 'bank', or 'black_money'
Core.AddMoney(src, amount, account)
Core.RemoveMoney(src, amount, account)
```

Convenience wrappers:

```lua
Core.AddCash(src, amount)        Core.RemoveCash(src, amount)        Core.GetCash(src)
Core.AddBank(src, amount)        Core.RemoveBank(src, amount)        Core.GetBank(src)
Core.AddBlackMoney(src, amount)  Core.RemoveBlackMoney(src, amount)  Core.GetBlackMoney(src)
```

### Jobs and Gangs

```lua
Core.GetJob(src)                   -- Returns { name, label, grade, gradeLabel }
Core.SetJob(src, jobName, grade)
Core.GetGang(src)                  -- Same shape as GetJob (QBCore/QBox only)
Core.SetGang(src, gangName, grade)
Core.HasJob(src, jobName, minGrade)
Core.GetPlayersByJob(jobName)      -- Returns array of sources
Core.CountPlayersByJob(jobName)
```

### Permissions

```lua
Core.HasPermission(src, perm)
Core.GetGroup(src)
```

### Inventory items

```lua
Core.GetItem(src, itemName)              -- Returns { name, count, label, weight, metadata } or nil
Core.GetItemCount(src, itemName)
Core.AddItem(src, itemName, count, metadata)
Core.RemoveItem(src, itemName, count, metadata)
Core.HasItem(src, itemName, count)
Core.CanCarryItem(src, itemName, count)
Core.RegisterUsableItem(itemName, callback)
Core.GetInventory(src)                   -- Returns the full inventory as an array
Core.ClearInventory(src)
Core.FindItem(src, itemName)
```

### Weapons

```lua
Core.GetWeapons(src)
Core.HasWeapon(src, weaponName)
Core.GiveWeapon(src, weaponName, ammo)
Core.RemoveWeapon(src, weaponName)
Core.GetAmmo(src, weaponName)
Core.AddAmmo(src, weaponName, amount)
Core.SetAmmo(src, weaponName, amount)
```

### Item metadata (ox\_inventory rich; others limited)

```lua
Core.SetItemMetadata(src, slot, metadata)
Core.GetItemMetadata(src, slot)
```

On non-`ox_inventory` frameworks, these no-op and log a one-time warning.

### Vehicles

```lua
Core.SpawnVehicle(coords, model, cb)
Core.DeleteVehicle(entity)
```

`rx-core` does not abstract vehicle ownership — that's per-script database logic.

### Society

```lua
Core.GetSocietyMoney(society)
Core.AddSocietyMoney(society, amount)
Core.RemoveSocietyMoney(society, amount)
```

### Callbacks

```lua
-- Server
Core.RegisterCallback(name, callback)

-- Client
Core.TriggerCallback(name, cb, ...)   -- 10s timeout, returns nil on timeout
```

### Events

```lua
Core.OnPlayerLoaded(callback)
Core.OnPlayerDropped(callback)
Core.OnPlayerDeath(callback)
Core.OnJobUpdate(callback)
```

### Unsupported features

When you call a function not supported by the detected framework (e.g. `Core.GetGang` on ESX), `rx-core` logs a one-time warning to the console and returns `nil` or `false`. Your script keeps running.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.rynexscripts.com/rx-core/api-reference.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
