Saving Player Pos mysql
#1

I am trying to save the player position, but dont know how...
Can anyone help?
Code:
Код:
stock SaveStats(playerid)
{
	new query[156];
	new Float:pX, Float:pY, Float:pZ;
	GetPlayerPos(playerid, pX, pY, pZ);
	format(query, sizeof(query), "UPDATE playerdata SET PosX=%f AND PosY=%f AND PosZ=%f WHERE Name='%s'", pX, pY, pZ, GetName(playerid));
	mysql_query(query);
	printf("Player Saved");
	return 1;
}
Код:
stock LoadStats(playerid)
{
	new Query[80];
	format(Query, sizeof(Query), "SELECT * FROM playerdata WHERE Name = '%s'", GetName(playerid));
	mysql_query(Query);
	mysql_store_result();
	mysql_fetch_row_format(Query, "|");
	sscanf(Query, "e<p<|>s[24]s[23]iiiiiii>", PlayerInfo[playerid]);
	mysql_free_result();
	GivePlayerMoney(playerid, PlayerInfo[playerid][Cash]);
	SetPlayerScore(playerid, PlayerInfo[playerid][Level]);
	SetSpawnInfo(playerid, 0, PlayerInfo[playerid][Skin], PlayerInfo[playerid][X], PlayerInfo[playerid][Y], PlayerInfo[playerid][Z], 0, 0, 0, 0, 0, 0, 0);
	SpawnPlayer(playerid);
	return 1;
}
Thanks
Reply
#2

This is with INI saving system

pawn Код:
public OnPlayerDisconnect( playerid, reason )
{
    GetPlayerPos( playerid, PosX[ playerid ], PosY[ playerid ], PosZ[ playerid ] );
    GetPlayerFacingAngle( playerid, Angle[ playerid ] );
   
    new INI:File = INI_Open( user_ini_file( playerid ) );
    INI_SetTag( File, "position" );
    INI_WriteFloat( File, "PositionX", PosX[ playerid ] );
    INI_WriteFloat( File, "PositionY", PosY[ playerid ] );
    INI_WriteFloat( File, "PositionZ", PosZ[ playerid ] );
    INI_WriteFloat( File, "Angle", Angle[ playerid ] );
    INI_WriteInt( File, "Interior", GetPlayerInterior( playerid ) );
    INI_WriteInt( File, "VirtualWorld", GetPlayerVirtualWorld( playerid ) );
    INI_Close( File );
    return ( 1 );
}
Try to somehow conver into mysql
Reply
#3

Hm?
pawn Код:
format(query, sizeof(query), "UPDATE playerdata SET PosX=%f, PosY=%f, PosZ=%f WHERE Name='%s'", pX, pY, pZ, GetName(playerid));
Reply
#4

Yeah that line... Its not updating the database with the new position
Reply
#5

Well try my form. Try increase query. Check errors in server_log. Check if you have created the right colums for the table.
Reply
#6

Ok it is updating the table but it keeps updating it to x(0) y(-1933.67)z(13.3859)
No matter were I am...
Just checked the server log and it says this when I log in
Quote:

[21:40:02] Number of vehicle models: 0
[21:40:22] Incoming connection: 127.0.0.1:63873
[21:40:22] [join] Jason_Smith has joined the server (0:127.0.0.1)
[21:40:26] sscanf warning: String buffer overflow.
[21:40:26] [debug] Run time error 6: "Invalid instruction"
[21:40:26] [debug] Unknown opcode 0x1000000 at address 0x0000004D
[21:40:26] [debug] AMX backtrace:
[21:40:26] [debug] #0 0000004d in public OnDialogResponse () from RP_Mysql.amx
[21:40:38] Player Saved
[21:40:38] [part] Jason_Smith has left the server (0:1)

Reply
#7

Increase query in load. 80 is too damn low for *
Reply
#8

I did 258 even gives me the problem
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)