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
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>SourcePawn Plugin Generator | Admin Immunity</title>
    <!-- FontAwesome for Icons -->
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
    
    <style>
        :root {
            --bg-dark: #0f172a;
            --bg-panel: #1e293b;
            --accent: #38bdf8;
            --accent-glow: rgba(56, 189, 248, 0.3);
            --text-main: #f1f5f9;
            --text-muted: #94a3b8;
            --border: #334155;
            --code-bg: #0b1116;
            --success: #22c55e;
            --danger: #ef4444;
        }

        * {
            box-sizing: box-box;
            margin: 0;
            padding: 0;
            font-family: 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
        }

        body {
            background-color: var(--bg-dark);
            color: var(--text-main);
            line-height: 1.6;
            min-height: 100vh;
            display: flex;
            flex-direction: column;
            overflow-x: hidden;
        }

        /* Header Styles */
        header {
            background: rgba(15, 23, 42, 0.9);
            border-bottom: 1px solid var(--border);
            padding: 1rem 2rem;
            display: flex;
            justify-content: space-between;
            align-items: center;
            position: sticky;
            top: 0;
            z-index: 100;
            backdrop-filter: blur(10px);
        }

        .brand {
            font-size: 1.25rem;
            font-weight: 700;
            color: var(--accent);
            display: flex;
            align-items: center;
            gap: 10px;
            text-transform: uppercase;
            letter-spacing: 1px;
        }

        .brand i {
            font-size: 1.1rem;
        }

        .anycoder-link {
            font-size: 0.85rem;
            color: var(--text-muted);
            background: var(--bg-panel);
            padding: 0.5rem 1rem;
            border-radius: 6px;
            border: 1px solid var(--border);
            transition: all 0.3s ease;
            text-decoration: none;
            display: flex;
            align-items: center;
            gap: 8px;
        }

        .anycoder-link:hover {
            background: var(--accent);
            color: var(--bg-dark);
            border-color: var(--accent);
            box-shadow: 0 0 15px var(--accent-glow);
        }

        /* Main Layout */
        main {
            display: grid;
            grid-template-columns: 1fr;
            gap: 2rem;
            padding: 2rem;
            max-width: 1400px;
            margin: 0 auto;
            width: 100%;
        }

        @media (min-width: 900px) {
            main {
                grid-template-columns: 1fr 1fr;
                gap: 2rem;
            }
        }

        /* Configuration Panel */
        .config-panel {
            background: var(--bg-panel);
            padding: 2rem;
            border-radius: 12px;
            border: 1px solid var(--border);
            box-shadow: 0 4px 20px rgba(0,0,0,0.2);
            animation: slideIn 0.6s ease-out;
        }

        .panel-title {
            font-size: 1.5rem;
            margin-bottom: 1.5rem;
            color: var(--text-main);
            border-bottom: 2px solid var(--border);
            padding-bottom: 0.5rem;
            display: inline-block;
        }

        .input-group {
            margin-bottom: 1.5rem;
        }

        .input-group label {
            display: block;
            font-size: 0.9rem;
            color: var(--text-muted);
            margin-bottom: 0.5rem;
            font-weight: 600;
        }

        .input-wrapper {
            position: relative;
        }

        input[type="text"], 
        input[type="number"], 
        select {
            width: 100%;
            background: var(--bg-dark);
            border: 1px solid var(--border);
            color: var(--text-main);
            padding: 0.8rem 1rem;
            border-radius: 6px;
            font-size: 0.95rem;
            transition: border-color 0.3s;
        }

        input:focus, select:focus {
            outline: none;
            border-color: var(--accent);
            box-shadow: 0 0 8px var(--accent-glow);
        }

        .checkbox-wrapper {
            display: flex;
            align-items: center;
            gap: 10px;
            cursor: pointer;
        }

        .checkbox-wrapper input {
            width: 18px;
            height: 18px;
            accent-color: var(--accent);
        }

        .checkbox-wrapper span {
            color: var(--text-main);
            font-size: 0.95rem;
        }

        /* Code Output Panel */
        .code-panel {
            background: var(--code-bg);
            padding: 1.5rem;
            border-radius: 12px;
            border: 1px solid var(--border);
            position: relative;
            display: flex;
            flex-direction: column;
            animation: slideIn 0.6s ease-out;
        }

        .code-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 1rem;
        }

        .code-title {
            font-family: 'Courier New', monospace;
            color: var(--accent);
            font-size: 0.9rem;
        }

        .copy-btn {
            background: transparent;
            border: 1px solid var(--border);
            color: var(--text-muted);
            padding: 0.4rem 0.8rem;
            border-radius: 4px;
            cursor: pointer;
            font-size: 0.8rem;
            transition: all 0.2s;
        }

        .copy-btn:hover {
            background: var(--bg-panel);
            color: var(--text-main);
        }

        .copy-btn.copied {
            color: var(--success);
            border-color: var(--success);
        }

        #code-output {
            width: 100%;
            height: 500px;
            background: transparent;
            border: none;
            color: var(--text-muted);
            font-family: 'Courier New', monospace;
            font-size: 0.85rem;
            resize: none;
            white-space: pre;
            overflow-x: auto;
        }

        /* Syntax Highlighting Simulation */
        .keyword { color: #f9a8d4; }
        .function { color: #818cf8; }
        .string { color: #38bdf8; }
        .comment { color: #64748b; }
        .number { color: #f472b6; }

        /* Action Buttons */
        .actions {
            display: flex;
            gap: 1rem;
            margin-top: 2rem;
        }

        .btn {
            padding: 1rem 2rem;
            border-radius: 6px;
            font-weight: 600;
            cursor: pointer;
            border: none;
            transition: transform 0.2s, box-shadow 0.2s;
            text-transform: uppercase;
            font-size: 0.8rem;
            letter-spacing: 1px;
            display: flex;
            align-items: center;
            gap: 8px;
        }

        .btn-primary {
            background: var(--accent);
            color: var(--bg-dark);
            box-shadow: 0 0 10px var(--accent-glow);
        }

        .btn-primary:hover {
            transform: translateY(-2px);
            box-shadow: 0 0 20px var(--accent-glow);
        }

        /* Animations */
        @keyframes slideIn {
            from { opacity: 0; transform: translateY(20px); }
            to { opacity: 1; transform: translateY(0); }
        }

        /* Responsive adjustments */
        @media (max-width: 768px) {
            header { padding: 1rem; }
            main { padding: 1rem; }
            .code-panel { height: auto; }
            #code-output { height: 400px; }
        }
    </style>
</head>
<body>

    <header>
        <div class="brand">
            <i class="fa-solid fa-code"></i>
            SourcePawn Generator
        </div>
        <a href="https://huggingface.co/spaces/akhaliq/anycoder" class="anycoder-link" target="_blank">
            <i class="fa-solid fa-robot"></i> Built with anycoder
        </a>
    </header>

    <main>
        <!-- Left Side: Configuration -->
        <section class="config-panel">
            <h2 class="panel-title">Plugin Configuration</h2>
            
            <div class="input-group">
                <label>Plugin Name</label>
                <input type="text" id="pluginName" value="SafeZone_Killer" placeholder="Name of the plugin">
            </div>

            <div class="input-group">
                <label>Friendly Team ID (Safe Zone)</label>
                <input type="number" id="teamId" value="1" min="1">
                <p class="hint" style="font-size: 0.8rem; color: var(--text-muted); margin-top: 5px;">The ID of the team allowed in this zone.</p>
            </div>

            <div class="input-group">
                <label>Admin Access Level</label>
                <input type="number" id="adminLevel" value="100" min="0">
                <p class="hint">Players with this level or higher will have immunity.</p>
            </div>

            <div class="input-group">
                <label>Map Name</label>
                <input type="text" id="mapName" value="de_dust2">
            </div>

            <div class="input-group">
                <label>Zone Coordinates (X, Y)</label>
                <div style="display: grid; grid-template-columns: 1fr 1fr; gap: 10px;">
                    <input type="number" id="zoneX" placeholder="X" value="1000">
                    <input type="number" id="zoneY" placeholder="Y" value="-2000">
                </div>
            </div>

            <div class="checkbox-wrapper">
                <input type="checkbox" id="instantKill" checked>
                <span>Instant Kill (Skip Damage)</span>
            </div>

            <div class="actions">
                <button class="btn btn-primary" onclick="generateSourcePawn()">
                    <i class="fa-solid fa-bolt"></i> Generate Code
                </button>
            </div>
        </section>

        <!-- Right Side: Output -->
        <section class="code-panel">
            <div class="code-header">
                <span class="code-title">Generated SourcePawn Script</span>
                <button class="copy-btn" onclick="copyCode()">
                    <i class="fa-regular fa-copy"></i> Copy
                </button>
            </div>
            <textarea id="code-output" readonly spellcheck="false"></textarea>
        </section>
    </main>

    <script>
        // Initial generation on load
        window.onload = generateSourcePawn;

        function generateSourcePawn() {
            const pluginName = document.getElementById('pluginName').value || "MyPlugin";
            const teamId = document.getElementById('teamId').value;
            const adminLevel = document.getElementById('adminLevel').value;
            const mapName = document.getElementById('mapName').value;
            const zoneX = document.getElementById('zoneX').value;
            const zoneY = document.getElementById('zoneY').value;
            const isInstantKill = document.getElementById('instantKill').checked;

            // Helper to format syntax highlighting
            const keyword = (text) => `<span class="keyword">${text}</span>`;
            const func = (text) => `<span class="function">${text}</span>`;
            const str = (text) => `<span class="string">"${text}"</span>`;
            const num = (text) => `<span class="number">${text}</span>`;
            const comment = (text) => `<span class="comment">${text}</span>`;

            let codeContent = "";

            // Constructing the raw code string logic first for the textarea
            // This will be inserted into HTML for display
            
            const rawCode = `
#include <amxmodx>
#include <amxmisc>

// Configuration Constants
new const PLUGIN_NAME[] = "${pluginName}";
new const PLUGIN_VERSION[] = "1.0";
new const PLUGIN_AUTHOR[] = "Anycoder";
new const PLUGIN_DESC[] = "Kills enemies entering spawn zones.";

// Variables
new g_friendly_team = ${teamId};
new g_admin_level = ${adminLevel};
new g_zone_x = ${parseFloat(zoneX)};
new g_zone_y = ${parseFloat(zoneY)};

public plugin_init() {
    register_plugin(PLUGIN_NAME, PLUGIN_VERSION, PLUGIN_AUTHOR);
    
    // Register the logic hook
    register_hook("CT_ClientCommand", "Hook_ClientCommand");
    
    log_amx("Plugin Loaded: Map ${mapName}");
}

public Hook_ClientCommand(player) {
    // 1. Check Admin Immunity
    if (get_user_admin(player) >= g_admin_level) {
        return PLUGIN_CONTINUE;
    }

    // 2. Get Player Team
    new team = get_user_team(player);
    
    // 3. Check if player is NOT in the friendly team
    if (team != g_friendly_team) {
        
        // 4. Check Coordinates
        new Float:player_x, Float:player_y, Float:player_z;
        get_user_origin(player, player_x, player_y, player_z);
        
        // Simple distance check or direct coordinate check
        // For this example, we check if they are within 100 units of the target spawn
        if (floatabs(player_x - g_zone_x) < 100.0 && floatabs(player_y - g_zone_y) < 100.0) {
            
            // 5. Execute Kill Logic
            if (${isInstantKill}) {
                // Instant death
                user_kill(player, 1); // 1 = No death message
                client_print(player, print_chat, "You are not allowed here!");
            } else {
                // Damage logic
                set_user_health(player, 0);
            }
        }
    }
    
    return PLUGIN_CONTINUE;
}
`;

            // Render to textarea with simulated highlighting
            const textarea = document.getElementById('code-output');
            textarea.innerHTML = rawCode; // Note: textarea usually takes text, but we are styling it via CSS classes
            
            // Since textarea doesn't render HTML tags inside value, we actually need to use a div for display 
            // OR simply put the text in textarea and use CSS coloring logic? 
            // For a simple single file solution, we will just put the text in the textarea.
            // To make it look "highlighted" without a complex library, we will just output the clean text.
            // But the prompt asked for UI. Let's use a <pre><code> block instead of textarea for better styling.

            textarea.style.display = 'none';
            
            // Create a Code Block
            const codeBlock = document.createElement('pre');
            codeBlock.id = 'syntax-block';
            codeBlock.style.cssText = 'width: 100%; height: 500px; overflow: auto; background: transparent; color: var(--text-muted); font-family: monospace;';
            
            // We need to process the rawCode string to inject spans
            let highlightedCode = rawCode.replace(/(\bnew\b|\bpublic\b|\breturn\b|\bif\b|\belse\b)/g, keyword('$1'));
            highlightedCode = highlightedCode.replace(/(\bregister_plugin\b|\bregister_hook\b|\bget_user_admin\b|\bget_user_team\b|\buser_kill\b|\bset_user_health\b|\bclient_print\b|\bget_user_origin\b)/g, func('$1'));
            highlightedCode = highlightedCode.replace(/(".+")/g, str('$1'));
            highlightedCode = highlightedCode.replace(/\/\/(.+)/g, comment('//$1'));
            highlightedCode = highlightedCode.replace(/\b(\d+)\b/g, num('$1'));

            codeBlock.innerHTML = highlightedCode;
            
            // Clear existing content in code-panel body and append new block
            const container = document.querySelector('.code-panel');
            const existingPre = document.getElementById('syntax-block');
            if(existingPre) existingPre.remove();
            
            // Insert after header
            container.appendChild(codeBlock);
        }

        function copyCode() {
            const rawCode = document.getElementById('code-output').value || document.getElementById('syntax-block').textContent;
            
            // Reconstruct raw text from the HTML if we used the syntax block
            if(document.getElementById('syntax-block')) {
                // We need to grab the text content from the generated HTML block
                const rawText = document.getElementById('syntax-block').textContent;
                
                navigator.clipboard.writeText(rawText).then(() => {
                    const btn = document.querySelector('.copy-btn');
                    btn.innerHTML = '<i class="fa-solid fa-check"></i> Copied';
                    btn.classList.add('copied');
                    
                    setTimeout(() => {
                        btn.innerHTML = '<i class="fa-regular fa-copy"></i> Copy';
                        btn.classList.remove('copied');
                    }, 2000);
                });
            } else {
                // Fallback
                document.getElementById('code-output').focus();
                document.getElementById('code-output').select();
                document.execCommand('copy');
            }
        }
    </script>
</body>
</html>