SA-MP Forums Archive
Mysql is not setting positions. - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Mysql is not setting positions. (/showthread.php?tid=342575)



Mysql is not setting positions. - Shockey HD - 14.05.2012

I have an dynamic house system that works great so far, except the part when the server restart's, The houses do not load in game.

They save perfectly into MYSQL with the right position, but thats it.

Heres the code where the house's gets loaded.

Код:

stock MySQL_House(playerid)
{
    new query[300], pname[24], savingstring[20],string1[128];
    GetPlayerName(playerid, pname, 24);
    format(query, sizeof(query), "SELECT * FROM house WHERE houseid = <0");
    mysql_query(query);
    mysql_store_result();
    while(mysql_fetch_row_format(query,"|"))
    {
        mysql_fetch_field_row(savingstring, "houseid"); HouseID[playerid] = strval(savingstring);
        mysql_fetch_field_row(savingstring, "Owner"); HouseOwner[playerid] = strval(savingstring);
		mysql_fetch_field_row(savingstring, "xHPos"); zHPos[playerid] = strval(savingstring);
		mysql_fetch_field_row(savingstring, "yHPos"); yHPos[playerid] = strval(savingstring);
		mysql_fetch_field_row(savingstring, "zHPos"); zHPos[playerid] = strval(savingstring);
		
		new X = xHPos[playerid];
		new Y = yHPos[playerid];
		new Z = zHPos[playerid];
		format(string1,sizeof string1,"House Owner: %s\nX:%d, Y:%d,Z:%d\nHouse ID:%d",HouseOwner,xHPos,yHPos,zHPos,HouseID);
		CreatePickup(1273,1,X,Y,Z);
		Create3DTextLabel(string1, 0xFFFFFFFF, X,Y,Z, 10.0, 0, 0);

	}
	mysql_free_result();
	return 1;
}
Any ideas on how to fix this?


Re: Mysql is not setting positions. - Bogdan1992 - 14.05.2012

EDIT: Use "floatstr(string);"

pawn Код:
mysql_fetch_field_row(savingstring, "xHPos"); zHPos[playerid] = floatstr(savingstring);
mysql_fetch_field_row(savingstring, "yHPos"); yHPos[playerid] = floatstr(savingstring);
mysql_fetch_field_row(savingstring, "zHPos"); zHPos[playerid] = floatstr(savingstring);
       
new Float:X = xHPos[playerid];
new Float:Y = yHPos[playerid];
new Float:Z = zHPos[playerid];



Re: Mysql is not setting positions. - Kitten - 14.05.2012

Use what bogdan1992 said, but i would really recommend you use sscanf to load.


Re: Mysql is not setting positions. - Shockey HD - 14.05.2012

Meh, Call me a noob or not but im getting errors

Код:
		mysql_fetch_field_row(savingstring, "xHPos"); zHPos[playerid] = floatstr(savingstring);
		mysql_fetch_field_row(savingstring, "yHPos"); yHPos[playerid] = floatstr(savingstring);
		mysql_fetch_field_row(savingstring, "zHPos"); zHPos[playerid] = floatstr(savingstring);
Код:
C:\Documents and Settings\Chris\My Documents\GTA\SAMP\filterscripts\Admin.pwn(409) : warning 213: tag mismatch
C:\Documents and Settings\Chris\My Documents\GTA\SAMP\filterscripts\Admin.pwn(410) : warning 213: tag mismatch
C:\Documents and Settings\Chris\My Documents\GTA\SAMP\filterscripts\Admin.pwn(411) : warning 213: tag mismatch



Re: Mysql is not setting positions. - Bogdan1992 - 14.05.2012

Tell me xHPos, yHPos, zHPos are defined as floats?


Re: Mysql is not setting positions. - Shockey HD - 14.05.2012

Indeed, they are.


Re: Mysql is not setting positions. - Bogdan1992 - 14.05.2012

pawn Код:
stock MySQL_House(playerid)
{
    new query[300], pname[24], savingstring[20],string1[128], x[20], y[20], z[20];
    GetPlayerName(playerid, pname, 24);
    format(query, sizeof(query), "SELECT * FROM house WHERE houseid = <0");
    mysql_query(query);
    mysql_store_result();
    while(mysql_fetch_row_format(query,"|"))
    {
        mysql_fetch_field_row(savingstring, "houseid"); HouseID[playerid] = strval(savingstring);
        mysql_fetch_field_row(savingstring, "Owner"); HouseOwner[playerid] = strval(savingstring);
        mysql_fetch_field_row(x, "xHPos");
        mysql_fetch_field_row(y, "yHPos");
        mysql_fetch_field_row(z, "zHPos");

        format(string1, sizeof string1, "House Owner: %s\nX:%d, Y:%d,Z:%d\nHouse ID:%d", HouseOwner, floatstr(x), floatstr(y), floatstr(z), HouseID);
        CreatePickup(1273, 1, floatstr(x), floatstr(y), floatstr(z));
        Create3DTextLabel(string1, 0xFFFFFFFF, floatstr(x), floatstr(y), floatstr(z), 10.0, 0, 0);

    }
    mysql_free_result();
    return 1;
}



Re: Mysql is not setting positions. - Shockey HD - 14.05.2012

Same problems, Houses fail to load.


Re: Mysql is not setting positions. - Bogdan1992 - 14.05.2012

Check the positions with a message

pawn Код:
new string2[50];
format(string2, 50, "x: %f, y:%f, z:%f", floatstr(x), floatstr(y), floatstr(z));
SendClientMessage(playerid, -1, string2);
EDIT: Try now,

pawn Код:
stock MySQL_House(playerid)
{
    new query[300], pname[24], savingstring[20],string1[128], x[20], y[20], z[20];
    GetPlayerName(playerid, pname, 24);
    format(query, sizeof(query), "SELECT * FROM `house`");
    mysql_query(query);
    mysql_store_result();
    while(mysql_fetch_row_format(query,"|"))
    {
        mysql_fetch_field_row(savingstring, "houseid"); HouseID[playerid] = strval(savingstring);
        mysql_fetch_field_row(savingstring, "Owner"); HouseOwner[playerid] = strval(savingstring);
        mysql_fetch_field_row(x, "xHPos");
        mysql_fetch_field_row(y, "yHPos");
        mysql_fetch_field_row(z, "zHPos");

        format(string1, sizeof string1, "House Owner: %s\nX:%d, Y:%d,Z:%d\nHouse ID:%d", HouseOwner, floatstr(x), floatstr(y), floatstr(z), strval(HouseID));
        CreatePickup(1273, 1, floatstr(x), floatstr(y), floatstr(z));
        Create3DTextLabel(string1, 0xFFFFFFFF, floatstr(x), floatstr(y), floatstr(z), 10.0, 0, 0);

    }
    mysql_free_result();
    return 1;
}



Re: Mysql is not setting positions. - Shockey HD - 14.05.2012

Recieved an Message.



Anything else we can try?