Help Loading Objects -
theralio - 29.11.2018
Hey when i read from a file i get this printed in my console:
19295 7538.399900 -2031.000000 332.500000 0.000000 0.000000 0.000000
Objectid X Y Z ROT:X ROT:Y ROT:Z
i need help to read this step by step
i use filemanager
Re: Help Loading Objects -
NaS - 29.11.2018
I'd suggest using sscanf. It's really easy to read line by line with that.
I assume you have the reading part done already, so you have the current line in an array inside a loop or so.
With sscanf you can extract the values by their format and load them into variables:
PHP код:
new model, Float:x, Float:y, Float:z, Float:rx, Float:ry, Float:rz;
if(sscanf(text, "iffffff", model, x, y, z, rx, ry, rz))
{
// Invalid line
}
else
{
// Line was parsed, you can now use model, x, y, z, rx, ry, rz to create the object
}
The "iffffff" part in the sscanf function tells it to read one integer (i) and 6 float values (f), followed by the variables to write the values to.
"text" would be the array with the current line you want to parse.
Re: Help Loading Objects -
theralio - 29.11.2018
But i read it like this from the file
Код:
19295 7538.399900 -2031.000000 332.500000 0.000000 0.000000 0.000000
How can i read it without the spaces like
Код:
CreateDynamicObject(19295,7538.399900, -2031.000000, 332.500000, 0.000000, 0.000000 ,0.000000);
Re: Help Loading Objects -
NaS - 29.11.2018
Quote:
Originally Posted by theralio
But i read it like this from the file
Код:
19295 7538.399900 -2031.000000 332.500000 0.000000 0.000000 0.000000
How can i read it without the spaces like
Код:
CreateDynamicObject(19295,7538.399900, -2031.000000, 332.500000, 0.000000, 0.000000 ,0.000000);
|
Oh I see.
You can do it with sscanf too:
PHP код:
sscanf(text, "p<,();>'CreateDynamicObject'iffffff", model, x, y, z, rx, ry, rz);
p<,();> will ignore the signs , ( ) ; (so all these signs are accepted as delimiters).
The 'CreateDynamicObject' part will require it to be part of the line (at the start).
Re: Help Loading Objects -
theralio - 29.11.2018
ok thx it works