Don't Load weapons...MYSQL
#1

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
Reply
#2

Show mysql_logs
Reply
#3

Код:
[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"
Reply
#4

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

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.
Reply
#6

So, what should I do??
Reply
#7

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.
Reply
#8

Reply
#9

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.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)