Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(weapons): Make logic easier #58

Merged
merged 3 commits into from
Dec 2, 2024
Merged
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
2 changes: 1 addition & 1 deletion src/addons/sourcemod/scripting/zombiereloaded.sp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@

#include <sdkhooks>

#define VERSION "3.10.13"
#define VERSION "3.10.14"

// Comment this line to exclude version info command. Enable this if you have
// the repository and HG installed (Mercurial or TortoiseHG).
Expand Down
62 changes: 23 additions & 39 deletions src/addons/sourcemod/scripting/zr/weapons/zmarket.inc
Original file line number Diff line number Diff line change
Expand Up @@ -111,19 +111,16 @@ void ZMarketLoad()

if (FindCharInString(zmarketcommand, ',') != -1)
{
int idx;
int lastidx;
while ((idx = FindCharInString(zmarketcommand[lastidx], ',')) != -1)
char commands[8][32];
int count = ExplodeString(zmarketcommand, ",", commands, sizeof(commands), sizeof(commands[]));

for (int i = 0; i < count; i++)
{
char out[16];
char fmt[8];
Format(fmt, sizeof(fmt), "%%.%ds", idx);
Format(out, sizeof(out), fmt, zmarketcommand[lastidx]);
RegConsoleCmd(out, ZMarketBuyCommand, weaponname);
lastidx += ++idx;

if (FindCharInString(zmarketcommand[lastidx], ',') == -1 && zmarketcommand[lastidx+1] != '\0')
RegConsoleCmd(zmarketcommand[lastidx], ZMarketBuyCommand, weaponname);
TrimString(commands[i]);
if (strlen(commands[i]) > 0)
{
RegConsoleCmd(commands[i], ZMarketBuyCommand, weaponname);
}
}
}
else
Rushaway marked this conversation as resolved.
Show resolved Hide resolved
Expand Down Expand Up @@ -156,41 +153,28 @@ public Action ZMarketBuyCommand(int client, int argc)
{
WeaponsGetZMarketCommand(weaponindex, zmarketcommand, sizeof(zmarketcommand));

if (FindCharInString(zmarketcommand, ',') != -1)
{
int idx;
int lastidx;
while ((idx = FindCharInString(zmarketcommand[lastidx], ',')) != -1)
{
if (!strncmp(command, zmarketcommand[lastidx], idx))
{
WeaponsGetName(weaponindex, weaponname, sizeof(weaponname));
ZMarketEquip(client, weaponname);
return Plugin_Handled;
}

lastidx += ++idx;
// Split the commands and check each one
char commands[8][32];
int count = ExplodeString(zmarketcommand, ",", commands, sizeof(commands), sizeof(commands[]));

if (FindCharInString(zmarketcommand[lastidx], ',') == -1 && zmarketcommand[lastidx+1] != '\0')
{
if (!strncmp(command, zmarketcommand[lastidx], idx))
{
WeaponsGetName(weaponindex, weaponname, sizeof(weaponname));
ZMarketEquip(client, weaponname);
return Plugin_Handled;
}
}
}
}
else
for (int i = 0; i < count; i++)
{
if(strcmp(command, zmarketcommand, false) == 0)
TrimString(commands[i]);
if (strcmp(command, commands[i], false) == 0)
{
WeaponsGetName(weaponindex, weaponname, sizeof(weaponname));
ZMarketEquip(client, weaponname);
return Plugin_Handled;
}
}

// Also check for single command case
if (strcmp(command, zmarketcommand, false) == 0)
Rushaway marked this conversation as resolved.
Show resolved Hide resolved
{
WeaponsGetName(weaponindex, weaponname, sizeof(weaponname));
ZMarketEquip(client, weaponname);
return Plugin_Handled;
}
}

return Plugin_Handled;
Expand Down