[Info]: Load data with sscanf2 / on MySQL
#1

Hello,

i have a question with sscanf... load data on mysql with sscanf:

i have found, this example:

pawn Код:
sscanf(resultline, "p<|>dd", PlayerInfo[playerid][level], PlayerInfo[playerid][adminlevel]);
the p<|> is the divisor... and i understand

but in this another example... no

this the code:

pawn Код:
sscanf(query, "e<p<|>s[24]s[17]iii>", ... ecc);
why e<p<|> ? .. who is the e<p ??
Reply
#2

E means that you're loading data into an enum. Asigning it in enum variables.
Reply
#3

Quote:
Originally Posted by irinel1996
Посмотреть сообщение
E means that you're loading data into an enum. Asigning it in enum variables.
yes i understand this.. but what is the e<p ?
Reply
#4

?
Reply
#5

e means that the variables where will be the data asigned are from an enum, nothing else. And the p is the same with or without e.
If you do that:
pawn Код:
enum Vars
{
    name[24], //string = s[24].
    age //integer = i
};
new example[MAX_PLAYERS][Vars];
//---------------------
sscanf(query,"e<p<|>s[24]i>",example[playerid][name],example[playerid][age]);
Hope you understand..
Reply
#6

p<|> means that sscanf will take out all | written in the text and split it up there, this is at least what I'm using it for.
Reply
#7

ok, i understand

Thanks
Reply
#8

another question for sscanf..

sscanf(query ,"e<p<|>{s[1]s[1]}dd>

why usage the { } , is used for ignore a variable ?
Reply
#9

help ?
Reply
#10

It jumps over it, doesn't load it.
Let's suppose that in your MySQL table you have 3 fields:
-name (varchar)
-sex (varchar - let's suppose it'd be 10 big cells in the enum to understand sscanf)
-age (integer)


And in your GM your enum has just 2 variables. Name and age:
pawn Код:
enum Vars {
 name[24],
 age
};
new data[MAX_PLAYERS][Vars];
//-----------
sscanf(query,"e<p<|>s[24]{s[10]}i",data[playerid][name],data[playerid][age]); //it didn't load sex because we don't have variable to asign the value.
Best regards!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)