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
import https from "https" | |
const options = { | |
hostname: "ipinfo.io", | |
path: "/ip", | |
method: "GET", | |
} | |
export const getExternalIp = (): Promise<string> => | |
new Promise<string>((resolve, reject) => { |
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
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 |
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
import alt from "alt-client" | |
const STRING_LIMIT = 2 ** 12 | |
const sendSnapshot = async (string) => { | |
const len = string.length | |
const parts = Math.ceil(len / STRING_LIMIT) | |
alt.log("sendSnapshot", "parts:", parts, "len:", len) |
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
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)); |
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
// js usage example for https://github.com/xxshady/altv-esbuild-rust-wasm | |
import alt from "alt-shared" | |
import loadWasm from "./rust-wasm/pkg/rust_wasm_bg.wasm" | |
const { on_every_tick } = loadWasm({}) | |
alt.everyTick(on_every_tick); |
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
// depends on web_time + wasm_bindgen | |
use std::{ | |
cell::{RefCell, RefMut}, | |
fmt::Debug, | |
}; | |
use web_time::{Duration, SystemTime}; | |
pub type TimerId = u64; |
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
use crate::timers::set_timeout; | |
use std::{ | |
future::{poll_fn, Future}, | |
task::Poll, | |
}; | |
use web_time::{Duration, SystemTime}; | |
pub fn wait(duration: Duration) -> impl Future { | |
let dest = SystemTime::now() + duration; | |
let mut timer_was_set = 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
fn main(main_context: &MainContext) { | |
let _players: &[Player] = main_context.all_players(); | |
every_tick(|ctx: &EveryTickContext| { | |
// cannot be called here | |
// main_context.all_players(); | |
let _players: &[Player] = ctx.all_players(); | |
// TODO: allow holding reference for unknown duration to player via Option? |