world.setRule
Turns a world rule on or off for every player.
Signature
Section titled “Signature”world.setRule(name: WorldRuleName, enabled: boolean): Promise<ActionResult>Parameters
Section titled “Parameters”| Name | Type | Description |
|---|---|---|
name |
WorldRuleName |
The rule’s name; the list is on world.isRuleEnabled. |
enabled |
boolean |
true to turn it on. |
Returns
Section titled “Returns”A promise of an ActionResult: applied once the server has changed it for everyone (also when it already was so), or rejected with vetoed when a server-side rule refused it. An unknown name is invalid-rule.
Example
Section titled “Example”Police come for wanted players.
import { world } from "nativemp";
await world.setRule("wanted", true);await world.setRule("petrolcap", false); // cap hits take ordinary body damagepetrolcap starts on. Turning it off preserves normal vehicle damage, fire and explosions after enough damage.
The change applies to subsequent hits for every connected player.
Related
Section titled “Related”world.isRuleEnabled: read one, and the list of rulesworldStateChanged: a rule changedplayerWantedLevelChangeRequest: decide individual wanted-level proposalsemergencyServiceDispatchRequest: decide individual service units- Wanted and emergency gameplay: broad rules and per-request policy