-
Notifications
You must be signed in to change notification settings - Fork 74
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
base: dev
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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 | ||
|
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.`); | ||
}); | ||
``` |
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.`); | ||
}); | ||
``` |
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.`); | ||
}); | ||
``` |
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}`); | ||
}); | ||
``` |
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 === alt.BaseObjectType.Player) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. your example is js but you use ts enums There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. then maybe there is a point to add them to alt exports? or is there another workaround to detect entity type? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. you can also check entity type like this: entity instanceof alt.Player |
||
console.log(`Player ${entity.name} entered colshape ${colshape.id}`); | ||
} | ||
}); | ||
``` |
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.type === alt.BaseObjectType.Player) { | ||
console.log(`Player ${entity.name} left colshape ${colshape.id}`); | ||
} | ||
}); | ||
``` |
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); | ||
}); | ||
``` |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# 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) |
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.type === alt.BaseObjectType.Ped) { | ||
alt.log(`Ped ${entity.id} has a new owner: ${owner ? owner.id : "null"}, old owner: ${oldOwner ? oldOwner.id : "null"}`); | ||
} | ||
}); | ||
``` |
This comment was marked as resolved.
Sorry, something went wrong.