Doesn't load object[MySQL]
#1

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

mysql_log.txt
PHP код:
 [DEBUGcache_get_field_content row1field_name"TagName"connection25max_len1
 
[DEBUGCMySQLResult::GetRowDataByName row'1'field"TagName"data"testtag"
[DEBUGcache_get_field_content row1field_name"TagOwner"connection25max_len1
[DEBUGCMySQLResult::GetRowDataByName row'1'field"TagOwner"data"vassilis"
[DEBUGcache_get_field_content row1field_name"TagFont"connection20max_len1
[DEBUGCMySQLResult::GetRowDataByName row'1'field"TagFont"data"the unseen"
[DEBUGcache_get_field_content_float row1field_name"TagX"connection1
[DEBUGCMySQLResult::GetRowDataByName row'1'field"TagX"data"1613.17"
[DEBUGcache_get_field_content_float row1field_name"TagY"connection1
[DEBUGCMySQLResult::GetRowDataByName row'1'field"TagY"data"-1843.19"
[DEBUGcache_get_field_content_float row1field_name"TagZ"connection1
[DEBUGCMySQLResult::GetRowDataByName row'1'field"TagZ"data"13.53"
[DEBUGcache_get_field_content_float row1field_name"TagRX"connection1
[DEBUGCMySQLResult::GetRowDataByName row'1'field"TagRX"data"0"
[DEBUGcache_get_field_content_float row1field_name"TagRY"connection1
[DEBUGCMySQLResult::GetRowDataByName row'1'field"TagRY"data"0"
[DEBUGcache_get_field_content_float row1field_name"TagRZ"connection1
[DEBUGCMySQLResult::GetRowDataByName row'1'field"TagRZ"data"88.3"
[DEBUGcache_get_field_content_int row1field_name"TagFontSize"connection1
[DEBUGCMySQLResult::GetRowDataByName row'1'field"TagFontSize"data"17"
[DEBUGcache_get_field_content_int row1field_name"TagFontColor"connection1
[DEBUGCMySQLResult::GetRowDataByName row'1'field"TagFontColor"data"-65536"
[DEBUGcache_get_field_content_int row1field_name"TagBold"connection1
[DEBUGCMySQLResult::GetRowDataByName row'1'field"TagBold"data"0"
[DEBUGCMySQLResult::~CMySQLResult() - deconstructor called 
Loading Function
PHP код:
    function LoadSprayTags(playerid)
                {
                
                    new 
rowsfields;
                    
cache_get_data(rowsfieldsmysql);
                    for(new 
0rowsi++)
                    {
                        
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(19482TagInfo[playerid][TagX], TagInfo[playerid][TagY], TagInfo[playerid][TagZ], TagInfo[playerid][TagRX], TagInfo[playerid][TagRY], TagInfo[playerid][TagRZ], -1, -1, -1300.0300.0);
                    
SetDynamicObjectMaterialText(TagInfo[playerid][TagObject], 0TagInfo[playerid][TagName], 70TagInfo[playerid][TagFont], TagInfo[playerid][TagFontSize], 1TagInfo[playerid][TagFontColor], 00);
                    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(playeridparams[])
{
          
TagInfo[playerid][TagObject] = CreateDynamicObject(19482XYZ0.00.00.0, -1, -1, -1300.0300.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(mysqlquerysizeof(query), "SELECT * FROM `spraytags` WHERE `TagOwnerID` = '%d'"pinfo[playerid][ID]);
                    
mysql_tquery(mysqlquery"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(playeridparams[]) 

        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(19482XYZ0.00.00.0, -1, -1, -1300.0300.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 
    0MAX_TAGS_PER_PLAYERi++) 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(playeridparams[]) 

        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(19482XYZ0.00.00.0, -1, -1, -1300.0300.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(playeridparams[]) 

        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(19482XYZ0.00.00.0, -1, -1, -1300.0300.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 
    0MAX_TAGS_PER_PLAYERi++) 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(playeridparams[]) 

        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(19482XYZ0.00.00.0, -1, -1, -1300.0300.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 
0iMAX_TAGS_PER_PLAYERi++) if(!TagInfo[i][TagExists]) return i;
                    return - 
1;
                } 
My command
PHP код:
CMD:create(playeridparams[])  
{  
    if(
tagIndex == -1) { 
        return 
SendClientMessage(playerid, -1"You have reached the maximum amount of tags per player."); 
    } 
    
TagInfo[playerid][tagIndex][TagObject] = CreateDynamicObject(19482XYZ0.00.00.0, -1, -1, -1300.0300.0); 
    return 
1;  

Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)