cmd:sellcell ~ Bugged
#1

I have a command to sell cells but it only allows you if you standing on cell A101 the first cell within the enum list

COMMAND

Код:
CMD:sellcell(playerid, params[])
{
	if(PlayerStat[playerid][Logged] != 1 || !IsPlayerConnected(playerid)) return SendErrorMessage(playerid, "Seems like you are not logged in!");
	if(PlayerStat[playerid][Cuffed] == 1 || PlayerStat[playerid][Dead] == 1 || PlayerStat[playerid][InHospital] == 1) return SendErrorMessage(playerid, "You cannot use this command at the moment!");
	if(PlayerStat[playerid][HasCell] == 0) return SendErrorMessage(playerid, "You don't have a cell you can sell!");

	new c = GetCellIDFromSQLID(PlayerStat[playerid][Cell]);
	new Confirmation[7], msg[255];
	if(sscanf(params,"s[128]", Confirmation))return SendClientMessage(playerid, GREY, "Are you SURE you want to sell your cell? if yes, type this: /sellcell confirm");
    else if(!strcmp(Confirmation, "confirm", true))
    {
		if(IsPlayerInRangeOfPoint(playerid, 1, CellSystem[c][CellEntPosX], CellSystem[c][CellEntPosY], CellSystem[c][CellEntPosZ]))
		{
			new cellPrice = CellSystem[c][CellPrice] / 2;
			CellSystem[c][CellOwner] = -1;
			CellSystem[c][CellLocked] = 1;
			PlayerStat[playerid][HasCell] = 0;
			PlayerStat[playerid][Cell] = -1;

			CellSystem[c][CellLevel] = 0;
			CellSystem[c][CellWeed] = 0;
			CellSystem[c][CellCoke] = 0;
			CellSystem[c][CellWeaponOne] = 0;
			CellSystem[c][CellWeaponTwo] = 0;

			GiveMoney(playerid, cellPrice);

			DestroyDynamicPickup(CellSystem[c][CellPickup]);
			DestroyDynamic3DTextLabel(Text3D:CellSystem[c][CellLabel]);

			format(msg, sizeof(msg),"You have sold your cell (%s) for $%d.",CellSystem[c][CellName], cellPrice);
			SendClientMessage(playerid,COLOR_GOLD,msg);

			UpdateCellDetails©;
			SaveCells©;
		}
	}
	return true;
}
STOCK
Код:
stock GetCellIDFromSQLID(sqlid)
{
	new cellid;
	for(new h = 0; h < sizeof(CellSystem); h ++)
	{
		if(CellSystem[h][CellSQLID] == sqlid)
		{
			cellid = h;
			break;
		}
	}
	return cellid;
}
Reply
#2

Are you sure that PlayerStat[playerid][Cell] holds the correct ID and GetCellIDFromSQLID(sqlid) provides the right enum?
Reply
#3

This holds the correct cell yes but I don't know about the GetCellIDFromSQLID(sqlid) holding the correct enum,

Also when I said this was fixed the loading, it seems to sometimes load them all and sometimes only load about 5 of them

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

	cache_get_data(rows, fields, g_iHandle);
	for(new total = 0; total < rows; total++)
	{
		CellSystem[total][CellSQLID] = cache_get_field_int(total, "id");

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

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

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

		CellSystem[total][CellLoaded] = 1;

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

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

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

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

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

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

I'd suggest using dummy SQL values instead of using the stock to see if there's a problem with the stock.

In regards to the cells sometimes loading, there is perhaps a problem with your query or it could be timing out.
Reply
#5

The stock works, but you still need to use the command at the first cell.

And for the loading, I ahve some mysql errors?

www.liamleonard.com/mysql_log.html
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)