This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local insert = table.insert | |
local ipairs = ipairs | |
local format = string.format | |
local assert = assert | |
local type = type | |
local print = print | |
local vec2 = vec2 | |
local setmetatable = setmetatable | |
local newPromise = promise.new | |
local thread = Citizen.CreateThread |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Most label names yoinked from https://forum.cfx.re/t/complete-weapon-labels-list-1-49/1167039 | |
WEAPONLABELS = { | |
weapon_dagger = "WT_DAGGER", | |
weapon_bat = "WT_BAT", | |
weapon_bottle = "WT_BOTTLE", | |
weapon_crowbar = "WT_CROWBAR", | |
weapon_unarmed = "WT_UNARMED", | |
weapon_flashlight = "WT_FLASHLIGHT", | |
weapon_golfclub = "WT_GOLFCLUB", | |
weapon_hammer = "WT_HAMMER", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- Transforms a table of tables into a possibly Markdown-formatted table | |
---@param tbl table The table to be sorted | |
---@param sorted boolean? If true, the resulting table will be very naïvely sorted. | |
---@param skipDivider boolean? If true, a divider line is omitted. This line is required for Markdown! | |
---@return table lines Table of strings containing the lines of the table. Just iterate and print. | |
function FormatTable(tbl, sorted, skipDivider) | |
local width = {} -- Stores the width of each column. | |
local maxIndex = 0 -- Stores the highest number of columns seen for a row | |
local lines = {} -- Will store the actual output |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if IsDuplicityVersion() then | |
local calls = {} | |
---Define a server-side call that a client can use to run code on the server. | |
---@param name string The uniquely identifying name of this call. | |
---@param code function The function to run when this call is made | |
---@return table eventData The event data associated with the event that was registered to handle this call. | |
function DefineServerCall(name, code) | |
local finalName = string.format("%s:RPC:%s", GetCurrentResourceName(), name) | |
if calls[finalName] then |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local function handler(request, response) | |
local key = GetConvar("playerLocationKey", "") | |
if key ~= "" then | |
if request.headers.Authorization == nil or request.headers.Authorization ~= "Bearer " .. key then | |
response.writeHead(403, {["Content-Type"] = "text/plain"}) | |
response.send("Invalid Bearer Token") | |
return | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
AddEventHandler('playerConnecting', function(playerName, setKickReason, deferrals) | |
-- First, a local copy of source, so it doesn't get lost while deferring. | |
local source = source | |
-- Actually defer the connection | |
deferrals.defer() | |
-- Wait a tick, so the deferral happens. | |
Citizen.Wait(0) | |
-- Tell the client what we're doing, in case it stalls at this point, somehow. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- This code is ANCIENT, and probably contains natives that have been renamed. | |
-- It also contains references to functions not provided here. | |
-- Either way, it should illustrate how to orbit a camera around a target Ped. | |
function moveCamera() | |
if IsEntityAPed(targetPed) then | |
local targetCoords = nil | |
if IsPedInAnyVehicle(targetPed,false) then | |
local vehicle = GetVehiclePedIsIn(targetPed,false) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DefineNightCallback('editor-save-json', function(source, jsonString) | |
if IsPlayerAceAllowed(source, 'admin') then | |
local data = json.decode(jsonString) | |
if data and data.name then | |
local name = string.lower(data.name) | |
name = name:gsub("[^a-z.]", "_") | |
name = name .. '.json' | |
local saved = SaveResourceFile(GetCurrentResourceName(), 'areas/'..name, jsonString, -1) | |
if saved then | |
tellplayer(source,'Saved!', 'Area saved as', name) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local dumpsterModels = { | |
218085040, | |
} | |
function Frob(dumpster) | |
end | |
function MaybeFrob(candidate) | |
if not DoesEntityExist(candidate) then return end | |
local model = GetEntityModel(candidate) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Here we list our ped models we want to cycle through. | |
local pedCycle = { | |
"s_m_y_fireman_01", | |
"s_m_y_hwaycop_01", | |
"s_m_y_marine_03", | |
"s_m_y_swat_01", | |
"s_m_m_fibsec_01", | |
"s_m_m_paramedic_01", | |
"s_f_y_scrubs_01", | |
"g_m_m_chicold_01", |
NewerOlder