public OnPlayerText(playerid, text[])
{
if(text[0] == '1')
{
if(FirstWeaponText[playerid] == 1)
{
new Amount;
if( sscanf ( text[1], "i",Amount)) return SendClientMessage(playerid,-1, "[amount]");// amount he wants.
if(Amount < 1 || Amount > 10000) return SendClientMessage(playerid,-1,"You can only buy from 1 - 10000 bullets");// check if player has writen more than required
{
GivePlayerMoney(playerid,-Amount*100); // this makes 1 bullet for 100$
GivePlayerWeapon(playerid, WEAPON_M4, Amount);
}
}
}
if(Amount < 1 || Amount > 10000) return SendClientMessage(playerid,-1,"You can only buy from 1 - 10000 bullets");// check if player has writen more than required
{ // This one
GivePlayerMoney(playerid,-Amount*100); // this makes 1 bullet for 100$
GivePlayerWeapon(playerid, WEAPON_M4, Amount);
} // and this one
public OnPlayerText(playerid, text[])
{
if(text[0] == '1')
{
if(FirstWeaponText[playerid] == 1)
{
new Amount;
if( sscanf ( text[1], "i",Amount)) return SendClientMessage(playerid,-1, "[amount]");// amount he wants.
{ // This one
GivePlayerMoney(playerid,-Amount*100); // this makes 1 bullet for 100$
GivePlayerWeapon(playerid, WEAPON_M4, Amount);
} // and this one
}
}
as i know you should remov brackers
PHP код:
give me 100 ammo i want making it when i'm write 1 in chat after that's write my amount ammo in chat |
public OnPlayerText(playerid, text[])
{
if(FirstWeaponText[playerid] == 1)
{
if(!isNumeric(text))
{
SendClientMessage(playerid,-1, "[Enter only digits]");// amount he wants.
return 0;
}
if(strval(text) < 1 || strval(text) > 10000)
{
SendClientMessage(playerid,-1,"You can only buy from 1 - 10000 bullets");// check if player has writen more than required
return 0;
}
GivePlayerMoney(playerid,-strval(text)*100); // this makes 1 bullet for 100$
GivePlayerWeapon(playerid, WEAPON_M4, strval(text));
FirstWeaponText[playerid] = 0;
return 0;
}
else
{
if(!strcmp(text, "1"))
{
FirstWeaponText[playerid] = 1;
SendClientMessage(playerid, -1, "Enter the amount of ammo:");
return 0;
}
}
return 1;
}
I think you want something like that:
PHP код:
|
(389) : error 017: undefined symbol "isNumeric" |
if(!isNumeric(text))
stock isNumeric(const string[])
{
new length=strlen(string);
if (length==0) return false;
for (new i = 0; i < length; i++)
{
if (
(string[i] > '9' || string[i] < '0' && string[i]!='-' && string[i]!='+') // Not a number,'+' or '-'
|| (string[i]=='-' && i!=0) // A '-' but not at first.
|| (string[i]=='+' && i!=0) // A '+' but not at first.
) return false;
}
if (length==1 && (string[0]=='-' || string[0]=='+')) return false;
return true;
}
PHP код:
|