sscanf problem
#1

I have a little issue with sscanf. Below is my code.

Код:
mysql_get_field("intX", tmp);
sscanf(tmp, "f", xintpos);
mysql_get_field("intY", tmp);
sscanf(tmp, "f", yintpos);
mysql_get_field("intZ", tmp);
sscanf(tmp, "f", zintpos);
But all xintpos, yintpos and zintpos return is 0.

Ideas?
Reply
#2

Why would you use sscanf in that case?
pawn Код:
mysql_get_field( "intX", tmp );
xintpos = floatstr( tmp );
// etc.
Reply
#3

floatstr gives "0" as well. any other thoughts? Heres the complete command

Код:
CMD:createhouse(playerid,params[])
{
	if(PInfo[playerid][pALevel] >= 1)
	{
		new price, slots, interiorid[10];
		if(!sscanf(params, "iis[10]", price, slots, interiorid))
  		{
			new qry[128], Store[128];
			format(qry, sizeof(qry), "SELECT * FROM interiors WHERE intUID = '%s'", interiorid);
			mysql_query(qry);
			mysql_store_result();
			if(mysql_num_rows() == 1)
			{
				new Float:xpos, Float:ypos, Float:zpos;
	        	new zone[30];
				GetPlayer2DZone(playerid,zone,sizeof(zone));
	    		GetPlayerPos(playerid, xpos, ypos, zpos);
	        	HouseInfo[nh][hID] = nh;
	        	HouseInfo[nh][hWorld] = nh;
	        	HouseInfo[nh][hX] = xpos;
	        	HouseInfo[nh][hY] = ypos;
	        	HouseInfo[nh][hZ] = zpos;
				mysql_get_field("intIntID", Store); HouseInfo[nh][hInt] = strval(Store);
				HouseInfo[nh][hOwned] = 0;
				HouseInfo[nh][hSlots] = slots;
				HouseInfo[nh][hZone] = zone;
				HouseInfo[nh][hPrice] = price;
				
				HouseInfo[nh][hIcon] = CreateDynamicMapIcon(HouseInfo[nh][hX],HouseInfo[nh][hY],HouseInfo[nh][hZ], 31, 0, 0, 0, -1, 500.0);
				HouseInfo[nh][hPickup] = CreateDynamicPickup(1273,23,HouseInfo[nh][hX],HouseInfo[nh][hY],HouseInfo[nh][hZ],-1,-1,-1,100.0);

				new msg[128];
    			format (msg, sizeof(msg), "House for sale!\nHouse ID: %d %s\nPrice: %d\nSlots: %d", HouseInfo[nh][hID], HouseInfo[nh][hZone], HouseInfo[nh][hPrice], HouseInfo[nh][hSlots]);
				CreateDynamic3DTextLabel(msg, COLOR_YELLOW, HouseInfo[nh][hX], HouseInfo[nh][hY], HouseInfo[nh][hZ] + 1.0, 50.0);

				new Float:xintpos, Float:yintpos, Float:zintpos, tmp[128];
				mysql_get_field("intX", tmp);
				xintpos = floatstr(tmp);
				//sscanf(tmp, "f", xintpos);
				mysql_get_field("intY", tmp);
				yintpos = floatstr(tmp);
				//sscanf(tmp, "f", yintpos);
				mysql_get_field("intZ", tmp);
				zintpos = floatstr(tmp);
				//sscanf(tmp, "f", zintpos);;
				mysql_free_result();
				new inserthouse[256];
				new owner[5] = "None";
				format(inserthouse, sizeof(inserthouse), "INSERT INTO houses (hX, hY, hZ, hIntX, hIntY, hIntZ, hInt, hOwner, hOwned, hSlots, hZone, hPrice, hPark) VALUES ('%f', '%f', '%f', '%f', '%f', '%f', '%d', '%s', '%d', '%d', '%s', '%d', '%d')",xpos,ypos,zpos,xintpos,yintpos,zintpos,HouseInfo[nh][hInt],owner,0,slots,zone,price,20);
				mysql_query(inserthouse);
				SendClientMessage(playerid,COLOR_LIMEGREEN,"[SeaBot] Success! House is now avaliable.");
	        	nh++;
	        }
	        else
	            SendClientMessage(playerid,COLOR_CORAL,"[SeaBot] Invalid Interior ID.");
    	}
     	else
			SendClientMessage(playerid,COLOR_CORAL,"[SeaBot] Usage: /createhouse <price> <slots> <interiorid>");
    }
    return 1;
}
Reply
#4

help? please?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)