Code:
Delete all arg1 references, delete that section that starts at /** *target_name and goes to for new...{
Change all target_list[i] to client.
Oh, and changes args != 2 to 1 and args != 3 to 2, and args == 3 to 2.
And GetCmdArg(2...) to GetCmdArg(1...) but not the arg2, sizeof... stuff.
Followed this...."guide". Ran into problems.
You didn't reference target_list (you only referenced target_list[i]), "if (tn_is_ml)". When I compiled the plugin after only following your changes, I ended up getting a bunch of errors relating to target_list and tn_is_ml. I ended up replacing "target_list" with "client" and "tn_is_ml"...well as you'll see in the code below, I flat-out removed that stuff.
I was trying to change sm_giveweapon, sm_giveweapon_ex and sm_resetex so that they don't require a player name to operate. sm_giveweapon_ex seems to work...kinda....if you're not holding a melee weapon when you go to give yourself a different melee weapon, nothing happens. And console still spits out "Unknown Command".
Code:
public Action:Command_WeaponEx(client, args)
{
decl String:arg2[32];
decl String:arg3[32];
new weaponLookupIndex = 0;
new mode = 0;
if (args != 1 && args != 2)
{
ReplyToCommand(client, "[TF2Items] Usage: sm_giveweapon_ex <player> <itemindex> [givenow]");
return Plugin_Handled;
}
/* Get the arguments */
GetCmdArg(1, arg2, sizeof(arg2));
if (args == 2)
{
GetCmdArg(3, arg3, sizeof(arg3));
mode = StringToInt(arg3);
}
weaponLookupIndex = StringToInt(arg2);
mode = StringToInt(arg3);
{
new weaponSlot;
new String:formatBuffer[32];
Format(formatBuffer, 32, "%d_%s", weaponLookupIndex, "slot");
new bool:isValidItem = GetTrieValue(g_hItemInfoTrie, formatBuffer, weaponSlot);
if (!isValidItem)
{
ReplyToCommand(client, "[TF2Items] Invalid Weapon Index");
return Plugin_Handled;
}
ReplyToCommand(client, "[TF2Items] Respawn or touch a locker to recieve your permanent weapon.");
g_hItems[client][weaponSlot] = weaponLookupIndex;
if (mode == 1) Command_WeaponBase(client, weaponLookupIndex, weaponSlot);
LogAction(client, client, "\"%L\" gave a permanent weapon to \"%L\"", client, weaponLookupIndex, client);
}
return Plugin_Handled;
}
public Action:Command_ResetEx(client, args)
{
new String:arg1[32];
if (args != 1)
{
ReplyToCommand(client, "[TF2Items] Usage: sm_resetex <target>");
return Plugin_Handled;
}
/* Get the arguments */
GetCmdArg(1, arg1, sizeof(arg1));
{
for (new slot = 0; slot < 6; slot++)
{
if (g_hItems[client][slot] != -1) g_hItems[client][slot] = -1;
}
LogAction(client, client, "\"%L\" reset permanent weapons for \"%L\"", client, client);
}
return Plugin_Handled;
}
public Action:Command_Weapon(client, args)
{
new String:arg2[32];
new weaponLookupIndex = 0;
if (args != 1) {
ReplyToCommand(client, "[TF2Items] Usage: sm_giveweapon <player> <itemindex>");
return Plugin_Handled;
}
/* Get the arguments */
GetCmdArg(1, arg2, sizeof(arg2));
weaponLookupIndex = StringToInt(arg2);
{
new weaponSlot;
new String:formatBuffer[32];
Format(formatBuffer, 32, "%d_%s", weaponLookupIndex, "slot");
new bool:isValidItem = GetTrieValue(g_hItemInfoTrie, formatBuffer, weaponSlot);
if (!isValidItem)
{
ReplyToCommand(client, "[TF2Items] Invalid Weapon Index");
return Plugin_Handled;
}
Command_WeaponBase(client, weaponLookupIndex, weaponSlot);
LogAction(client, client, "\"%L\" gave a weapon to \"%L\"", client, weaponLookupIndex, client);
}
return Plugin_Handled;
}
Now, it'd be nifty if you could do me a huge favour. Seeing as the steps you posted above were good...kind of...but they still ended up leaving me with a hardly-working plugin, could you go through what's left of my code above, and fix it up so that it works properly and doesn't require a player name input?
I'd love to spend all day and night working on it, but I'm leaving for Florida tomorrow, and won't be back until the 30th. I've gotta be heading to bed now. I might be able to slide on my laptop early tomorrow before I leave though.