12.06.2014, 18:01
Acutally, sscanf is a better way than strtok, your command will become like that using it
(If you wanna keep using the '/' in the command name, simply remove the " '/' " when you use the "sscanf" function on cmdtext)
pawn Код:
#include <sscanf2>
public OnPlayerCommandText(playerid, cmdtext[])
{
new cmd[33], params[128];
sscanf(cmdtext, "'/'s[33]s[128]", cmd, params);
if(!strcmp(cmd, "selldrugs", true) || !strcmp(cmd, "sd", true))
{
new gpid, drugname[21], amount, price;
if(sscanf(params, "us[21]dd", gpid, drugname, amount, price))
{
SendClientMessage(playerid, -1, "{FF6A22}USAGE: {FFFFFF}/selldrugs (/sd) [playerid] [drugname] [amount] [price]");
return SendClientMessage(playerid, -1, "{FF6A22}Available names: {FFFFFF}Weed, Cocaine, Crack, Meth, Ectasy, Heroin");
}
if(!IsPlayerConnected(gpid)) return SendClientMessage(playerid, -1, "The player isn't connected !");
if(ProxDetectorS(8.0, playerid, gpid))
{
if(!strcmp(drugname,"weed",true))
{
format(string, sizeof(string), "* You offered to sell %d grams of weed to %s for $%d, Wait for a reply.", needed, giveplayer, price);
SendClientMessage(playerid, 0x33CCFFAA, string);
//
format(string, sizeof(string), "* %s wants to sell %d grams of weed to you for $%d, (type /acceptdrugs cocaine) to buy.", sendername, needed, price);
SendClientMessage(gpid, 0x33CCFFAA, string);
}
}
else
{
SendClientMessage(playerid, -1, "{FF6A22}INFO:{FFFFFF} That player isn't enough close");
}
return 1;
}
}