MySQL r41 help!
#1

I have problem with changing r39 > r41 and i got this issue

Код:
		format(str, sizeof(str), "pRadio%i", i);
		PlayerInfo[playerid][pRadio][i] = cache_get_field_content_int(0, str, ourConnection);
How to change this line?
Reply
#2

You can use this wiki: https://sampwiki.blast.hk/wiki/MySQL/R40
for loading the data as integer you can use that function "cache_get_value_index_int(row_idx, column_idx, &destination)". Check all the functions in the wiki!
Also I will edit your code to the R41 version. Here you are:
PHP код:
format(strsizeof(str), "pRadio%i"i);
cache_get_value_index_int(0strPlayerInfo[playerid][pRadio][i]); 
I hope I helped enough! +1 REP if I did!
Reply
#3

Ty for that code
Another problem

Код:
function:Query_LoadFactionRanks(factionid)
{
	new rows, fields;
	cache_get_row_count(rows);
	cache_get_field_count(fields);
	for (new i = 0; i < rows && i< MAX_FACTION_RANKS; i++)
	{
		cache_get_value_name(i, "FactionRank1", FactionRanks[PlayerInfo[i][pFaction]["NotSet"]);
                cache_get_value_name(i, "FactionRank2", FactionRanks[PlayerInfo[i][pFaction]["NotSet"]); // example
	}
	return 1;
}
And my database screenshot
https://imgur.com/a/HP2JgJO

My variable

Код:
pFactionRank,
new FactionRanks[MAX_FACTIONS][MAX_FACTION_RANKS][60];
If you guys wanna see the old code
I try to add 1 by 1 lines so i change it

Код:
function:Query_LoadFactionRanks(factionid)
{
	new str[128];

	new rows, fields; cache_get_data(rows, fields, ourConnection);

	for (new i = 0; i < rows; i++)
	{
		for (new j = 1; j < MAX_FACTION_RANKS; j++)
		{
			format(str, sizeof(str), "FactionRank%i", j);
			cache_get_field_content(i, str, FactionRanks[factionid][j], ourConnection, 60);
		}
	}
	return 1;
}
I dont know what to do with this code can anyone explain please
Sorry for stupid question
Reply
#4

Converting to R40 and above: https://sampforum.blast.hk/showthread.php?tid=616103

pawn Код:
for (new j = 1; j < MAX_FACTION_RANKS; j++)
{
    format(str, sizeof(str), "FactionRank%i", j);
    cache_get_field_content(i, str, FactionRanks[factionid][j], ourConnection, 60);
}
This is bad design, use another table not columns.
Reply
#5

Check this https://sampwiki.blast.hk/wiki/MySQL/R40

and the code need be like this
Код:
function:Query_LoadFactionRanks(factionid)
{
	new str[128];

	new rows = cache_num_rows();

	for (new i = 0; i < rows; i++)
	{
		for (new j = 1; j < MAX_FACTION_RANKS; j++)
		{
			format(str, sizeof(str), "FactionRank%i", j);
			cache_get_value(i, str, FactionRanks[factionid][j], 60);
		}
	}
	return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)