Help with sscanf
#1

I have public like this, to read from my saved player account. And I want to know how to make 2 public becouse this one isn't big enough, i have error that i have to many things in it,
Код:
fatal error 102: table overflow: "staging buffer"
and I want to separate that one public into two, but don't now how. There it is:

Код:
public ReadLine(playerid, line[])
{
    new xdata;
	sscanf(line, "p<|>is[24]s[32]s[50]iiiiiiiiis[15]iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiis[32]iiiiiis[32]s[32]s[32]iiiiiiiiis[32]s[32]iiiiiiiis[32]s[32]iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii",
	xdata, -> Here are listed my pinfo files like PlayerInfo[playerid][Level], PlayerInfo[playerid][pAdmin],.... etc. );
}
And can somebody explain to me what means :
Код:
sscanf(line, "p<|>
that sign p<|> what it means?,
this "is[24]s[32]...etc" means is it number or letter, or what?
And what for is xdata here?
thanks everybody, sorry for my bad english
Reply
#2

sscanf (SA-MP version) splits a string that has many values with spaces in between values them and stores them into variables. Instead of using spaces, some people separate pieces of data by using the pipeline character |

sscanf just basically recognizes the pipeline as a space, or whatever character is between the < >.

Every letter you see there is a specifier. You can see all of the specifiers here.

There is also an easier way to do this without writing every player variable one by one.

example
pawn Код:
enum pInfo
{
    pCash,
    Float:pHealth,
    Float:pArmour,
    pPass[129]
}

new PlayerInfo[MAX_PLAYERS][pInfo];

stock readLine(playerid, line[])
{
    sscanf(readLine, "e<p<|>iffs[129]>", PlayerInfo[playerid]);
}
Make sure whatever is enclosed in e<> matches your enumerator structure. I've never used sscanf for that though, so don't quote me on it, and do your own research in the sscanf release thread.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)