Convert string with numbers into numbers only?
#4

pawn Код:
new pInfo[5], buff[5], string[24];

for(new i; i < 5; i++)
{
     pInfo[i] = "You have +200 points";
     points[i] += 5;
     buff[i] = strval(pInfo[i]);
     printf("Points %i %d", i, buff[i]);
     //more code...
}
Well there's several problems with the code already...like this

pawn Код:
pInfo[i] = "You have +200 points";
You can't store all of those characters in a single cell. I'm quite confused as to what this piece of code is supposed to do...

Really it should be initialized as a multi-dimensional array to store all of those characters.

pawn Код:
new pInfo[5][15];
Anyway as for your question, strval won't extract the numbers from a string, it'll give you the integer value of it (the ASCII value, as far as I know). If you wanted to extract numbers from a string, you'd probably need a function that loops through each character in the string and checking if it's a number or not, then storing it. I'm unaware of an existing function that does that.
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 2 Guest(s)