get amount onplayertext - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: get amount onplayertext (
/showthread.php?tid=84321)
get amount onplayertext -
happyface - 30.06.2009
im trying to make deposit for bank, and am trying to use onplayertext for the amount part, something kind of like:
pawn Код:
public OnPlayerText(playerid, text[])
{
if(TestList[playerid] == 1)
{
new amount = strlen(text);
new String[50];
format(String, sizeof(String), "Amount = %i", amount);
SendClientMessage(playerid, 0xE60000FF, String);
TestList[playerid] = 0;
return 0;
}
return 1;
}
the problem is the "amount" = how many characters there are, not the actual amount you entered. like 1234 = 4 instead of 1234.
so if you wanted to deposit $500 and enter "500", it say 3 instead because its 3 char..
i searched but cant find how to get the amount.
i hope i make myself clear, please help.
Re: get amount onplayertext -
Ignas1337 - 30.06.2009
that's strlen(const string[]);
this funciton returns the number of symbols used in a string
Re: get amount onplayertext -
happyface - 30.06.2009
strval?
Re: get amount onplayertext -
Ignas1337 - 30.06.2009
no, you don't want it to return the number inputed, but the number of characters, right?
for example
new str[8]="1234567";
strval(str) = 1234567;
strlen(str) = 7;