31.08.2013, 10:06
Alright, so i'll cut to the chase directly.
I'm using MYSQL to run with my server, well Mysql R5 to be more precise.
It all works great and all that, but there is one thing that I can't seem to understand.
When ever the server saves something to the MYSQL Database, it does that perfectly fine, but the server itself, does NOT read the changes to the MYSQL Database, untill there is a GMX.
Am I missing some command, to make the server read the actual changes to the databases?
For example, this is my weapon saving system;
The above works perfectly fine, and gets saved in the MYSQL database accordingly and in the correct way.
Now, this is the code that happens when the server needs to load the saved weapons.
Now the thing is, as soon it does that specific code, it doesn't read anything at all. It just treaths them as 0, like it was before in the database.
This is the code I use to give them their weapons, but obviously, it can't set them, as they have none according to the server.
This also happens when dynamicly adding a faction vehicle. It gets added just fine, but it'll respawn at the place where you created the vehicle with "/veh", untill there is a GMX. After the GMX, the vehicle just respawns fine.
Edit: Forgot to mention, that it does this whenever the mysql database gets updated. The server does not read the changed values at all.
Best example is unbanning a player. They get unbanned perfectly fine in the MYSQL database, but as soon they reconnect, prior to a GMX, they still are banned. After unbanning and a GMX, they can rejoin perfectly fine.
Thanks in advance,
Tessa.
I'm using MYSQL to run with my server, well Mysql R5 to be more precise.
It all works great and all that, but there is one thing that I can't seem to understand.
When ever the server saves something to the MYSQL Database, it does that perfectly fine, but the server itself, does NOT read the changes to the MYSQL Database, untill there is a GMX.
Am I missing some command, to make the server read the actual changes to the databases?
For example, this is my weapon saving system;
Код:
stock SaveWeapons(playerid) { new query[1024], pname[24]; GetPlayerName(playerid, pname, 24); GetPlayerWeaponData(playerid, 1, Player[playerid][Weapon1], Player[playerid][Weapon1a]); GetPlayerWeaponData(playerid, 2, Player[playerid][Weapon2], Player[playerid][Weapon2a]); GetPlayerWeaponData(playerid, 3, Player[playerid][Weapon3], Player[playerid][Weapon3a]); GetPlayerWeaponData(playerid, 4, Player[playerid][Weapon4], Player[playerid][Weapon4a]); GetPlayerWeaponData(playerid, 5, Player[playerid][Weapon5], Player[playerid][Weapon5a]); GetPlayerWeaponData(playerid, 6, Player[playerid][Weapon6], Player[playerid][Weapon6a]); GetPlayerWeaponData(playerid, 7, Player[playerid][Weapon7], Player[playerid][Weapon7a]); GetPlayerWeaponData(playerid, 8, Player[playerid][Weapon8], Player[playerid][Weapon8a]); format(query, sizeof(query), "UPDATE Accounts SET Weapon1=%d, Weapon1A=%d, Weapon2=%d, Weapon2A=%d, Weapon3=%d, Weapon3A=%d, Weapon4=%d, Weapon4A=%d, Weapon5=%d, Weapon5A=%d, Weapon6=%d, Weapon6A=%d, Weapon7=%d, Weapon7A=%d, Weapon8=%d, Weapon8A=%d WHERE Username='%s'", Player[playerid][Weapon1], Player[playerid][Weapon1a], Player[playerid][Weapon2], Player[playerid][Weapon2a], Player[playerid][Weapon3], Player[playerid][Weapon3a], Player[playerid][Weapon4], Player[playerid][Weapon4a], Player[playerid][Weapon5], Player[playerid][Weapon5a], Player[playerid][Weapon6], Player[playerid][Weapon6a], Player[playerid][Weapon7], Player[playerid][Weapon7a], Player[playerid][Weapon8], Player[playerid][Weapon8a], pname); mysql_query(query); return 1; }
Now, this is the code that happens when the server needs to load the saved weapons.
Код:
mysql_fetch_field_row(savingstring, "Weapon1"); Player[playerid][Weapon1] = strval(savingstring); mysql_fetch_field_row(savingstring, "Weapon1A"); Player[playerid][Weapon1a] = strval(savingstring); mysql_fetch_field_row(savingstring, "Weapon2"); Player[playerid][Weapon2] = strval(savingstring); mysql_fetch_field_row(savingstring, "Weapon2A"); Player[playerid][Weapon2a] = strval(savingstring); mysql_fetch_field_row(savingstring, "Weapon3"); Player[playerid][Weapon3] = strval(savingstring); mysql_fetch_field_row(savingstring, "Weapon3A"); Player[playerid][Weapon3a] = strval(savingstring); mysql_fetch_field_row(savingstring, "Weapon4"); Player[playerid][Weapon4] = strval(savingstring); mysql_fetch_field_row(savingstring, "Weapon4A"); Player[playerid][Weapon4a] = strval(savingstring); mysql_fetch_field_row(savingstring, "Weapon5"); Player[playerid][Weapon5] = strval(savingstring); mysql_fetch_field_row(savingstring, "Weapon5A"); Player[playerid][Weapon5a] = strval(savingstring); mysql_fetch_field_row(savingstring, "Weapon6"); Player[playerid][Weapon6] = strval(savingstring); mysql_fetch_field_row(savingstring, "Weapon6A"); Player[playerid][Weapon6a] = strval(savingstring); mysql_fetch_field_row(savingstring, "Weapon7"); Player[playerid][Weapon7] = strval(savingstring); mysql_fetch_field_row(savingstring, "Weapon7A"); Player[playerid][Weapon7a] = strval(savingstring); mysql_fetch_field_row(savingstring, "Weapon8"); Player[playerid][Weapon8] = strval(savingstring); mysql_fetch_field_row(savingstring, "Weapon8A"); Player[playerid][Weapon8a] = strval(savingstring);
This is the code I use to give them their weapons, but obviously, it can't set them, as they have none according to the server.
Код:
GivePlayerWeapon(playerid, Player[playerid][Weapon1], Player[playerid][Weapon1a]); GivePlayerWeapon(playerid, Player[playerid][Weapon2], Player[playerid][Weapon2a]); GivePlayerWeapon(playerid, Player[playerid][Weapon3], Player[playerid][Weapon3a]); GivePlayerWeapon(playerid, Player[playerid][Weapon4], Player[playerid][Weapon4a]); GivePlayerWeapon(playerid, Player[playerid][Weapon5], Player[playerid][Weapon5a]); GivePlayerWeapon(playerid, Player[playerid][Weapon6], Player[playerid][Weapon6a]); GivePlayerWeapon(playerid, Player[playerid][Weapon7], Player[playerid][Weapon7a]); GivePlayerWeapon(playerid, Player[playerid][Weapon8], Player[playerid][Weapon8a]);
Edit: Forgot to mention, that it does this whenever the mysql database gets updated. The server does not read the changed values at all.
Best example is unbanning a player. They get unbanned perfectly fine in the MYSQL database, but as soon they reconnect, prior to a GMX, they still are banned. After unbanning and a GMX, they can rejoin perfectly fine.
Thanks in advance,
Tessa.