cmds in OnPlayerText(playerid, text[]) with 2 params or more, not work.
public OnPlayerText(playerid, text[])
{
if(text[0] == !)
{
new tmp[64], idx;
tmp = strtok(text, idx);
commands(playerid, 0, tmp, text[strlen(tmp) + 1]);
}
return 1;
}
public OnPlayerCommand(playerid, cmdtext[])
{
new tmp[64], idx;
tmp = strtok(text, idx);
commands(playerid, 1, tmp, text[strlen(tmp) + 1]);
return 1;
}
stock CmdType(type, string[])
{
new str[128];
if(type == 1) format(str, sizeof(str), "* Usage: /c %s", string);
else format(str,sizeof(str), "* Usage: !%s", string);
return str;
}
public commands(playerid, type, cmd[], params[])
{
if(strcmp(params, "wep",true))
{
new weapon[64], ammo[4], wid, am, msg[128];
if(sscanf(params,"sz",weapon, ammo)) return SendMessageToPlayer(playerid, CFG_Color, CmdType(type, "wep <WeaponName/WeaponID> <Ammo>"));
wid = ReturnWeapon(weapon);
if(wid == -1) return SendMessageToPlayer(playerid, CFG_Color, ">> Error: Invalid Weapon!");
if(!strlen(ammo) || !IsNumeric(ammo)) am = 500;
else am = strval(ammo);
format(msg, 128, ">> Weapon Name: %s - Ammo: %d", wid, am);
SendMessageToPlayer(playerid, CFG_Color, msg);
GivePlayerWeapon(playerid, wid, am);
}
return 1;
}