Skip to content

Instantly share code, notes, and snippets.

@bladecoding
bladecoding / AnonymousEventHandler.cs
Last active Aug 23, 2020
AnonymousEventHandler.cs
View AnonymousEventHandler.cs
public class AnonymousEventHandler
{
object Handler;
private AnonymousEventHandler(object handler) {
Handler = handler;
}
public static Action<Player> Create(Action<Player> func) {
var r = new AnonymousEventHandler(func);
return r.Do;
}
View proxy_obj.lua
function ProxyObj(obj)
return {
set = function(k, val)
obj[k] = val
end,
get = function(k)
local v = obj[k]
if type(v) == 'table' and not rawget(v, '__cfx_functionReference') then
return ProxyObj(v)
else
@bladecoding
bladecoding / dot_and_angle.lua
Created May 15, 2019
[FiveM] calculate visualize dot product and angle between player and closest vehicle
View dot_and_angle.lua
local entityEnumerator = {
__gc = function(enum)
if enum.destructor and enum.handle then
enum.destructor(enum.handle)
end
enum.destructor = nil
enum.handle = nil
end
}
@bladecoding
bladecoding / test.js
Created Apr 30, 2019
JS async exports
View test.js
let Delay = (ms) => new Promise(res => setTimeout(res, ms));
exportsAsync = new Proxy(()=>{}, {
get(t, k) {
const resource = k;
return new Proxy({}, {
get(t, k) {
return (...args) => {
return new Promise((resolve, reject) => {
let cb = (err, data) => { if (err) reject(err); else resolve(data); };
View __resource.lua
resource_manifest_version '77731fab-63ca-442c-a67b-abc70f28dfa5'
client_script 'afkchecker_client.lua'
server_script 'afkchecker_server.lua'
server_exports {
'getTracking',
}