Skip to content

Instantly share code, notes, and snippets.

@DemmyDemon
DemmyDemon / laundry.md
Last active March 30, 2019 14:13
Design spec for money laundry script

MONEY LAUNDRY

Rates

Amount laundered Percentage taken Laundered per second
0-100k 25% 150
100k-500k 20% 300
over 500k 15% 600
@DemmyDemon
DemmyDemon / zoneNames.lua
Created November 27, 2018 10:17
Just a list of the zone names by their text entry
local zoneNames = {
AIRP = "Los Santos International Airport",
ALAMO = "Alamo Sea",
ALTA = "Alta",
ARMYB = "Fort Zancudo",
BANHAMC = "Banham Canyon Dr",
BANNING = "Banning",
BAYTRE = "Baytree Canyon",
BEACH = "Vespucci Beach",
BHAMCA = "Banham Canyon",
@DemmyDemon
DemmyDemon / pHashPathOk.lua
Last active December 5, 2018 09:43
Checking if a given path is valid for nested hash-like tables in Lua
local test = {
foo = {
bar = {
boz = 42,
},
},
}
function pHashPathOk(hash,...)
if hash == nil or type(hash) ~= 'table' then
@DemmyDemon
DemmyDemon / stopzone.fragment.lua
Created December 30, 2018 20:18
The salient bits of the stop zone stuff
function removeStopZone(heap,player)
if heap.stopZones[player] then
local zone = heap.stopZones[player]
local success = RemoveSpeedZone(zone.id)
if success then
log('Speed zone',zone.id,'removed')
else
log('Failed to remove speed zone',zone.id)
end
@DemmyDemon
DemmyDemon / pSwitchLocation.lua
Last active October 9, 2024 07:35
Demonstration adapted from how I do location switching with the "camera in the clouds" effect
function pSwichLocation(location,heading,groundCoord)
local camPitch = GetGameplayCamRelativePitch()
local camHeading = GetGameplayCamRelativeHeading()
local ped = PlayerPedId()
local origin = GetEntityCoords(ped)
if groundCoord then
location = vector3(location.x,location.y,location.z + 1.0)
@DemmyDemon
DemmyDemon / pBindString.lua
Created March 9, 2019 10:10
Partial translation of control action to currently bound key
local BINDSTRING = {
--[[ TODO: All the controller stuff
b_0 = '',
b_1 = '',
b_2 = '',
b_3 = '',
b_4 = '',
b_5 = '',
b_6 = '',
b_7 = '',
@DemmyDemon
DemmyDemon / zathrazoom_main.lua
Created September 1, 2019 13:44
Just some zoomy Vendetta bits
local zZoom = {
current = tonumber(Game.GetCVar('fov') or 90),
target = 90,
step = 10,
min = 20,
max = 90,
reset = 90,
verbose = false,
}
@DemmyDemon
DemmyDemon / server_callback.lua
Last active October 16, 2020 15:38
How server callbacks are done in Night City
local on_server = IsDuplicityVersion()
local resource = GetCurrentResourceName()
local callbacks = {}
local eventName = resource..':night-callback'
if on_server then
local callbacks = {}
function DefineNightCallback(name, funcref)
if callbacks[name] then
return false
@DemmyDemon
DemmyDemon / pickone.lua
Last active June 29, 2024 16:31
Simple, ugly menu where you just "pick one" using the mouse.
---@class PickOne
---@field header string The text above the buttons
---@field begin vector2 Top left of menu when it opens
---@field fontSize number Size of the menu font
---@field widest number The width of the widest element in the menu
---@field verticalSpace number The vertical spacing between menu items
---@field verticalOffset number The vertical offset for the cursor location
---@field itemHeight number The number of each item
---@field textOffset number The offset between the button location and where text is drawn, vertically.
---@field buttons table A table of the buttons to draw
@DemmyDemon
DemmyDemon / superman_client.lua
Created August 19, 2020 19:35
The event I use for the replication of "cloudfall", except you can actually fly *up*
RegisterNetEvent('night-tools:superman')
AddEventHandler ('night-tools:superman', function()
serverlog('is flying!')
SetPlayerParachutePackTintIndex(PlayerId(),3)
SetPlayerParachuteTintIndex(PlayerId(),6)
Citizen.CreateThread(function()
GiveWeaponToPed(PlayerPedId(),`GADGET_PARACHUTE`,1,false,true)