Rpc integration + type fixes #3

Merged
rilaxik merged 26 commits from dev into master 2024-10-28 12:13:19 +00:00
18 changed files with 143 additions and 142 deletions
Showing only changes of commit 75b528ca45 - Show all commits

View File

@ -4,15 +4,15 @@ import {
_CefEventHasArgs, _CefEventHasArgs,
_ClientEventHasArgs, _ClientEventHasArgs,
_ServerEventHasArgs, _ServerEventHasArgs,
RageFW_CefArguments, RageFW_CefArgs,
RageFW_CefCallback, RageFW_CefCallback,
RageFW_CefReturn, RageFW_CefReturn,
RageFW_ClientArguments, RageFW_ClientArgs,
RageFW_ClientReturn, RageFW_ClientReturn,
RageFW_ICustomCefEvent, RageFW_ICustomCefEvent,
RageFW_ICustomClientEvent, RageFW_ICustomClientEvent,
RageFW_ICustomServerEvent, RageFW_ICustomServerEvent,
RageFW_ServerArguments, RageFW_ServerArgs,
RageFW_ServerReturn, RageFW_ServerReturn,
} from './types' } from './types'
@ -29,7 +29,7 @@ class Cef {
public trigger<EventName extends keyof RageFW_ICustomCefEvent>( public trigger<EventName extends keyof RageFW_ICustomCefEvent>(
eventName: EventName, eventName: EventName,
...args: _CefEventHasArgs<EventName> extends true ...args: _CefEventHasArgs<EventName> extends true
? [RageFW_CefArguments<EventName>] ? [RageFW_CefArgs<EventName>]
: [] : []
): Promise<RageFW_CefReturn<EventName>> { ): Promise<RageFW_CefReturn<EventName>> {
if ('mp' in window) { if ('mp' in window) {
@ -44,7 +44,7 @@ class Cef {
public triggerServer<EventName extends keyof RageFW_ICustomServerEvent>( public triggerServer<EventName extends keyof RageFW_ICustomServerEvent>(
eventName: EventName, eventName: EventName,
...args: _ServerEventHasArgs<EventName> extends true ...args: _ServerEventHasArgs<EventName> extends true
? [RageFW_ServerArguments<EventName>] ? [RageFW_ServerArgs<EventName>]
: [] : []
): Promise<RageFW_ServerReturn<EventName>> { ): Promise<RageFW_ServerReturn<EventName>> {
if ('mp' in window) { if ('mp' in window) {
@ -59,7 +59,7 @@ class Cef {
public triggerClient<EventName extends keyof RageFW_ICustomClientEvent>( public triggerClient<EventName extends keyof RageFW_ICustomClientEvent>(
eventName: EventName, eventName: EventName,
...args: _ClientEventHasArgs<EventName> extends true ...args: _ClientEventHasArgs<EventName> extends true
? [RageFW_ClientArguments<EventName>] ? [RageFW_ClientArgs<EventName>]
: [] : []
): Promise<RageFW_ClientReturn<EventName>> { ): Promise<RageFW_ClientReturn<EventName>> {
if ('mp' in window) { if ('mp' in window) {

View File

@ -1,4 +1,5 @@
import { RageFW_ICustomCefEvent } from 'rage-fw-shared-types' import { RageFW_ICustomCefEvent } from 'rage-fw-shared-types'
export { RageFW_ICustomCefEvent } from 'rage-fw-shared-types' export { RageFW_ICustomCefEvent } from 'rage-fw-shared-types'
/** /**
@ -11,7 +12,7 @@ export type RageFW_CefEvent = keyof RageFW_ICustomCefEvent
* Array of arguments of an event you pass as a generic * Array of arguments of an event you pass as a generic
* These only include custom cef events * These only include custom cef events
*/ */
export type RageFW_CefArguments<K extends RageFW_CefEvent> = Parameters< export type RageFW_CefArgs<K extends RageFW_CefEvent> = Parameters<
RageFW_ICustomCefEvent[K] RageFW_ICustomCefEvent[K]
> >
@ -28,7 +29,7 @@ export type RageFW_CefReturn<K extends RageFW_CefEvent> = ReturnType<
* These only include custom cef events * These only include custom cef events
*/ */
export type RageFW_CefCallback<K extends keyof RageFW_ICustomCefEvent> = ( export type RageFW_CefCallback<K extends keyof RageFW_ICustomCefEvent> = (
args: RageFW_CefArguments<K>, args: RageFW_CefArgs<K>,
) => RageFW_CefReturn<K> ) => RageFW_CefReturn<K>
export type _CefEventHasArgs<EventName extends keyof RageFW_ICustomCefEvent> = export type _CefEventHasArgs<EventName extends keyof RageFW_ICustomCefEvent> =

View File

@ -1,4 +1,5 @@
import type { RageFW_ICustomClientEvent } from 'rage-fw-shared-types' import type { RageFW_ICustomClientEvent } from 'rage-fw-shared-types'
export type { RageFW_ICustomClientEvent } from 'rage-fw-shared-types' export type { RageFW_ICustomClientEvent } from 'rage-fw-shared-types'
/** /**
@ -11,7 +12,7 @@ export type RageFW_ClientEvent = keyof RageFW_ICustomClientEvent
* Array of arguments of event you pass as a generic * Array of arguments of event you pass as a generic
* These only include custom client events * These only include custom client events
*/ */
export type RageFW_ClientArguments<K extends RageFW_ClientEvent> = Parameters< export type RageFW_ClientArgs<K extends RageFW_ClientEvent> = Parameters<
RageFW_ICustomClientEvent[K] RageFW_ICustomClientEvent[K]
> >

View File

@ -1,4 +1,5 @@
import type { RageFW_ICustomServerEvent } from 'rage-fw-shared-types' import type { RageFW_ICustomServerEvent } from 'rage-fw-shared-types'
export type { RageFW_ICustomServerEvent } from 'rage-fw-shared-types' export type { RageFW_ICustomServerEvent } from 'rage-fw-shared-types'
/** /**
@ -11,7 +12,7 @@ export type RageFW_ServerEvent = keyof RageFW_ICustomServerEvent
* Array of arguments of event you pass as a generic * Array of arguments of event you pass as a generic
* These only include custom server events * These only include custom server events
*/ */
export type RageFW_ServerArguments<K extends RageFW_ServerEvent> = Parameters< export type RageFW_ServerArgs<K extends RageFW_ServerEvent> = Parameters<
RageFW_ICustomServerEvent[K] RageFW_ICustomServerEvent[K]
> >

View File

@ -0,0 +1,8 @@
import { Player } from './'
export class Browser extends Player {
public registerBrowser(browser: BrowserMp) {
this.browser = browser
return browser
}
}

20
client/src/core/client.ts Normal file
View File

@ -0,0 +1,20 @@
import rpc from 'rage-rpc'
import { RageFW_ClientCallback, RageFW_ClientEvent } from '../types'
export class Client {
public register<EventName extends RageFW_ClientEvent>(
eventName: EventName,
callback: RageFW_ClientCallback<EventName>,
): void {
rpc.register(eventName, data => {
return callback(data)
})
}
public unregister<EventName extends RageFW_ClientEvent>(
eventName: EventName,
): void {
rpc.unregister(eventName)
}
}

4
client/src/core/index.ts Normal file
View File

@ -0,0 +1,4 @@
export * from './client'
export * from './player'
export * from './browser'
export * from './logger'

View File

@ -1,4 +1,4 @@
export default class Logger { export class Logger {
public error(message: unknown) { public error(message: unknown) {
mp.console.logError( mp.console.logError(
`[${new Date().toLocaleTimeString()}] [ERROR] ${message}`, `[${new Date().toLocaleTimeString()}] [ERROR] ${message}`,

49
client/src/core/player.ts Normal file
View File

@ -0,0 +1,49 @@
import rpc from 'rage-rpc'
import type { RageFW_ICustomClientEvent } from 'rage-fw-shared-types'
import {
_CefEventHasArgs,
_ClientEventHasArgs,
_ServerEventHasArgs,
RageFW_CefArgs,
RageFW_CefEvent,
RageFW_CefReturn,
RageFW_ClientEventArguments,
RageFW_ClientEventReturn,
RageFW_ClientServerEvent,
RageFW_ClientServerEventArguments,
RageFW_ClientServerEventReturn,
} from '../types'
export class Player {
public browser: BrowserMp | undefined
public trigger<EventName extends keyof RageFW_ICustomClientEvent>(
eventName: EventName,
...args: _ClientEventHasArgs<EventName> extends true
? [RageFW_ClientEventArguments<EventName>]
: []
): Promise<RageFW_ClientEventReturn<EventName>> {
return rpc.call<RageFW_ClientEventReturn<EventName>>(eventName, args)
}
public triggerServer<EventName extends RageFW_ClientServerEvent>(
eventName: EventName,
...args: _ServerEventHasArgs<EventName> extends true
? [RageFW_ClientServerEventArguments<EventName>]
: []
): Promise<RageFW_ClientServerEventReturn<EventName>> {
return rpc.callServer(eventName, args)
}
public triggerBrowser<EventName extends RageFW_CefEvent>(
eventName: EventName,
...args: _CefEventHasArgs<EventName> extends true
? [RageFW_CefArgs<EventName>]
: []
): Promise<RageFW_CefReturn<EventName>> {
if (!this.browser)
throw new Error('You need to initialize browser first!')
return rpc.callBrowser(this.browser, eventName, args)
}
}

View File

@ -1,81 +1,4 @@
import rpc from 'rage-rpc' import { Browser, Client, Logger, Player } from './core'
import Logger from './logger'
import {
_CefEventHasArgs,
_ClientEventHasArgs,
_ServerEventHasArgs,
RageFW_CefArgs,
RageFW_CefEvent,
RageFW_CefReturn,
RageFW_ClientEvent,
RageFW_ClientEventArguments,
RageFW_ClientEventCallback,
RageFW_ClientEventReturn,
RageFW_ClientServerEvent,
RageFW_ClientServerEventArguments,
RageFW_ClientServerEventReturn,
} from './types'
import type { RageFW_ICustomClientEvent } from 'rage-fw-shared-types'
class Client {
public register<EventName extends RageFW_ClientEvent>(
eventName: EventName,
callback: RageFW_ClientEventCallback<EventName>,
): void {
rpc.register(eventName, data => {
return callback(data)
})
}
public unregister<EventName extends RageFW_ClientEvent>(
eventName: EventName,
): void {
rpc.unregister(eventName)
}
}
class Player {
public browser: BrowserMp | undefined
public trigger<EventName extends keyof RageFW_ICustomClientEvent>(
eventName: EventName,
...args: _ClientEventHasArgs<EventName> extends true
? [RageFW_ClientEventArguments<EventName>]
: []
): Promise<RageFW_ClientEventReturn<EventName>> {
return rpc.call<RageFW_ClientEventReturn<EventName>>(eventName, args)
}
public triggerServer<EventName extends RageFW_ClientServerEvent>(
eventName: EventName,
...args: _ServerEventHasArgs<EventName> extends true
? [RageFW_ClientServerEventArguments<EventName>]
: []
): Promise<RageFW_ClientServerEventReturn<EventName>> {
return rpc.callServer(eventName, args)
}
public triggerBrowser<EventName extends RageFW_CefEvent>(
eventName: EventName,
...args: _CefEventHasArgs<EventName> extends true
? [RageFW_CefArgs<EventName>]
: []
): Promise<RageFW_CefReturn<EventName>> {
if (!this.browser)
throw new Error('You need to initialize browser first!')
return rpc.callBrowser(this.browser, eventName, args)
}
}
class Browser extends Player {
public registerBrowser(browser: BrowserMp) {
this.browser = browser
return browser
}
}
export const fw = { export const fw = {
event: new Client(), event: new Client(),

View File

@ -14,7 +14,7 @@ export type RageFW_ClientEvent =
* Array of arguments for an event, name of which you pass as a generic * Array of arguments for an event, name of which you pass as a generic
* These include custom and system events * These include custom and system events
*/ */
export type RageFW_ClientEventArguments<K extends RageFW_ClientEvent> = export type RageFW_ClientArgs<K extends RageFW_ClientEvent> =
K extends keyof RageFW_ICustomClientEvent K extends keyof RageFW_ICustomClientEvent
? Parameters<RageFW_ICustomClientEvent[K]> ? Parameters<RageFW_ICustomClientEvent[K]>
: K extends keyof IClientEvents : K extends keyof IClientEvents
@ -25,15 +25,15 @@ export type RageFW_ClientEventArguments<K extends RageFW_ClientEvent> =
* Callback (function) for an event, name of which you pass as a generic * Callback (function) for an event, name of which you pass as a generic
* These only include custom events * These only include custom events
*/ */
export type RageFW_ClientEventCallback<K extends RageFW_ClientEvent> = ( export type RageFW_ClientCallback<K extends RageFW_ClientEvent> = (
args: RageFW_ClientEventArguments<K>, args: RageFW_ClientArgs<K>,
) => RageFW_ClientEventReturn<K> ) => RageFW_ClientReturn<K>
/** /**
* Return type for an event, name of which you pass as a generic * Return type for an event, name of which you pass as a generic
* These only include custom events * These only include custom events
*/ */
export type RageFW_ClientEventReturn<K extends RageFW_ClientEvent> = export type RageFW_ClientReturn<K extends RageFW_ClientEvent> =
K extends keyof RageFW_ICustomClientEvent K extends keyof RageFW_ICustomClientEvent
? ReturnType<RageFW_ICustomClientEvent[K]> ? ReturnType<RageFW_ICustomClientEvent[K]>
: never : never

View File

@ -15,17 +15,16 @@ export type RageFW_ClientServerEvent = keyof RageFW_ICustomServerEvent
* Array of arguments for an event, name of which you pass as a generic * Array of arguments for an event, name of which you pass as a generic
* These only include custom events * These only include custom events
*/ */
export type RageFW_ClientServerEventArguments< export type RageFW_ClientServerArgs<K extends RageFW_ClientServerEvent> =
K extends RageFW_ClientServerEvent, K extends keyof RageFW_ICustomServerEvent
> = K extends keyof RageFW_ICustomServerEvent ? Parameters<RageFW_ICustomServerEvent[K]>
? Parameters<RageFW_ICustomServerEvent[K]> : never
: never
/** /**
* Return type for an event, name of which you pass as a generic * Return type for an event, name of which you pass as a generic
* These only include custom events * These only include custom events
*/ */
export type RageFW_ClientServerEventReturn<K extends RageFW_ClientServerEvent> = export type RageFW_ClientServerReturn<K extends RageFW_ClientServerEvent> =
K extends keyof RageFW_ICustomServerEvent K extends keyof RageFW_ICustomServerEvent
? ReturnType<RageFW_ICustomServerEvent[K]> ? ReturnType<RageFW_ICustomServerEvent[K]>
: never : never

View File

@ -1,4 +1,5 @@
import winston, { format } from 'winston' import winston, { format } from 'winston'
const { timestamp, printf, colorize } = format const { timestamp, printf, colorize } = format
export class Logger { export class Logger {

View File

@ -7,8 +7,8 @@ import {
RageFW_CefEvent, RageFW_CefEvent,
RageFW_CefReturn, RageFW_CefReturn,
RageFW_ClientEvent, RageFW_ClientEvent,
RageFW_ServerClientEventArguments, RageFW_ServerClientArgs,
RageFW_ServerClientEventReturn, RageFW_ServerClientReturn,
} from '../types' } from '../types'
export class Player { export class Player {
@ -16,9 +16,9 @@ export class Player {
player: PlayerMp, player: PlayerMp,
eventName: EventName, eventName: EventName,
...args: _ClientEventHasArgs<EventName> extends true ...args: _ClientEventHasArgs<EventName> extends true
? [RageFW_ServerClientEventArguments<EventName>] ? [RageFW_ServerClientArgs<EventName>]
: [] : []
): Promise<RageFW_ServerClientEventReturn<EventName>> { ): Promise<RageFW_ServerClientReturn<EventName>> {
return rpc.callClient(player, eventName, args) return rpc.callClient(player, eventName, args)
} }

View File

@ -3,19 +3,13 @@ import { RageFW_ICustomServerEvent } from 'rage-fw-shared-types'
import { nativeEvents } from '../native.events' import { nativeEvents } from '../native.events'
import { import {
_CefEventHasArgs,
_ClientEventHasArgs,
_ServerEventHasArgs, _ServerEventHasArgs,
RageFW_CefArgs, RageFW_ServerArgs,
RageFW_CefEvent, RageFW_ServerCallback,
RageFW_ClientEvent, RageFW_ServerCallbackCustom,
RageFW_ServerClientEventArguments, RageFW_ServerCallbackNative,
RageFW_ServerEvent, RageFW_ServerEvent,
RageFW_ServerEventArguments, RageFW_ServerReturn,
RageFW_ServerEventCallback,
RageFW_ServerEventCallbackCustom,
RageFW_ServerEventCallbackNative,
RageFW_ServerEventReturn,
} from '../types' } from '../types'
type MiddlewarePoolServer<EventName extends RageFW_ServerEvent> = Partial<{ type MiddlewarePoolServer<EventName extends RageFW_ServerEvent> = Partial<{
@ -25,11 +19,11 @@ type MiddlewarePoolServer<EventName extends RageFW_ServerEvent> = Partial<{
} }
}> }>
type MiddlewareFunction<EventName extends RageFW_ServerEvent> = ( export type MiddlewareFunction<EventName extends RageFW_ServerEvent> = (
player: PlayerMp, player: PlayerMp,
eventName: EventName, eventName: EventName,
...args: _ServerEventHasArgs<EventName> extends true ...args: _ServerEventHasArgs<EventName> extends true
? [RageFW_ServerEventArguments<EventName>] ? [RageFW_ServerArgs<EventName>]
: [] : []
) => void ) => void
@ -56,11 +50,11 @@ export class Server {
private registerCustom<EventName extends keyof RageFW_ICustomServerEvent>( private registerCustom<EventName extends keyof RageFW_ICustomServerEvent>(
eventName: EventName, eventName: EventName,
callback: RageFW_ServerEventCallbackCustom<EventName>, callback: RageFW_ServerCallbackCustom<EventName>,
): void { ): void {
rpc.register( rpc.register(
eventName, eventName,
async (args: RageFW_ServerEventArguments<EventName>, info) => { async (args: RageFW_ServerArgs<EventName>, info) => {
callback([info.player as PlayerMp, ...args]) callback([info.player as PlayerMp, ...args])
}, },
) )
@ -68,7 +62,7 @@ export class Server {
private registerNative<EventName extends keyof IServerEvents>( private registerNative<EventName extends keyof IServerEvents>(
eventName: EventName, eventName: EventName,
callback: RageFW_ServerEventCallbackNative<EventName>, callback: RageFW_ServerCallbackNative<EventName>,
): void { ): void {
mp.events.add( mp.events.add(
eventName, eventName,
@ -79,35 +73,35 @@ export class Server {
public register<EventName extends RageFW_ServerEvent>( public register<EventName extends RageFW_ServerEvent>(
eventName: EventName, eventName: EventName,
callback: RageFW_ServerEventCallback<EventName>, callback: RageFW_ServerCallback<EventName>,
): void { ): void {
if (this.isNativeEvent(eventName)) { if (this.isNativeEvent(eventName)) {
this.registerNative( this.registerNative(
eventName, eventName,
callback as RageFW_ServerEventCallbackNative, callback as RageFW_ServerCallbackNative,
) )
} else { } else {
this.registerCustom( this.registerCustom(
eventName, eventName,
callback as unknown as RageFW_ServerEventCallbackCustom, callback as unknown as RageFW_ServerCallbackCustom,
) )
} }
} }
public registerMany<EventName extends RageFW_ServerEvent>(events: { public registerMany<EventName extends RageFW_ServerEvent>(events: {
[event in EventName]: RageFW_ServerEventCallback<event> [event in EventName]: RageFW_ServerCallback<event>
}): void { }): void {
Object.entries<RageFW_ServerEventCallback<EventName>>(events).map( Object.entries<RageFW_ServerCallback<EventName>>(events).map(
([eventName, callback]) => { ([eventName, callback]) => {
if (this.isNativeEvent(eventName)) { if (this.isNativeEvent(eventName)) {
this.registerNative( this.registerNative(
eventName, eventName,
callback as RageFW_ServerEventCallbackNative, callback as RageFW_ServerCallbackNative,
) )
} else { } else {
this.registerCustom( this.registerCustom(
eventName as keyof RageFW_ICustomServerEvent, eventName as keyof RageFW_ICustomServerEvent,
callback as unknown as RageFW_ServerEventCallbackCustom, callback as unknown as RageFW_ServerCallbackCustom,
) )
} }
}, },
@ -139,9 +133,9 @@ export class Server {
public trigger<EventName extends keyof RageFW_ICustomServerEvent>( public trigger<EventName extends keyof RageFW_ICustomServerEvent>(
eventName: EventName, eventName: EventName,
...args: _ServerEventHasArgs<EventName> extends true ...args: _ServerEventHasArgs<EventName> extends true
? [RageFW_ServerEventArguments<EventName>] ? [RageFW_ServerArgs<EventName>]
: [] : []
): Promise<RageFW_ServerEventReturn<EventName>> { ): Promise<RageFW_ServerReturn<EventName>> {
return rpc.call<RageFW_ServerEventReturn<EventName>>(eventName, args) return rpc.call<RageFW_ServerReturn<EventName>>(eventName, args)
} }
} }

View File

@ -1,4 +1,4 @@
import { Server, Logger, Player } from './core' import { Logger, Player, Server } from './core'
export const fw = { export const fw = {
event: new Server(), event: new Server(),

View File

@ -12,7 +12,7 @@ export type RageFW_ClientEvent = keyof RageFW_ICustomClientEvent
* Array of arguments of an event you pass as a generic * Array of arguments of an event you pass as a generic
* These only include custom events * These only include custom events
*/ */
export type RageFW_ServerClientEventArguments<K extends RageFW_ClientEvent> = export type RageFW_ServerClientArgs<K extends RageFW_ClientEvent> =
K extends RageFW_ClientEvent K extends RageFW_ClientEvent
? Parameters<RageFW_ICustomClientEvent[K]> ? Parameters<RageFW_ICustomClientEvent[K]>
: never : never
@ -21,7 +21,7 @@ export type RageFW_ServerClientEventArguments<K extends RageFW_ClientEvent> =
* Return type of event you pass as a generic * Return type of event you pass as a generic
* These only include custom events * These only include custom events
*/ */
export type RageFW_ServerClientEventReturn<K extends RageFW_ClientEvent> = export type RageFW_ServerClientReturn<K extends RageFW_ClientEvent> =
K extends RageFW_ClientEvent K extends RageFW_ClientEvent
? ReturnType<RageFW_ICustomClientEvent[K]> ? ReturnType<RageFW_ICustomClientEvent[K]>
: never : never

View File

@ -18,7 +18,7 @@ export type RageFW_ServerEvent =
* Array of arguments for an event, name of which you pass as a generic * Array of arguments for an event, name of which you pass as a generic
* These also include system events * These also include system events
*/ */
export type RageFW_ServerEventArguments<K extends RageFW_ServerEvent> = export type RageFW_ServerArgs<K extends RageFW_ServerEvent> =
K extends keyof RageFW_ICustomServerEvent K extends keyof RageFW_ICustomServerEvent
? Parameters<RageFW_ICustomServerEvent[K]> ? Parameters<RageFW_ICustomServerEvent[K]>
: K extends keyof IServerEvents : K extends keyof IServerEvents
@ -29,18 +29,18 @@ export type RageFW_ServerEventArguments<K extends RageFW_ServerEvent> =
* Callback (function) for an event, name of which you pass as a generic * Callback (function) for an event, name of which you pass as a generic
* These include system and custom events * These include system and custom events
*/ */
export type RageFW_ServerEventCallback<K extends RageFW_ServerEvent> = export type RageFW_ServerCallback<K extends RageFW_ServerEvent> =
K extends keyof RageFW_ICustomServerEvent K extends keyof RageFW_ICustomServerEvent
? RageFW_ServerEventCallbackCustom<K> ? RageFW_ServerCallbackCustom<K>
: K extends keyof IServerEvents : K extends keyof IServerEvents
? RageFW_ServerEventCallbackNative<K> ? RageFW_ServerCallbackNative<K>
: never : never
/** /**
* Return type for an event, name of which you pass as a generic * Return type for an event, name of which you pass as a generic
* These include system and custom events * These include system and custom events
*/ */
export type RageFW_ServerEventReturn<K extends RageFW_ServerEvent> = export type RageFW_ServerReturn<K extends RageFW_ServerEvent> =
K extends keyof RageFW_ICustomServerEvent K extends keyof RageFW_ICustomServerEvent
? ReturnType<RageFW_ICustomServerEvent[K]> ? ReturnType<RageFW_ICustomServerEvent[K]>
: K extends keyof IServerEvents : K extends keyof IServerEvents
@ -51,17 +51,17 @@ export type RageFW_ServerEventReturn<K extends RageFW_ServerEvent> =
* Array of arguments for an event, name of which you pass as a generic * Array of arguments for an event, name of which you pass as a generic
* These only include custom events * These only include custom events
*/ */
export type RageFW_ServerEventCallbackCustom< export type RageFW_ServerCallbackCustom<
K extends keyof RageFW_ICustomServerEvent = keyof RageFW_ICustomServerEvent, K extends keyof RageFW_ICustomServerEvent = keyof RageFW_ICustomServerEvent,
> = ( > = (
payload: [player: PlayerMp, ...args: RageFW_ServerEventArguments<K>], payload: [player: PlayerMp, ...args: RageFW_ServerArgs<K>],
) => RageFW_ServerEventReturn<K> ) => RageFW_ServerReturn<K>
/** /**
* Array of arguments for an event, name of which you pass as a generic * Array of arguments for an event, name of which you pass as a generic
* These only include system events * These only include system events
*/ */
export type RageFW_ServerEventCallbackNative< export type RageFW_ServerCallbackNative<
K extends keyof IServerEvents = keyof IServerEvents, K extends keyof IServerEvents = keyof IServerEvents,
> = (payload: Parameters<IServerEvents[K]>) => ReturnType<IServerEvents[K]> > = (payload: Parameters<IServerEvents[K]>) => ReturnType<IServerEvents[K]>