-
Notifications
You must be signed in to change notification settings - Fork 1
/
client.ts
32 lines (25 loc) · 849 Bytes
/
client.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import { contract, useTypes } from "@yannbcf/altv-rpc";
import { fromClientContract } from "./shared.ts";
import { z } from "zod";
import * as alt from "alt-client";
const $client = useTypes(alt);
// const net = rpc.initContract("client", fromClientContract, {
// once: alt.onceServer,
// off: alt.offServer,
// emit: alt.emitServer,
// });
// net.notifyOtherPlayer({ otherPlayer: null /* never type */ });
const exFromClientContract = contract.extend("no_typecheck", fromClientContract, {
notifyOtherPlayer: {
args: z.object({
otherPlayer: $client.player
})
}
});
const net = contract.init("client", exFromClientContract, {
once: alt.onceServer,
off: alt.offServer,
emit: alt.emitServer,
});
// client side alt.Player type
net.notifyOtherPlayer({ otherPlayer: alt.Player.local });