sscanf problem
#1

Hello guys, I have just created a command for creating in-game objects, but when the object has negative value, it sets the coordinate to 0.00000. I'm using sscanf for the command, so please help me! Look at my code:
PHP код:
if(sscanf(params"iffffffii"ObjectInfo[o][oModel], ObjectInfo[o][oX], ObjectInfo[o][oY], ObjectInfo[o][oZ], ObjectInfo[o][oRX], ObjectInfo[o][oRY], ObjectInfo[o][oRZ], ObjectInfo[o][oVW], ObjectInfo[o][oInt]))
    return 
SendClientMessage(playeridCOLOR_WHITE"Usage: /cObject [ModelID] [Position:X] [Position:Y] [Position:Z] [Rotation:X] [Rotation:Y] [Rotation:Z] [VirtualWorldID] [InteriorID]"); 
PLEASE HELP, +1 REP TO THE HELPERS
Reply
#2

Show the full command.
Reply
#3

Are you using latest sscanf? if no then consider using it because I have just tested that and it worked perfectly.

https://sampforum.blast.hk/showthread.php?tid=602923
Reply
#4

Here is the full code:
PHP код:
cmd:cObject(playeridparams[])
{
    if(
sscanf(params"iffffffii"ObjectInfo[o][oModel], ObjectInfo[o][oX], ObjectInfo[o][oY], ObjectInfo[o][oZ], ObjectInfo[o][oRX], ObjectInfo[o][oRY], ObjectInfo[o][oRZ], ObjectInfo[o][oVW], ObjectInfo[o][oInt]))
    return 
SendClientMessage(playeridCOLOR_WHITE"Usage: /cObject [ModelID] [Position:X] [Position:Y] [Position:Z] [Rotation:X] [Rotation:Y] [Rotation:Z] [VirtualWorldID] [InteriorID]");
    
CreateDynamicObject(ObjectInfo[o][oModel], ObjectInfo[o][oX],ObjectInfo[o][oY],ObjectInfo[o][oZ], ObjectInfo[o][oRX],ObjectInfo[o][oRY],ObjectInfo[o][oRZ], ObjectInfo[o][oVW], ObjectInfo[o][oInt]);
    return 
1;

Reply
#5

Quote:
Originally Posted by jlalt
Посмотреть сообщение
Are you using latest sscanf? if no then consider using it because I have just tested that and it worked perfectly.

https://sampforum.blast.hk/showthread.php?tid=602923
I have just downloaded the latest sscanf, but still this problem, try to type:
/cobject 693 -1432.66492 299.67242 11.42419 0.00000 0.00000 0.00000 -1 -1
It is creating the object to coordinates: 0.000000, 299.672424, 11.42419, 0, 0, 0
Reply
#6

Quote:
Originally Posted by Kraeror
Посмотреть сообщение
I have just downloaded the latest sscanf, but still this problem, try to type:
/cobject 693 -1432.66492 299.67242 11.42419 0.00000 0.00000 0.00000 -1 -1
It is creating the object to coordinates: 0.000000, 299.672424, 11.42419, 0, 0, 0
Are you sure about that? [ I have just did another test, and see result by yourself. ]



code used:

PHP код:
#include a_samp
#include sscanf2
public OnFilterScriptInit()
{
    new 
value1Float:floats[6], twoint[2];
    
sscanf("693 -1432.66492 299.67242 11.42419 0.00000 0.00000 0.00000 -1 -1""iffffffii"value1floats[0], floats[1], floats[2], floats[3], floats[4], floats[5], twoint[0], twoint[1]);
    
printf("| %d | %f | %f | %f | %f | %f | %f | %d | %d |"value1floats[0], floats[1], floats[2], floats[3], floats[4], floats[5], twoint[0], twoint[1]);

Reply
#7

Myb try something like this:

Код:
cmd:cObject(playerid, params[])
{
	new model,x,y,z,rx,ry,rz,vw,in;
    if(sscanf(params, "iiiiiiiii", model,x,y,z,rx,rx,rz,vw,in)) return SendClientMessage(playerid, COLOR_WHITE, "Usage: /cObject [ModelID] [Position:X] [Position:Y] [Position:Z] [Rotation:X] [Rotation:Y] [Rotation:Z] [VirtualWorldID] [InteriorID]");
    ObjectInfo[o][oModel] = model;
	ObjectInfo[o][oX] = float(x); ObjectInfo[o][oY] = float(y); ObjectInfo[o][oZ] = float(z);
	ObjectInfo[o][oRX] = float(rx); ObjectInfo[o][oRY] = float(ry); ObjectInfo[o][oRZ] = float(rz);
	ObjectInfo[o][oVW] = vw;
	ObjectInfo[o][oInt] = in;
    CreateDynamicObject(ObjectInfo[o][oModel], ObjectInfo[o][oX],ObjectInfo[o][oY],ObjectInfo[o][oZ], ObjectInfo[o][oRX],ObjectInfo[o][oRY],ObjectInfo[o][oRZ], ObjectInfo[o][oVW], ObjectInfo[o][oInt]);
    return 1;
}
Reply
#8

Quote:
Originally Posted by jlalt
Посмотреть сообщение
Are you sure about that? [ I have just did another test, and see result by yourself. ]



code used:

PHP код:
#include a_samp
#include sscanf2
public OnFilterScriptInit()
{
    new 
value1Float:floats[6], twoint[2];
    
sscanf("693 -1432.66492 299.67242 11.42419 0.00000 0.00000 0.00000 -1 -1""iffffffii"value1floats[0], floats[1], floats[2], floats[3], floats[4], floats[5], twoint[0], twoint[1]);
    
printf("| %d | %f | %f | %f | %f | %f | %f | %d | %d |"value1floats[0], floats[1], floats[2], floats[3], floats[4], floats[5], twoint[0], twoint[1]);

Look:
https://imgur.com/a/3SyJL
Reply
#9

Quote:
Originally Posted by Danisoni
Посмотреть сообщение
Myb try something like this:

Код:
cmd:cObject(playerid, params[])
{
	new model,x,y,z,rx,ry,rz,vw,in;
    if(sscanf(params, "iiiiiiiii", model,x,y,z,rx,rx,rz,vw,in)) return SendClientMessage(playerid, COLOR_WHITE, "Usage: /cObject [ModelID] [Position:X] [Position:Y] [Position:Z] [Rotation:X] [Rotation:Y] [Rotation:Z] [VirtualWorldID] [InteriorID]");
    ObjectInfo[o][oModel] = model;
	ObjectInfo[o][oX] = float(x); ObjectInfo[o][oY] = float(y); ObjectInfo[o][oZ] = float(z);
	ObjectInfo[o][oRX] = float(rx); ObjectInfo[o][oRY] = float(ry); ObjectInfo[o][oRZ] = float(rz);
	ObjectInfo[o][oVW] = vw;
	ObjectInfo[o][oInt] = in;
    CreateDynamicObject(ObjectInfo[o][oModel], ObjectInfo[o][oX],ObjectInfo[o][oY],ObjectInfo[o][oZ], ObjectInfo[o][oRX],ObjectInfo[o][oRY],ObjectInfo[o][oRZ], ObjectInfo[o][oVW], ObjectInfo[o][oInt]);
    return 1;
}
Nooo ...
It is not working to object with coordinates with values for example: 1.1454, 247,1546, -14,1564 . It is working only with whole numbers like: 1, 147, -241
Reply
#10

You don't see this :P ?
Код:
ObjectInfo[o][oX] = float(x);
There is float(x).
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)