OxPlayer
- charId:
number - identifier:
string - ped:
number - source:
number - stateId:
string - userId:
number - username:
string
OxPlayer.addLicense
Grants a license to the player.
player.addLicense(licenseName)Parameters
- licenseName:
string
Returns
boolean
OxPlayer.addStatus
Increases the value of a status.
player.addStatus(statusName, value)Parameters
- statusName:
string - value:
number
Returns
boolean
OxPlayer.createCharacter
Registers a new character for a player that has not already selected a character.
player.createCharacter(data)Parameters
- data:
object- firstName:
string - lastName:
string - gender:
string - date:
number
- firstName:
Returns
number- The index of the new character in an array of all characters owned by the player.
OxPlayer.deleteCharacter
Deletes a character with the given charId, if owned by the player and they have not selected a character.
player.deleteCharacter(charId)Parameters
- charId:
number
Returns
boolean
OxPlayer.emit
Triggers a client event for the player.
player.emit(eventName, ...args)Parameters
- eventName:
string - ...args:
any
OxPlayer.get
Get the value of a specific key from the player's metadata.
player.get(key)Parameters
- key:
string
Returns
unknown
OxPlayer.getAccount
Returns the player's default OxAccount object.
player.getAccount()Returns
OxPlayer.getCoords
Returns the player's current coordinates.
player.getCoords()Returns
vector3
OxPlayer.getGroup
Returns the player's grade of a given group name, or the first matched name and grade in a filter.
player.getGroup(filter)Parameters
- filter:
string|string[]|{ [string]: number }
Returns
number|stringnumber?
OxPlayer.getGroupByType
Returns the player's name and grade of a group with a matching type.
player.getGroupByType(type)Parameters
- type:
string
Returns
string?number?
OxPlayer.getGroups
Returns an object of all groups the player is currently in, using the group name as a key.
player.getGroups()Returns
{ [string]: number }
OxPlayer.getLicense
Returns an object containing information for the specified license.
player.getLicense(licenseName: string): objectParameters
- licenseName:
string
Returns
objectissued: numbersuspended?: [number, number][key: string]: any
OxPlayer.getLicenses
Returns an object containing information for all licenses.
player.getLicenses()Returns
object{ [string]: object }issued: numbersuspended?: [number, number][key: string]: any
OxPlayer.getStatus
Returns the value of the status.
player.getStatus(statusName)Parameters
- statusName:
string
Returns
- value:
number
OxPlayer.getStatuses
Returns an object containing all statuses, using the status name as the key.
player.getStatuses()Returns
{ [string]: number }
OxPlayer.hasPermission
Checks if a user has been granted a permission by one of their groups.
player.hasPermission(permission)Parameters
- permission:
string
Returns
boolean
Example
-- Adding a permission to a group
Ox.SetGroupPermission('police', 1, 'handcuff', 'allow')
-- Checking if a player has the 'handcuff' permission
if player.hasPermission('group.police.handcuff') then
-- Do something
endOxPlayer.logout
Clears data for the active character and transitions the player to character selection, if valid.
player.logout(save, dropped)Parameters
- save?:
boolean- If the active character data should be saved to the database, defaulting to
true.
- If the active character data should be saved to the database, defaulting to
- dropped?:
boolean- If the player has been disconnected from the server.
OxPlayer.payInvoice
Pays an account invoice with the given invoiceId.
player.payInvoice(invoiceId)Parameters
- invoiceId:
number
Returns
object- success:
boolean - message?:
"no_charId"|"no_permission"|"no_balance"|"no_invoice"|"invoice_paid"|"insufficient_balance"
- success:
OxPlayer.removeLicense
Remove a license from the player.
player.removeLicense(licenseName)Parameters
- licenseName:
string
Returns
boolean
OxPlayer.removeStatus
Reduces the value of a status.
player.removeStatus(statusName, value)Parameters
- statusName:
string - value:
number
Returns
boolean
OxPlayer.save
Saves the active character to the database.
player.save()OxPlayer.set
Stores a value in the player's metadata, which can be optionally synced with the client.
player.set(key, value, replicated)Parameters
- key:
string - value:
any - replicated?:
boolean
OxPlayer.setActiveCharacter
Loads and sets a character as the player's active character. Takes a charId or an object containing new character data.
player.setActiveCharacter(data)Parameters
- data:
number|object- firstName:
string - lastName:
string - gender:
string - date:
number
- firstName:
Returns
object- charId:
number - stateId:
string - firstName:
string - lastName:
string - x?:
number - y?:
number - z?:
number - heading?:
number - lastPlayed?:
string - health?:
number - armour?:
number - isNew?:
boolean
- charId:
OxPlayer.setActiveGroup
Sets a group the player is in as their active or "primary" group. If no arguments are passed, no active group will be set.
player.setActiveGroup(groupName?: string, temporary?: boolean)Parameters
- groupName:
string - temporary?:
boolean- If
trueit will not persist through sessions.
- If
Returns
boolean
OxPlayer.setGroup
Sets the player's grade within a group. If grade is undefined or 0 they will be removed from the group.
player.setGroup(groupName, grade)Parameters
- groupName:
string - grade?:
number
Returns
boolean
OxPlayer.setStatus
Sets the value of a status.
player.setStatus(statusName, value)Parameters
- statusName:
string - value:
number
Returns
boolean
OxPlayer.updateLicense
Sets information on a player license.
player.updateLicense(licenseName, key, value)Parameters
- licenseName:
string - key:
string - value:
unknown
Returns
boolean