MySQL Login/Register problem
#1

I used this tutorial to get started, but since it uses a old and outdated MySQL version i wanted to convert it all to the new one

Tutorial link: https://sampforum.blast.hk/showthread.php?tid=574714

My mysql script: http://pastebin.com/P5CR5VZs

But i get those errors:

Код:
(72) : error 017: undefined symbol "LOG_ALL"
(73) : warning 213: tag mismatch
(106) : warning 213: tag mismatch
(107) : warning 213: tag mismatch
(293) : warning 213: tag mismatch
(294) : warning 213: tag mismatch
(319) : warning 213: tag mismatch
(320) : warning 213: tag mismatch
(338) : error 017: undefined symbol "cache_get_data"
(342) : warning 202: number of arguments does not match definition
(343) : error 035: argument type mismatch (argument 2)
(337) : warning 203: symbol is never used: "fields"
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


3 Errors.
Otherwise, if you have a good tutorial with one of the lastest MySQL plugin/include that would be nice too :P
Reply
#2

https://sampforum.blast.hk/showthread.php?tid=627520 , though it doesn't seem as thoroughly explained as the one you linked.
Reply
#3

I followed your tutorial but when i'm in-game and i leave the server it doesn't save the stats inside my DB

Код:
public OnPlayerDisconnect(playerid, reason)
{
    Corrupt_Check[playerid]++;

	new DB_Query[512];
	
	new Float: X, Float: Y, Float: Z, Float: R;
	
	GetPlayerPos(playerid, X, Y, Z);
	GetPlayerFacingAngle(playerid,R);
	
	PlayerInfo[playerid][PosX] = X;
	PlayerInfo[playerid][PosY] = Y;
	PlayerInfo[playerid][PosZ] = Z;
	PlayerInfo[playerid][PosR] = R;
	
	//Running a query to save the player's data using the stored stuff.
	mysql_format(Database, DB_Query, sizeof(DB_Query), "UPDATE `Users` SET `IP` = %s, `Admin` = %d, `VIP` = %d, `Money` = %d, `PosX` = %f, `PosY` = %.2f, `PosZ` = %.2f, `PosR` = %.2f, `Gun1` = %d, `Gun2` = %d, `Gun3` = %d, `Ammo1` = %d, `Ammo2` = %d, `Ammo3` = %d, `Skin` = %d, `Kills` = %d, `Deaths` = %d WHERE `ID` = %d LIMIT 1",
																																							PlayerInfo[playerid][IP],
																																							PlayerInfo[playerid][Admin],
																																							PlayerInfo[playerid][VIP],
																																							GetPlayerMoney(playerid),
																																							PlayerInfo[playerid][PosX],
																																							PlayerInfo[playerid][PosY],
																																							PlayerInfo[playerid][PosZ],
																																							PlayerInfo[playerid][PosR],
																																							PlayerInfo[playerid][Gun1],
																																							PlayerInfo[playerid][Gun2],
																																							PlayerInfo[playerid][Gun3],
																																							PlayerInfo[playerid][Ammo1],
																																							PlayerInfo[playerid][Ammo2],
																																							PlayerInfo[playerid][Ammo3],
																																							GetPlayerSkin(playerid),
																																							PlayerInfo[playerid][Kills],
																																							PlayerInfo[playerid][Deaths]);

	mysql_tquery(Database, DB_Query);

	if(cache_is_valid(PlayerInfo[playerid][Player_Cache])) //Checking if the player's cache ID is valid.
	{
		cache_delete(PlayerInfo[playerid][Player_Cache]); // Deleting the cache.
		PlayerInfo[playerid][Player_Cache] = MYSQL_INVALID_CACHE; // Setting the stored player Cache as invalid.
	}

	PlayerInfo[playerid][LoggedIn] = false;
	print("OnPlayerDisconnect has been called."); // Sending message once OnPlayerDisconnect is called.
	return 1;
}
I don't know if OPD is enough, if you need any other part of the code just ask
Reply
#4

Post your error log.
Reply
#5

Код:
[03/20/17 03:10:56] [DEBUG] mysql_format(1, 0xB50FB5EC, 512, "UPDATE `Users` SET `IP` = %s, `Admin` = %d, `VIP` = %d, `Money` = %d, `PosX` = %f, `PosY` = %.2f, `PosZ` = %.2f, `PosR` = %.2f, `Gun1` = %d, `Gun2` = %d, `Gun3` = %d, `Ammo1` = %d, `Ammo2` = %d, `Ammo3` = %d, `Skin` = %d, `Kills` = %d, `Deaths` = %d WHERE `ID` = %d LIMIT 1")
[03/20/17 03:10:56] [ERROR] mysql_format: no value for specifier '%d' passed
[03/20/17 03:10:56] [DEBUG] mysql_format: return value: '0'
[03/20/17 03:10:56] [DEBUG] mysql_tquery(1, "", "", "")
Reply
#6

The amount of arguments does not match the amount of specifiers.
Reply
#7

Quote:
Originally Posted by Flamehaze7
Посмотреть сообщение
I followed your tutorial but when i'm in-game and i leave the server it doesn't save the stats inside my DB

Код:
public OnPlayerDisconnect(playerid, reason)
{
    Corrupt_Check[playerid]++;

	new DB_Query[512];
	
	new Float: X, Float: Y, Float: Z, Float: R;
	
	GetPlayerPos(playerid, X, Y, Z);
	GetPlayerFacingAngle(playerid,R);
	
	PlayerInfo[playerid][PosX] = X;
	PlayerInfo[playerid][PosY] = Y;
	PlayerInfo[playerid][PosZ] = Z;
	PlayerInfo[playerid][PosR] = R;
	
	//Running a query to save the player's data using the stored stuff.
	mysql_format(Database, DB_Query, sizeof(DB_Query), "UPDATE `Users` SET `IP` = %s, `Admin` = %d, `VIP` = %d, `Money` = %d, `PosX` = %f, `PosY` = %.2f, `PosZ` = %.2f, `PosR` = %.2f, `Gun1` = %d, `Gun2` = %d, `Gun3` = %d, `Ammo1` = %d, `Ammo2` = %d, `Ammo3` = %d, `Skin` = %d, `Kills` = %d, `Deaths` = %d WHERE `ID` = %d LIMIT 1",
																																							PlayerInfo[playerid][IP],
																																							PlayerInfo[playerid][Admin],
																																							PlayerInfo[playerid][VIP],
																																							GetPlayerMoney(playerid),
																																							PlayerInfo[playerid][PosX],
																																							PlayerInfo[playerid][PosY],
																																							PlayerInfo[playerid][PosZ],
																																							PlayerInfo[playerid][PosR],
																																							PlayerInfo[playerid][Gun1],
																																							PlayerInfo[playerid][Gun2],
																																							PlayerInfo[playerid][Gun3],
																																							PlayerInfo[playerid][Ammo1],
																																							PlayerInfo[playerid][Ammo2],
																																							PlayerInfo[playerid][Ammo3],
																																							GetPlayerSkin(playerid),
																																							PlayerInfo[playerid][Kills],
																																							PlayerInfo[playerid][Deaths]);

	mysql_tquery(Database, DB_Query);

	if(cache_is_valid(PlayerInfo[playerid][Player_Cache])) //Checking if the player's cache ID is valid.
	{
		cache_delete(PlayerInfo[playerid][Player_Cache]); // Deleting the cache.
		PlayerInfo[playerid][Player_Cache] = MYSQL_INVALID_CACHE; // Setting the stored player Cache as invalid.
	}

	PlayerInfo[playerid][LoggedIn] = false;
	print("OnPlayerDisconnect has been called."); // Sending message once OnPlayerDisconnect is called.
	return 1;
}
I don't know if OPD is enough, if you need any other part of the code just ask
Please do not save everything under OnPlayerDisconnect. Lets imagine for a second that for some reason you need to /gmx and everyone gets disconnected at the same time, and lets say you have 100 players on. This means 100 x queries will be processed one after the other as well as other code running. I can bet this will cause some delays, since thats a lot of processing to do in one small time. Not only this but over time your query will get bigger and bigger due to the amount of stuff you may add.

Instead save the data after it has been modified, if a player updates his name, save it to db, if a player gets a kill update the db, this will reduce the stress of the server.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)