Add support for a cross-resource API
sudojunior opened this issue · 0 comments
sudojunior commented
- Server
setIndicatorsFor(vehicle: Vehicle, lights: VehicleIndicatorLights)
Allow bypassing
netOwner
/driver
patch if setting from another resource.setActive(vehicle: Vehicle, state: boolean)
Allow indicator lights to be forcibly locked to their current state.
Further updates from the server would be ignored for that specific vehicle, until it would be re-enabled.setAllEnabled(state: boolean)
Allow another resource to set the global state for indicators, providing the opportunity for a complete blackout effect.
Setting to false will keep the current state for all vehicles, but force all that have the attribute to be disabled.
Client
- No planned implementations...
import indicatorsAPI from 'altv-indicators';
// as passenger, from server context within event from any player
indicatorsAPI.setIndicatorsFor(player.vehicle, VehicleIndicatorLights.BlinkRight);
indicatorsAPI.setActive(player.vehicle, false);
// lock to the right signal
// due to the the `setActive` another streamed meta change would be emitted.
// as for disabling all active indicators, that would require an active boolean to be stored at all times
const isGloballyActive = true;
export function setAllEnabled(state: boolean) {
isGloballyActive = state;
alt.emitAllClients("indicators:change", isGloballyActive);
}
alt.onClient("indicators:requestActive", (player: Player) => {
player.emit("indicators:change", isGloballyActive);
});
// or
alt.on("playerConnected", (player) => /* ... */);
State would continue to be updated for all vehicles, it just requires the state to remain updated in some capacity.