From 55a34ef36b9c2f18f008dfe2a9488ee4a09c93a7 Mon Sep 17 00:00:00 2001 From: nomi-nonsz Date: Sat, 16 Aug 2025 20:52:02 +0700 Subject: [PATCH] add spawn command --- scripting/admingod.sp | 41 +++++++++++++++++++++++++++++++++++++---- 1 file changed, 37 insertions(+), 4 deletions(-) diff --git a/scripting/admingod.sp b/scripting/admingod.sp index a7e478b..8ec1acb 100644 --- a/scripting/admingod.sp +++ b/scripting/admingod.sp @@ -29,6 +29,20 @@ public void OnPluginStart() { RegAdminCmd("sm_quick_noclip", Command_QuickNoclip, ADMFLAG_SLAY|ADMFLAG_CHEATS); RegAdminCmd("sm_god", Command_Godmode, ADMFLAG_SLAY|ADMFLAG_CHEATS); RegAdminCmd("sm_give", Command_Give, ADMFLAG_SLAY|ADMFLAG_CHEATS); + RegAdminCmd("sm_spawn", Command_Spawn, ADMFLAG_SLAY|ADMFLAG_CHEATS); +} + +public void ExecCommand(int client, char[] command) { + int flagsgive = GetCommandFlags("give"); + int flagszspawn = GetCommandFlags("z_spawn_old"); + + SetCommandFlags("give", flagsgive & ~FCVAR_CHEAT); + SetCommandFlags("z_spawn_old", flagszspawn & ~FCVAR_CHEAT); + + FakeClientCommand(client, cmd); + + SetCommandFlags("give", flagsgive|FCVAR_CHEAT); + SetCommandFlags("z_spawn_old", flagsgive|FCVAR_CHEAT); } public Action Command_QuickNoclip(int client, int args) { @@ -89,10 +103,29 @@ public Action Command_Give(int client, int args) StrCat(cmd, sizeof(cmd), "give "); StrCat(cmd, sizeof(cmd), arg); - int flagsgive = GetCommandFlags("give"); - SetCommandFlags("give", flagsgive & ~FCVAR_CHEAT); - FakeClientCommand(client, cmd); - SetCommandFlags("give", flagsgive|FCVAR_CHEAT); + ExecCommand(client, cmd); + + return Plugin_Handled; +} + +public Action Command_Spawn(int client, int args) +{ + if (!IsClientInGame(client) || !IsPlayerAlive(client)) return Plugin_Handled; + + if (args < 1) + { + ReplyToCommand(client, "[SM] Usage: sm_spawn "); + return Plugin_Handled; + } + + char arg[64]; + GetCmdArg(1, arg, sizeof(arg)); + + char cmd[64]; + StrCat(cmd, sizeof(cmd), "z_spawn_old "); + StrCat(cmd, sizeof(cmd), arg); + + ExecCommand(client, cmd); return Plugin_Handled; } \ No newline at end of file