Skip to content

Commit 8414e4e

Browse files
Finish weapons list
1 parent bc9bc7d commit 8414e4e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+169
-39
lines changed

assets/images/Weapons/0.png

1012 Bytes

assets/images/Weapons/0.webp

-862 Bytes
Binary file not shown.

assets/images/Weapons/1.png

1.42 KB

assets/images/Weapons/1.webp

-940 Bytes
Binary file not shown.

assets/images/Weapons/10.png

2.19 KB

assets/images/Weapons/11.png

2.58 KB

assets/images/Weapons/12.png

2.32 KB

assets/images/Weapons/13.png

1.59 KB

assets/images/Weapons/14.png

2.09 KB

assets/images/Weapons/15.png

902 Bytes

assets/images/Weapons/16.png

1.68 KB

assets/images/Weapons/17.png

1.81 KB

assets/images/Weapons/18.png

2.68 KB

assets/images/Weapons/2.png

838 Bytes

assets/images/Weapons/22.png

1.34 KB

assets/images/Weapons/23.png

1.59 KB

assets/images/Weapons/24.png

1.08 KB

assets/images/Weapons/25.png

1.98 KB

assets/images/Weapons/26.png

1.86 KB

assets/images/Weapons/27.png

2.51 KB

assets/images/Weapons/28.png

984 Bytes

assets/images/Weapons/29.png

1.44 KB

assets/images/Weapons/3.png

1.24 KB

assets/images/Weapons/30.png

2.3 KB

assets/images/Weapons/31.png

2.18 KB

assets/images/Weapons/32.png

862 Bytes

assets/images/Weapons/33.png

1.67 KB

assets/images/Weapons/34.png

1.47 KB

assets/images/Weapons/35.png

2.04 KB

assets/images/Weapons/36.png

2.29 KB

assets/images/Weapons/37.png

1.43 KB

assets/images/Weapons/38.png

1.72 KB

assets/images/Weapons/39.png

1.54 KB

assets/images/Weapons/4.png

2.14 KB

assets/images/Weapons/40.png

1.17 KB

assets/images/Weapons/41.png

3.06 KB

assets/images/Weapons/42.png

1.42 KB

assets/images/Weapons/43.png

1.93 KB

assets/images/Weapons/44.png

1.92 KB

assets/images/Weapons/45.png

1.92 KB

assets/images/Weapons/46.png

1.5 KB

assets/images/Weapons/5.png

1.04 KB

assets/images/Weapons/6.png

1.23 KB

assets/images/Weapons/7.png

453 Bytes

assets/images/Weapons/8.png

932 Bytes

assets/images/Weapons/9.png

2.29 KB
Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
import os
2+
import requests
3+
from bs4 import BeautifulSoup
4+
from urllib.parse import urljoin
5+
6+
BASE_URL = "https://wiki.multitheftauto.com"
7+
TARGET_URL = f"{BASE_URL}/Weapons"
8+
OUTPUT_DIR = "weapon_images"
9+
TS_OUTPUT_FILE = "weapons.ts"
10+
11+
os.makedirs(OUTPUT_DIR, exist_ok=True)
12+
13+
response = requests.get(TARGET_URL)
14+
soup = BeautifulSoup(response.text, "html.parser")
15+
16+
table = soup.select_one("table.wikitable")
17+
weapons = []
18+
19+
# These keep track of rowspan values
20+
current_slot = None
21+
current_type = None
22+
current_ammo = None
23+
current_bsync = None
24+
rowspan_tracker = {
25+
"slot": 0,
26+
"type": 0,
27+
"ammo": 0,
28+
"bsync": 0
29+
}
30+
31+
rows = table.select("tr")[1:]
32+
33+
for row in rows:
34+
cells = row.find_all(["td", "th"])
35+
cell_idx = 0
36+
37+
# Handle rowspan cells
38+
if rowspan_tracker["slot"] == 0:
39+
current_slot = cells[cell_idx].get_text(strip=True)
40+
rowspan_tracker["slot"] = int(cells[cell_idx].get("rowspan", 1)) - 1
41+
cell_idx += 1
42+
else:
43+
rowspan_tracker["slot"] -= 1
44+
45+
if rowspan_tracker["type"] == 0:
46+
current_type = cells[cell_idx].get_text(strip=True)
47+
rowspan_tracker["type"] = int(cells[cell_idx].get("rowspan", 1)) - 1
48+
cell_idx += 1
49+
else:
50+
rowspan_tracker["type"] -= 1
51+
52+
# Now parse fixed columns: Image, Name, ID, Model ID, Clip
53+
if cell_idx + 5 > len(cells):
54+
continue # malformed row
55+
56+
image_tag = cells[cell_idx].select_one("img")
57+
image_url = urljoin(BASE_URL, image_tag["src"]) if image_tag else None
58+
image_page = urljoin(BASE_URL, cells[cell_idx].find("a")["href"]) if cells[cell_idx].find("a") else None
59+
cell_idx += 1
60+
61+
name = cells[cell_idx].get_text(strip=True)
62+
cell_idx += 1
63+
weapon_id = cells[cell_idx].get_text(strip=True)
64+
cell_idx += 1
65+
model_id = cells[cell_idx].get_text(strip=True)
66+
cell_idx += 1
67+
clip = cells[cell_idx].get_text(strip=True)
68+
cell_idx += 1
69+
70+
# Handle ammo sharing
71+
if rowspan_tracker["ammo"] == 0:
72+
current_ammo = cells[cell_idx].get_text(strip=True)
73+
rowspan_tracker["ammo"] = int(cells[cell_idx].get("rowspan", 1)) - 1
74+
cell_idx += 1
75+
else:
76+
rowspan_tracker["ammo"] -= 1
77+
78+
# Handle bullet sync
79+
if rowspan_tracker["bsync"] == 0:
80+
current_bsync = cells[cell_idx].get_text(strip=True)
81+
rowspan_tracker["bsync"] = int(cells[cell_idx].get("rowspan", 1)) - 1
82+
else:
83+
rowspan_tracker["bsync"] -= 1
84+
85+
# DL images
86+
87+
# image_filename = None
88+
# if image_page:
89+
# img_page_resp = requests.get(image_page)
90+
# img_soup = BeautifulSoup(img_page_resp.text, "html.parser")
91+
# full_image_tag = img_soup.select_one("#file > a")
92+
# if full_image_tag and full_image_tag["href"]:
93+
# full_image_url = urljoin(BASE_URL, full_image_tag["href"])
94+
# ext = os.path.splitext(full_image_url)[-1]
95+
# image_filename = f"{weapon_id}{ext}"
96+
# image_path = os.path.join(OUTPUT_DIR, image_filename)
97+
98+
# if not os.path.exists(image_path):
99+
# img_data = requests.get(full_image_url).content
100+
# with open(image_path, "wb") as f:
101+
# f.write(img_data)
102+
103+
weapons.append({
104+
"slot": int(current_slot),
105+
"type": current_type,
106+
"name": name,
107+
"id": int(weapon_id),
108+
"modelId": int(model_id) if model_id.isdigit() else None,
109+
"clip": clip if clip != "-" else None,
110+
"sharingAmmoSlot": current_ammo if current_ammo != "-" else None,
111+
"bulletSync": current_bsync.lower().startswith("yes"),
112+
})
113+
114+
with open(TS_OUTPUT_FILE, "w", encoding="utf-8") as f:
115+
f.write("const weapons = ")
116+
f.write(str(weapons).replace("None", "null").replace("True", "true").replace("False", "false"))
117+
f.write(";\n")
118+

web/src/pages/reference/ID_Lists/Weapons.astro

Lines changed: 51 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -11,20 +11,15 @@ import { getAssetImagePath } from '@src/utils/general';
1111
1212
import NoteBox from '@src/components/NoteBox.astro';
1313
14-
const weaponsBySlot = {
15-
0: [
16-
{ id: 0, name: 'Fist', type: 'Hand', modelId: null, sharingSlotAmmo: false, bulletSync: false },
17-
{ id: 1, name: 'Brass Knuckles', type: 'Hand', modelId: 331, sharingSlotAmmo: false, bulletSync: false }
18-
],
19-
}
14+
const weapons = [{'slot': 0, 'type': 'Hand', 'name': 'Fist', 'id': 0, 'modelId': null, 'clip': null, 'sharingAmmoSlot': null, 'bulletSync': false}, {'slot': 0, 'type': 'Hand', 'name': 'Brassknuckle', 'id': 1, 'modelId': 331, 'clip': null, 'sharingAmmoSlot': null, 'bulletSync': false}, {'slot': 1, 'type': 'Melee', 'name': 'Golfclub', 'id': 2, 'modelId': 333, 'clip': null, 'sharingAmmoSlot': null, 'bulletSync': false}, {'slot': 1, 'type': 'Melee', 'name': 'Nightstick', 'id': 3, 'modelId': 334, 'clip': null, 'sharingAmmoSlot': null, 'bulletSync': false}, {'slot': 1, 'type': 'Melee', 'name': 'Knife', 'id': 4, 'modelId': 335, 'clip': null, 'sharingAmmoSlot': null, 'bulletSync': false}, {'slot': 1, 'type': 'Melee', 'name': 'Bat', 'id': 5, 'modelId': 336, 'clip': null, 'sharingAmmoSlot': null, 'bulletSync': false}, {'slot': 1, 'type': 'Melee', 'name': 'Shovel', 'id': 6, 'modelId': 337, 'clip': null, 'sharingAmmoSlot': null, 'bulletSync': false}, {'slot': 1, 'type': 'Melee', 'name': 'Poolstick', 'id': 7, 'modelId': 338, 'clip': null, 'sharingAmmoSlot': null, 'bulletSync': false}, {'slot': 1, 'type': 'Melee', 'name': 'Katana', 'id': 8, 'modelId': 339, 'clip': null, 'sharingAmmoSlot': null, 'bulletSync': false}, {'slot': 1, 'type': 'Melee', 'name': 'Chainsaw', 'id': 9, 'modelId': 341, 'clip': null, 'sharingAmmoSlot': null, 'bulletSync': false}, {'slot': 2, 'type': 'Handguns', 'name': 'Colt 45', 'id': 22, 'modelId': 346, 'clip': '17 (34)', 'sharingAmmoSlot': 'NoReplacing handgun resets slot 2 ammo', 'bulletSync': true}, {'slot': 2, 'type': 'Handguns', 'name': 'Silenced', 'id': 23, 'modelId': 347, 'clip': '17', 'sharingAmmoSlot': 'NoReplacing handgun resets slot 2 ammo', 'bulletSync': true}, {'slot': 2, 'type': 'Handguns', 'name': 'Deagle', 'id': 24, 'modelId': 348, 'clip': '7', 'sharingAmmoSlot': 'NoReplacing handgun resets slot 2 ammo', 'bulletSync': true}, {'slot': 3, 'type': 'Shotguns', 'name': 'Shotgun', 'id': 25, 'modelId': 349, 'clip': '1', 'sharingAmmoSlot': 'Yes', 'bulletSync': true}, {'slot': 3, 'type': 'Shotguns', 'name': 'Sawed-off', 'id': 26, 'modelId': 350, 'clip': '2 (4)', 'sharingAmmoSlot': 'Yes', 'bulletSync': true}, {'slot': 3, 'type': 'Shotguns', 'name': 'Combat Shotgun', 'id': 27, 'modelId': 351, 'clip': '7', 'sharingAmmoSlot': 'Yes', 'bulletSync': true}, {'slot': 4, 'type': 'Sub-Machine Guns', 'name': 'Uzi', 'id': 28, 'modelId': 352, 'clip': '50 (100)', 'sharingAmmoSlot': 'Yes', 'bulletSync': true}, {'slot': 4, 'type': 'Sub-Machine Guns', 'name': 'MP5', 'id': 29, 'modelId': 353, 'clip': '30', 'sharingAmmoSlot': 'Yes', 'bulletSync': true}, {'slot': 4, 'type': 'Sub-Machine Guns', 'name': 'Tec-9', 'id': 32, 'modelId': 372, 'clip': '50 (100)', 'sharingAmmoSlot': 'Yes', 'bulletSync': true}, {'slot': 5, 'type': 'Assault Rifles', 'name': 'AK-47', 'id': 30, 'modelId': 355, 'clip': '30', 'sharingAmmoSlot': 'Yes', 'bulletSync': true}, {'slot': 5, 'type': 'Assault Rifles', 'name': 'M4', 'id': 31, 'modelId': 356, 'clip': '50', 'sharingAmmoSlot': 'Yes', 'bulletSync': true}, {'slot': 6, 'type': 'Rifles', 'name': 'Rifle', 'id': 33, 'modelId': 357, 'clip': '1', 'sharingAmmoSlot': 'NoReplacing rifle resets slot 6 ammo', 'bulletSync': true}, {'slot': 6, 'type': 'Rifles', 'name': 'Sniper', 'id': 34, 'modelId': 358, 'clip': '1', 'sharingAmmoSlot': 'NoReplacing rifle resets slot 6 ammo', 'bulletSync': true}, {'slot': 7, 'type': 'Heavy Weapons', 'name': 'Rocket Launcher', 'id': 35, 'modelId': 359, 'clip': '1', 'sharingAmmoSlot': 'NoReplacing heavy weapon resets slot 7 ammo', 'bulletSync': false}, {'slot': 7, 'type': 'Heavy Weapons', 'name': 'Rocket Launcher HS', 'id': 36, 'modelId': 360, 'clip': '1', 'sharingAmmoSlot': 'NoReplacing heavy weapon resets slot 7 ammo', 'bulletSync': false}, {'slot': 7, 'type': 'Heavy Weapons', 'name': 'Flamethrower', 'id': 37, 'modelId': 361, 'clip': '50', 'sharingAmmoSlot': 'NoReplacing heavy weapon resets slot 7 ammo', 'bulletSync': false}, {'slot': 7, 'type': 'Heavy Weapons', 'name': 'Minigun', 'id': 38, 'modelId': 362, 'clip': '500', 'sharingAmmoSlot': 'NoReplacing heavy weapon resets slot 7 ammo', 'bulletSync': false}, {'slot': 8, 'type': 'Projectiles', 'name': 'Grenade', 'id': 16, 'modelId': 342, 'clip': '1', 'sharingAmmoSlot': 'NoReplacing projectile resets slot 8 ammo', 'bulletSync': false}, {'slot': 8, 'type': 'Projectiles', 'name': 'Teargas', 'id': 17, 'modelId': 343, 'clip': '1', 'sharingAmmoSlot': 'NoReplacing projectile resets slot 8 ammo', 'bulletSync': false}, {'slot': 8, 'type': 'Projectiles', 'name': 'Molotov', 'id': 18, 'modelId': 344, 'clip': '1', 'sharingAmmoSlot': 'NoReplacing projectile resets slot 8 ammo', 'bulletSync': false}, {'slot': 8, 'type': 'Projectiles', 'name': 'Satchel', 'id': 39, 'modelId': 363, 'clip': '1', 'sharingAmmoSlot': 'NoReplacing projectile resets slot 8 ammo', 'bulletSync': false}, {'slot': 9, 'type': 'Special 1', 'name': 'Spraycan', 'id': 41, 'modelId': 365, 'clip': '500', 'sharingAmmoSlot': 'NoReplacing slot 9 weapon resets slot 9 ammo', 'bulletSync': false}, {'slot': 9, 'type': 'Special 1', 'name': 'Fire Extinguisher', 'id': 42, 'modelId': 366, 'clip': '500', 'sharingAmmoSlot': 'NoReplacing slot 9 weapon resets slot 9 ammo', 'bulletSync': false}, {'slot': 9, 'type': 'Special 1', 'name': 'Camera', 'id': 43, 'modelId': 367, 'clip': '36', 'sharingAmmoSlot': 'NoReplacing slot 9 weapon resets slot 9 ammo', 'bulletSync': false}, {'slot': 10, 'type': 'Gifts', 'name': 'Dildo', 'id': 10, 'modelId': 321, 'clip': null, 'sharingAmmoSlot': null, 'bulletSync': false}, {'slot': 10, 'type': 'Gifts', 'name': 'Purple Dildo', 'id': 11, 'modelId': 322, 'clip': null, 'sharingAmmoSlot': null, 'bulletSync': false}, {'slot': 10, 'type': 'Gifts', 'name': 'Vibrator', 'id': 12, 'modelId': 323, 'clip': null, 'sharingAmmoSlot': null, 'bulletSync': false}, {'slot': 10, 'type': 'Gifts', 'name': 'Silver Vibrator', 'id': 13, 'modelId': 324, 'clip': null, 'sharingAmmoSlot': null, 'bulletSync': false}, {'slot': 10, 'type': 'Gifts', 'name': 'Flower', 'id': 14, 'modelId': 325, 'clip': null, 'sharingAmmoSlot': null, 'bulletSync': false}, {'slot': 10, 'type': 'Gifts', 'name': 'Cane', 'id': 15, 'modelId': 326, 'clip': null, 'sharingAmmoSlot': null, 'bulletSync': false}, {'slot': 11, 'type': 'Special 2', 'name': 'Nightvision', 'id': 44, 'modelId': 368, 'clip': null, 'sharingAmmoSlot': null, 'bulletSync': false}, {'slot': 11, 'type': 'Special 2', 'name': 'Infrared', 'id': 45, 'modelId': 369, 'clip': null, 'sharingAmmoSlot': null, 'bulletSync': false}, {'slot': 11, 'type': 'Special 2', 'name': 'Parachute', 'id': 46, 'modelId': 371, 'clip': null, 'sharingAmmoSlot': null, 'bulletSync': false}, {'slot': 12, 'type': 'Satchel Detonator', 'name': 'Bomb', 'id': 40, 'modelId': 364, 'clip': null, 'sharingAmmoSlot': null, 'bulletSync': false}];
2015
2116
---
2217
<StarlightPage frontmatter={{
2318
template: 'doc',
2419
title: 'Weapons',
2520
tableOfContents: false,
2621
}}>
27-
<p>Scripting functions that ask for a <strong>Weapon ID</strong> need an integer that refers to the GTASA weapon ID list. They are listed below. Each weapon corresponds to an object model in-game.</p>
22+
<p>Scripting functions that ask for a <strong>Weapon ID</strong> need an integer that refers to the GTASA weapon ID list, defined below. Each weapon is represented by an object that is identified by its model ID.</p>
2823

2924
<NoteBox type='info'>Weapon <strong>Name</strong> is compatible with functions <a href="/reference/getWeaponNameFromID">getWeaponNameFromID</a> and <a href="/reference/getWeaponIDFromName">getWeaponIDFromName</a>.</NoteBox>
3025
<NoteBox type='info'><strong>Bullet Sync</strong> refers to whether they are triggered by the <a href="/reference/onPlayerWeaponFire">onPlayerWeaponFire</a> event.</NoteBox>
@@ -42,50 +37,56 @@ const weaponsBySlot = {
4237
<th>ID</th>
4338
<th>Model ID</th>
4439
<th>Clip</th>
45-
<th>Sharing slot ammo</th>
4640
<th>Bullet Sync</th>
4741
</tr>
4842
</thead>
4943
<tbody>
50-
{Object.entries(weaponsBySlot).map(([slotId, weapons]) => (
51-
weapons.map((weapon) => (
52-
<tr>
53-
<td>{slotId}</td>
54-
<td>{weapon.type}</td>
55-
<td>
56-
<Image src={getAssetImagePath("Weapons/" + weapon.id + ".webp")} alt={weapon.name}
57-
class="weapon-image" />
58-
</td>
59-
<td>{weapon.name}</td>
60-
<td>{weapon.id}</td>
61-
<td>{weapon.modelId}</td>
62-
<td>{weapon.clipSize || '-'}</td>
63-
<td>{weapon.sharingSlotAmmo}</td>
64-
<td>{weapon.bulletSync ? 'Yes' : 'No'}</td>
65-
</tr>
66-
))
44+
{weapons.map((weapon) => (
45+
<tr>
46+
<td>{weapon.slot}
47+
{weapon.sharingAmmoSlot && <span class="color-special">*</span>}</td>
48+
<td>{weapon.type}</td>
49+
<td class="weapon-image-container">
50+
<Image src={getAssetImagePath("Weapons/" + weapon.id + ".png")} alt={weapon.name}
51+
class="weapon-image" />
52+
</td>
53+
<td><code>{weapon.name}</code></td>
54+
<td><code>{weapon.id}</code></td>
55+
<td><a target="_blank" href={"https://dev.prineside.com/en/gtasa_samp_model_id/model/" + weapon.modelId}>{weapon.modelId}</a></td>
56+
<td>{weapon.clip || '-'}</td>
57+
<td class={weapon.bulletSync ? 'color-yes' : ''}>{weapon.bulletSync ? 'Yes' : 'No'}</td>
58+
</tr>
6759
))}
6860
</tbody>
6961
</table>
7062

63+
<h5><span class="color-special">*</span> Sharing slot ammo:</h5>
64+
<ul>
65+
<li><strong>Slot 2 (Handguns)</strong>: Replacing handgun resets slot 2 ammo</li>
66+
<li><strong>Slot 6 (Rifles)</strong>: Replacing rifle resets slot 6 ammo</li>
67+
<li><strong>Slot 7 (Heavy Weapons)</strong>: Replacing heavy weapon resets slot 7 ammo</li>
68+
<li><strong>Slot 8 (Projectiles)</strong>: Replacing projectile resets slot 8 ammo</li>
69+
<li><strong>Slot 9 (Special 1)</strong>: Replacing slot 9 weapon resets slot 9 ammo</li>
70+
</ul>
71+
7172
<section data-pagefind-ignore>
7273
<h5>Lua tables with weapons:</h5>
7374
<Code lang="lua" code={`
7475
local weaponIDs = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 22, 23, 24, 25, 26, 27, 28, 29, 32, 30, 31, 33, 34, 35, 36, 37, 38, 16, 17, 18, 39, 41, 42, 43, 10, 11, 12, 13, 14, 15, 44, 45, 46, 40}
7576
local weaponIDsBySlot = {
76-
[0] = {0, 1}, -- hand
77-
[1] = {2, 3, 4, 5, 6, 7, 8, 9}, -- melee
78-
[2] = {22, 23, 24}, -- handguns
79-
[3] = {25, 26, 27}, -- shotguns
80-
[4] = {28, 29, 32}, -- sub-machine guns
81-
[5] = {30, 31}, -- assault rifles
82-
[6] = {33, 34}, -- rifles
83-
[7] = {35, 36, 37, 38}, -- heavy weapons
84-
[8] = {16, 17, 18, 39}, -- projectiles
85-
[9] = {41, 42, 43}, -- special 1
86-
[10] = {10, 11, 12, 13, 14, 15}, -- gifts
87-
[11] = {44, 45, 46}, -- special 2
88-
[12] = {40}, -- satchel detonator
77+
[0] = {0, 1}, -- Hand
78+
[1] = {2, 3, 4, 5, 6, 7, 8, 9}, -- Melee
79+
[2] = {22, 23, 24}, -- Handguns
80+
[3] = {25, 26, 27}, -- Shotguns
81+
[4] = {28, 29, 32}, -- Sub-Machine Guns
82+
[5] = {30, 31}, -- Assault Rifles
83+
[6] = {33, 34}, -- Rifles
84+
[7] = {35, 36, 37, 38}, -- Heavy Weapons
85+
[8] = {16, 17, 18, 39}, -- Projectiles
86+
[9] = {41, 42, 43}, -- Special 1
87+
[10] = {10, 11, 12, 13, 14, 15},-- Gifts
88+
[11] = {44, 45, 46}, -- Special 2
89+
[12] = {40}, -- Satchel Detonator
8990
}`} />
9091
</section>
9192

@@ -100,8 +101,19 @@ local weaponIDsBySlot = {
100101
overflow-x: auto;
101102
white-space: nowrap;
102103
}
104+
.weapon-image-container {
105+
background-color: rgba(255, 255, 255, 1);
106+
border-radius: 10px;
107+
margin: 0 auto;
108+
}
103109
.weapon-image {
104110
max-width: 50px;
105-
height: auto;
111+
}
112+
.color-special {
113+
color: red;
114+
font-weight: bold;
115+
}
116+
.color-yes {
117+
color: var(--color-mta-orange);
106118
}
107119
</style>

0 commit comments

Comments
 (0)