Skip to content

Instantly share code, notes, and snippets.

@xxshady
xxshady / lib.rs
Created April 30, 2024 18:18
working tokio multi threading on alt:V
use std::{
cell::RefCell,
sync::{Arc, Mutex},
};
#[altv::main]
fn main() -> impl altv::IntoVoidResult {
let rt = Arc::new(RefCell::new(Some(tokio::runtime::Runtime::new().unwrap())));
let data = Arc::new(Mutex::new(1));
@xxshady
xxshady / client.js
Last active April 7, 2023 23:42
Saving clientside JS heap snaphot as file on alt:V
import alt from "alt-client"
const STRING_LIMIT = 2 ** 15
const sendSnapshot = async (string) => {
const len = string.length
const parts = Math.ceil(len / STRING_LIMIT)
alt.log("sendSnapshot", "parts:", parts, "len:", len)
@xxshady
xxshady / client.js
Last active December 31, 2023 13:39
alt:V player look sync
import alt from "alt-client"
import native from "natives"
const localPlayer = alt.Player.local
const SYNC_MS_DELAY = 500
const SYNC_MS_DELAY_REMOTE = 100
const MAX_HEADING_DIST = 70.0
const BACKWARDS_HEADING_DIST = 145.0
const TASK_LOOK_AT_COORD_DURATION = 300
const LOOKING_AT_POS_OFFSET = 5.0
@xxshady
xxshady / external-ip.ts
Last active December 7, 2021 21:32
external ip nodejs
import https from "https"
const options = {
hostname: "ipinfo.io",
path: "/ip",
method: "GET",
}
export const getExternalIp = (): Promise<string> =>
new Promise<string>((resolve, reject) => {