Doesn't load housename
#1

Loadhouses
PHP Code:
LoadHouses()
{
    new 
Cache:result,rows;
    new 
label[250];
    
result mysql_query(mysql"SELECT * FROM `houses`");
    if((
rows cache_num_rows()))
    {
        for(new 
i=0rowsi++)
        {
            
HouseInfo[i][XEnt] = cache_get_field_content_float(i"XEnt"); //we're getting a field 4 from row 0. And since it's an integer, we use cache_get_row_int
            
HouseInfo[i][YEnt] = cache_get_field_content_float(i"YEnt"); //Above
            
HouseInfo[i][ZEnt] = cache_get_field_content_float(i"ZEnt");//Above
            
HouseInfo[i][XExit] = cache_get_field_content_float(i"XExit");//Above. Since player's position is a float, we use cache_get_field_content_float
            
HouseInfo[i][YExit] = cache_get_field_content_float(i"YExit");//Above
            
HouseInfo[i][ZExit] = cache_get_field_content_float(i"ZExit");//Above
            
HouseInfo[i][HVirtualWorld] = cache_get_field_content_int(i"HVirtualWorld");
            
HouseInfo[i][HInterior] = cache_get_field_content_int(i"HInterior");
            
HouseInfo[i][HPrice] = cache_get_field_content_int(i"HPrice");
            
HouseInfo[i][HOwnerID] = cache_get_field_content_int(0"HOwnerID");
            
HouseInfo[i][HOwned] = cache_get_field_content_int(i"HOwned");
            
HouseInfo[i][HLocked] = cache_get_field_content_int(i"HLocked");
            
cache_get_field_content(i"HName"HouseInfo[i][HName], 30);
            if(
HouseInfo[i][HOwned] == 1)
        {
                
format(label,sizeof(label),""COL_GREEN"HouseName"COL_WHITE":%s\n"COL_GREEN"",HouseInfo[i][HName]);
                
HouseInfo[i][H3D] = CreateDynamic3DTextLabel(labelCOLOR_YELLOWHouseInfo[i][XEnt],  HouseInfo[i][YEnt], HouseInfo[i][ZEnt], 40.0);
        }
        
        else if(
HouseInfo[i][HOwned] == 0)
        {
            
format(label,sizeof(label),""COL_GREEN"HouseName"COL_WHITE": No Owner\n"COL_GREEN"Price"COL_WHITE": %d",HouseInfo[i][HPrice]);
            
HouseInfo[i][H3D] = CreateDynamic3DTextLabel(labelCOLOR_YELLOWHouseInfo[i][XEnt],  HouseInfo[i][YEnt], HouseInfo[i][ZEnt], 40.0);
        }
        }
        
printf("Successfully Loaded All Houses! ( %d )",rows);
    }
    else
    {
        print(
"There are no houses to load!");
    }
        
cache_delete(result);

It loads correctly anything else but on
screen it has Housename as blank
it says on 3d text
"Housename: "
mysql_log
pawn Code:
[14:31:04] [DEBUG] cache_get_field_content - row: 1, field_name: "HName", connection: 30, max_len: 1
[14:31:04] [DEBUG] CMySQLResult::GetRowDataByName - row: '1', field: "HName", data: "test"
Reply
#2

print house name if owned example:
PHP Code:
if(HouseInfo[i][HOwned] == 1
        { 
         
printf("%s",HouseInfo[i][HName]);
         
//... 
also be sure you have set size for HName in house enum like:
HName[MAX_PLAYER_NAME+1],
Reply
#3

Quote:
Originally Posted by jlalt
View Post
print house name if owned example:
PHP Code:
if(HouseInfo[i][HOwned] == 1
        { 
         
printf("%s",HouseInfo[i][HName]);
         
//... 
also be sure you have set size for HName in house enum like:
HName[MAX_PLAYER_NAME+1],
i hadn't set size i will set it now at 30 thanks jlalt i am going to check if it works
Reply
#4

It prints
pawn Code:
Housename:
blank :/

On mysql log it loads it correctly but does it has anything to do with "max len: 1 that it says at mysql log?
pawn Code:
[17:03:02] [DEBUG] cache_get_field_content - row: 0, field_name: "HName", connection: 30, max_len: 1
[17:03:02] [DEBUG] CMySQLResult::GetRowDataByName - row: '0', field: "HName", data: "testname"
EDIT: Sorry for double post
Reply
#5

Quote:
Originally Posted by vassilis
View Post
It doesn't print something i used it on gamemode init
PHP Code:
for(new i=1;i<MAX_HOUSES;i++)
    {    
        if(
HouseInfo[i][HOwned] == 1)  
        {  
             
printf("Housename : %s",HouseInfo[i][HName]); 
        }
    } 
On mysql log it loads it correctly but does it has anything to do with "max len: 1 that it says at mysql log?
pawn Code:
[17:03:02] [DEBUG] cache_get_field_content - row: 0, field_name: "HName", connection: 30, max_len: 1
[17:03:02] [DEBUG] CMySQLResult::GetRowDataByName - row: '0', field: "HName", data: "testname"
EDIT: Sorry for double post
probably yeah, did you make HName with varchar(30)?
and no need to make new house loop look print here:

PHP Code:
LoadHouses() 

    new 
Cache:result,rows
    new 
label[250]; 
    
result mysql_query(mysql"SELECT * FROM `houses`"); 
    if((
rows cache_num_rows())) 
    { 
        for(new 
i=0rowsi++) 
        { 
            
HouseInfo[i][XEnt] = cache_get_field_content_float(i"XEnt"); //we're getting a field 4 from row 0. And since it's an integer, we use cache_get_row_int 
            
HouseInfo[i][YEnt] = cache_get_field_content_float(i"YEnt"); //Above 
            
HouseInfo[i][ZEnt] = cache_get_field_content_float(i"ZEnt");//Above 
            
HouseInfo[i][XExit] = cache_get_field_content_float(i"XExit");//Above. Since player's position is a float, we use cache_get_field_content_float 
            
HouseInfo[i][YExit] = cache_get_field_content_float(i"YExit");//Above 
            
HouseInfo[i][ZExit] = cache_get_field_content_float(i"ZExit");//Above 
            
HouseInfo[i][HVirtualWorld] = cache_get_field_content_int(i"HVirtualWorld"); 
            
HouseInfo[i][HInterior] = cache_get_field_content_int(i"HInterior"); 
            
HouseInfo[i][HPrice] = cache_get_field_content_int(i"HPrice"); 
            
HouseInfo[i][HOwnerID] = cache_get_field_content_int(0"HOwnerID"); 
            
HouseInfo[i][HOwned] = cache_get_field_content_int(i"HOwned"); 
            
HouseInfo[i][HLocked] = cache_get_field_content_int(i"HLocked"); 
            
cache_get_field_content(i"HName"HouseInfo[i][HName], 30); 
            if(
HouseInfo[i][HOwned] == 1
        { 
                
printf("Housename : %s",HouseInfo[i][HName]); 
                
format(label,sizeof(label),""COL_GREEN"HouseName"COL_WHITE":%s\n"COL_GREEN"",HouseInfo[i][HName]); 
                
HouseInfo[i][H3D] = CreateDynamic3DTextLabel(labelCOLOR_YELLOWHouseInfo[i][XEnt],  HouseInfo[i][YEnt], HouseInfo[i][ZEnt], 40.0); 
        } 
         
        else if(
HouseInfo[i][HOwned] == 0
        { 
            
format(label,sizeof(label),""COL_GREEN"HouseName"COL_WHITE": No Owner\n"COL_GREEN"Price"COL_WHITE": %d",HouseInfo[i][HPrice]); 
            
HouseInfo[i][H3D] = CreateDynamic3DTextLabel(labelCOLOR_YELLOWHouseInfo[i][XEnt],  HouseInfo[i][YEnt], HouseInfo[i][ZEnt], 40.0); 
        } 
        } 
        
printf("Successfully Loaded All Houses! ( %d )",rows); 
    } 
    else 
    { 
        print(
"There are no houses to load!"); 
    } 
        
cache_delete(result); 

Reply
#6

Quote:
Originally Posted by jlalt
View Post
probably yeah, did you make HName with varchar(30)?
and no need to make new house loop look print here:

PHP Code:
LoadHouses() 

    new 
Cache:result,rows
    new 
label[250]; 
    
result mysql_query(mysql"SELECT * FROM `houses`"); 
    if((
rows cache_num_rows())) 
    { 
        for(new 
i=0rowsi++) 
        { 
            
HouseInfo[i][XEnt] = cache_get_field_content_float(i"XEnt"); //we're getting a field 4 from row 0. And since it's an integer, we use cache_get_row_int 
            
HouseInfo[i][YEnt] = cache_get_field_content_float(i"YEnt"); //Above 
            
HouseInfo[i][ZEnt] = cache_get_field_content_float(i"ZEnt");//Above 
            
HouseInfo[i][XExit] = cache_get_field_content_float(i"XExit");//Above. Since player's position is a float, we use cache_get_field_content_float 
            
HouseInfo[i][YExit] = cache_get_field_content_float(i"YExit");//Above 
            
HouseInfo[i][ZExit] = cache_get_field_content_float(i"ZExit");//Above 
            
HouseInfo[i][HVirtualWorld] = cache_get_field_content_int(i"HVirtualWorld"); 
            
HouseInfo[i][HInterior] = cache_get_field_content_int(i"HInterior"); 
            
HouseInfo[i][HPrice] = cache_get_field_content_int(i"HPrice"); 
            
HouseInfo[i][HOwnerID] = cache_get_field_content_int(0"HOwnerID"); 
            
HouseInfo[i][HOwned] = cache_get_field_content_int(i"HOwned"); 
            
HouseInfo[i][HLocked] = cache_get_field_content_int(i"HLocked"); 
            
cache_get_field_content(i"HName"HouseInfo[i][HName], 30); 
            if(
HouseInfo[i][HOwned] == 1
        { 
                
printf("Housename : %s",HouseInfo[i][HName]); 
                
format(label,sizeof(label),""COL_GREEN"HouseName"COL_WHITE":%s\n"COL_GREEN"",HouseInfo[i][HName]); 
                
HouseInfo[i][H3D] = CreateDynamic3DTextLabel(labelCOLOR_YELLOWHouseInfo[i][XEnt],  HouseInfo[i][YEnt], HouseInfo[i][ZEnt], 40.0); 
        } 
         
        else if(
HouseInfo[i][HOwned] == 0
        { 
            
format(label,sizeof(label),""COL_GREEN"HouseName"COL_WHITE": No Owner\n"COL_GREEN"Price"COL_WHITE": %d",HouseInfo[i][HPrice]); 
            
HouseInfo[i][H3D] = CreateDynamic3DTextLabel(labelCOLOR_YELLOWHouseInfo[i][XEnt],  HouseInfo[i][YEnt], HouseInfo[i][ZEnt], 40.0); 
        } 
        } 
        
printf("Successfully Loaded All Houses! ( %d )",rows); 
    } 
    else 
    { 
        print(
"There are no houses to load!"); 
    } 
        
cache_delete(result); 

PHP Code:
Housename
It's blank no result..
And yes its varchar(30)
Reply
#7

Theres is connectionHandle between destination and max_len.
Quote:

(row, const field_name[], destination[], connectionHandle = 1, max_len = sizeof(destination))

Reply
#8

Quote:
Originally Posted by Matess
View Post
Theres is connectionHandle between destination and max_len.
should i set it as 1?
Reply
#9

yeah its default value or delete 30
Reply
#10

Your code should be something like this i hope

Code:
cache_get_field_content(i, "HName", HouseInfo[i][HName],1, 30);
Syntax
Code:
cache_get_field_content(row, const field_name[], destination[], connectionHandle = 1, max_len = sizeof(destination))
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)