Skip to content

Commit

Permalink
Correct several grammar errors in callback documentation (#1054)
Browse files Browse the repository at this point in the history
* Fixes several grammar mistakes

* Update OnPlayerWeaponShot.md

* Removes docs/scripting/callbacks/OnScriptCash.md

* Change tip to warning

* Add missing word
  • Loading branch information
FreddieCrew authored Sep 22, 2024
1 parent 0e85394 commit 244bfdd
Show file tree
Hide file tree
Showing 18 changed files with 105 additions and 127 deletions.
56 changes: 29 additions & 27 deletions docs/scripting/callbacks/OnDialogResponse.md
Original file line number Diff line number Diff line change
@@ -1,31 +1,31 @@
---
title: OnDialogResponse
description: This callback is called when a player responds to a dialog shown using ShowPlayerDialog by either clicking a button, pressing ENTER/ESC or double-clicking a list item (if using a list style dialog).
description: This callback is called when a player responds to a dialog shown using ShowPlayerDialog. The response can be by clicking a button, pressing ENTER/ESC, or double-clicking a list item (in the case of a list-style dialog).
tags: ["dialog"]
---

## Description

This callback is called when a player responds to a dialog shown using ShowPlayerDialog by either clicking a button, pressing ENTER/ESC or double-clicking a list item (if using a list style dialog).
This callback is called when a player responds to a dialog shown using ShowPlayerDialog. The response can be by clicking a button, pressing ENTER/ESC, or double-clicking a list item (in the case of a list-style dialog).

| Name | Description |
| ----------- | ----------------------------------------------------------------------------------------------------------------------- |
| playerid | The ID of the player that responded to the dialog. |
| dialogid | The ID of the dialog the player responded to, assigned in ShowPlayerDialog. |
| response | 1 for left button and 0 for right button (if only one button shown, always 1) |
| listitem | The ID of the list item selected by the player (starts at 0) (only if using a list style dialog, otherwise will be -1). |
| inputtext[] | The text entered into the input box by the player or the selected list item text. |
| playerid | The ID of the player who responded to the dialog. |
| dialogid | The ID of the dialog the player responded to, as assigned in ShowPlayerDialog. |
| response | 1 for the left button, and 0 for the right button (if only one button is shown, it will always be 1) |
| listitem | The ID of the list item selected by the player (starts at 0). For non-list dialogs, it will be -1. |
| inputtext[] | The text entered in the input box by the player, or the selected list item text. |

## Returns

It is always called first in filterscripts so returning 1 there blocks other filterscripts from seeing it.
This callback is always called first in filterscripts. Returning 1 blocks other filterscripts from processing it.

## Examples

**DIALOG_STYLE_MSGBOX**

```c
// Define the dialog ID so we can handle responses
// Define the dialog ID for handling responses
#define DIALOG_RULES 1

// In some command
Expand All @@ -35,18 +35,18 @@ public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
if (dialogid == DIALOG_RULES)
{
if (response) // If they clicked 'Yes' or pressed enter
if (response) // If the left button was pressed or ENTER was pressed
{
SendClientMessage(playerid, COLOR_GREEN, "Thank you for agreeing to the server rules!");
}
else // Pressed ESC or clicked cancel
else // ESC was pressed or the right button was pressed
{
Kick(playerid);
}
return 1; // We handled a dialog, so return 1. Just like OnPlayerCommandText.
return 1; // Return 1 to indicate the dialog was handled.
}

return 0; // You MUST return 0 here! Just like OnPlayerCommandText.
return 0; // Return 0 for unhandled dialogs.
}
```
Expand All @@ -62,11 +62,11 @@ public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
if (dialogid == DIALOG_LOGIN)
{
if (!response) // If they clicked 'Cancel' or pressed esc
if (!response) // ESC was pressed or the right button was pressed
{
Kick(playerid);
}
else // Pressed ENTER or clicked 'Login' button
else // ESC was pressed or the right button was pressed
{
if (CheckPassword(playerid, inputtext))
{
Expand All @@ -80,10 +80,10 @@ public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT, "Login", "Please enter your password:", "Login", "Cancel");
}
}
return 1; // We handled a dialog, so return 1. Just like OnPlayerCommandText.
return 1; // Return 1 to indicate the dialog was handled.
}
return 0; // You MUST return 0 here! Just like OnPlayerCommandText.
return 0; // Return 0 for unhandled dialogs.
}
```

Expand All @@ -99,29 +99,29 @@ public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
if (dialogid == DIALOG_WEAPONS)
{
if (response) // If they clicked 'Select' or double-clicked a weapon
if (response) // The right button was clicked or an item was double-clicked.
{
// Give them the weapon
// Give the player the selected weapon.
switch (listitem)
{
case 0:
{
GivePlayerWeapon(playerid, WEAPON_DEAGLE, 14); // Give them a desert eagle
GivePlayerWeapon(playerid, WEAPON_DEAGLE, 14); // Give the player a desert eagle.
}
case 1:
{
GivePlayerWeapon(playerid, WEAPON_AK47, 120); // Give them an AK-47
GivePlayerWeapon(playerid, WEAPON_AK47, 120); // Give the player an AK-47.
}
case 2:
{
GivePlayerWeapon(playerid, WEAPON_SHOTGSPA, 28); // Give them a Combat Shotgun
GivePlayerWeapon(playerid, WEAPON_SHOTGSPA, 28); // Give the player a Combat Shotgun.
}
}
}
return 1; // We handled a dialog, so return 1. Just like OnPlayerCommandText.
return 1; // Return 1 to indicate the dialog was handled.
}

return 0; // You MUST return 0 here! Just like OnPlayerCommandText.
return 0; // Return 0 for unhandled dialogs.
}
```
Expand Down Expand Up @@ -172,19 +172,21 @@ public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])

:::tip

Parameters can contain different values, based on dialog's style ([click for more examples](../resources/dialogstyles)).
The parameters can have different values depending on the dialog's style. ([Click here for more examples](../resources/dialogstyles)).

:::

:::tip

It is appropriate to switch through different dialogids, if you have many.
Using a switch-case statement instead of if blocks is an appropriate method for handling multiple dialogs.

:::

:::warning

A player's dialog doesn't hide when the gamemode restarts, causing the server to print "Warning: PlayerDialogResponse PlayerId: 0 dialog ID doesn't match last sent dialog ID" if a player responded to this dialog after restart.
A player's dialog doesn't automatically close when the gamemode restarts.

If a player responds to a dialog after the server was restarted, the server will print the warning: "Warning: PlayerDialogResponse PlayerId: 0 dialog ID doesn't match last sent dialog ID".

:::

Expand Down
2 changes: 1 addition & 1 deletion docs/scripting/callbacks/OnPlayerClickPlayerTextDraw.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ This callback is called when a player clicks on a player-textdraw. It is not cal

## Returns

It is always called first in filterscripts so returning 1 there also blocks other scripts from seeing it.
It is always called first in filterscripts so returning 1 there also blocks other scripts from processing it.

## Examples

Expand Down
2 changes: 1 addition & 1 deletion docs/scripting/callbacks/OnPlayerClickTextDraw.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ This callback is called when a player clicks on a textdraw or cancels the select

## Returns

It is always called first in filterscripts so returning 1 there also blocks other scripts from seeing it.
It is always called first in filterscripts so returning 1 there also blocks other scripts from processing it.

## Examples

Expand Down
2 changes: 1 addition & 1 deletion docs/scripting/callbacks/OnPlayerCommandText.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ This callback is called when a player enters a command into the client chat wind

## Returns

It is always called first in filterscripts so returning 1 there blocks other scripts from seeing it.
It is always called first in filterscripts so returning 1 there blocks other scripts from processing it.

## Examples

Expand Down
2 changes: 1 addition & 1 deletion docs/scripting/callbacks/OnPlayerGiveDamage.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ This callback is called when a player gives damage to another player.

0 - Allows this callback to be called in other filterscripts.

It is always called first in filterscripts so returning 1 there blocks other filterscripts from seeing it.
It is always called first in filterscripts so returning 1 there blocks other filterscripts from processing it.

## Examples

Expand Down
2 changes: 1 addition & 1 deletion docs/scripting/callbacks/OnPlayerGiveDamageActor.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ This callback is called when a player gives damage to an actor.

0 - Allows this callback to be called in other filterscripts.

It is always called first in filterscripts so returning 1 there blocks other filterscripts from seeing it.
It is always called first in filterscripts so returning 1 there blocks other filterscripts from processing it.

## Examples

Expand Down
2 changes: 1 addition & 1 deletion docs/scripting/callbacks/OnPlayerRequestSpawn.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ This callback is called when a player attempts to spawn via class selection eith

## Returns

It is always called first in filterscripts so returning 0 there also blocks other scripts from seeing it.
It is always called first in filterscripts so returning 0 there also blocks other scripts from processing it.

## Examples

Expand Down
2 changes: 1 addition & 1 deletion docs/scripting/callbacks/OnPlayerTakeDamage.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ This callback is called when a player takes damage.

0 - Allows this callback to be called in other filterscripts.

It is always called first in filterscripts so returning 1 there blocks other filterscripts from seeing it.
It is always called first in filterscripts so returning 1 there blocks other filterscripts from processing it.

## Examples

Expand Down
19 changes: 14 additions & 5 deletions docs/scripting/callbacks/OnPlayerText.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@ tags: ["player"]

## Description

This callback is called when a player sends a chat message.
This callback is called when a player sends a message in chat.

| Name | Description |
| -------- | ---------------------------------------- |
| playerid | The ID of the player who typed the text. |
| text[] | The text the player typed. |
| playerid | The ID of the player who sent the message. |
| text[] | The content of the message that the player sent. |

## Returns

It is always called first in filterscripts so returning 0 there blocks other scripts from seeing it.
It is always called first in filterscripts so returning 0 on it blocks other scripts from processing it.

## Examples

Expand All @@ -25,14 +25,23 @@ public OnPlayerText(playerid, text[])
new string[144];
format(string, sizeof (string), "(%d) %s", playerid, text);
SendPlayerMessageToAll(playerid, string);
return 0; // ignore the default text and send the custom one

// Returning 0 ignores the default message format and sends the custom one instead.
// Returning 1 will result in the message being duplicated, as the default message will also be sent.
return 0;
}
```
## Notes
<TipNPCCallbacks />
::: tip
By default, this callback sends a message containing the content of the message, the player's name, and their ID. Returning 0 will ignore this default behaviour, as demonstrated in the code example above.
:::
## Related Callbacks
The following callbacks might be useful, as they're related to this callback in one way or another.
Expand Down
47 changes: 31 additions & 16 deletions docs/scripting/callbacks/OnPlayerWeaponShot.md
Original file line number Diff line number Diff line change
@@ -1,30 +1,30 @@
---
title: OnPlayerWeaponShot
description: This callback is called when a player fires a shot from a weapon.
description: This callback is called when a player fires a weapon.
tags: ["player"]
---

## Description

This callback is called when a player fires a shot from a weapon. Only bullet weapons are supported. Only passenger drive-by is supported (not driver drive-by, and not sea sparrow / hunter shots).
This callback is called when a player fires a weapon. Only firearms are supported.

| Name | Description |
|-------------------------|-----------------------------------------------------------------------------------------------------------|
| playerid | The ID of the player that shot a weapon. |
| WEAPON:weaponid | The ID of the [weapon](../resources/weaponids) shot by the player. |
| BULLET_HIT_TYPE:hittype | The [type](../resources/bullethittypes) of thing the shot hit (none, player, vehicle, or (player)object). |
| hitid | The ID of the player, vehicle or object that was hit. |
| Float:fX | The X coordinate that the shot hit. |
| Float:fY | The Y coordinate that the shot hit. |
| Float:fZ | The Z coordinate that the shot hit. |
| playerid | The ID of the player who fired the weapon. |
| WEAPON:weaponid | The ID of the [weapon](../resources/weaponids) fired by the player. |
| BULLET_HIT_TYPE:hittype | The [type](../resources/bullethittypes) of target hit by the shot. |
| hitid | The ID of the player, vehicle, or object that was hit. |
| Float:fX | The X coordinate where the shot hit. |
| Float:fY | The Y coordinate where the shot hit. |
| Float:fZ | The Z coordinate where the shot hit. |

## Returns

0 - Prevent the bullet from causing damage.

1 - Allow the bullet to cause damage.

It is always called first in filterscripts so returning 0 there also blocks other scripts from seeing it.
It is always called first in filterscripts so returning 0 there also blocks other scripts from processing it.

## Examples

Expand All @@ -44,24 +44,39 @@ public OnPlayerWeaponShot(playerid, WEAPON:weaponid, BULLET_HIT_TYPE:hittype, hi
This callback is only called when lag compensation is enabled. If hittype is:
- `BULLET_HIT_TYPE_NONE`: the fX, fY and fZ parameters are normal coordinates, will give 0.0 for coordinates if nothing was hit (e.g. far object that the bullet can't reach);
- Others: the fX, fY and fZ are offsets relative to the hitid.
- BULLET_HIT_TYPE_NONE: The fX, fY, and fZ parameters are absolute coordinates. These will return 0.0 if nothing was hit (e.g., a distant object that the bullet can't reach).
- Other values: The fX, fY, and fZ values are offsets relative to hitid.
:::
:::tip
[GetPlayerLastShotVectors](../functions/GetPlayerLastShotVectors) can be used in this callback for more detailed bullet vector information.
# Known bugs and issues
:::warning
This callback isn't called when firing from a vehicle as the driver or when shooting while looking backward with the aim enabled (shooting into the air).
:::
:::warning
When shooting a player inside a vehicle, this callback will be triggered as BULLET_HIT_TYPE_VEHICLE with the correct hitid (the hit player's vehicleid). It won't be triggered as BULLET_HIT_TYPE_PLAYER.
:::
:::warning
Known Bug(s):
Partially fixed in SA-MP 0.3.7: If fake weapon data is sent by a malicious client, other players' clients may freeze or crash. To prevent this, check if the reported weaponid can, in fact, fire projectiles.
:::
:::warning
- Isn't called if you fired in vehicle as driver or if you are looking behind with the aim enabled (shooting in air).
- It is called as `BULLET_HIT_TYPE_VEHICLE` with the correct `hitid` (the hit player's vehicleid) if you are shooting a player which is in a vehicle. It won't be called as `BULLET_HIT_TYPE_PLAYER` at all.
- Partially fixed in SA-MP 0.3.7: If fake weapon data is sent by a malicious user, other player clients may freeze or crash. To combat this, check if the reported weaponid can actually fire bullets.
This callback is not called when driving-by as a driver, firing the turret of a Seasparrow, Hunter, or any other armed vehicle.
:::
Expand Down
18 changes: 10 additions & 8 deletions docs/scripting/callbacks/OnRconCommand.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
---
title: OnRconCommand
description: This callback is called when a command is sent through the server console, remote RCON, or via the in-game "/rcon command".
description: This callback is called when a command is sent through the server console, RCON, or via the in-game "/rcon command".
tags: ["rcon", "administration"]
---

## Description

This callback is called when a command is sent through the server console, remote RCON, or via the in-game "/rcon command".
This callback is called when a command is sent through the server console, RCON (Remote Console), or via the in-game "/rcon command".

| Name | Description |
| ----- | --------------------------------------------------------------------------------- |
| cmd[] | A string containing the command that was typed, as well as any passed parameters. |
| cmd[] | A string containing the command that was typed, along with any passed parameters. |

## Returns

It is always called first in filterscripts so returning 1 there blocks gamemode from seeing it.
It is always called first in filterscripts so returning 1 on it blocks the main script from processing it.

## Examples

Expand All @@ -39,17 +39,19 @@ public OnRconCommand(cmd[])
## Notes
:::tip
:::warning
The /rcon prefix is not included in the cmd parameter when a player types a command. If you use the print function here, it will send a message to both the player who typed the command in-game and the server log.
"/rcon " is not included in "cmd" when a player types a command. If you use the "print" function here, it will send a message to the player who typed the command in-game as well as the log. This callback is not called when the player is not logged in as RCON admin. When the player is not logged in as RCON admin and uses /rcon login, this callback will not be called and OnRconLoginAttempt is called instead. However, when the player is logged in as RCON admin, the use of this command will call this callback.
This callback is not called if the player is not logged in as an RCON admin. When a player uses /rcon login to log in, this callback will not be called, instead, OnRconLoginAttempt is called. Once logged in as an RCON admin, any subsequent commands will trigger this callback.
:::
:::warning
In SA-MP you will need to include this callback in a loaded filterscript for it to work in the gamemode!
In SA-MP, you need to include this callback in a loaded filterscript for it to work.
But it is fixed in open.mp
However, this issue was fixed in open.mp.
:::
Expand Down
Loading

0 comments on commit 244bfdd

Please sign in to comment.