Warp/docs/api/1.0/server.md

211 lines
3.3 KiB
Markdown
Raw Normal View History

2024-01-31 06:33:19 +00:00
# Server <Badge type="tip" text="event" />
2024-01-05 12:14:38 +00:00
For Server-sided
2024-01-30 13:33:31 +00:00
## `.Server` <Badge type="warning" text="yield" />
2024-01-05 12:14:38 +00:00
Create new Warp event.
::: code-group
```lua [Variable]
(
Identifier: string,
rateLimit: {
2024-01-31 06:33:19 +00:00
maxEntrance: number?,
interval: number?,
2024-01-05 12:14:38 +00:00
}?
)
```
```lua [Example]
2024-01-30 13:33:31 +00:00
local Remote = Warp.Server("Remote")
2024-01-05 12:14:38 +00:00
```
:::
2024-01-30 13:33:31 +00:00
## `.fromServerArray` <Badge type="warning" text="yield" />
Create new Warp events with array.
::: code-group
```lua [Variable]
(
{ any }
)
```
```lua [Example]
local Events = Warp.fromServerArray({
["Remote1"] = {
maxEntrance: 50,
interval: 1,
}, -- with rateLimit configuration
"Remote2", -- without rateLimit configuration
["Remote3"] = {
maxEntrance: 10,
}, -- with rateLimit configuration
})
-- Usage
Events.Remote1:Connect(function(player, ...) end)
Events.Remote2:Connect(function(player, ...) end)
Events.Remote3:Connect(function(player, ...) end)
```
:::
2024-01-05 12:14:38 +00:00
## `:Connect`
Connect event to receive incoming from client way.
::: code-group
```lua [Variable]
(
player: Player,
callback: (...any) -> ()
): string
```
```lua [Example]
Remote:Connect(function(player, ...)
print(player, ...)
end)
```
:::
## `:Once`
This function likely `:Connect` but it disconnect the event once it fired.
::: code-group
```lua [Variable]
(
player: Player,
callback: (...any) -> ()
)
```
```lua [Example]
Remote:Once(function(player, ...)
print(player, ...)
end)
```
:::
## `:Disconnect`
Disconnect the event connection.
::: code-group
```lua [Variable]
(
key: string
2024-03-16 16:49:23 +00:00
): boolean
2024-01-05 12:14:38 +00:00
```
```lua [Example]
local connection = Remote:Connect(function(player, ...) end) -- store the key
Remote:Disconnect(connection)
```
:::
## `:DisconnectAll`
Disconnect All the event connection.
```lua [Example]
Remote:DisconnectAll()
```
## `:Fire`
Fire the event to a client.
::: code-group
```lua [Variable]
(
reliable: boolean,
player: Player,
...: any
)
```
```lua [Example]
Remote:Fire(true, player, "Hello World!")
```
:::
## `:Fires` <Badge type="tip" text="Server Only" />
Fire the event to all clients.
::: code-group
```lua [Variable]
(
reliable: boolean,
...: any
)
```
```lua [Example]
Remote:Fires(true, "Hello World!")
```
:::
2024-03-02 16:43:36 +00:00
## `:FireExcept` <Badge type="tip" text="Server Only" />
Fire the event to all clients but except a players.
::: code-group
```lua [Variable]
(
reliable: boolean,
except: { Player },
...: any
)
```
```lua [Example]
Remote:FireExcept(true, { Players.Eternity_Devs, Players.Player2 }, "Hello World!") -- this will sent to all players except { Players.Eternity_Devs, Players.Player2 }.
```
:::
2024-01-30 13:33:31 +00:00
## `:Invoke` <Badge type="warning" text="yield" />
2024-01-05 12:14:38 +00:00
2024-03-16 16:49:23 +00:00
Semiliar to `:InvokeClient`, but it have timeout system that not exists on `RemoteFunction.InvokeClient`.
2024-01-05 12:14:38 +00:00
::: code-group
```lua [Variable]
(
timeout: number,
player: Player,
...: any
) -> (...any)
```
```lua [Example]
local Request = Remote:Invoke(2, player, "Hello World!")
```
:::
::: warning
This function is yielded, once it timeout it will return nil.
:::
2024-01-30 13:33:31 +00:00
## `:Wait` <Badge type="warning" text="yield" />
2024-01-05 12:14:38 +00:00
Wait the event being triggered.
```lua
2024-03-16 16:49:23 +00:00
Remote:Wait() -- :Wait return number value
2024-01-05 12:14:38 +00:00
```
::: warning
This function is yielded, Invoke might also ping this one and also causing error.
:::
## `:Destroy`
Disconnect all connection of event and remove the event from Warp.
```lua
Remote:Destroy()
```