@@ -77,6 +77,80 @@ $decoded = InspectLink::deserialize($hex); // round-trip
7777
7878---
7979
80+ ## Gen codes
81+
82+ Gen codes are space-separated command strings used on CS2 community servers to spawn items.
83+
84+ Format:
85+ ```
86+ !gen {defindex} {paintindex} {paintseed} {paintwear} [{s0_id} {s0_wear} ... {s4_id} {s4_wear}] [{kc_id} {kc_wear} ...]
87+ ```
88+
89+ - Stickers are always represented as 5 slot pairs (padded with ` 0 0 ` for empty slots)
90+ - Keychains are appended without padding, only for present slots
91+ - Float values have trailing zeros stripped (max 8 decimal places); ` 0.0 ` becomes ` "0" `
92+
93+ ### Generate a Steam inspect URL from parameters
94+
95+ ``` php
96+ use VlyDev\Steam\GenCode;
97+
98+ $url = GenCode::generate(
99+ defIndex: 7,
100+ paintIndex: 474,
101+ paintSeed: 306,
102+ paintWear: 0.22540508,
103+ rarity: 6,
104+ );
105+ // steam://rungame/730/76561202255233023/+csgo_econ_action_preview%200018...
106+ ```
107+
108+ ### Convert an ItemPreviewData to a gen code
109+
110+ ``` php
111+ use VlyDev\Steam\GenCode;
112+ use VlyDev\Steam\ItemPreviewData;
113+ use VlyDev\Steam\Sticker;
114+
115+ $item = new ItemPreviewData(
116+ defindex: 7,
117+ paintindex: 474,
118+ paintseed: 306,
119+ paintwear: 0.22540508,
120+ stickers: [
121+ new Sticker(slot: 2, stickerId: 7203),
122+ ],
123+ );
124+
125+ $code = GenCode::toGenCode($item);
126+ // "!gen 7 474 306 0.22540508 0 0 0 0 7203 0 0 0 0 0"
127+
128+ $code = GenCode::toGenCode($item, '!g'); // custom prefix
129+ ```
130+
131+ ### Parse a gen code string
132+
133+ ``` php
134+ use VlyDev\Steam\GenCode;
135+
136+ $item = GenCode::parseGenCode('!gen 7 474 306 0.22540508 0 0 0 0 7203 0 0 0 0 0');
137+ echo $item->defindex; // 7
138+ echo $item->paintindex; // 474
139+ echo $item->paintseed; // 306
140+ echo $item->paintwear; // 0.22540508
141+
142+ $item2 = GenCode::parseGenCode('7 474 306 0.22540508'); // prefix is optional
143+ ```
144+
145+ ### Convert an existing inspect link directly to a gen code
146+
147+ ``` php
148+ $code = GenCode::genCodeFromLink('steam://rungame/730/76561202255233023/+csgo_econ_action_preview%20001A...');
149+ // "!gen 7 474 306 0.22540508"
150+ ```
151+
152+ ---
153+
80154## Validation
81155
82156Use ` isMasked() ` and ` isClassic() ` to detect the link type without attempting to decode it.
0 commit comments