3.9 KiB
title
| title |
|---|
| Methods |
import Tabs from '@theme/Tabs'; import TabItem from '@theme/TabItem';
These functions are inherited by instances of CPlayer.
player.set
Update the player's metadata, optionally syncing it with the client.
local key, value = 'iq', 300
player.set(key, value)
const [key, value] = ['iq', 300];
player.set(key, value);
player.setdb
Update the player's metadata and store in the DB, optionally syncing it with the client.
local key, value = 'iq', 300
player.setdb(key, value)
const [key, value] = ['iq', 300];
player.setdb(key, value);
player.get
Return the player's metadata. Sending an argument will retrieve a specific metadata key.
local data = player.get()
local iq = player.get('iq')
const data = player.get();
const iq = player.get('iq');
player.getCoords
Return the player's world position.
local coords = player.getCoords()
const coords = player.getCoords();
player.setGroup
Updates the player's grade for the given group. Any value below 1 will remove the group from the player.
local group, grade = 'police', 3
player.setGroup(group, grade)
const [group, grade] = ['police', 3];
player.setGroup(group, grade);
player.getGroup
Returns the player's current grade for a given group.
local grade = player.getGroup()
const grade = player.getGroup();
player.getGroup
Returns an object of all groups the player is in, with the current grade as the value.
local groups = player.getGroups()
const groups = player.getGroups();
player.hasGroup
Check if the player is a member of a given group, and returns the matching group name and grade.
The filter can be a string, array, or object where key is the group, and value is the minimum grade.
local filter = { police = 0, sheriff = 0 }
local group, grade = player.hasGroup(filter)
const filter = { police: 0, sheriff: 0 };
const [group, grade] = player.hasGroup(filter);
player.getPlayersInScope
Return an array of all player id's inside the player's scope.
local inScope = player.getPlayersInScope()
const inScope = player.getPlayersInScope();
player.isPlayerInScope
Check if the given source is inside the player's scope.
local target = 2
local inScope = player.isPlayerInScope(target)
const target = 2;
const inScope = player.isPlayerInScope(target);
player.triggerScopedEvent
Trigger a client event for all players in the player's scope.
player.triggerScopedEvent(eventName, ...)
player.triggerScopedEvent(eventName, ...)