/
index.d.ts
168 lines (137 loc) · 5.7 KB
/
index.d.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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
/// <reference path="./natives_universal.d.ts"/>
interface IntPtrInitialized {}
interface FloatPtrInitialized {}
interface IntPtr {}
interface FloatPtr {}
interface VectorPtr {}
interface ReturnResultAnyway {}
interface ResultAsInteger {}
interface ResultAsFloat {}
interface ResultAsString {}
interface ResultAsVector {}
interface ResultAsLong {}
interface ResultAsObject {}
type InputArgument =
string |
number |
IntPtrInitialized |
FloatPtrInitialized |
IntPtr |
FloatPtr |
VectorPtr |
ReturnResultAnyway |
ResultAsInteger |
ResultAsFloat |
ResultAsString |
ResultAsVector |
ResultAsLong |
ResultAsObject;
interface StateBagInterface {
[key: string]: any;
set(key: string, value: any, replicated: boolean): void
}
interface EntityInterface {
state: StateBagInterface
}
interface CitizenInterface {
trace(...args: string[]): void
setTickFunction(callback: Function): void
setEventFunction(callback: Function): void
setCallRefFunction(callback: Function): void
setDeleteRefFunction(callback: Function): void
setDuplicateRefFunction(callback: Function): void
canonicalizeRef(ref: number): string
invokeFunctionReference(ref: string, args: Uint8Array): Uint8Array
getTickCount(): number
invokeNative<T = void>(hash: string, ...args: InputArgument[]): T
startProfiling(name?: string): void
stopProfiling(name?: string): {}
pointerValueIntInitialized(): IntPtrInitialized
pointerValueFloatInitialized(): FloatPtrInitialized
pointerValueInt(): IntPtr
pointerValueFloat(): FloatPtr
pointerValueVector(): VectorPtr
returnResultAnyway(): ReturnResultAnyway
resultAsInteger(): ResultAsInteger
resultAsFloat(): ResultAsFloat
resultAsString(): ResultAsString
resultAsVector(): ResultAsVector
resultAsLong(): ResultAsLong
resultAsObject(): ResultAsObject
makeRefFunction(refFunction: Function): string
}
interface CitizenTimer {
ref(): CitizenTimer,
unref(): CitizenTimer,
hasRef(): boolean,
refresh(): CitizenTimer,
[Symbol.toPrimitive](): number,
}
type CitizenImmediate = Omit<CitizenTimer, 'refresh'>;
declare var Citizen: CitizenInterface;
declare function addRawEventListener(eventName: string, callback: Function): void
declare function setMaxRawEventListeners(max: number): void
declare function addEventListener(eventName: string, callback: Function, netSafe?: boolean): void
declare function on(eventName: string, callback: Function): void
declare function AddEventHandler(eventName: string, callback: Function): void
declare function setMaxEventListeners(max: number): void
declare function addNetEventListener(eventName: string, callback: Function): void
declare function onNet(eventName: string, callback: Function): void
declare function emit(eventName: string, ...args: any[]): void
declare function TriggerEvent(eventName: string, ...args: any[]): void
declare function emitNet(eventName: string, ...args: any[]): void
declare function TriggerServerEvent(eventName: string, ...args: any[]): void
declare function TriggerLatentServerEvent(eventName: string, bps: number, ...args: any[]): void
declare function getPlayerIdentifiers(player: number|string): string[]
declare function getPlayerTokens(player: number|string): string[]
declare function getPlayers(): string[]
declare function SendNUIMessage(data: any): void
declare function emitNet(eventName: string, target: number|string, ...args: any[]): void
declare function TriggerClientEvent(eventName: string, target: number|string, ...args: any[]): void
declare function TriggerLatentClientEvent(eventName: string, target: number|string, bps: number, ...args: any[]): void
declare function removeEventListener(eventName: string, callback: Function): void
declare function setTimeout<T extends any[]>(callback: (...args: T) => void, ms?: number, ...args: T): CitizenTimer;
declare function clearTimeout(timeout: CitizenTimer): void;
declare function setInterval<T extends any[]>(callback: (...args: T) => void, ms?: number, ...args: T): CitizenTimer;
declare function clearInterval(interval: CitizenTimer): void;
declare function setImmediate<T extends any[]>(callback: (...args: T) => void, ...args: T): CitizenImmediate;
declare function clearImmediate(immediate: CitizenImmediate): void;
declare function setTick(callback: Function): number
declare function clearTick(callback: number): void
declare function NewStateBag(name: string) : StateBagInterface;
declare function Entity(entity: number): EntityInterface
declare var GlobalState : StateBagInterface
declare function Player(entity: number|string): EntityInterface
declare var LocalPlayer : EntityInterface
interface CitizenExports {
(exportKey: string | number, exportFunction: Function): void;
[resourceName: string] : {
[exportKey: string | number]: Function
};
}
declare var exports: CitizenExports;
declare var source: number;
// Commented methods are not implemented yet
interface Console {
assert(condition?: boolean, ...data: any[]): void;
// clear(): void;
count(label?: string): void;
countReset(label?: string): void;
debug(...data: any[]): void;
dir(item?: any, options?: any): void;
// dirxml(...data: any[]): void;
error(...data: any[]): void;
// group(...data: any[]): void;
// groupCollapsed(...data: any[]): void;
// groupEnd(): void;
info(...data: any[]): void;
log(...data: any[]): void;
// table(tabularData?: any, properties?: string[]): void;
time(label?: string): void;
timeEnd(label?: string): void;
// timeLog(label?: string, ...data: any[]): void;
// timeStamp(label?: string): void;
trace(...data: any[]): void;
warn(...data: any[]): void;
}
declare var console: Console;