SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 11/12/2016, 10:55 AM   #1
SkyFlare
Huge Clucker
 
SkyFlare's Avatar
 
Join Date: Apr 2015
Location: NZ
Posts: 221
Reputation: 43
Default So weird..MySql not saving coordinate.

Hey guys, I have a very weird problem with my script..
X Float, Z Float & A Float Coordinates are saving perfectly fine.
Y Float is like "Nah too mainstream" and saves as 0.

Any ideas on why guys?

(OnPlayerDisconnect)
Code:
calling UpdateUserPosition(playerid);
(UpdateUserPosition(playerid))
Code:
UpdateUserPosition(playerid)
{
	GetUserPosition(playerid);
    new query[654];
    mysql_format(g_SQL, query, sizeof query, "UPDATE `accounts` SET `posX` =%f, `posY` =%f, `posZ` =%f, `posA` =%f WHERE `id` = %d LIMIT 1", Player[playerid][X_Pos], Player[playerid][Y_Pos], Player[playerid][Z_Pos], Player[playerid][A_Pos], Player[playerid][ID]);
	mysql_tquery(g_SQL, query);
	return 1;
}
(GetUserPosition(playerid))
Code:
stock GetUserPosition(playerid)
{
	new Float: pos[4];
    GetPlayerPos(playerid, pos[0], pos[1], pos[2]);
    GetPlayerFacingAngle(playerid, pos[3]);
    Player[playerid][X_Pos] = pos[0];
    Player[playerid][Y_Pos] = pos[1];
    Player[playerid][Z_Pos] = pos[2];
    Player[playerid][A_Pos] = pos[3];
	return 1;
}
__________________
Purchasable Scripting Services Available, Inbox me with your Requests.
My Project Progress Tracker
My Work
Link
Information
S-Store System V2 LinkIngame Store in Dialogs

Last edited by SkyFlare; 11/12/2016 at 11:28 AM.
SkyFlare is offline   Reply With Quote
Old 11/12/2016, 10:58 AM   #2
amirm3hdi
Banned
 
Join Date: Apr 2015
Location: Brain
Posts: 270
Reputation: 14
Default Re: So weird..MySql not saving coordinate.

Don't give bullshit, try printing the query and give it to me.
amirm3hdi is offline   Reply With Quote
Old 11/12/2016, 10:59 AM   #3
BiosMarcel
Banned
 
Join Date: Jul 2012
Location: Germany
Posts: 1,219
Reputation: 234
Default Re: So weird..MySql not saving coordinate.

Even tho this is theoretically working (and not a fix to your problem):

PHP Code:
new Float:angleposition[1]; 
it is stupid to make an array with the size of 1, just make a normal Float variable.

And about your problem: print X, Y and Z before saving it, to see what it is, since the variables are at the top of your script (why ever that is so), they might be overwritten from somehwere else.
BiosMarcel is offline   Reply With Quote
Old 11/12/2016, 11:50 AM   #4
SkyFlare
Huge Clucker
 
SkyFlare's Avatar
 
Join Date: Apr 2015
Location: NZ
Posts: 221
Reputation: 43
Default Re: So weird..MySql not saving coordinate.

Quote:
Originally Posted by [Bios]Marcel View Post
Even tho this is theoretically working (and not a fix to your problem):

PHP Code:
new Float:angleposition[1]; 
it is stupid to make an array with the size of 1, just make a normal Float variable.

And about your problem: print X, Y and Z before saving it, to see what it is, since the variables are at the top of your script (why ever that is so), they might be overwritten from somehwere else.
Found the problem, Sql does not like Capital letters when saving.... so I changed it in the Database and in the script to lowercase
Code:
UpdateUserPosition(playerid)
{
	GetUserPosition(playerid);
    new query[512];
    mysql_format(g_SQL, query, sizeof query, "UPDATE `accounts` SET `posx` = %f, `posy` = %f, `posz` = %f, `posa` = %f WHERE `id` = %d LIMIT 1", Player[playerid][X_Pos], Player[playerid][Y_Pos], Player[playerid][Z_Pos], Player[playerid][A_Pos], Player[playerid][ID]);
	mysql_tquery(g_SQL, query);
	return 1;
}
Also i fixed my array mess ( I fixed this first, still was showing 0 by the way)
Code:
stock GetUserPosition(playerid)
{
	new Float: pos[4];
    GetPlayerPos(playerid, pos[0], pos[1], pos[2]);
    GetPlayerFacingAngle(playerid, pos[3]);
    Player[playerid][X_Pos] = pos[0];
    Player[playerid][Y_Pos] = pos[1];
    Player[playerid][Z_Pos] = pos[2];
    Player[playerid][A_Pos] = pos[3];
	return 1;
}
__________________
Purchasable Scripting Services Available, Inbox me with your Requests.
My Project Progress Tracker
My Work
Link
Information
S-Store System V2 LinkIngame Store in Dialogs
SkyFlare is offline   Reply With Quote
Old 12/12/2016, 07:42 AM   #5
amirm3hdi
Banned
 
Join Date: Apr 2015
Location: Brain
Posts: 270
Reputation: 14
Default Re: So weird..MySql not saving coordinate.

If you're not experienced with SQL, you'll have more errors on the way, always print them and if you still don't get whats the problem, run the in PhpMyAdmin or something.
amirm3hdi is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Really weird problem (y_ini saving) nerovani Scripting Help 7 02/04/2016 06:59 AM
Weird Bug for mysql DavidLuango Scripting Help 6 07/01/2015 10:40 PM
Weird MySQL on GMX bug. Boooth Scripting Help 4 23/06/2013 03:27 PM
Parts saving but not loading, so weird! Jack_Leslie Help Archive 2 16/08/2011 08:23 AM
Coordinate Saving Problem Adamrcook Help Archive 6 24/08/2009 11:40 PM


All times are GMT. The time now is 07:34 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.