SetPlayerFlying
Lets the player fly - or lands them.
Flying, the player moves along where they look with their movement keys - Space up, C down, Shift three times faster - with no gravity and through walls, and the server’s movement checks (the speed cap, the height over the terrain, the walls) and fall damage leave them alone; what they see around them follows them, so a flying admin shows a crowd from above. Landing puts them on the ground under where they are, and the checks and falls start again a few seconds later. A death, a mount, a cart seat and a respawn land them too. The server has no command for it: a mode gives its admins one (the example).
Syntax
Section titled “Syntax”SetPlayerFlying(pid, flying [, speed])| Parameter | Type | |
|---|---|---|
pid |
number | the player |
flying |
boolean | true to fly, false to land |
speed |
number | the pace in m/s, 1 to 50 (Shift triples it); 12 when left out (optional) |
Returns
Section titled “Returns”boolean - true, or false and the reason as the player reads it ("Get off the horse first.", "You are dead." …)
Example
Section titled “Example”-- /fly [speed] for admins: again to landfunction OnPlayerCommandText(pid, cmd, args) if cmd == "fly" and IsPlayerAdmin(pid) then local ok, why = SetPlayerFlying(pid, not IsPlayerFlying(pid), tonumber(args)) if not ok then SendClientMessage(pid, COLOR_SERVER, why) end return true endendSee also
Section titled “See also”IsPlayerFlying · SetPlayerPos · the Players group of the index
