[MySql]Interior not loading.
#1

Hello guys, i am trying to create a simple business system.
But i got some problems. I am using MySql. It's loading everything fine just problem with interior load.

My code :

Selecting all from business :
PHP код:
format(querysizeof(query), "SELECT * FROM business");
    
mysql_function_query(dbhandlequerytrue"OnBizLoad"""); 
OnBizLoad :
PHP код:
public OnBizLoad()
{
    new 
num_fields,num_rows;
    
cache_get_data(num_rows,num_fields,dbhandle);
    if(!
num_rows)return 1;
    for(new 
i=0i<num_rowsi++)
     {
         new 
id=GetFreeBizID();
        
bInfo[id][b_x]=cache_get_field_content_float(i"b_x",dbhandle);
        
bInfo[id][b_y]=cache_get_field_content_float(i"b_y",dbhandle);
        
bInfo[id][b_z]=cache_get_field_content_float(i"b_z",dbhandle);
        
bInfo[id][b_intx]=cache_get_field_content_float(i"b_intx",dbhandle);
        
bInfo[id][b_inty]=cache_get_field_content_float(i"b_inty",dbhandle);
        
bInfo[id][b_intz]=cache_get_field_content_float(i"b_intz",dbhandle);
        
bInfo[id][b_int]=cache_get_field_content_int(i"b_int"dbhandle);
        
bInfo[id][b_entry]=cache_get_field_content_int(i"b_entry"dbhandle);
        
bInfo[id][b_price]=cache_get_field_content_int(i"b_price"dbhandle);
        
bInfo[id][b_selling]=cache_get_field_content_int(i"b_selling"dbhandle);
        new 
tmp_bname[128],tmp_type[20];
        
cache_get_field_content(i"b_name"tmp_bname);
        
strmid(bInfo[id][b_name], tmp_bname0sizeof(tmp_bname), sizeof(tmp_bname));
        
cache_get_field_content(i"b_type"tmp_type);
        
strmid(bInfo[id][b_type], tmp_type0sizeof(tmp_type), sizeof(tmp_type));
        new 
tmp_name[MAX_PLAYER_NAME];
        
cache_get_field_content(i"b_owner"tmp_name);
        
strmid(bInfo[id][b_owner], tmp_name0sizeof(tmp_name), sizeof(tmp_name));
        
bInfo[id][b_id]=cache_get_field_content_int(i"id"dbhandle);
        
bInfo[id][b_price]=cache_get_field_content_int(i"b_price"dbhandle);
        new 
m[126];
        
format(msizeof(m), "ICON POST : %f,%f,%f | Interiror : %f,%f,%f"bInfo[id][b_x],bInfo[id][b_y],bInfo[id][b_z],bInfo[id][b_intx],bInfo[id][b_inty],bInfo[id][b_intz]);
        
SendClientMessageToAll(-1m);
        
UpdateBiz(id);
     }
    return 
1;

I had tested with format and sendclientmessage to check the interior is loading. it shows 0.00000
Reply
#2

anyone?
Reply
#3

If the problem is in your enum?

Do you get any error or anything?


If your exterior works, then why interior not?
Reply
#4

Quote:
Originally Posted by SoFahim
Посмотреть сообщение
If the problem is in your enum?

Do you get any error or anything?


If your exterior works, then why interior not?
idk, enum and database both are okay
Reply
#5

try this cmd
PHP код:
YCMD:biz(playeridparams[], help)
{

    new 
biz;
    if(
sscanf(params"i"biz)) return SendUsage(playerid,"/biz <number>");
    
SetPlayerInterior(playerid,bInfo[biz][b_int]);
    
SetPlayerPos(playerid,bInfo[biz][b_intx],bInfo[biz][b_inty],bInfo[biz][b_intz]);

    return 
1;

and see if it teleports you into the interiors.
Reply
#6

Quote:
Originally Posted by PepsiCola23
Посмотреть сообщение
try this cmd
PHP код:
YCMD:biz(playeridparams[], help)
{
    new 
biz;
    if(
sscanf(params"i"biz)) return SendUsage(playerid,"/biz <number>");
    
SetPlayerInterior(playerid,bInfo[biz][b_int]);
    
SetPlayerPos(playerid,bInfo[biz][b_intx],bInfo[biz][b_inty],bInfo[biz][b_intz]);
    return 
1;

and see if it teleports you into the interiors.
Interior isn't loading from database, then how it will work?

interior post showing me 0.0000
Reply
#7

Can you actually show how you not really getting the data?

The code seems okay to me.
Reply
#8

Here is my ENUM

PHP код:
enum BizInfo{
    
b_id,
    
b_name[156],
    
b_owner[MAX_PLAYER_NAME],
    
b_type,
    
b_int,
    
Float:b_ix,
    
Float:b_iy,
    
Float:b_iz,
    
b_selling,
    
b_price,
    
b_entry,
    
Float:b_x,
    
Float:b_y,
    
Float:b_z,
    
Text3D:b_label,
    
b_pickup
}; 
Reply
#9

PHP код:
       bInfo[id][b_intx]=cache_get_field_content_float(i"b_intx",dbhandle);
        
bInfo[id][b_inty]=cache_get_field_content_float(i"b_inty",dbhandle);
        
bInfo[id][b_intz]=cache_get_field_content_float(i"b_intz",dbhandle); 
But your enum says

PHP код:
    Float:b_ix,
    
Float:b_iy,
    
Float:b_iz
Fix this
Reply
#10

Quote:
Originally Posted by SoFahim
Посмотреть сообщение
PHP код:
       bInfo[id][b_intx]=cache_get_field_content_float(i"b_intx",dbhandle);
        
bInfo[id][b_inty]=cache_get_field_content_float(i"b_inty",dbhandle);
        
bInfo[id][b_intz]=cache_get_field_content_float(i"b_intz",dbhandle); 
But your enum says

PHP код:
    Float:b_ix,
    
Float:b_iy,
    
Float:b_iz
Fix this
Here is full code and as you said i fixed the problem, but it still isn't loading...
PHP код:
enum BizInfo{
    
b_id,
    
b_name[156],
    
b_owner[MAX_PLAYER_NAME],
    
b_type,
    
b_int,
    
Float:b_ix,
    
Float:b_iy,
    
Float:b_iz,
    
b_selling,
    
b_price,
    
b_entry,
    
Float:b_x,
    
Float:b_y,
    
Float:b_z,
    
Text3D:b_label,
    
b_pickup
};
new 
bInfo[MAX_BIZ][BizInfo];
forward OnBizLoad();
public 
OnGameModeInit()
{
    
DisableInteriorEnterExits();
    
//mysql
    
dbhandle mysql_connect(db_host,db_user,db_db,db_pass);
    
// Don't use these lines if it's a filterscript
    
SetGameModeText("Blank Script");
    
AddPlayerClass(01958.37831343.157215.3746269.1425000000);
    
//Load Biz
    
format(querysizeof(query), "SELECT * FROM business");
    
mysql_function_query(dbhandlequerytrue"OnBizLoad""");
    return 
1;
}
public 
OnBizLoad()
{
    new 
num_fields,num_rows;
    
cache_get_data(num_rows,num_fields,dbhandle);
    if(!
num_rows)return 1;
    for(new 
i=0i<num_rowsi++)
     {
         new 
id=GetFreeBizID();
        
bInfo[id][b_x]=cache_get_field_content_float(i"b_x",dbhandle);
        
bInfo[id][b_y]=cache_get_field_content_float(i"b_y",dbhandle);
        
bInfo[id][b_z]=cache_get_field_content_float(i"b_z",dbhandle);
        
bInfo[id][b_ix]=cache_get_field_content_float(i"b_x",dbhandle);
        
bInfo[id][b_iy]=cache_get_field_content_float(i"b_y",dbhandle);
        
bInfo[id][b_iz]=cache_get_field_content_float(i"b_z",dbhandle);
        
bInfo[id][b_int]=cache_get_field_content_int(i"b_int"dbhandle);
        
bInfo[id][b_entry]=cache_get_field_content_int(i"b_entry"dbhandle);
        
bInfo[id][b_price]=cache_get_field_content_int(i"b_price"dbhandle);
        
bInfo[id][b_selling]=cache_get_field_content_int(i"b_selling"dbhandle);
        new 
tmp_bname[128],tmp_type[20];
        
cache_get_field_content(i"b_name"tmp_bname);
        
strmid(bInfo[id][b_name], tmp_bname0sizeof(tmp_bname), sizeof(tmp_bname));
        
cache_get_field_content(i"b_type"tmp_type);
        
strmid(bInfo[id][b_type], tmp_type0sizeof(tmp_type), sizeof(tmp_type));
        new 
tmp_name[MAX_PLAYER_NAME];
        
cache_get_field_content(i"b_owner"tmp_name);
        
strmid(bInfo[id][b_owner], tmp_name0sizeof(tmp_name), sizeof(tmp_name));
        
bInfo[id][b_id]=cache_get_field_content_int(i"id"dbhandle);
        
bInfo[id][b_price]=cache_get_field_content_int(i"b_price"dbhandle);
        new 
m[126];
        
format(msizeof(m), "ICON POST : %f,%f,%f | Interiror : %f,%f,%f"bInfo[id][b_x],bInfo[id][b_y],bInfo[id][b_z],bInfo[id][b_ix],bInfo[id][b_iy],bInfo[id][b_iz]);
        
SendClientMessageToAll(-1m);
        
UpdateBiz(id);
     }
    return 
1;
}
UpdateBiz(id)
{
    new 
string[126];
    if(
bInfo[id][b_pickup])
    {
        
DestroyPickup(bInfo[id][b_pickup]);
    }
    if(
bInfo[id][b_label])
    {
        
Delete3DTextLabel(bInfo[id][b_label]);
    }
    if(!
strlen(bInfo[id][b_owner]))
    {
         
bInfo[id][b_pickup]=CreatePickup(12731bInfo[id][b_x], bInfo[id][b_y], bInfo[id][b_z], -1);
           
format(string,sizeof(string),"Business for sell!\nID : %i\nPrice : $%i",bInfo[id][b_id],bInfo[id][b_price]);
         
bInfo[id][b_label] = Create3DTextLabel(string0x008080FFbInfo[id][b_x], bInfo[id][b_y], bInfo[id][b_z] , 1001);
         new 
query[128];
        
format(querysizeof(query), "UPDATE business SET b_owner='%s', b_price='%i', b_selling='%i', b_name='%s', b_entry='%i' WHERE id='%i'"bInfo[id][b_owner],bInfo[id][b_price],bInfo[id][b_selling],bInfo[id][b_name],bInfo[id][b_entry],bInfo[id][b_id]);
        
mysql_function_query(dbhandlequeryfalse"""");
    }
    else
    {
         
bInfo[id][b_pickup]=CreatePickup(12721bInfo[id][b_x], bInfo[id][b_y], bInfo[id][b_z], -1);
           
format(string,sizeof(string),"%s\nBuisness Name:%s\nBusiness owner:{f70404}%s\nEntry Fee:$%i",bInfo[id][b_type],bInfo[id][b_name],bInfo[id][b_owner],bInfo[id][b_entry]);
        
bInfo[id][b_label] = Create3DTextLabel(string0xFFFF00AAbInfo[id][b_x], bInfo[id][b_y], bInfo[id][b_z] , 1001);
        new 
query[128];
        
format(querysizeof(query), "UPDATE business SET b_owner='%s', b_price='%i', b_selling='%i', b_name='%s', b_entry='%i' WHERE id='%i'"bInfo[id][b_owner],bInfo[id][b_price],bInfo[id][b_selling],bInfo[id][b_name],bInfo[id][b_entry],bInfo[id][b_id]);
        
mysql_function_query(dbhandlequeryfalse"""");
    }
    
    if(
bInfo[id][b_int] == 0)
    {
        if(
bInfo[id][b_label])
        {
            
Delete3DTextLabel(bInfo[id][b_label]);
          }
    }
    return 
1;

Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)