Events
Built-in events describe runtime lifecycle and entity changes. Custom named events carry gamemode-specific JSON-compatible payloads.
Server handlers
vimp.on receives built-in events with their declared positional arguments. A custom client event additionally receives the sending player.
vimp.on('garage:spawn', (player, payload) => {
const vehicle = vimp.vehicles.create(
vimp.hash(payload.model),
94.5,
-1940.2,
20.7,
307,
{ numberPlate: 'VIMP', engineOn: true },
)
if (vehicle) {
player.emit('garage:spawned', { vehicleId: vehicle.id })
}
})Use player.emit(name, payload) for one client and vimp.emitAllClients(name, payload) for a broadcast. Server vimp.emit is local, synchronous dispatch; it does not send a network message.
Client and UI
Client vimp.emitServer sends a request to the server. A CEF page can call emitClient or emitServer. Server-to-client events and CEF-to-client events arrive through client vimp.on.
Strong payload types
Extend the empty event maps through declaration merging. Keep the declarations in context-specific .d.ts files included by the matching tsconfig.
declare module '@vimp-mp/types/server' {
interface VimpServerEvents {
'inventory:use': { slot: number }
}
}TypeScript checks payload construction, but it does not validate data at runtime. Validate client-originated payloads on the server before acting.