[DEBUG] cache_get_field_content - row: 1, field_name: "TagName", connection: 25, max_len: 1
[DEBUG] CMySQLResult::GetRowDataByName - row: '1', field: "TagName", data: "testtag"
[DEBUG] cache_get_field_content - row: 1, field_name: "TagOwner", connection: 25, max_len: 1
[DEBUG] CMySQLResult::GetRowDataByName - row: '1', field: "TagOwner", data: "vassilis"
[DEBUG] cache_get_field_content - row: 1, field_name: "TagFont", connection: 20, max_len: 1
[DEBUG] CMySQLResult::GetRowDataByName - row: '1', field: "TagFont", data: "the unseen"
[DEBUG] cache_get_field_content_float - row: 1, field_name: "TagX", connection: 1
[DEBUG] CMySQLResult::GetRowDataByName - row: '1', field: "TagX", data: "1613.17"
[DEBUG] cache_get_field_content_float - row: 1, field_name: "TagY", connection: 1
[DEBUG] CMySQLResult::GetRowDataByName - row: '1', field: "TagY", data: "-1843.19"
[DEBUG] cache_get_field_content_float - row: 1, field_name: "TagZ", connection: 1
[DEBUG] CMySQLResult::GetRowDataByName - row: '1', field: "TagZ", data: "13.53"
[DEBUG] cache_get_field_content_float - row: 1, field_name: "TagRX", connection: 1
[DEBUG] CMySQLResult::GetRowDataByName - row: '1', field: "TagRX", data: "0"
[DEBUG] cache_get_field_content_float - row: 1, field_name: "TagRY", connection: 1
[DEBUG] CMySQLResult::GetRowDataByName - row: '1', field: "TagRY", data: "0"
[DEBUG] cache_get_field_content_float - row: 1, field_name: "TagRZ", connection: 1
[DEBUG] CMySQLResult::GetRowDataByName - row: '1', field: "TagRZ", data: "88.3"
[DEBUG] cache_get_field_content_int - row: 1, field_name: "TagFontSize", connection: 1
[DEBUG] CMySQLResult::GetRowDataByName - row: '1', field: "TagFontSize", data: "17"
[DEBUG] cache_get_field_content_int - row: 1, field_name: "TagFontColor", connection: 1
[DEBUG] CMySQLResult::GetRowDataByName - row: '1', field: "TagFontColor", data: "-65536"
[DEBUG] cache_get_field_content_int - row: 1, field_name: "TagBold", connection: 1
[DEBUG] CMySQLResult::GetRowDataByName - row: '1', field: "TagBold", data: "0"
[DEBUG] CMySQLResult::~CMySQLResult() - deconstructor called
function LoadSprayTags(playerid)
{
new rows, fields;
cache_get_data(rows, fields, mysql);
for(new i = 0; i < rows; i++)
{
cache_get_field_content(i, "TagName", TagInfo[playerid][TagName], 25);
cache_get_field_content(i, "TagOwner", TagInfo[playerid][TagOwner], 25);
cache_get_field_content(i, "TagFont", TagInfo[playerid][TagFont], 20);
TagInfo[playerid][TagX] = cache_get_field_content_float(i, "TagX");
TagInfo[playerid][TagY] = cache_get_field_content_float(i, "TagY");
TagInfo[playerid][TagZ] = cache_get_field_content_float(i, "TagZ");
TagInfo[playerid][TagRX] = cache_get_field_content_float(i, "TagRX");
TagInfo[playerid][TagRY] = cache_get_field_content_float(i, "TagRY");
TagInfo[playerid][TagRZ] = cache_get_field_content_float(i, "TagRZ");
TagInfo[playerid][TagRZ] = cache_get_field_content_int(i, "TagFontSize");
TagInfo[playerid][TagRZ] = cache_get_field_content_int(i, "TagFontColor");
TagInfo[playerid][TagRZ] = cache_get_field_content_int(i, "TagBold");
}
TagInfo[playerid][TagObject] = CreateDynamicObject(19482, TagInfo[playerid][TagX], TagInfo[playerid][TagY], TagInfo[playerid][TagZ], TagInfo[playerid][TagRX], TagInfo[playerid][TagRY], TagInfo[playerid][TagRZ], -1, -1, -1, 300.0, 300.0);
SetDynamicObjectMaterialText(TagInfo[playerid][TagObject], 0, TagInfo[playerid][TagName], 70, TagInfo[playerid][TagFont], TagInfo[playerid][TagFontSize], 1, TagInfo[playerid][TagFontColor], 0, 0);
return 1;
cache_get_field_content(i, "TagName", TagInfo[playerid][TagName], mysql, 25); cache_get_field_content(i, "TagOwner", TagInfo[playerid][TagOwner], mysql, 25); cache_get_field_content(i, "TagFont", TagInfo[playerid][TagFont], mysql, 20);
It shouldn't be in a loop as your script only allows one object per player.
|
I want to point out about the string loading though. The 4th parameter is the connection handle and not the length of the said string to store the text.
Код:
cache_get_field_content(i, "TagName", TagInfo[playerid][TagName], mysql, 25); cache_get_field_content(i, "TagOwner", TagInfo[playerid][TagOwner], mysql, 25); cache_get_field_content(i, "TagFont", TagInfo[playerid][TagFont], mysql, 20); |
#define MAX_TAGS_PER_PLAYER 3
enum E_TAG_DATA {
// enumerators...
};
new TagInfo[MAX_PLAYERS][MAX_TAGS_PER_PLAYER][E_TAG_DATA];
Add an extra dimension which goes up to MAX_TAGS_PER_PLAYER which you can define to any value you like.
PHP код:
|
CMD:create(playerid, params[])
{
TagInfo[playerid][TagObject] = CreateDynamicObject(19482, X, Y, Z, 0.0, 0.0, 0.0, -1, -1, -1, 300.0, 300.0);
return 1;
}
mysql_format(mysql, query, sizeof(query), "SELECT * FROM `spraytags` WHERE `TagOwnerID` = '%d'", pinfo[playerid][ID]);
mysql_tquery(mysql, query, "LoadSprayTags", "i", playerid);
enum E_PLAYER_DATA {
tagCount
};
new PlayerInfo[MAX_PLAYERS][E_PLAYER_DATA];
enum E_TAG_DATA {
// enumerators
};
new TagInfo[MAX_PLAYERS][MAX_TAGS_PER_PLAYER][E_TAG_DATA];
CMD:create(playerid, params[])
{
if(PlayerInfo[playerid][tagCount] >= MAX_TAGS_PER_PLAYER)
return SendClientMessage(playerid, -1, "You have reached the maximum amount of tags per player.");
new tagIndex = ((PlayerInfo[playerid][tagCount] == 0) ? (PlayerInfo[playerid][tagCount]) : (PlayerInfo[playerid][tagCount] - 1));
TagInfo[playerid][tagIndex][TagObject] = CreateDynamicObject(19482, X, Y, Z, 0.0, 0.0, 0.0, -1, -1, -1, 300.0, 300.0);
return 1;
}
enum E_TAG_INFO {
bool:tagExists
};
new TagInfo[MAX_PLAYERS][MAX_TAGS_PER_PLAYER][E_TAG_INFO];
function SprayTag_GetFreeID(playerid) {
for(new i = 0; i < MAX_TAGS_PER_PLAYER; i++) if(!TagInfo[playerid][i][tagExists]) {
return i; // Return the free index
}
return -1; // All tags are in use (= player has reached MAX_TAGS_PER_PLAYER tags).
}
CMD:create(playerid, params[])
{
new tagIndex = SprayTag_GetFreeID(playerid);
if(tagIndex == -1) {
return SendClientMessage(playerid, -1, "You have reached the maximum amount of tags per player.");
}
TagInfo[playerid][tagIndex][TagObject] = CreateDynamicObject(19482, X, Y, Z, 0.0, 0.0, 0.0, -1, -1, -1, 300.0, 300.0);
return 1;
}
You can do two things:
|
new TagInfo[MAX_TAGS_PER_PLAYER][TagInformation], tagIndex = SprayTags_GetFreeSlot();
function SprayTag_GetFreeID()
{
for(new i = 0; i< MAX_TAGS_PER_PLAYER; i++) if(!TagInfo[i][TagExists]) return i;
return - 1;
}
CMD:create(playerid, params[])
{
if(tagIndex == -1) {
return SendClientMessage(playerid, -1, "You have reached the maximum amount of tags per player.");
}
TagInfo[playerid][tagIndex][TagObject] = CreateDynamicObject(19482, X, Y, Z, 0.0, 0.0, 0.0, -1, -1, -1, 300.0, 300.0);
return 1;
}