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



cache_get_field_content - Fabyx15 - 24.12.2018

Hello guys, i' m trying to make a business system, so i created a table in mysql, when i create a business by default the owner is "State" and the description is "None". I want to get the "state" and "none" from my mysql table. By default the row Owner is set to "State" and Description is "None". When im formatting the business description, the 3d text label is saying that : Owner: and Description: (owner and description is empty, but it should be state and none by default from mysql table)

Script:

Код:
CMD:createbiz(playerid, params[])
{
	if(PlayerInfo[playerid][pAdmin] < 6) return SCM(playerid, COLOR_GREY, "Nu ai acces la aceasta comanda. ");
	new float:bEntryx, float:bEntryy, float:bEntryz, float:bExitx,float:bExity,float:bExitz, type, fee, description[64], owner[24];

	if(sscanf(params, "ii", type, fee)) return SCM(playerid, COLOR_GREY, "Usage: {FFFFFF}/createbiz <type>  <fee> (Type /bizztypes for info)");
	GetPlayerPos(playerid, Float:bEntryx, Float:bEntryy, Float:bEntryz);

	gQuery[0] = EOS;
	mysql_format(SQL, gQuery, sizeof(gQuery), "INSERT INTO `bizz` (`ID`, `Type`, `bEntryx`,	`bEntryy`, `bEntryz`, `bExitx`,  `bExity`, `bExitz`, `Fee`) VALUES (0, '%d', '%f', '%f', '%f', 0, 0, 0, '%d')", type, bEntryx, bEntryy, bEntryz, fee);
	mysql_tquery(SQL, gQuery, "", "");
	CreatePickup(1239, 1, Float:bEntryx, Float:bEntryy, Float:bEntryz, 0);
	new string[256];
	if(type == 1 )
	{
		cache_get_field_content(2, "Description", description);
		cache_get_field_content(2, "Owner", owner);
		format(string, 256, "{F2EA74}Business type: {74CFF2}24/7\n{F2EA74}Owner: {74CFF2}%s\n{F2EA74}Description: {74CFF2}%s\n{F2EA74}Entry Fee: {74CFF2}$%s",owner, description, FormatNumber(fee));
		Create3DTextLabel(string, -1, Float:bEntryx, Float:bEntryy, Float:bEntryz-0.150, 30, 0);
	}
	return 1;
}
And the mysql table:


Re: cache_get_field_content - Calisthenics - 24.12.2018

You cannot call cache functions to retrieve data without an active cache. You create the biz at that moment so you know it is not owned by any player but the State, just add the default values in format.