new Amount[MAX_PLAYERS];
new bool: IsWritingAmount[MAX_PLAYERS];
public OnPlayerText(playerid, text[])
{
if(IsWritingAmount[playerid] == true)
{
if(strval(text) == text)
{
new string[50];
Amount[playerid] = text; // Consider the text was "300"
format(string, sizeof(string), "You have purchased %i of this thing for some money.", text); //%i would be 300
SendClientMessage(playerid, -1, string);
}
return 0;
}
else // if the player writes normal text
{
SendClientMessage(playerid, -1, "You should only write an integer at the moment to purchase an amount.")
return 0;
}
return 1;
}
if(strcmp(text, "0", true) == 0 || strval(text) < 0 || strval(text) > 0) // String is numeric.
else // String isn't numeric.
new Amount[MAX_PLAYERS];
public OnPlayerText(playerid, text[])
{
if(strcmp(text, "0", true) == 0 || strval(text) < 0 || strval(text) > 0)
{
new string[144];
Amount[playerid] = text;
format(string, sizeof(string), "You have purchased %d of this thing for some money.", strval(text));
SendClientMessage(playerid, -1, string);
return 0;
}
else
{
SendClientMessage(playerid, -1, "You should only write an integer at the moment to purchase an amount.")
return 0;
}
return 1;
}
if(strcmp(text, "0", true) == 0)
new amount;
if(sscanf(text, "i", amount)) return SendClientMessage(playerid, -1, "You should only write an integer at the moment to purchase an amount.");
new amount;
amount = strval(text);
if(amount < 1) return SendClientMessage(playerid, -1, "You should only write an integer at the moment to purchase an amount.");
|
Would you please explain this part?..
Why did you compare the text with zero? pawn Код:
|