Compare commits

..

No commits in common. "4695f5dbd123b0cc5a4739878718226ef46c335b" and "2da34bd38281b401aa161fb9e25411b992becbb2" have entirely different histories.

3 changed files with 16 additions and 20 deletions

View File

@ -38,21 +38,20 @@ class Server {
public registerMany<EventName extends RageFW_ServerEvent>(events: { public registerMany<EventName extends RageFW_ServerEvent>(events: {
[event in EventName]: RageFW_ServerEventCallback<event> [event in EventName]: RageFW_ServerEventCallback<event>
}): void { }): void {
Object.entries<RageFW_ServerEventCallback<EventName>>(events).map( Object.entries(events).map(([eventName, callback]) => {
([eventName, callback]) => { if (nativeEvents.includes(eventName)) {
if (this.isNativeEvent(eventName)) { mp.events.add(
mp.events.add(eventName, callback) eventName as keyof IServerEvents,
} else { callback as (...arg: unknown[]) => void,
rpc.register(eventName, (args: unknown[]) => { )
return Array.isArray(args) } else {
? (callback as (...arg: typeof args) => void)( rpc.register(eventName, (args: unknown[]) => {
...args, return Array.isArray(args)
) ? (callback as (...arg: typeof args) => void)(...args)
: (callback as (arg: typeof args) => void)(args) : (callback as (arg: typeof args) => void)(args)
}) })
} }
}, })
)
} }
} }

View File

@ -16,7 +16,7 @@ export type RageFW_ServerEventCallback<K extends RageFW_ServerEvent> =
...args: Parameters<RageFW_ICustomServerEvent[K]> ...args: Parameters<RageFW_ICustomServerEvent[K]>
) => ReturnType<RageFW_ICustomServerEvent[K]> ) => ReturnType<RageFW_ICustomServerEvent[K]>
: K extends keyof IServerEvents : K extends keyof IServerEvents
? IServerEvents[K] ? ThisifyServerEvents[K]
: never : never
export type RageFW_ClientEvent = keyof RageFW_ICustomClientEvent export type RageFW_ClientEvent = keyof RageFW_ICustomClientEvent

View File

@ -1,8 +1,5 @@
declare module 'rage-fw-shared-types' { declare module 'rage-fw-shared-types' {
export interface RageFW_ICustomServerEvent { export interface RageFW_ICustomServerEvent {}
customServerEvent(customArgs: string[]): boolean
customServerEvent2(customArgs2: number[]): void
}
export interface RageFW_ICustomClientEvent {} export interface RageFW_ICustomClientEvent {}
} }