Float problem
#1

Hello,
I built a menu and had a problem with it. At the menu-create (cmd /skin) the script checks the mysql-databbase for all skins in a special table. If the skinname is "frei" the for-loop breaks;
The idea for the menu is working, but I've got a problem with the OnPlayerSelectedMenuRow.
Here's the script:
Quote:

new pName[MPN], pSkin[4], Menu:current;
current = GetPlayerMenu(playerid);

if(current == PlayerMenu[playerid])
{
format(query,sizeof query,"SELECT * FROM `skin` WHERE `name` = '%s'",pName);
mysql_query(query);
mysql_store_result();
mysql_fetch_field("skin1x",pSkin[0]);
mysql_fetch_field("skin1y",pSkin[1]);
mysql_fetch_field("skin1z",pSkin[2]);
mysql_fetch_field("skin1a",pSkin[3]);
SetPlayerPos(playerid,floatstr(pSkin[0]),floatstr(pSkin[1]),floatstr(pSkin[2]));
SetPlayerFacingAngle(playerid,floatstr(pSkin[3]));
/* There will be up to 4 options in the menu, and every option will load a specific field out of the mysql.
But I though if the first one don't work, I should fix the problem before doing the other ones. */
}

NOW here's the problem: Every time I used this menu I got teleported to the point 0.0,0.0,0.0. So I printed (print(pSkin[0]) the X-Coordinate of the player (mysql = skin1x) and it printed in the console the text "sssname". I dunno why. So I'm asking here.

I hope you can help
Padarom
Reply
#2

Try
new pSkin[4][50]
Reply
#3

Still get another message in my console. Now it's samp-rl - the name of the mysql database.

Padarom
Reply
#4

I already changed the row-type (in the mysql) from varchar to decimal to float, but still the same error.

Can no one help?
Reply
#5

Код:
new Float:Pos[3],sql[1024];
mysql_fetch_field("X_Kordinate",sql); Pos[0] = floatstr(sql);
mysql_fetch_field("Y_Kordinate",sql); Pos[1] = floatstr(sql);
mysql_fetch_field("Z_Kordinate",sql); Pos[2] = floatstr(sql);
SetPlayerPos(playerid,Pos[0],Pos[1],Pos[2]);
Reply
#6

With this method I get a tag mismatch.

**edit**
sry, I didn't define Pos as Float

**edit**
Mh... after I do /skins and select the first menu row, the console went out without an error.
could it be because there are only 2 menu rows?
Reply
#7

The problem is not in my script.. Show us that your command
Reply
#8

I don't think that the command's the problem. the cmd itself works, but the console shut down in the moment I select a menu row.
here's the script:
http://pastebin.com/H9br045c

Padarom
Reply
#9

Don't you want to try GUI? Menu is old and looks shitty. GUI is much better

Try like this:
Код:
public OnPlayerSelectedMenuRow(playerid, row)
{
		new pName[MPN], Float:ySkin[4], Float:pSkin[4], Float:xSkin[4], Float:zSkin[4], sql[128], sqlline[128], Menu:current;
		current = GetPlayerMenu(playerid);

		if(current == PlayerMenu[playerid])
		{
			format(query,1024,"SELECT * FROM skin WHERE name = '%s'",pName);
			mysql_query(query);
			mysql_store_result();
			mysql_fetch_row(sqlline);
 			mysql_fetch_field("skin1x",sql); ySkin[0] = floatstr(sql);
 			mysql_fetch_field("skin1y",sql); ySkin[1] = floatstr(sql);
 			mysql_fetch_field("skin1z",sql); ySkin[2] = floatstr(sql);
 			mysql_fetch_field("skin1a",sql); ySkin[3] = floatstr(sql);
			mysql_fetch_field("skin2x",sql); pSkin[0] = floatstr(sql);
			mysql_fetch_field("skin2y",sql); pSkin[1] = floatstr(sql);
			mysql_fetch_field("skin2z",sql); pSkin[2] = floatstr(sql);
			mysql_fetch_field("skin2a",sql); pSkin[3] = floatstr(sql);
			mysql_fetch_field("skin3x",sql); xSkin[0] = floatstr(sql);
			mysql_fetch_field("skin3y",sql); xSkin[1] = floatstr(sql);
			mysql_fetch_field("skin3z",sql); xSkin[2] = floatstr(sql);
			mysql_fetch_field("skin3a",sql); xSkin[3] = floatstr(sql);
			mysql_fetch_field("skin4x",sql); zSkin[0] = floatstr(sql);
			mysql_fetch_field("skin4y",sql); zSkin[1] = floatstr(sql);
			mysql_fetch_field("skin4z",sql); zSkin[2] = floatstr(sql);
			mysql_fetch_field("skin4a",sql); zSkin[3] = floatstr(sql);
			switch(row)
			{
				case 0:
				{
 				 	SetPlayerPos(playerid,ySkin[0],ySkin[1],ySkin[2]);
  					SetPlayerFacingAngle(playerid,ySkin[3]);
				}
				case 1:
				{
					SetPlayerPos(playerid,pSkin[0],pSkin[1],pSkin[2]);
					SetPlayerFacingAngle(playerid,pSkin[3]);
				}
				case 2:
				{
					SetPlayerPos(playerid,xSkin[0],xSkin[1],xSkin[2]);
					SetPlayerFacingAngle(playerid,xSkin[3]);
				}
				case 3:
				{
					SetPlayerPos(playerid,zSkin[0],zSkin[1],zSkin[2]);
					SetPlayerFacingAngle(playerid,zSkin[3]);
				}
			}
			mysql_free_result();
		}
		return 1;
}
Don't use sizeof because it eats more RAM of the server.
Reply
#10

Now the console don't close, but I still get teleported to coordinates 0.0,0.0,0.0
And it prints in the console it couldn't find the fields skin1x up to skin4a, although they exists.
What is the "mysql_fetch_row(sqlline);" for and what do I have to fill in instead of sqlline (because it is only defined, but what is it?)

Padarom
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)