Functions
This is the way of getting the Core API Functions (Server Side)
local TPZ = exports.tpz_core:getCoreAPI()
General
Trigger Client Event Async based on coordinates distance
-- @param eventName : requires the event that needs to be triggered.
-- @param data : requires the data in a table form for sending to the triggered event {}.
-- @param coords : requires the coords (x,y,z) in a table form.
-- @param radius : requires in a double integer value the radius to update the data instantly on the players who are nearby to the coords - radius.
-- @param delay : requires in an integer the duration time in milliseconds to update on every player the data (who are not within the radius).
-- that means, if default is 200 milliseconds and there are 80 players outside of the radius, it will take 16 seconds in total (except the ones who are within the radius).
-- @param multiplyDelay : requires a boolean to multiply the @delay input * 2.
-- @param multiplyMinPlayers : requires an integer, the specified option is with @multiplyDelay,
-- If @multiplyMinPlayers input is 40, it will multiply the update delay but if the players are more than 40, it will not multiply but use the default delay input.
-- The multiply feature is for the 40 players to take the same time to be updated as it should in 80 players.
TPZ.TriggerClientEventAsyncByCoords(eventName, data, coords, radius, delay, multiplyDelay, multiplyMinPlayers)
Get online players who are NOT in a session (character selection).
-- @param players (int): returns the players source
-- @param count (int): returns the players total count
-- Looping through the function example:
local onlinePlayers = TPZ.GetPlayers()
if onlinePlayers.count > 0 then -- We are checking if players are available before looping through the list.
for index, player in pairs(onlinePlayers.players) do
print(player.source) -- player.source will return all the sources from the available players.
end
end
Get online players who ARE in a session (character selection).
-- @param players (int): returns the players source
-- @param count (int): returns the players total count
-- Looping through the function example:
local onlinePlayers = TPZ.GetPlayersInSession()
if onlinePlayers.count > 0 then -- We are checking if players are available before looping through the list.
for index, player in pairs(onlinePlayers.players) do
print(player.source) -- player.source will return all the sources from the available players.
end
end
Get job players (online) based on the input job
-- @param players (int): returns the players source which belong to this job )
-- @param count (int): returns the players total count which belong to this job )
-- Looping through the function example:
local medicPlayersList = TPZ.GetJobPlayers("medic")
if medicPlayersList.count > 0 then -- We are checking if medics are available before looping through the list.
for index, player in pairs(medicPlayersList.players) do
print(player.source) -- player.source will return all the sources from the available players with "medic" job.
end
end
Get group players (online) based on the input group
-- @param players (int): returns the players source which belong to this group)
-- @param count (int): returns the players total count which belong to this group)
-- Looping through the function example:
local onlineAdminsList = TPZ.GetGroupPlayers("admin")
if onlineAdminsList.count > 0 then -- We are checking if admins are available before looping through the list.
for index, player in pairs(onlineAdminsList.players) do
print(player.source) -- player.source will return all the sources from the available players with "admin" group.
end
end
Get players (online) who are administrators based on the group & discord roles who are configured through tpz_core > config.lua
-- @param players (int): returns the players source
-- @param count (int): returns the players total count
-- Looping through the function example:
local onlineAdminsList = TPZ.GetPlayersByAdministratorPermissions()
if onlineAdminsList.count > 0 then -- We are checking if admins are available before looping through the list.
for index, player in pairs(onlineAdminsList.players) do
print(player.source) -- player.source will return all the sources from the available players with the administrator permissions..
end
end
Disconnect (Kick) ALL the online players BUT, by checking if you want the administrators to be kicked / not.
-- @param reason (string): the reason for kicking the players of the server.
-- @param kickAdministrators (boolean): a boolean if you want to kick administrators / not
TPZ.DisconnectAll(reason, kickAdministrators)
Webhooks
Discord Webhooks (Embed)
-- @param webhook: the webhook url for the httprequest to be sent to the discord server.
-- @param title: the title.
-- @param description: the description.
-- @param color: All colors can be found here: https://gist.github.com/thomasbnt/b6f455e2c7d743b796917fa3c205f812
TPZ.SendToDiscord(webhook, title, description, color) -- server to server.
Discord Webhooks (Embed) with player parameters.
-- @param webhook: the webhook url for the httprequest to be sent to the discord server.
-- @param title: the title.
-- @param source : the online player target source.
-- @param steamName : the player target steam name.
-- @param username : the player target character first and lastname.
-- @param identifier : the player target identifier.
-- @param charidentifier : the player target selected character identifier.
-- @param description: the description.
-- @param color: All colors can be found here: https://gist.github.com/thomasbnt/b6f455e2c7d743b796917fa3c205f812
TPZ.SendToDiscordWithPlayerParameters(webhook, title, source, steamName, username, identifier, charidentifier, description, color)
Discord Webhooks (Embed) with url image support.
-- @param webhook: the webhook url for the httprequest to be sent to the discord server.
-- @param title: the title.
-- @param description: the description.
-- @param url: the url of the image to be used and displayed.
-- @param color: All colors can be found here: https://gist.github.com/thomasbnt/b6f455e2c7d743b796917fa3c205f812
TPZ.SendImageUrlToDiscord(webhook, title, description, url, color) -- server to server.
Notifications
TPZ.NotifyLeft(source, firsttext, secondtext, dict, icon, duration, color) -- server side to client side
TPZ.NotifyTip(source, text, duration) -- server side to client side
TPZ.NotifyTop(source, text, location, duration) -- server side to client side
TPZ.NotifyRightTip(source, text, duration) -- server side to client side
TPZ.NotifyObjective(source, text, duration) -- server side to client side
TPZ.NotifySimpleTop(source, title, subtitle, duration) -- server side to client side
TPZ.NotifyAvanced(source, text, dict, icon, text_color, duration, quality) -- server side to client side
TPZ.NotifyBasicTop(source, text, duration) -- server side to client side
TPZ.NotifyCenter(source, text, duration) -- server side to client side
TPZ.NotifyBottomRight(source, text, duration) -- server side to client side
TPZ.NotifyFail(source, title, subtitle, duration) -- server side to client side
TPZ.NotifyDead(source, title, audioRef, audioName, duration) -- server side to client side
TPZ.NotifyUpdate(source, utitle, umsg, duration) -- server side to client side
TPZ.NotifyWarning(source, title, msg, audioRef, audioName, duration) -- server side to client side
TPZ.NotifyLeftRank(source, title, subtitle, dict, icon, duration, color) -- server side to client side
Last updated