Skip to content

Commit

Permalink
Merge pull request #817 from adib-yg/master
Browse files Browse the repository at this point in the history
Add weapon slots docs
  • Loading branch information
adib-yg authored Jan 9, 2024
2 parents d870a2c + ec19499 commit 4a780a6
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 9 deletions.
27 changes: 21 additions & 6 deletions docs/scripting/functions/GetPlayerWeaponData.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ tags: ["player"]

Get the weapon and ammo in a specific player's weapon slot (e.g. the weapon in the 'SMG' slot).

| Name | Description |
| -------- | ------------------------------------------------------------------------------------------ |
| playerid | The ID of the player whose weapon data to retrieve. |
| slot | The weapon slot to get data for (0-12). |
| &weapons | A variable in which to store the [weapon ID](../resources/weaponids), passed by reference. |
| &ammo | A variable in which to store the ammo, passed by reference. |
| Name | Description |
|------------------|--------------------------------------------------------------------------------------------|
| playerid | The ID of the player whose weapon data to retrieve. |
| WEAPON_SLOT:slot | The [weapon slot](../resources/weaponslots) to get data for (0-12). |
| &WEAPON:weapons | A variable in which to store the [weapon ID](../resources/weaponids), passed by reference. |
| &ammo | A variable in which to store the ammo, passed by reference. |

## Returns

Expand All @@ -35,6 +35,17 @@ for (new i = 0; i <= 12; i++)
}
```

Another example:

```c
new
weaponid,
ammo;

// Get the player weapon ID and ammo in the PISTOL slot
GetPlayerWeaponData(playerid, WEAPON_SLOT_PISTOL, weaponid, ammo);
```
## Notes
:::tip
Expand All @@ -47,3 +58,7 @@ Old weapons with no ammo left are still returned.
- [GetPlayerWeapon](GetPlayerWeapon): Check what weapon a player is currently holding.
- [GivePlayerWeapon](GivePlayerWeapon): Give a player a weapon.
## Related Resources
- [Weapon Slots](../resources/weaponslots).
10 changes: 7 additions & 3 deletions docs/scripting/functions/GetWeaponSlot.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Gets the slot of one weapon.

## Returns

The number of the slot (0 - 12)
The number of the [weapon slot](../resources/weaponslots) (0 - 12)

## Examples

Expand All @@ -26,8 +26,8 @@ public OnPlayerCommandText(playerid, cmdtext[])
if(strcmp(cmdtext, "/weaponslot", true) == 0)
{
new weaponid = GetPlayerWeapon(playerid); // will store the id of the weapon the player is currently holding
new slot = GetWeaponSlot(weaponid); // will store the id of the weapon slot
SendClientMessage(playerid, -1, "Your weapon is occupying the slot %d.", slot); // sends a formatted message to the player
new WEAPON_SLOT:slot = GetWeaponSlot(weaponid); // will store the id of the weapon slot
SendClientMessage(playerid, -1, "Your weapon is occupying the slot %d.", _:slot); // sends a formatted message to the player
return 1;
}

Expand All @@ -42,3 +42,7 @@ public OnPlayerCommandText(playerid, cmdtext[])
- [GetPlayerAmmo](GetPlayerAmmo): Gets the amount of ammo in a player's current weapon..
- [SetPlayerArmedWeapon](SetPlayerArmedWeapon): Sets which weapon (that a player already has) the player is holding.
- [ResetPlayerWeapon](ResetPlayerWeapons): Removes all weapons from a player.
## Related Resources
- [Weapon Slots](../resources/weaponslots).
27 changes: 27 additions & 0 deletions docs/scripting/resources/weaponslots.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
---
title: Weapon Slots
description: Weapon Slots used by GetWeaponSlot and GetPlayerWeaponData.
---

:::info

Weapon Slots used by [GetWeaponSlot](../functions/GetWeaponSlot) and [GetPlayerWeaponData](../functions/GetPlayerWeaponData).

:::

| Definition | Value |
|---------------------------|-------|
| WEAPON_SLOT_UNKNOWN | -1 |
| WEAPON_SLOT_UNARMED | 0 |
| WEAPON_SLOT_MELEE | 1 |
| WEAPON_SLOT_PISTOL | 2 |
| WEAPON_SLOT_SHOTGUN | 3 |
| WEAPON_SLOT_MACHINE_GUN | 4 |
| WEAPON_SLOT_ASSAULT_RIFLE | 5 |
| WEAPON_SLOT_LONG_RIFLE | 6 |
| WEAPON_SLOT_ARTILLERY | 7 |
| WEAPON_SLOT_EXPLOSIVES | 8 |
| WEAPON_SLOT_EQUIPMENT | 9 |
| WEAPON_SLOT_GIFT | 10 |
| WEAPON_SLOT_GADGET | 11 |
| WEAPON_SLOT_DETONATOR | 12 |

0 comments on commit 4a780a6

Please sign in to comment.