sscanf - Solution? -
yellow - 19.07.2014
Hey guys,
Got a problem with my code.
Код:
stock LoadBiz()
{
new idx,
result[200];
format(result, 128, "SELECT * FROM `bizdata`");
mysql_query(result);
mysql_store_result();
while(mysql_fetch_row_format(result, "|"))
{
sscanf(result, "p<|>{i}is[60]s[23]iiffffffii",data[idx]);
idx ++;
BIZ++;
}
mysql_free_result();
printf(" ->> %d Biz's loaded!",BIZ);
}
Код:
sscanf warning: Format specifier does not match parameter count.
[18:31:41] sscanf warning: Format specifier does not match parameter count.
[18:31:41] ->> 2 Biz's loaded!
Enum:
Код:
/*
b_id,//uniqu. id
b_name[64],//name
b_owner[32],//own
b_buyprice, //bp
b_owned,//
Float:b_enterposx,//
Float:b_enterposy,//
Float:b_enterposz,
Float:b_exitposx,
Float:b_exitposy,
Float:b_exitposz,
b_int,//interior,
b_vw//vw
*/
Database:
Why does that warning appear in the logs?
Greetz
Re: sscanf - Solution? -
Scottas - 19.07.2014
https://github.com/Y-Less/sscanf/wiki/%22e%22-Specifier
AW: sscanf - Solution? -
yellow - 19.07.2014
Oh, yea. Thanks
AW: sscanf - Solution? -
yellow - 19.07.2014
Another probl. ^^
Код:
stock LoadBiz()
{
new idx,
result[200];
format(result, 128, "SELECT * FROM `bizdata`");
mysql_query(result);
mysql_store_result();
while(mysql_fetch_row_format(result, "|"))
{
sscanf(result, "e<p<|>{i}is[60]s[23]iiffffffii>",data[idx]);
new text[128];
CreatePickup(1239,2,data[idx][b_enterposx],data[idx][b_enterposy],data[idx][b_enterposz],data[idx][b_vw]);
printf(" %f %f %f",data[idx][b_enterposx],data[idx][b_enterposy],data[idx][b_enterposz]);
//format(text,sizeof(text),(data[idx][b_owned] == 0) ? ("> %s <\n> -: -<\n> - : %d <") : ("> %s <\n -: %s <"),data[idx][b_name],data[idx][b_buyprice]);
idx ++;
BIZ++;
}
mysql_free_result();
printf(" ->> %d Biz's loaded!",BIZ);
}
ignore the ternary oper. -> i know that this won't work, it's just a "pre-write".
The problem is:
enterposx, enterposy & enterpos z are 0.0000. But they aren't.
The value is false, but in the mysql_log the value is right. dafuq?
Re: sscanf - Solution? -
Scottas - 19.07.2014
print out result before sscanf, also try to change split operator position ( I don't know really if it will help ).
pawn Код:
print(result);
sscanf(result, "p<|>e<{i}is[60]s[23]iiffffffii>",data[idx]);
AW: sscanf - Solution? -
yellow - 19.07.2014
Код:
[19:20:18] 1|0|DSGJKDFGJKD|Noone|15|0|1963.6|1327.61|9.2501|1.2345|1.2345|1.2345|0|0
[19:20:18] 0.000000 0.000000 0.000000
[19:20:18] 2|1|SDFSDFSFDSFSDF|Noone|150|0|1959.67|1323.08|9.25781|0|0|0|0|0
[19:20:18] 0.000000 0.000000 0.000000
1st = print(result)
2nd = printf( %f ..)
3rd = print(result) 2nd DB_Entry
4th = printf( %f ..) 2nd DB_Entry
The output from the DB is correct, but the value of data[idx][enterpos..] is wrong.
Re: sscanf - Solution? -
Jefff - 19.07.2014
Try
sscanf(result, "p<|>{i}e<is[60]s[23]iiffffffii>",data[idx]);
AW: sscanf - Solution? -
yellow - 19.07.2014
Doesn't work either.
Re: sscanf - Solution? -
Jefff - 19.07.2014
Try to print full line as result not only x, y, z
AW: sscanf - Solution? -
yellow - 19.07.2014
Serverlog:
Код:
1|0|DSGJKDFGJKD|Noone|15|0|1963.6|1327.61|9.2501|1.2345|1.2345|1.2345|0|0
[20:28:40] --------------------------------------------------
[20:28:40] (null)
[20:28:40] --------------------------------------------------
[20:28:40] 0|DSGJKDFGJKD|and|0|0|0.000000|0.000000|0.000000|0.000000|0.000000|0.000000|0|0
Код:
print(result);
sscanf(result, "p<|>{i}e<is[60]s[23]iiffffffii>",data[idx]);
print(" --------------------------------------------------");
print(data[idx]);
print(" --------------------------------------------------");
printf("%i|%s|%s|%i|%i|%f|%f|%f|%f|%f|%f|%i|%i",data[idx][b_id],data[idx][b_name],data[idx][b_owner],data[idx][b_buyprice],data[idx][b_owned],data[idx][b_enterposx], \
data[idx][b_enterposy],data[idx][b_enterposz],data[idx][b_exitposx],data[idx][b_exitposy],data[idx][b_exitposz],data[idx][b_int],data[idx][b_vw]);