Doesn't load object[MySQL]
#1

At mysql_log it loads it correctly but i guess i have forgotten something?

mysql_log.txt
PHP код:
 [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 
Loading Function
PHP код:
    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; 
It doesn't create the object though.. Have i done something wrong on creatingobject? or the materialtext?
Reply
#2

It shouldn't be in a loop as your script only allows one object per player.
Reply
#3

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);
Reply
#4

Quote:
Originally Posted by AndySedeyn
Посмотреть сообщение
It shouldn't be in a loop as your script only allows one object per player.
But how could i make it so each player can have max 3 objects?

Quote:
Originally Posted by Konstantinos
Посмотреть сообщение
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);
Ok thanks. I don't really think though that's the problem since it loads it correctly.
Reply
#5

Quote:
Originally Posted by vassilis
Посмотреть сообщение
But how could i make it so each player can have max 3 objects?
Add an extra dimension which goes up to MAX_TAGS_PER_PLAYER which you can define to any value you like.
PHP код:
#define MAX_TAGS_PER_PLAYER 3
enum E_TAG_DATA {
    
// enumerators...
};
new 
TagInfo[MAX_PLAYERS][MAX_TAGS_PER_PLAYER][E_TAG_DATA]; 
Reply
#6

Quote:
Originally Posted by AndySedeyn
Посмотреть сообщение
Add an extra dimension which goes up to MAX_TAGS_PER_PLAYER which you can define to any value you like.
PHP код:
#define MAX_TAGS_PER_PLAYER 3
enum E_TAG_DATA {
    
// enumerators...
};
new 
TagInfo[MAX_PLAYERS][MAX_TAGS_PER_PLAYER][E_TAG_DATA]; 
Ok and let's say the player has created the object
How should i use the variable with one more dimension?
For example
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;
} 
How this should be changed with the extra dimension?
EDIT: Forgot to mention that i am using in my script
PHP код:
mysql_format(mysql, query, sizeof(query), "SELECT * FROM `spraytags` WHERE `TagOwnerID` = '%d'", pinfo[playerid][ID]);
                    
mysql_tquery(mysql, query, "LoadSprayTags", "i", playerid); 
Reply
#7

You can do two things:
  • Keep count on how many objects the player already has:
    PHP код:
    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; 
    } 
  • Or via more sophisticated loops:
    PHP код:
    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; 
    } 
These are just short and incomplete examples on how you could tackle the problem.
Reply
#8

Quote:
Originally Posted by AndySedeyn
Посмотреть сообщение
You can do two things:
  • Keep count on how many objects the player already has:
    PHP код:
    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; 
    } 
  • Or via more sophisticated loops:
    PHP код:
    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; 
    } 
These are just short and incomplete examples on how you could tackle the problem.
Thank you for taking into consideration my queries. I really had problems understanding how "houseids", "bizids" and other custom ids work. I think i understood a lot.

One last question? How could i use TagInfo[playerid][][tagExists] ?
Reply
#9

You can't. I can't think of a situation where that might be a solution.
Reply
#10

Will it be better If i change my enum to TagInfo[MAX_TAGS_PER_PLAYER][TagInformation], removing all [playerid] dimensions ?
Doing something like that:
at top of the script

PHP код:
new TagInfo[MAX_TAGS_PER_PLAYER][TagInformation], tagIndex = SprayTags_GetFreeSlot(); 
Function
PHP код:
function SprayTag_GetFreeID()
                {
                    for(new 
i = 0; i< MAX_TAGS_PER_PLAYER; i++) if(!TagInfo[i][TagExists]) return i;
                    return - 
1;
                } 
My command
PHP код:
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;  
} 
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)