[SSCANF] Help?
#1

Require a little bit of help with this one line of SSCANF code.


Код:
if (!sscanf(string, "p<,>CreateObject(dffffff", modelid, x, y, z, rx, ry, rz))
So I am trying to get the modelid, x,y,z,rx,ry,rz from normal CreateObject codes.

String:
Код:
CreateObject(19573, 662.2805, -1438.3465, 14.2938, 90.0000, 90.0000, 0.0000); //BriquettesBag1
Everything I try doesn't seem to work.


What am I doing wrong here? I am fairly useless with sscanf, even after reading the thread explaining it - still can't get my head around it entirely.

Appreciate all replies! Will +rep !!
Reply
#2

pawn Код:
new string[] = "CreateObject(1, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0)";
new modelid;
new Float:x, Float:y, Float:z, Float:rx, Float:ry, Float:rz, Float:dd;
if (!sscanf(string[12], "P<,()>dfffffff", modelid, x, y, z, rx, ry, rz, dd)) {
    printf("Yay %d %.2f %.2f %.2f %.2f %.2f %.2f %.2f", modelid, x, y, z, rx, ry, rz, dd);
}
In short: skip 12 first characters (using string[12]), and add "(" and ")" to delimeters

Edit: better yet, skip 13 and drop the ( from delimeters.

pawn Код:
new string[] = "CreateObject(1, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0)";
new modelid;
new Float:x, Float:y, Float:z, Float:rx, Float:ry, Float:rz, Float:dd;
if (!sscanf(string[13], "P<,)>dfffffff", modelid, x, y, z, rx, ry, rz, dd)) {
    printf("Yay %d %.2f %.2f %.2f %.2f %.2f %.2f %.2f", modelid, x, y, z, rx, ry, rz, dd);
}
Reply
#3

Quote:
Originally Posted by Misiur
Посмотреть сообщение
pawn Код:
new string[] = "CreateObject(1, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0)";
new modelid;
new Float:x, Float:y, Float:z, Float:rx, Float:ry, Float:rz, Float:dd;
if (!sscanf(string[12], "P<,()>dfffffff", modelid, x, y, z, rx, ry, rz, dd)) {
    printf("Yay %d %.2f %.2f %.2f %.2f %.2f %.2f %.2f", modelid, x, y, z, rx, ry, rz, dd);
}
In short: skip 12 first characters (using string[12]), and add "(" and ")" to delimeters

Edit: better yet, skip 13 and drop the ( from delimeters.

pawn Код:
new string[] = "CreateObject(1, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0)";
new modelid;
new Float:x, Float:y, Float:z, Float:rx, Float:ry, Float:rz, Float:dd;
if (!sscanf(string[13], "P<,)>dfffffff", modelid, x, y, z, rx, ry, rz, dd)) {
    printf("Yay %d %.2f %.2f %.2f %.2f %.2f %.2f %.2f", modelid, x, y, z, rx, ry, rz, dd);
}
Thank you for that.

What is the Float:dd for?
Reply
#4

its for Draw distance,
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)