anycoder-1ea3ac17 / index.html
Crossper6's picture
Upload folder using huggingface_hub
3a36e46 verified
<!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>