Client Helper
Last updated
Was this helpful?
Last updated
Was this helpful?
Client helper contains all methods of inherited .
getUniqueId()
Returns a unique id as string
.
getCurrentTimestamp()
Returns the current timestamp from posix time in seconds.
getCurrentMsTimestamp()
Returns the current timestamp from posix time in milliseconds.
getCurrentServerTimestamp()
This method is synchronous and will block the client thread until the server responds.
Asks the server for the current timestamp and returns it.
Returns the current server timestamp in seconds.
getAllActivePlayerIds()
getPlayersInRadius(ped, radius)
ped
(number or nil) - The ped id to get the players in radius from. If nil
the player ped will be used.
radius
(number or nil) - The radius in meters (floated values are allowed). If nil
the default radius of 100.0
meters will be used.
getPlayerClientIdsInRadius(ped, radius)
ped
(number or nil) - The ped id to get the players in radius from. If nil
the player ped will be used.
radius
(number or nil) - The radius in meters (floated values are allowed). If nil
the default radius of 100.0
meters will be used.
Returns a list of all player client ids in the radius number[]
or nil
if no player is in the radius.
getPlayerServerIdsInRadius(ped, radius)
ped
(number or nil) - The ped id to get the players in radius from. If nil
the player ped will be used.
radius
(number or nil) - The radius in meters (floated values are allowed). If nil
the default radius of 100.0
meters will be used.
ignore_dead
(boolean, optional) - If true
dead players will be ignored. Default is false
.
Returns a list of all player server ids in the radius number[]
or nil
if no player is in the radius.
getNearestPlayersInRadius(ped, radius)
ped
(number or nil) - The ped id to get the players in radius from. If nil
the player ped will be used.
radius
(number or nil) - The radius in meters (floated values are allowed). If nil
the default radius of 100.0
meters will be used.
Returns the nearest player in the radius NssLibsClientHelperPlayerIdItem
or nil
if no player is in the radius.
getInGameDate(format)
format
(string, optional) - The format of the date string. Available placeholders are D (day), M (month), Y ( year). Default see Config.DefaultDateFormat
.
Returns the current in-game date as string
.
hasPlayers()
Returns true
if there are active players (including current active player) otherwise false
.
dateToTimestamp(date_str, format)
date_str
(string) - The date string to convert.
format
(string, optional) - The format of the date string. Available placeholders are D (day), M (month), Y ( year). Default see Config.DefaultDateFormat
.
Returns the timestamp derived from the date string in seconds as number
(integer).
getInGameDateTimestamp(format)
format
(string, optional) - The format of the date string. Available placeholders are D (day), M (month), Y ( year). Default see Config.DefaultDateFormat
.
Returns the current in-game date as timestamp in seconds as number
(integer).
getClientPlayerIdFromServer(server_player_id)
This is a shorthand.
server_player_id
(number) - The server id of the player.
Returns the client id of the player as number
.
getServerPlayerId()
This is a shorthand.
Returns the server id of the current player as number
.
timeout(callback, interval_in_ms)
This method is asynchronous and will not block the client thread.
callback
(function) - The function to call after the interval.
interval_in_ms
(number) - The interval in milliseconds.
Returns a function
to clear the timeout.
addEventHandler(event_name, callback, resource_name)
event_name
(string) - The name of the event.
callback
(function) - The function to call when the event is triggered.
If the callback returns false
other additional callbacks registered after this callback will not be called.
resource_name
(string) - The name of the resource that is listening to the event.
on_destroy_callback
(function, optional) - Called before the event handler is destroyed. If the callback returns false
the event handler will not be destroyed.
waitUntilLoadingsScreenEnds()
This method is synchronous and will block the client thread until the loading screen ends.
Returns nothing.
playAnimation(ped, dict, name, flag)
Plays the given animation on given ped.
Important: This method is asynchronous and will not block the client thread.
ped
(number) - The player ped id.
dict
(string) - The animation dictionary.
name
(string) - The animation name.
flag
(number, optional) - The flag of the animation. Default is 0
.
Returns nothing.
requestAnimDict(dict)
Requests the given animation dictionary.
dict
(string) - The animation dictionary.
Returns true
if the animation dict is requested successfully otherwise false
.
NssLibsClientHelperPlayerIdItem
client
(number) - The client id of the player.
server
(number) - The server id of the player.
players
(NssLibsClientHelperPlayerIdItem[]) - The list of players in radius.
nearest_player
(NssLibsClientHelperPlayerIdItem|nil) - The nearest player in radius.
Returns a list of all active player ids .
Returns a list of all player ids in the radius or nil
if no player is in the radius.
Returns a instance.