SA-MP Forums Archive
Loading System - 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: Loading System (/showthread.php?tid=629943)



Loading System +REP - JessThompson - 06.03.2017

Код:
{
	new total = 0, cell = 1, pickupmodel, LabelCell[258], InitialTicks = GetTickCount();
	static
		rows,
		fields;

	cache_get_data(rows, fields, g_iHandle);
    if(rows)
    {
		while(total < rows)
		{
			CellSystem[cell][CellSQLID] = cache_get_row_int(total, 0);

			cache_get_field_content(total, "Cell_Name", CellSystem[cell][CellName], g_iHandle, 128);

			CellSystem[cell][CellLocked] = cache_get_field_int(total, "Cell_Locked");
			CellSystem[cell][CellOwner] = cache_get_field_int(total, "Cell_Owner");
			CellSystem[cell][CellPrice] = cache_get_field_int(total, "Cell_Price");
			CellSystem[cell][CellLevel] = cache_get_field_int(total, "Cell_Level");
			CellSystem[cell][CellWeaponOne] = cache_get_field_int(total, "Cell_Weapon_One");
			CellSystem[cell][CellWeaponTwo] = cache_get_field_int(total, "Cell_Weapon_Two");
			CellSystem[cell][CellWeed] = cache_get_field_int(total, "Cell_Weed");
			CellSystem[cell][CellCoke] = cache_get_field_int(total, "Cell_Coke");

			CellSystem[cell][CellEntPosX] = cache_get_field_float(total, "Cell_Ent_Pos_X");
			CellSystem[cell][CellEntPosY] = cache_get_field_float(total, "Cell_Ent_Pos_Y");
			CellSystem[cell][CellEntPosZ] = cache_get_field_float(total, "Cell_Ent_Pos_Z");
			CellSystem[cell][CellExtPosX] = cache_get_field_float(total, "Cell_Ext_Pos_X");
			CellSystem[cell][CellExtPosY] = cache_get_field_float(total, "Cell_Ext_Pos_Y");
			CellSystem[cell][CellExtPosZ] = cache_get_field_float(total, "Cell_Ext_Pos_Z");

			CellSystem[cell][CellLoaded] = 1;

			if(CellSystem[cell][CellOwner] == -1) pickupmodel = 19522;
			else pickupmodel = 1273;

			CellSystem[cell][CellPickup] = CreateDynamicPickup(pickupmodel, 23, CellSystem[cell][CellEntPosX], CellSystem[cell][CellEntPosY], CellSystem[cell][CellEntPosZ], 0, -1, -1, 20.0);

			if(CellSystem[cell][CellOwner] == -1) format(LabelCell, sizeof(LabelCell), "%s\n /buycell to buy this cell for $%d", CellSystem[cell][CellName], CellSystem[cell][CellPrice]);
			//else format(LabelCell, sizeof(LabelCell), "%s\n Owner: %s | Cell level: %i | Cell Locked: %i", CellSystem[cell][CellName], ReturnNameFromID(CellSystem[cell][CellOwner]), CellSystem[cell][CellLevel], CellSystem[cell][CellLocked]);

			CellSystem[cell][CellLabel] = CreateDynamic3DTextLabel(LabelCell, -1, CellSystem[cell][CellEntPosX], CellSystem[cell][CellEntPosY], CellSystem[cell][CellEntPosZ]+0.5, 15.0, INVALID_PLAYER_ID, INVALID_VEHICLE_ID, 1, 0, -1, -1, 15.0);
	    	total++;
	    	cell ++;

	    	printf("loop id: %i | enum id: %i  | Cell Name: %s", cell, CellSystem[cell][CellSQLID], CellSystem[cell][CellName]);

	    }

	}
	printf("%i cells have been successfully loaded. [%i miliseconds]", cache_num_rows(), GetTickCount() - InitialTicks);
	return 1;
}
I have been looking at this this past couple of days but I can't seem to figure out why its not loading anything when I printf at the bottom I get this

Код:
[00:40:55] loop id: 2 | enum id: 0  | Cell Name: 
[00:40:55] loop id: 3 | enum id: 0  | Cell Name: 
[00:40:55] loop id: 4 | enum id: 0  | Cell Name: 
[00:40:55] loop id: 5 | enum id: 0  | Cell Name: 
[00:40:55] loop id: 6 | enum id: 0  | Cell Name: 
[00:40:55] loop id: 7 | enum id: 0  | Cell Name: 
[00:40:55] loop id: 8 | enum id: 0  | Cell Name: 
[00:40:55] loop id: 9 | enum id: 0  | Cell Name: 
[00:40:55] loop id: 10 | enum id: 0  | Cell Name: 
[00:40:55] loop id: 11 | enum id: 0  | Cell Name: 
[00:40:55] loop id: 12 | enum id: 0  | Cell Name: 
[00:40:55] loop id: 13 | enum id: 0  | Cell Name: 
[00:40:55] loop id: 14 | enum id: 0  | Cell Name: 
[00:40:55] loop id: 15 | enum id: 0  | Cell Name: 
[00:40:55] loop id: 16 | enum id: 0  | Cell Name: 
[00:40:55] loop id: 17 | enum id: 0  | Cell Name: 
[00:40:55] loop id: 18 | enum id: 0  | Cell Name: 
[00:40:55] loop id: 19 | enum id: 0  | Cell Name: 
[00:40:55] loop id: 20 | enum id: 0  | Cell Name: 
[00:40:55] loop id: 21 | enum id: 0  | Cell Name: 
[00:40:55] loop id: 22 | enum id: 0  | Cell Name: 
[00:40:55] loop id: 23 | enum id: 0  | Cell Name: 
[00:40:55] loop id: 24 | enum id: 0  | Cell Name: 
[00:40:55] loop id: 25 | enum id: 0  | Cell Name: 
[00:40:55] loop id: 26 | enum id: 0  | Cell Name: 
[00:40:55] loop id: 27 | enum id: 0  | Cell Name: 
[00:40:55] loop id: 28 | enum id: 0  | Cell Name: 
[00:40:55] loop id: 29 | enum id: 0  | Cell Name: 
[00:40:55] loop id: 30 | enum id: 0  | Cell Name: 
[00:40:55] loop id: 31 | enum id: 0  | Cell Name: 
[00:40:55] loop id: 32 | enum id: 0  | Cell Name: 
[00:40:55] loop id: 33 | enum id: 0  | Cell Name: 
[00:40:55] loop id: 34 | enum id: 0  | Cell Name: 
[00:40:55] loop id: 35 | enum id: 0  | Cell Name: 
[00:40:55] loop id: 36 | enum id: 0  | Cell Name: 
[00:40:55] loop id: 37 | enum id: 0  | Cell Name: 
[00:40:55] loop id: 38 | enum id: 0  | Cell Name: 
[00:40:55] loop id: 39 | enum id: 0  | Cell Name: 
[00:40:55] loop id: 40 | enum id: 0  | Cell Name: 
[00:40:55] loop id: 41 | enum id: 0  | Cell Name: 
[00:40:55] loop id: 42 | enum id: 0  | Cell Name: 
[00:40:55] loop id: 43 | enum id: 0  | Cell Name: 
[00:40:55] loop id: 44 | enum id: 0  | Cell Name: 
[00:40:55] loop id: 45 | enum id: 0  | Cell Name: 
[00:40:55] loop id: 46 | enum id: 0  | Cell Name: 
[00:40:55] loop id: 47 | enum id: 0  | Cell Name: 
[00:40:55] loop id: 48 | enum id: 0  | Cell Name: 
[00:40:55] loop id: 49 | enum id: 0  | Cell Name: 
[00:40:55] loop id: 50 | enum id: 0  | Cell Name: 
[00:40:55] loop id: 51 | enum id: 0  | Cell Name:
It does not load any of the data for some odd reason can anyone see why?

This is my MySQL table




Re: Loading System - Unte99 - 06.03.2017

https://sampwiki.blast.hk/wiki/MySQL/R33#mysql_log


Re: Loading System - JessThompson - 06.03.2017

Nothing shows up in the log, It don't even create one and I have enabled logging

Here is the HTML version
http://liamleonard.com/mysql_log.html


That is why I don't understand why its not working, As in the logs it says that it is grabbing it but its not storing it within the enum variable?

Here is the enum

Код:
enum CellInfo
{
	CellSQLID,
	CellName[128],
	CellLocked,
	CellOwner,
	CellPrice,
	CellLevel,
	CellWeaponOne,
	CellWeaponTwo,
	CellWeed,
	CellCoke,
	Float:CellEntPosX,
	Float:CellEntPosY,
	Float:CellEntPosZ,
	Float:CellExtPosX,
	Float:CellExtPosY,
	Float:CellExtPosZ,
	CellPickup,
	CellLabel,
	CellLoaded,
}
new CellSystem[MAX_CELLS][CellInfo];



Re: Loading System - Unte99 - 06.03.2017

Show the query you are sending.


Re: Loading System - JessThompson - 06.03.2017

mysql_tquery(g_iHandle, "SELECT * FROM `samp_cells` ORDER BY `id` ASC", "LoadCells", "");


Re: Loading System - Unte99 - 06.03.2017

Open the same link that I gave you for the logging. When you open the link, find how mysql_tquery is used.


Re: Loading System - JessThompson - 06.03.2017

Yes I have found that?

Thing is it loads the cells in game, but for some reason does not seem to print the enum ids?


Re: Loading System - Unte99 - 06.03.2017

Quote:
Originally Posted by JessThompson
Посмотреть сообщение
Yes I have found that?

Thing is it loads the cells in game, but for some reason does not seem to print the enum ids?
Show me how you use mysql_tquery and how it is used in the link I gave you.


Re: Loading System - JessThompson - 06.03.2017

Here is the thread for that query

Код:
BCPRP::LoadCells()
{
	new total = 0, cell = 1, pickupmodel, LabelCell[258], InitialTicks = GetTickCount();
	static
		rows,
		fields;

	cache_get_data(rows, fields, g_iHandle);
    if(rows)
    {
		while(total < rows)
		{
			CellSystem[cell][CellSQLID] = cache_get_row_int(total, 0);

			cache_get_field_content(total, "Cell_Name", CellSystem[cell][CellName], g_iHandle, 128);

			CellSystem[cell][CellLocked] = cache_get_field_int(total, "Cell_Locked");
			CellSystem[cell][CellOwner] = cache_get_field_int(total, "Cell_Owner");
			CellSystem[cell][CellPrice] = cache_get_field_int(total, "Cell_Price");
			CellSystem[cell][CellLevel] = cache_get_field_int(total, "Cell_Level");
			CellSystem[cell][CellWeaponOne] = cache_get_field_int(total, "Cell_Weapon_One");
			CellSystem[cell][CellWeaponTwo] = cache_get_field_int(total, "Cell_Weapon_Two");
			CellSystem[cell][CellWeed] = cache_get_field_int(total, "Cell_Weed");
			CellSystem[cell][CellCoke] = cache_get_field_int(total, "Cell_Coke");

			CellSystem[cell][CellEntPosX] = cache_get_field_float(total, "Cell_Ent_Pos_X");
			CellSystem[cell][CellEntPosY] = cache_get_field_float(total, "Cell_Ent_Pos_Y");
			CellSystem[cell][CellEntPosZ] = cache_get_field_float(total, "Cell_Ent_Pos_Z");
			CellSystem[cell][CellExtPosX] = cache_get_field_float(total, "Cell_Ext_Pos_X");
			CellSystem[cell][CellExtPosY] = cache_get_field_float(total, "Cell_Ext_Pos_Y");
			CellSystem[cell][CellExtPosZ] = cache_get_field_float(total, "Cell_Ext_Pos_Z");

			CellSystem[cell][CellLoaded] = 1;

			if(CellSystem[cell][CellOwner] == -1) pickupmodel = 19522;
			else pickupmodel = 1273;

			CellSystem[cell][CellPickup] = CreateDynamicPickup(pickupmodel, 23, CellSystem[cell][CellEntPosX], CellSystem[cell][CellEntPosY], CellSystem[cell][CellEntPosZ], 0, -1, -1, 20.0);

			if(CellSystem[cell][CellOwner] == -1) format(LabelCell, sizeof(LabelCell), "%s\n /buycell to buy this cell for $%d", CellSystem[cell][CellName], CellSystem[cell][CellPrice]);
			//else format(LabelCell, sizeof(LabelCell), "%s\n Owner: %s | Cell level: %i | Cell Locked: %i", CellSystem[cell][CellName], ReturnNameFromID(CellSystem[cell][CellOwner]), CellSystem[cell][CellLevel], CellSystem[cell][CellLocked]);

			CellSystem[cell][CellLabel] = CreateDynamic3DTextLabel(LabelCell, -1, CellSystem[cell][CellEntPosX], CellSystem[cell][CellEntPosY], CellSystem[cell][CellEntPosZ]+0.5, 15.0, INVALID_PLAYER_ID, INVALID_VEHICLE_ID, 1, 0, -1, -1, 15.0);
	    	total++;
	    	cell ++;

	    	printf("loop id: %i | enum id: %i  | Cell Name: %s", cell, CellSystem[cell][CellSQLID], CellSystem[cell][CellName]);

	    }

	}
	printf("%i cells have been successfully loaded. [%i miliseconds]", cache_num_rows(), GetTickCount() - InitialTicks);
	return 1;
}



Re: Loading System - Unte99 - 06.03.2017

Quote:
Originally Posted by JessThompson
Посмотреть сообщение
Here is the thread for that query

Код:
BCPRP::LoadCells()
{
	new total = 0, cell = 1, pickupmodel, LabelCell[258], InitialTicks = GetTickCount();
	static
		rows,
		fields;

	cache_get_data(rows, fields, g_iHandle);
    if(rows)
    {
		while(total < rows)
		{
			CellSystem[cell][CellSQLID] = cache_get_row_int(total, 0);

			cache_get_field_content(total, "Cell_Name", CellSystem[cell][CellName], g_iHandle, 128);

			CellSystem[cell][CellLocked] = cache_get_field_int(total, "Cell_Locked");
			CellSystem[cell][CellOwner] = cache_get_field_int(total, "Cell_Owner");
			CellSystem[cell][CellPrice] = cache_get_field_int(total, "Cell_Price");
			CellSystem[cell][CellLevel] = cache_get_field_int(total, "Cell_Level");
			CellSystem[cell][CellWeaponOne] = cache_get_field_int(total, "Cell_Weapon_One");
			CellSystem[cell][CellWeaponTwo] = cache_get_field_int(total, "Cell_Weapon_Two");
			CellSystem[cell][CellWeed] = cache_get_field_int(total, "Cell_Weed");
			CellSystem[cell][CellCoke] = cache_get_field_int(total, "Cell_Coke");

			CellSystem[cell][CellEntPosX] = cache_get_field_float(total, "Cell_Ent_Pos_X");
			CellSystem[cell][CellEntPosY] = cache_get_field_float(total, "Cell_Ent_Pos_Y");
			CellSystem[cell][CellEntPosZ] = cache_get_field_float(total, "Cell_Ent_Pos_Z");
			CellSystem[cell][CellExtPosX] = cache_get_field_float(total, "Cell_Ext_Pos_X");
			CellSystem[cell][CellExtPosY] = cache_get_field_float(total, "Cell_Ext_Pos_Y");
			CellSystem[cell][CellExtPosZ] = cache_get_field_float(total, "Cell_Ext_Pos_Z");

			CellSystem[cell][CellLoaded] = 1;

			if(CellSystem[cell][CellOwner] == -1) pickupmodel = 19522;
			else pickupmodel = 1273;

			CellSystem[cell][CellPickup] = CreateDynamicPickup(pickupmodel, 23, CellSystem[cell][CellEntPosX], CellSystem[cell][CellEntPosY], CellSystem[cell][CellEntPosZ], 0, -1, -1, 20.0);

			if(CellSystem[cell][CellOwner] == -1) format(LabelCell, sizeof(LabelCell), "%s\n /buycell to buy this cell for $%d", CellSystem[cell][CellName], CellSystem[cell][CellPrice]);
			//else format(LabelCell, sizeof(LabelCell), "%s\n Owner: %s | Cell level: %i | Cell Locked: %i", CellSystem[cell][CellName], ReturnNameFromID(CellSystem[cell][CellOwner]), CellSystem[cell][CellLevel], CellSystem[cell][CellLocked]);

			CellSystem[cell][CellLabel] = CreateDynamic3DTextLabel(LabelCell, -1, CellSystem[cell][CellEntPosX], CellSystem[cell][CellEntPosY], CellSystem[cell][CellEntPosZ]+0.5, 15.0, INVALID_PLAYER_ID, INVALID_VEHICLE_ID, 1, 0, -1, -1, 15.0);
	    	total++;
	    	cell ++;

	    	printf("loop id: %i | enum id: %i  | Cell Name: %s", cell, CellSystem[cell][CellSQLID], CellSystem[cell][CellName]);

	    }

	}
	printf("%i cells have been successfully loaded. [%i miliseconds]", cache_num_rows(), GetTickCount() - InitialTicks);
	return 1;
}
Did you even read what I asked you to show...? This is not what I asked you to show.