SA-MP Forums Archive
Don't Load weapons...MYSQL - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Don't Load weapons...MYSQL (/showthread.php?tid=615641)



Don't Load weapons...MYSQL - kexy96 - 25.08.2016

Hi all!

Код:
mysql_format(mysql, query, sizeof(query), "SELECT weaponid, ammo FROM player_weapons WHERE userid = %d;", pData[playerid][pID]);
	mysql_tquery(mysql, query, "OnLoadPlayerWeapons", "d", playerid);
Код:
forward OnLoadPlayerWeapons(playerid);
public OnLoadPlayerWeapons(playerid)
{
	new weaponid, ammo;

	for(new i, j = cache_get_row_count(mysql); i < j; i++) 
	{
	    weaponid 	= cache_get_row_int(i, 0, mysql);
	    ammo    	= cache_get_row_int(i, 1, mysql);

		if(!(0 <= weaponid <= 46)) // check if weapon is valid (should be)
		{
		continue;
		}
		GivePlayerWeapon(playerid, weaponid, ammo);
	}
	return;
}
Why don't load weapons?? :/ PLS HELP ME


Re: Don't Load weapons...MYSQL - Shinja - 25.08.2016

Show mysql_logs


Re: Don't Load weapons...MYSQL - kexy96 - 25.08.2016

Код:
[13:09:22] [DEBUG] mysql_format - connection: 1, len: 128, format: "SELECT weaponid, ammo FROM player_weapons WHERE userid = %d;"
[13:09:22] [DEBUG] CMySQLResult::CMySQLResult() - constructor called
[13:09:22] [DEBUG] mysql_tquery - connection: 1, query: "SELECT weaponid, ammo FROM player_weapons WHERE userid = 0;", callback: "OnLoadPlayerWeapons", format: "d"



Re: Don't Load weapons...MYSQL - Shinja - 25.08.2016

That's all no errors? show all please, make sure there are weapons under userid 0 in the table also


Re: Don't Load weapons...MYSQL - Konstantinos - 25.08.2016

There are simply no rows because if auto increment has been used, unique IDs start from 1.
When the player logins, assign to pID their unique ID because it seems you forgot to.


Re: Don't Load weapons...MYSQL - kexy96 - 25.08.2016

So, what should I do??


Re: Don't Load weapons...MYSQL - Konstantinos - 25.08.2016

Quote:
Originally Posted by kexy96
Посмотреть сообщение
So, what should I do??
Quote:
Originally Posted by Konstantinos
Посмотреть сообщение
[..]
When the player logins, assign to pID their unique ID because it seems you forgot to.
Posting a screenshot of the user IDs from the table to confirm it would also be good.


Re: Don't Load weapons...MYSQL - kexy96 - 25.08.2016




Re: Don't Load weapons...MYSQL - Konstantinos - 25.08.2016

Auto increment is enabled; thus this means that pID starts from 1 as I mentioned previously. Currently, the value of pData[playerid][pID] is 0 so the possible reasons are:

1) When a player registers, you do not retrieve the unique ID after sending the INSERT query using mysql_insert_id() (for StrickenKid's plugin or BlueG's older versions) or cache_insert_id() (for BlueG's R33+).
2) When a player logins, you do not store the player's unique ID to the variable.