sscanf floats in-accurate
#1

This is the command to attach an object to yourself:

pawn Code:
dcmd_ostick(playerid, params[])
{
    new bone, model, slot;
    new Float:offset[3];
    new Float:rot[3];
    new Float:scale[3];
    if(sscanf(params, "iiI(1)F(0.0)F(0.0)F(0.0)F(0.0)F(0.0)F(0.0)F(1.0)F(1.0)F(1.0)", slot, model, bone, offset[0], offset[1], offset[2], rot[0], rot[1], rot[2], scale[0], scale[1], scale[2]))
    {
            // errors (removed, un-neccesary, makes more code to look at)
    }
    printf("%f", scale[2]);
    SetPlayerAttachedObject(playerid, slot, model, bone, offset[0], offset[1], offset[2], rot[0], rot[1], rot[2], scale[0], scale[1], scale[2]);
    return 1;
}
(some un-necessary code removed)

But the floats (offset[] rot[] and scale[]) are sometimes in-accurate. If I type /ostick [blah blah blah] 1.3 1.3 1.3
the final values being scale[0] [1] and [2], it sets them to 2.999999.. why is that?

Quote:
Originally Posted by server_log.txt
[21:07:40] [cmd] [Jacob]: /ostick 0 1238 2 0 0 0 0 0 0 1.3 1.3 1.3
[21:07:40] 1.299999
[21:07:44] [cmd] [Jacob]: /ostick 0 1238 2 0 0 0 0 0 0 1.5 1.5 1.5
[21:07:44] 1.500000
[21:07:45] [cmd] [Jacob]: /ostick 0 1238 2 0 0 0 0 0 0 1.3 1.3 1.3
[21:07:45] 1.299999
The floats are the printf() in the above command.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)