new string[256];
format(string, sizeof(string), "%d %d %d", playerid1, playerid2, amount);
if(!strcmp(string, "0 8 9999", false)) // if the string corresponds to playerid1 = 0; playerid 2 = 8 and amount = 9999, do :
don't say use sscanf,y_ini what ever I want with strcmp,thanks. |
if(strcmp(cmd, "/selldrugs", true) == 0 || strcmp(cmd, "/sd", true) == 0)
{
new string[256];
new tmp[256];
new giveplayer[MAX_PLAYER_NAME];
new sendername[MAX_PLAYER_NAME];
new gpid = ReturnUser(tmp);
new price;
new needed;
new x_nr[256];
x_nr = strtok(cmdtext, idx);
tmp = strtok(cmdtext, idx);
GetPlayerName(gpid, giveplayer, sizeof(giveplayer));
GetPlayerName(playerid, sendername, sizeof(sendername));
if(IsPlayerConnected(gpid))
{
if(!strlen(tmp))
{
SendClientMessage(playerid, -1, "{FF6A22}INFO: {FFFFFF}/selldrugs (/sd) [playerid] [drugname] [amount] [price]");
return 1;
}
if(!strlen(x_nr))
{
SendClientMessage(playerid, -1, "{FF6A22}USAGE: {FFFFFF}/selldrugs (/sd) [playerid] [drugname] [amount] [price]");
SendClientMessage(playerid, -1, "{FF6A22}Available names: {FFFFFF}Weed, Cocaine, Crack, Meth, Ectasy, Heroin");
return 1;
}
if(gpid != INVALID_PLAYER_ID)
{
if(ProxDetectorS(8.0, playerid, gpid))
{
if(strcmp(x_nr,"weed",true) == 0)
{
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");
}
} // invalid player ID
}
else
{
SendClientMessage(playerid, -1, "{FF6A22}INFO:{FFFFFF} Invalid player ID.");
}
return 1;
}
// rest of Commands
return 0;
}
#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;
}
}
new string[256];
new params[128];
new sendername[MAX_PLAYER_NAME];
new giveplayer[MAX_PLAYER_NAME];
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.", amount, 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, amount, price);
SendClientMessage(gpid, 0x33CCFFAA, string);
}
}
else
{
SendClientMessage(playerid, -1, "{FF6A22}INFO:{FFFFFF} That player isn't enough close");
}
return 1;
}
return 0;
}
if(strcmp(cmd, "/selldrugs", true) == 0 || strcmp(cmd, "/sd", true) == 0)
{
new drug_name[10],amount,price;
tmp = strtok(cmdtext, idx); // [playerid]
new gpid = ReturnUser(tmp);
if(gpid == INVALID_PLAYER_ID) return SendClientMessage(playerid, -1, "{FF6A22}INFO:{FFFFFF} Invalid player ID.");
strcat(drug_name, strtok(cmdtext, idx)); // [drugname]
if(!drug_name[0])
{
SendClientMessage(playerid, -1, "{FF6A22}USAGE: {FFFFFF}/selldrugs (/sd) [playerid] [drugname] [amount] [price]");
SendClientMessage(playerid, -1, "{FF6A22}Available names: {FFFFFF}Weed, Cocaine, Crack, Meth, Ectasy, Heroin");
return 1;
}
tmp = strtok(cmdtext, idx); // [amount]
if(!strlen(tmp))
{
// some info here
return 1;
}
amount = strval(tmp);
tmp = strtok(cmdtext, idx); // [price]
if(!strlen(tmp))
{
// some info here
return 1;
}
price = strval(tmp);
if(ProxDetectorS(8.0, playerid, gpid))
{
new giveplayer[MAX_PLAYER_NAME];
new sendername[MAX_PLAYER_NAME]
GetPlayerName(gpid, giveplayer, MAX_PLAYER_NAME);
GetPlayerName(playerid, sendername, MAX_PLAYER_NAME);
if(strcmp(drug_name,"weed",true) == 0)
{
format(string, sizeof(string), "* You offered to sell %d grams of weed to %s for $%d, Wait for a reply.", amount, 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, amount, price);
SendClientMessage(gpid, 0x33CCFFAA, string);
}
}
else
SendClientMessage(playerid, -1, "{FF6A22}INFO:{FFFFFF} That player isn't enough close");
return 1;
}
// rest of Commands
return 0;
}