Skip to content
English

Character

Core API Server Side Only

Detect when a character/player has spawned

Feather core sends a server and client event as soon as the player is loaded/spawned into the world.

Event: Feather:Character:Spawned

Example Usage:

lua
RegisterNetEvent("Feather:Character:Spawned", function(character)
    -- character param is the character object (x, y, z, etc)
    -- Do something here now that the character is spawned
end)
RegisterNetEvent("Feather:Character:Spawned", function(character)
    -- character param is the character object (x, y, z, etc)
    -- Do something here now that the character is spawned
end)

Create Character

Create a character in DB

ParameterDescription
useridthe numerical id of the User
roldidthe numerical id of the role assigned to the user
firstnamethe string value for firstname
lastnamethe string value for lastname
dobstring in format mm-dd-yyyy
dollarsfloat value for money
goldfloat value
tokensfloat value
xpfloat value
xfloat value for position x
yfloat value for position y
zfloat value for position z
langstring value of the active language for user

FeatherCore.Character.CreateCharacter(userid, roldid, firstname, lastname, dob, dollars, gold, tokens, xp, x, y, z, lang)

Example Usage:

lua
CharacterAPI.CreateCharacter(1, 1, 'Test', 'Mcgee', '10-10-1941', 0, 0, 0, 0, 0, 0, 0, "en_us")
CharacterAPI.CreateCharacter(1, 1, 'Test', 'Mcgee', '10-10-1941', 0, 0, 0, 0, 0, 0, 0, "en_us")

Initiate(spawn)

ParameterDescription
srcthe source to initiate/spawn the character on
charidint representation of the character id

FeatherCore.Character.InitiateCharacter(src, 1)

Example Usage:

lua
FeatherCore.Character.InitiateCharacter(src, 1)
FeatherCore.Character.InitiateCharacter(src, 1)

Get All Available Characters from DataBase

lua
FeatherCore.Character.GetAvailableCharactersFromDB(src)
FeatherCore.Character.GetAvailableCharactersFromDB(src)

or

lua
FeatherCore.Character.GetAllCharacters(src)
FeatherCore.Character.GetAllCharacters(src)

Get Character

By Source

lua
FeatherCore.Character.GetCharacter({ src = src })
FeatherCore.Character.GetCharacter({ src = src })

By Character ID

lua
FeatherCore.Character.GetCharacterByID({ id = charid })
FeatherCore.Character.GetCharacterByID({ id = charid })

Remove Character (despawn)

lua
local player = FeatherCore.Character.GetCharacter({ src = src })
player:RemoveCharacter()
local player = FeatherCore.Character.GetCharacter({ src = src })
player:RemoveCharacter()

Get Character Data

lua
local player = FeatherCore.Character.GetCharacterByID({ id = charid })
local character = player.char

print(character.xp)
local player = FeatherCore.Character.GetCharacterByID({ id = charid })
local character = player.char

print(character.xp)

Update Character Field

ParameterDescription
keythe key to change in the cache/db
valuethe value to update the key with

player:UpdateAttribute(key, val)

Example Usage:

lua
local player = FeatherCore.Character.GetCharacter({ src = src })
player:UpdateAttribute('lang', 'en_us')
local player = FeatherCore.Character.GetCharacter({ src = src })
player:UpdateAttribute('lang', 'en_us')

Add to character field

ParameterDescription
keythe key to change (dollars, gold, xp, tokens)
amountfloat/int, how much to add

player:Add(key, amount)

Example Usage:

lua
local player = FeatherCore.Character.GetCharacter({ src = src })
player:Add('dollars', 10)
local player = FeatherCore.Character.GetCharacter({ src = src })
player:Add('dollars', 10)

Subtract from character field

ParameterDescription
keythe key to change (dollars, gold, xp, tokens)
amountfloat/int, how much to subtract

player:Subtract(src, key, amount)

Example Usage:

lua
local player = FeatherCore.Character.GetCharacter({ src = src })
player:Subtract('dollars', 5)
local player = FeatherCore.Character.GetCharacter({ src = src })
player:Subtract('dollars', 5)

Logout

lua
local player = FeatherCore.Character.GetCharacter({ src = src })
player:Logout()
local player = FeatherCore.Character.GetCharacter({ src = src })
player:Logout()