Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions source/client/main.qc
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@
*/
float need_vid_reload;

// Commands that should be forwarded to the server when typed in the client
string server_forward_commands[] = {
"addmoney",
"infammo",
};

void() ToggleMenu =
{
if (serverkey("constate") != "disconnected")
Expand Down Expand Up @@ -154,6 +160,10 @@ noref void(float apiver, string enginename, float enginever) CSQC_Init =
registercommand("togglemenu");
registercommand("promptjoin");
registercommand("showscores");
// Register server-forwarded commands for console autocomplete
for (float _i = 0; _i < server_forward_commands.length; _i++) {
registercommand(server_forward_commands[_i]);
}

cvar_set("r_fb_models", ftos(0));
autocvar(r_viewmodel_default_fov, 70);
Expand Down Expand Up @@ -850,6 +860,13 @@ noref float(string cmd) CSQC_ConsoleCommand =
score_show = TRUE;
return TRUE;
default:
// If this matches a known server-only command, forward it to server.
for (float _i = 0; _i < server_forward_commands.length; _i++) {
if (argv(0) == server_forward_commands[_i]) {
localcmd(sprintf("cmd %s\n", cmd));
return TRUE;
}
}
return FALSE;
}
return FALSE;
Expand Down
3 changes: 3 additions & 0 deletions source/server/defs/custom.qc
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,9 @@ float ach_tracker_spin;

float global_trace_damage_multiplier;

// Cheats
.float cheat_infiniteammo;

.float has_ads_toggle;
.float ads_release;
.float has_doubletap_damage_buff;
Expand Down
54 changes: 46 additions & 8 deletions source/server/utilities/command_parser.qc
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
commands, and a table storing command information. Modeled after
pr_cmds.

Copyright (C) 2021-2024 NZ:P Team
Copyright (C) 2021-2026 NZ:P Team

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
Expand Down Expand Up @@ -73,21 +73,24 @@ float(string params) Command_addmoney =
bprint(PRINT_HIGH, "Someone tried to issue Add Money in a Co-Op match. Nice try!\n");
return COMMAND_FAILURE;
}

// No parameter provided -> print a helpful message and fail.
if (argv(0) == "") {
sprint(self, 1, "Usage: addmoney <point_value>\n Adds <point_value> amount of points to your score.\n");
return COMMAND_FAILURE;
}
// Grab parameters.
tokenize(params);
float point_value = stof(argv(0));

// Safety checks
if (point_value == 0) {
sprint(self, 1, "Command_addmoney: <point_value> is either zero or blank string. Failing.\n");
return COMMAND_FAILURE;
if (point_value <= 0 && argv(0) != "0" && argv(0) != "0.0") {
sprint(self, 1, "Command_addmoney: <point_value> is either zero or lower or blank string. Failing.\n");
return COMMAND_FAILURE;
}

// Assign points to the player.
Player_ChangeScore(self, point_value, false);
Player_ChangeScore(self, point_value, false);

return COMMAND_SUCCESS;
return COMMAND_SUCCESS;
}

//
Expand Down Expand Up @@ -188,6 +191,40 @@ float(string params) Command_tracedmgmultiplier =
return COMMAND_SUCCESS;
}

//
// Command_infammo()
// Toggles Infinite Ammo.
//
float(string params) Command_infammo =
{
// Anti-Cheat in Co-Op.
if (player_count > 1 && cheats_have_been_activated == false) {
bprint(PRINT_HIGH, "Someone tried to issue Infinite Ammo in a Co-Op match. Nice try!\n");
return COMMAND_FAILURE;
}

self.cheat_infiniteammo = !self.cheat_infiniteammo;

if (self.cheat_infiniteammo) {
// Fill all weapons/reserves immediately so it feels instant.
for (float i = 0; i < MAX_PLAYER_WEAPONS; i++) {
self.weapons[i].weapon_reserve = getWeaponAmmo(self.weapons[i].weapon_id);
self.weapons[i].weapon_magazine = getWeaponMag(self.weapons[i].weapon_id);
if (IsDualWeapon(self.weapons[i].weapon_id))
self.weapons[i].weapon_magazine_left = getWeaponMag(self.weapons[i].weapon_id);
}
self.primary_grenades = 4;
if (self.grenades & 2)
self.secondary_grenades = 2;

sprint(self, 1, "Infinite Ammo: ON\n");
} else {
sprint(self, 1, "Infinite Ammo: OFF\n");
}

return COMMAND_SUCCESS;
}

//
// Command_say()
// Sends message via CSQC to other clients (FTE-only)
Expand Down Expand Up @@ -244,6 +281,7 @@ var struct {
{"give", Command_give, true, "Usage: give <weapon number>\n Gives `weapon` of index.\n"},
{"qc_soft_restart", Command_softrestart, false, "Executes the Soft_Restart QuakeC function. Useful for debugging its functionality.\n"},
{"god", Command_godmode, false, "Toggles God Mode.\n"},
{"infammo", Command_infammo, false, "Toggles Infinite Ammo.\n"},
{"noclip", Command_noclip, false, "Toggles No Clip.\n"},
{"sv_tracedmgmultiplier", Command_tracedmgmultiplier, true, "Multiplies damage output with weapons that fire Traces.\n"},
{"spawn_pu", Command_powerup, true, "Usage: spawn_pu <powerup>\n Spawns a Power-Up of a given ID in front of you. -1 for random.\n"},
Expand Down
17 changes: 15 additions & 2 deletions source/server/weapons/weapon_core.qc
Original file line number Diff line number Diff line change
Expand Up @@ -970,6 +970,17 @@ void(float side) W_Fire =
if (GetFiretype(self.weapon) == FIRETYPE_FLAME && self.cooldown)
return;

// Cheat: keep ammo topped up.
if (self.cheat_infiniteammo) {
self.weapons[0].weapon_reserve = getWeaponAmmo(self.weapon);
self.weapons[0].weapon_magazine = getWeaponMag(self.weapon);
if (IsDualWeapon(self.weapon))
self.weapons[0].weapon_magazine_left = getWeaponMag(self.weapon);
self.primary_grenades = 4;
if (self.grenades & 2)
self.secondary_grenades = 2;
}

if (self.switch_delay > time || self.dive || self.isBuying)
return;

Expand Down Expand Up @@ -1172,10 +1183,12 @@ void(float side) W_Fire =
Sound_PlaySound(self, soundname, SOUND_TYPE_WEAPON_FIRE, SOUND_PRIORITY_PLAYALWAYS);

if (side == S_RIGHT) {
self.weapons[0].weapon_magazine = self.weapons[0].weapon_magazine - 1;
if (!self.cheat_infiniteammo)
self.weapons[0].weapon_magazine = self.weapons[0].weapon_magazine - 1;
self.fire_delay = delay + time;
} else {
self.weapons[0].weapon_magazine_left = self.weapons[0].weapon_magazine_left - 1;
if (!self.cheat_infiniteammo)
self.weapons[0].weapon_magazine_left = self.weapons[0].weapon_magazine_left - 1;
self.fire_delay2 = delay + time;
}

Expand Down