Not tested but should work in both versions of sscanf. It's a logical solution, so if it works then bonus! Not sure if you use a command processor but here's the code for OnPlayerCommandText
.
pawn Код:
public OnPlayerCommandText(playerid,cmdtext[])
{
if (!strcmp(cmdtext, "/call", true, 5))
{
new
output_1[128], // First parameter (the command)
output_2[128], // Second parameter if it's a string
player_calling; // Calling id
// If sscanf completes any of these succesfull then we carry on!
if (!sscanf(cmdtext, "si", output_1, player_calling) || !sscanf(cmdtext, "ss", output_1, output_2))
{
if (!player_calling)
{
// If the player_calling variable hasn't been set to something other than
// 0 then we'll check the string and create a number from that.
if (!strcmp(output_2, "pizza"))
player_calling = 1; // The string is "pizza" so the player is calling "1"
else if (!strcmp(output_2, "other"))
player_calling = 2; // The string is "other" so the player is calling "2"
}
switch (player_calling)
{
case 1:
{
return SendClientMessage(playerid, 0xFFFFFFFF, "You just called the pizza place!");
}
case 2:
{
return SendClientMessage(playerid, 0xFFFFFFFF, "You just called something else!");
}
default:return SendClientMessage(playerid, 0xFF0000FF, "Error: Invalid number/name");
}
}
else
return SendClientMessage(playerid, 0xFF0000FF, "Usage: /call [number/name]");
}
return 0;
}