Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docs events section rework #300

Draft
wants to merge 4 commits into
base: dev
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 0 additions & 29 deletions docs/articles/events/before-player-connect.md

This file was deleted.

8 changes: 8 additions & 0 deletions docs/articles/events/client/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Server Events

## List

[Full list of client events.](https://docs.altv.mp/js/api/alt-client.IClientEvent.html)

## Documentation

15 changes: 15 additions & 0 deletions docs/articles/events/server/any-resource-error.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# anyResourceError

## A General Overview

<a href="https://docs.altv.mp/js/api/alt-server.IServerEvent.html#_altmp_altv_types_alt_server_IServerEvent_anyResourceError" target="_blank"> You can find information about the types here. (click to redirect) </a>

## Example

```js
import alt from "alt-server";

alt.on('anyResourceError', (resourceName) => {
console.error(`Resource ${resourceName} has an error.`);
});
```
15 changes: 15 additions & 0 deletions docs/articles/events/server/any-resource-start.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# anyResourceStart

## A General Overview

<a href="https://docs.altv.mp/js/api/alt-server.IServerEvent.html#_altmp_altv_types_alt_server_IServerEvent_anyResourceStart" target="_blank"> You can find information about the types here. (click to redirect) </a>

## Example

```js
import alt from "alt-server";

alt.on('anyResourceStart', (resourceName) => {
console.log(`Resource ${resourceName} has started.`);
});
```
15 changes: 15 additions & 0 deletions docs/articles/events/server/any-resource-stop.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# anyResourceStop

## A General Overview

<a href="https://docs.altv.mp/js/api/alt-server.IServerEvent.html#_altmp_altv_types_alt_server_IServerEvent_anyResourceStop" target="_blank"> You can find information about the types here. (click to redirect) </a>

## Example

```js
import alt from "alt-server";

alt.on('anyResourceStop', (resourceName) => {
console.log(`Resource ${resourceName} has stopped.`);
});
```
23 changes: 23 additions & 0 deletions docs/articles/events/server/console-command.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# consoleCommand

## A General Overview

<a href="https://docs.altv.mp/js/api/alt-server.IServerEvent.html#_altmp_altv_types_alt_server_IServerEvent_consoleCommand" target="_blank"> You can find information about the types here. (click to redirect) </a>

## Example

```js
import alt from "alt-server";

alt.on("consoleCommand", (name, ...args) => {
console.log(`Console command ${name} was executed with the following arguments: ${args.join(", ")}`);

// example console command handle
if (name === "hello") {
console.log("Hello from consoleCommand event!");
return;
}

console.error(`Unknown console command ${name}`);
});
```
21 changes: 21 additions & 0 deletions docs/articles/events/server/entity-enter-colshape.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# entityEnterColshape

## A General Overview

<a href="https://docs.altv.mp/js/api/alt-server.IServerEvent.html#_altmp_altv_types_alt_server_IServerEvent_entityEnterColshape" target="_blank"> You can find information about the types here. (click to redirect) </a>

Triggered when an entity enters a colshape.

## Example

```js
import alt from "alt-server";

let colshape = new alt.ColshapeSphere(new alt.Vector3(0, 0, 71), 5, 10);

alt.on("entityEnterColshape", (colshape, entity) => {
if (entity.type instanceof alt.Player) {
console.log(`Player ${entity.name} entered colshape ${colshape.id}`);
}
});
```
21 changes: 21 additions & 0 deletions docs/articles/events/server/entity-leave-colshape.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# entityLeaveColshape

## A General Overview

<a href="https://docs.altv.mp/js/api/alt-server.IServerEvent.html#_altmp_altv_types_alt_server_IServerEvent_entityLeaveColshape" target="_blank"> You can find information about the types here. (click to redirect) </a>

Triggered when an entity enters a colshape.

## Example

```js
import alt from "alt-server";

let colshape = new alt.ColshapeSphere(new alt.Vector3(0, 0, 71), 5, 10);

alt.on("entityLeaveColshape", (colshape, entity) => {
if (entity instanceof alt.Player) {
console.log(`Player ${entity.name} left colshape ${colshape.id}`);
}
});
```
23 changes: 23 additions & 0 deletions docs/articles/events/server/explosion.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# explosion

## A General Overview

<a href="https://docs.altv.mp/js/api/alt-server.IServerEvent.html#_altmp_altv_types_alt_server_IServerEvent_explosion" target="_blank"> You can find information about the types here. (click to redirect) </a>

Triggered when an explosion occurs by players. Behavior can be cancelled by returning `false`.

## Example

```js
import alt from "alt-server";

function canPlayerCreateExplosion(player) {
// Your logic here

return true;
}

alt.on("explosion", (source, type, pos, fx, target) => {
return canPlayerCreateExplosion(source, type, pos, fx, target);
});
```
23 changes: 23 additions & 0 deletions docs/articles/events/server/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Server Events

## List

[Full list of server events.](https://docs.altv.mp/js/api/alt-server.IServerEvent.html)

## Documentation

- [anyResourceError](https://docs.altv.mp/js/articles/events/server/anyResourceError.html)
- [anyResourceStart](https://docs.altv.mp/js/articles/events/server/anyResourceStart.html)
- [anyResourceStop](https://docs.altv.mp/js/articles/events/server/anyResourceStop.html)
- [beforePlayerConnect](https://docs.altv.mp/js/articles/events/server/beforePlayerConnect.html)
- [consoleCommand](https://docs.altv.mp/js/articles/events/server/consoleCommand.html)
- [entityEnterColshape](https://docs.altv.mp/js/articles/events/server/entityEnterColshape.html)
- [entityLeaveColshape](https://docs.altv.mp/js/articles/events/server/entityLeaveColshape.html)
- [explosion](https://docs.altv.mp/js/articles/events/server/explosion.html)
- [netOwnerChange](https://docs.altv.mp/js/articles/events/server/netOwnerChange.html)
- [playerChangedVehicleSeat](https://docs.altv.mp/js/articles/events/server/playerChangedVehicleSeat.html)
- [playerConnect](https://docs.altv.mp/js/articles/events/server/playerConnect.html)
- [playerConnectDenied](https://docs.altv.mp/js/articles/events/server/playerConnectDenied.html)
- [playerDamage](https://docs.altv.mp/js/articles/events/server/playerDamage.html)
- [playerDeath](https://docs.altv.mp/js/articles/events/server/playerDeath.html)
- [playerDisconnect](https://docs.altv.mp/js/articles/events/server/playerDisconnect.html)
19 changes: 19 additions & 0 deletions docs/articles/events/server/net-owner-change.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# netOwnerChange

## A General Overview

<a href="https://docs.altv.mp/js/api/alt-server.IServerEvent.html#_altmp_altv_types_alt_server_IServerEvent_netOwnerChange" target="_blank"> You can find information about the types here. (click to redirect) </a>

Triggered when netOwner of the entity changes.

## Example

```js
import alt from "alt-server";

alt.on("netOwnerChange", (entity, owner, oldOwner) => {
if (entity instanceof alt.Ped) {
alt.log(`Ped ${entity.id} has a new owner: ${owner ? owner.id : "null"}, old owner: ${oldOwner ? oldOwner.id : "null"}`);
}
});
```
15 changes: 15 additions & 0 deletions docs/articles/events/server/player-changed-vehicle-seat.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# playerChangedVehicleSeat

## A General Overview

<a href="https://docs.altv.mp/js/api/alt-server.IServerEvent.html#_altmp_altv_types_alt_server_IServerEvent_playerChangedVehicleSeat" target="_blank"> You can find information about the types here. (click to redirect) </a>

## Example

```js
import alt from "alt-server";

alt.on("playerChangedVehicleSeat", (player, vehicle, oldSeat, seat) => {
console.log(`${player.name} changed seat from ${oldSeat} to ${seat} in vehicle ${vehicle.id}`);
});
```
15 changes: 15 additions & 0 deletions docs/articles/events/server/player-connect-denied.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# playerConnectDenied

## A General Overview

<a href="https://docs.altv.mp/js/api/alt-server.IServerEvent.html#_altmp_altv_types_alt_server_IServerEvent_playerConnectDenied" target="_blank"> You can find information about the types here. (click to redirect) </a>

## Example

```js
import alt from "alt-server";

alt.on("playerConnectDenied", (reason, name, ip, passwordHash, isDebug, branch, version, cdnURL, discordId) => {
console.log(`Player ${name} with IP ${ip} was denied to connect. Reason: ${reason}`);
});
```
15 changes: 15 additions & 0 deletions docs/articles/events/server/player-connect.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# playerConnect

## A General Overview

<a href="https://docs.altv.mp/js/api/alt-server.IServerEvent.html#_altmp_altv_types_alt_server_IServerEvent_playerConnect" target="_blank"> You can find information about the types here. (click to redirect) </a>

## Example

```js
import alt from "alt-server";

alt.on("playerConnect", (player) => {
console.log(`${player.name} (RSC ID: ${player.socialID}) connected`);
});
```
17 changes: 17 additions & 0 deletions docs/articles/events/server/player-damage.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# playerDamage

## A General Overview

<a href="https://docs.altv.mp/js/api/alt-server.IServerEvent.html#_altmp_altv_types_alt_server_IServerEvent_playerDamage" target="_blank"> You can find information about the types here. (click to redirect) </a>

## Example

```js
import alt from "alt-server";

alt.on("playerDamage", (victim, attacker, healthDamage, armourDamage, weaponHash) => {
let attackerName = attacker ? attacker.name : "Environment";

console.log(`${victim.name} was damaged by ${attackerName} with weapon ${weaponHash}. Health damage: ${healthDamage}, Armour damage: ${armourDamage}`);
});
```
17 changes: 17 additions & 0 deletions docs/articles/events/server/player-death.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# playerDamage

## A General Overview

<a href="https://docs.altv.mp/js/api/alt-server.IServerEvent.html#_altmp_altv_types_alt_server_IServerEvent_playerDeath" target="_blank"> You can find information about the types here. (click to redirect) </a>

## Example

```js
import alt from "alt-server";

alt.on("playerDeath", (victim: Player, killer, weaponHash) => {
let killerName = killer ? killer.name : "Environment";

console.log(`${victim.name} was killed by ${killerName} with weapon ${weaponHash}`);
});
```
15 changes: 15 additions & 0 deletions docs/articles/events/server/player-disconnect.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# playerDisconnect

## A General Overview

<a href="https://docs.altv.mp/js/api/alt-server.IServerEvent.html#_altmp_altv_types_alt_server_IServerEvent_playerDisconnect" target="_blank"> You can find information about the types here. (click to redirect) </a>

## Example

```js
import alt from "alt-server";

alt.on("playerDisconnect", (player, reason) => {
console.log(`${player.name} has disconnected from the server (reason: ${reason})`);
});
```
25 changes: 23 additions & 2 deletions docs/articles/toc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,29 @@
- name: Events
href: events/index.md
items:
- name: beforePlayerConnect
href: events/before-player-connect.md
- name: Client Events
href: events/client/index.md
- name: Server Events
href: events/server/index.md
items:
- name: anyResourceError
href: events/server/any-resource-error.md
- name: anyResourceStart
href: events/server/any-resource-start.md
- name: anyResourceStop
href: events/server/any-resource-stop.md
- name: beforePlayerConnect
href: events/server/before-player-connect.md
- name: consoleCommand
href: events/server/console-command.md
- name: entityEnterColshape
href: events/server/entity-enter-colshape.md
- name: entityLeaveColshape
href: events/server/entity-leave-colshape.md
- name: explosion
href: events/server/explosion.md
- name: netOwnerChange
href: events/server/net-owner-change.md
- name: Player
href: player/index.md
items:
Expand Down
Loading