Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
263 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
content/docs/resources/spawnmanager/functions/addSpawnPoint.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
--- | ||
title: addSpawnPoint | ||
--- | ||
|
||
## About | ||
This export allows you to add a spawn point to the spawnmanager and returns an index for that spawnpoint. | ||
|
||
## Name | ||
``` | ||
addSpawnPoint | ||
``` | ||
|
||
## Parameters | ||
|
||
``` | ||
object spawn | ||
``` | ||
|
||
### Required Arguments | ||
|
||
- **spawn**: An object containing the following information: | ||
- **(float) x**: The x coordinate of where the player spawned to. | ||
- **(float) y**: The y coordinate of where the player spawned to. | ||
- **(float) z**: The z coordinate of where the player spawned to. | ||
- **(float) heading**: The heading that the player is facing when spawned. | ||
- **(Hash) model**: The ped model hash the player spawned as. | ||
|
||
Examples | ||
-------- | ||
|
||
##### Lua Example: | ||
```lua | ||
local mySpawnPoint = exports.spawnmanager:addSpawnPoint({ | ||
z = 111.5291, | ||
y = 197.7201, | ||
x = 466.8401, | ||
heading = 291.71, | ||
idx = 6, | ||
model = 1631478380 | ||
}) | ||
|
||
-- Spawns the player at the spawn point we just created | ||
exports.spawnmanager:spawnPlayer(mySpawnPoint) | ||
``` |
25 changes: 25 additions & 0 deletions
25
content/docs/resources/spawnmanager/functions/forceRespawn.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
--- | ||
title: forceRespawn | ||
--- | ||
|
||
## About | ||
If the auto-spawn flag is enabled, this export instantly and forcefully respawns the player, disregarding the 2 second cooldown. | ||
|
||
## Name | ||
``` | ||
forceRespawn | ||
``` | ||
|
||
##### Lua Example: | ||
|
||
```lua | ||
Citizen.CreateThread(function() | ||
exports.spawnmanager:setAutoSpawn(true) -- must be true for this to work | ||
while true do | ||
if IsEntityDead(PlayerPedId()) then -- check if the player is dead | ||
exports.spawnmanager:forceRespawn() -- forcefully respawn without a cooldown | ||
end | ||
Citizen.Wait(100) | ||
end | ||
end) | ||
``` |
42 changes: 42 additions & 0 deletions
42
content/docs/resources/spawnmanager/functions/loadSpawns.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
--- | ||
title: loadSpawns | ||
--- | ||
|
||
## About | ||
This export loads a set of spawn points into the spawnmanager from a JSON string. | ||
|
||
## Name | ||
``` | ||
loadSpawns | ||
``` | ||
|
||
## Parameters | ||
|
||
``` | ||
string spawnString | ||
``` | ||
|
||
### Required Arguments | ||
|
||
- **spawnString** A normal *spawn* object in JSON format | ||
|
||
##### Example | ||
|
||
```js | ||
{ | ||
'spawns': [ | ||
{ | ||
z: 111.5291, | ||
y: 197.7201, | ||
x: 466.8401, | ||
heading: 291.71, | ||
idx: 6, | ||
model: 1631478380 | ||
} | ||
] | ||
} | ||
``` | ||
|
||
## Examples | ||
|
||
TODO |
40 changes: 40 additions & 0 deletions
40
content/docs/resources/spawnmanager/functions/removeSpawnPoint.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
--- | ||
title: removeSpawnPoint | ||
--- | ||
|
||
## About | ||
This export allows you to remove an existing spawnpoint from the spawnmanager. | ||
|
||
## Name | ||
``` | ||
removeSpawnPoint | ||
``` | ||
|
||
## Parameters | ||
|
||
``` | ||
int spawnIdx | ||
``` | ||
|
||
### Required Arguments | ||
|
||
- **spawnIdx** The index of the spawnpoint to remove. | ||
|
||
Examples | ||
-------- | ||
|
||
##### Lua Example: | ||
```lua | ||
-- Add a new spawnpoint! | ||
local mySpawnPoint = exports.spawnmanager:addSpawnPoint({ | ||
z = 111.5291, | ||
y = 197.7201, | ||
x = 466.8401, | ||
heading = 291.71, | ||
idx = 6, | ||
model = 1631478380 | ||
}) | ||
|
||
-- Now let's remove it... | ||
exports.spawnmanager:removeSpawnPoint(mySpawnPoint) | ||
``` |
30 changes: 30 additions & 0 deletions
30
content/docs/resources/spawnmanager/functions/setAutoSpawn.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
--- | ||
title: setAutoSpawn | ||
--- | ||
|
||
## About | ||
This export allows you to change the auto-spawning flag. | ||
|
||
When this is enabled, players will be automatically spawned after the loading screen. They will also be automatically respawned with a 2 second cooldown. To instantly and forcefully respawn the player without the cooldown, use [forceRespawn](./functions/forceRespawn). | ||
|
||
If the auto-spawning flag is disabled, you will have to manually spawn players when they first log in and also manually respawn players when they die, could be useful in an environment where you don't want instant respawn. | ||
|
||
## Name | ||
``` | ||
setAutoSpawn | ||
``` | ||
|
||
## Parameters | ||
|
||
``` | ||
bool enabled | ||
``` | ||
|
||
### Required Arguments | ||
|
||
- **enabled** Whether to enable or disable auto-spawning. | ||
|
||
##### Lua Example: | ||
```lua | ||
exports.spawnmanager:setAutoSpawn(true) | ||
``` |
28 changes: 28 additions & 0 deletions
28
content/docs/resources/spawnmanager/functions/setAutoSpawnCallback.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
--- | ||
title: setAutoSpawnCallback | ||
--- | ||
|
||
## About | ||
This export allows you to choose your own callback for autospawning, instead of using spawnmanager's 'native' [spawnPlayer](https://github.com/citizenfx/cfx-server-data/blob/2bde7889b4593d842e911827a33294211f40de93/resources/%5Bmanagers%5D/spawnmanager/spawnmanager.lua#L207) function. | ||
|
||
## Name | ||
``` | ||
setAutoSpawnCallback | ||
``` | ||
|
||
## Parameters | ||
|
||
``` | ||
function callback | ||
``` | ||
|
||
### Required Arguments | ||
|
||
- **callback** The callback to execute when auto-spawning the player. | ||
|
||
##### Lua Example: | ||
```lua | ||
exports.spawnmanager:setAutoSpawnCallback(function() | ||
-- todo fancy spawning stuff | ||
end) | ||
``` |
41 changes: 41 additions & 0 deletions
41
content/docs/resources/spawnmanager/functions/spawnPlayer.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
--- | ||
title: spawnPlayer | ||
--- | ||
|
||
## About | ||
This export allows you to choose specifically when or where to spawn a player. You'll most likely want to use this if you've turned off the auto-spawn flag with [setAutoSpawn](./functions/setAutoSpawn). | ||
|
||
Once the player has spawned, the [playerSpawned](../../events/playerSpawned) event will be triggered. | ||
|
||
|
||
## Name | ||
``` | ||
spawnPlayer | ||
``` | ||
|
||
## Parameters | ||
|
||
``` | ||
int spawnIdx, function callback(object spawn) | ||
``` | ||
|
||
### Optional Arguments | ||
|
||
- `spawnIdx` this can be a spawn point from a map resource registered by [mapmanager](../../../mapmanager), or can be added with [addSpawnPoint](./functions/addSpawnPoint). If this isn't specified, a random spawn point will be picked out of the already registered spawn points (if any). | ||
|
||
- `callback` is executed once the player has successfully spawned and passes a `spawn` object as specified in [playerSpawned](../../events/playerSpawned). | ||
|
||
## Examples | ||
|
||
##### Lua Example: | ||
```lua | ||
-- Spawns the player at a random spawnpoint | ||
exports.spawnmanager:spawnPlayer() | ||
``` | ||
|
||
```lua | ||
-- Spawns the player at a specific spawnpoint with a callback | ||
exports.spawnmanager:spawnPlayer(1, function(spawn) | ||
TriggerEvent('chat:addMessage', { args = { 'You have spawned! Congrats!' } }) | ||
end) | ||
``` |