Client Helper
Client helper contains all methods of inherited Shared helper.
Import client helper
Methods
getUniqueId()
getUniqueId()
Returns a unique id as string
.
getCurrentTimestamp()
getCurrentTimestamp()
Returns the current timestamp from posix time in seconds.
getCurrentMsTimestamp()
getCurrentMsTimestamp()
Returns the current timestamp from posix time in milliseconds.
getCurrentServerTimestamp()
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.
Important: Use with care as often you call this method, as often the server will be asked for the current timestamp.
Returns the current server timestamp in seconds.
getAllActivePlayerIds()
getAllActivePlayerIds()
Returns a list of all active player ids NssLibsClientHelperPlayerIdItem[]
.
getPlayersInRadius(ped, radius)
getPlayersInRadius(ped, radius)
ped
(number or nil) - The ped id to get the players in radius from. Ifnil
the player ped will be used.radius
(number or nil) - The radius in meters (floated values are allowed). Ifnil
the default radius of100.0
meters will be used.
Returns a list of all player ids in the radius NssLibsClientHelperPlayerIdItem[]
or nil
if no player is in the radius.
getPlayerClientIdsInRadius(ped, radius)
getPlayerClientIdsInRadius(ped, radius)
ped
(number or nil) - The ped id to get the players in radius from. Ifnil
the player ped will be used.radius
(number or nil) - The radius in meters (floated values are allowed). Ifnil
the default radius of100.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)
getPlayerServerIdsInRadius(ped, radius)
ped
(number or nil) - The ped id to get the players in radius from. Ifnil
the player ped will be used.radius
(number or nil) - The radius in meters (floated values are allowed). Ifnil
the default radius of100.0
meters will be used.ignore_dead
(boolean, optional) - Iftrue
dead players will be ignored. Default isfalse
.
Returns a list of all player server ids in the radius number[]
or nil
if no player is in the radius.
getNearestPlayersInRadius(ped, radius)
getNearestPlayersInRadius(ped, radius)
ped
(number or nil) - The ped id to get the players in radius from. Ifnil
the player ped will be used.radius
(number or nil) - The radius in meters (floated values are allowed). Ifnil
the default radius of100.0
meters will be used.
Returns the nearest player in the radius NssLibsClientHelperPlayerIdItem
or nil
if no player is in the radius.
getInGameDate(format)
getInGameDate(format)
format
(string, optional) - The format of the date string. Available placeholders are D (day), M (month), Y ( year). Default seeConfig.DefaultDateFormat
.
Returns the current in-game date as string
.
hasPlayers()
hasPlayers()
Returns true
if there are active players (including current active player) otherwise false
.
dateToTimestamp(date_str, format)
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 seeConfig.DefaultDateFormat
.
Returns the timestamp derived from the date string in seconds as number
(integer).
getInGameDateTimestamp(format)
getInGameDateTimestamp(format)
format
(string, optional) - The format of the date string. Available placeholders are D (day), M (month), Y ( year). Default seeConfig.DefaultDateFormat
.
Returns the current in-game date as timestamp in seconds as number
(integer).
getClientPlayerIdFromServer(server_player_id)
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()
getServerPlayerId()
This is a shorthand.
Returns the server id of the current player as number
.
timeout(callback, interval_in_ms)
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)
addEventHandler(event_name, callback, resource_name)
Important: If the related resource is stopped, the event will be removed automatically.
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 returnsfalse
the event handler will not be destroyed.
Returns a NssLibsSharedHelperEventHandlerApi
instance.
waitUntilLoadingsScreenEnds()
waitUntilLoadingsScreenEnds()
This method is synchronous and will block the client thread until the loading screen ends.
Returns nothing.
playAnimation(ped, dict, name, flag)
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 is0
.
Returns nothing.
requestAnimDict(dict)
requestAnimDict(dict)
Requests the given animation dictionary.
dict
(string) - The animation dictionary.
Returns true
if the animation dict is requested successfully otherwise false
.
Objects
NssLibsClientHelperPlayerIdItem
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.
Last updated