Help furniture
#1

Hi all.

- I recently added a gaming system, everything is ok, it saves the objects in the database and works perfectly, after the first restart I show only the last object added not the rest of the objects. I do not understand what might be the problem. Thank you!

* Picture with object added (save)
https://imgur.com/EFTrt6C
https://imgur.com/xUTcp9Y

* Picture after restart, before it shows me that there are 3 out of 30 and now 1 out of 30
https://imgur.com/VThxQae
https://imgur.com/EXGO6vc - This is where objects are saved

PHP код:
pc LoadFurnitures()
{
    new 
objects 0;
    
Total_FUR_Created cache_num_rows();
    new 
i,x;
    for(
i=0;i<Total_FUR_Created;i++)
    {
        
objects ++;
           
cache_get_value_int(i"ID",            FurnitureInfo[x][fiID]);
           
cache_get_value_int(i"Model",         FurnitureInfo[x][fiModel]);
           
cache_get_value_float(i"X",           FurnitureInfo[x][fiX]);
         
cache_get_value_float(i"Y",           FurnitureInfo[x][fiY]);
          
cache_get_value_float(i"Z",           FurnitureInfo[x][fiZ]);
           
cache_get_value_float(i"RotX",        FurnitureInfo[x][fiRotX]);
           
cache_get_value_float(i"RotY",        FurnitureInfo[x][fiRotY]);
           
cache_get_value_float(i"RotZ",        FurnitureInfo[x][fiRotZ]);
           
cache_get_value_int(i"Virtual",       FurnitureInfo[x][fiVirtual]);
           
cache_get_value_int(i"House",         FurnitureInfo[x][fiHouse]);
        
FurnitureInfo[x][fiObject] = CreateDynamicObject(FurnitureInfo[x][fiModel], FurnitureInfo[x][fiX], FurnitureInfo[x][fiY], FurnitureInfo[x][fiZ], FurnitureInfo[x][fiRotX], FurnitureInfo[x][fiRotY], FurnitureInfo[x][fiRotZ], FurnitureInfo[x][fiVirtual], -1, -1200.0);
    }
    print(
"=============================================================");
    
printf("[GAMEMODE]:         Furniture Sistem Loaded %d object's"objects);
    print(
"=============================================================\n");
    return 
1;

PHP код:
pc SaveObject(const id
{
    
format(query,sizeof(query),"UPDATE `fobjects` SET `Model`='%d', `X`='%f', `Y`='%f', `Z`='%f', `RotX`='%f', `RotY`='%f', `RotZ`='%f', `Virtual`='%d', `House`='%d' WHERE `ID`='%d'",
    
FurnitureInfo[id][fiModel], FurnitureInfo[id][fiX], FurnitureInfo[id][fiY], FurnitureInfo[id][fiZ], FurnitureInfo[id][fiRotX], FurnitureInfo[id][fiRotY], FurnitureInfo[id][fiRotZ], FurnitureInfo[id][fiVirtual], FurnitureInfo[id][fiHouse], id);
    
mysql_tquery(handlequery);
    return 
1;

PHP код:
stock GetHouseObjects(houseid
{
    new 
x;
    for(new 
0!= sizeof(FurnitureInfo); i++)
    {
        if(
FurnitureInfo[i][fiHouse] == houseidx++;
    }
    return 
x;

and

PHP код:
 format(strong,sizeof(strong),    "{f9f7ce}Numele casei \t%s\n\
                                         {f9f7ce}Chirie \t%s\n\
                                         {f9f7ce}Casa inchisa \t%s\n\
                                         {f9f7ce}Bani in casa \t%s$\n\
                                         {f9f7ce}Materiale in casa \t%s\n\
                                         {f9f7ce}Droguri in casa \t%s grame\n\
                                         {f9f7ce}Mobilier casa \t%d/30 obiecte\n\                                  
                                         {f9f7ce}Editeaza mobilier"
,
                                         
HouseInfo[h][hName],renttext,locktext,FormatNumber(HouseInfo[h][hSeif]),FormatNumber(HouseInfo[h][hMats]),FormatNumber(HouseInfo[h][hDrugs]), GetHouseObjects(PlayerInfo[playerid][pHouse]));
        
ShowPlayerDialog(playeridDIALOG_HMDIALOG_STYLE_TABLIST"{02901a}Meniu casa",strong"Select""Cancel"); 
and [pHouse] is houseky.
Reply
#2

Quote:
Originally Posted by ******
Посмотреть сообщение
Where do you set x?
No where, I've modified it, and it's the same problem

PHP код:
stock GetHouseObjects(houseid)  

    for(new 
0!= sizeof(FurnitureInfo); i++) 
    { 
        if(
FurnitureInfo[i][fiHouse] == houseidi++; 
    } 
    return 
1

Reply
#3

I believe he means in this code:
Код:
pc LoadFurnitures()
{
    new objects = 0;
    Total_FUR_Created = cache_num_rows();
    new i,x;
    for(i=0;i<Total_FUR_Created;i++)
    {
        objects ++;
           cache_get_value_int(i, "ID",            FurnitureInfo[x][fiID]);
           cache_get_value_int(i, "Model",         FurnitureInfo[x][fiModel]);
           cache_get_value_float(i, "X",           FurnitureInfo[x][fiX]);
         cache_get_value_float(i, "Y",           FurnitureInfo[x][fiY]);
          cache_get_value_float(i, "Z",           FurnitureInfo[x][fiZ]);
           cache_get_value_float(i, "RotX",        FurnitureInfo[x][fiRotX]);
           cache_get_value_float(i, "RotY",        FurnitureInfo[x][fiRotY]);
           cache_get_value_float(i, "RotZ",        FurnitureInfo[x][fiRotZ]);
           cache_get_value_int(i, "Virtual",       FurnitureInfo[x][fiVirtual]);
           cache_get_value_int(i, "House",         FurnitureInfo[x][fiHouse]);
        FurnitureInfo[x][fiObject] = CreateDynamicObject(FurnitureInfo[x][fiModel], FurnitureInfo[x][fiX], FurnitureInfo[x][fiY], FurnitureInfo[x][fiZ], FurnitureInfo[x][fiRotX], FurnitureInfo[x][fiRotY], FurnitureInfo[x][fiRotZ], FurnitureInfo[x][fiVirtual], -1, -1, 200.0);
    }
    print("=============================================================");
    printf("[GAMEMODE]:         Furniture Sistem Loaded %d object's", objects);
    print("=============================================================\n");
    return 1;
}
Your array index never changed, because you declare x even though you're incrementing i in the for loop.

So your objects are permanently being created in the first index of the array, which is why you only have the last object being created.

So
Код:
           cache_get_value_int(i, "ID",            FurnitureInfo[x][fiID]);
would become
Код:
           cache_get_value_int(i, "ID",            FurnitureInfo[i][fiID]);
so on and so forth for each of your variables.
Reply
#4

Quote:
Originally Posted by Chyakka
Посмотреть сообщение
I believe he means in this code:
Код:
pc LoadFurnitures()
{
    new objects = 0;
    Total_FUR_Created = cache_num_rows();
    new i,x;
    for(i=0;i<Total_FUR_Created;i++)
    {
        objects ++;
           cache_get_value_int(i, "ID",            FurnitureInfo[x][fiID]);
           cache_get_value_int(i, "Model",         FurnitureInfo[x][fiModel]);
           cache_get_value_float(i, "X",           FurnitureInfo[x][fiX]);
         cache_get_value_float(i, "Y",           FurnitureInfo[x][fiY]);
          cache_get_value_float(i, "Z",           FurnitureInfo[x][fiZ]);
           cache_get_value_float(i, "RotX",        FurnitureInfo[x][fiRotX]);
           cache_get_value_float(i, "RotY",        FurnitureInfo[x][fiRotY]);
           cache_get_value_float(i, "RotZ",        FurnitureInfo[x][fiRotZ]);
           cache_get_value_int(i, "Virtual",       FurnitureInfo[x][fiVirtual]);
           cache_get_value_int(i, "House",         FurnitureInfo[x][fiHouse]);
        FurnitureInfo[x][fiObject] = CreateDynamicObject(FurnitureInfo[x][fiModel], FurnitureInfo[x][fiX], FurnitureInfo[x][fiY], FurnitureInfo[x][fiZ], FurnitureInfo[x][fiRotX], FurnitureInfo[x][fiRotY], FurnitureInfo[x][fiRotZ], FurnitureInfo[x][fiVirtual], -1, -1, 200.0);
    }
    print("=============================================================");
    printf("[GAMEMODE]:         Furniture Sistem Loaded %d object's", objects);
    print("=============================================================\n");
    return 1;
}
Your array index never changed, because you declare x even though you're incrementing i in the for loop.

So your objects are permanently being created in the first index of the array, which is why you only have the last object being created.

So
Код:
           cache_get_value_int(i, "ID",            FurnitureInfo[x][fiID]);
would become
Код:
           cache_get_value_int(i, "ID",            FurnitureInfo[i][fiID]);
so on and so forth for each of your variables.
Thx, problem solved!
Reply
#5

Sorry for double post, but now after this thing has a new problem, no editing / deleting an object

PHP код:
pc LoadFurnitures()
{
    new 
objects 0;
    
Total_FUR_Created cache_num_rows();
    new 
i,x;
    for(
i=0;i<Total_FUR_Created;i++)
    {
        
objects ++;
           
cache_get_value_int(i"ID",            FurnitureInfo[i][fiID]);
           
cache_get_value_int(i"Model",         FurnitureInfo[i][fiModel]);
           
cache_get_value_float(i"X",           FurnitureInfo[i][fiX]);
         
cache_get_value_float(i"Y",           FurnitureInfo[i][fiY]);
          
cache_get_value_float(i"Z",           FurnitureInfo[i][fiZ]);
           
cache_get_value_float(i"RotX",        FurnitureInfo[i][fiRotX]);
           
cache_get_value_float(i"RotY",        FurnitureInfo[i][fiRotY]);
           
cache_get_value_float(i"RotZ",        FurnitureInfo[i][fiRotZ]);
           
cache_get_value_int(i"Virtual",       FurnitureInfo[i][fiVirtual]);
           
cache_get_value_int(i"House",         FurnitureInfo[i][fiHouse]);
        
FurnitureInfo[i][fiObject] = CreateDynamicObject(FurnitureInfo[i][fiModel], FurnitureInfo[i][fiX], FurnitureInfo[i][fiY], FurnitureInfo[i][fiZ], FurnitureInfo[i][fiRotX], FurnitureInfo[i][fiRotY], FurnitureInfo[i][fiRotZ], FurnitureInfo[i][fiVirtual], -1, -1200.0);
    }
    print(
"=============================================================");
    
printf("[GAMEMODE]:         Furniture Sistem Loaded %d object's"objects);
    print(
"=============================================================\n");
    return 
1;

PHP код:
     switch(dialogid)
    {
        case 
DIALOG_EDITMOBILA: {
            if(!
response) return 1;
            
SlotSel[playerid] = listitem;
            
ShowPlayerDialog(playeridDIALOG_EDITMOBILA2DIALOG_STYLE_MSGBOX"{02901a}Editeaza mobilier""{bfc0c2}Ce vrei sa faci cu acest obiect? \n* {f9f7ce}Editezi (edit)\n* {f9f7ce}Stergi (delete)""Edit""Delete");
        }
        case 
DIALOG_EDITMOBILA2: {
            new 
id SelMobila[playerid][SlotSel[playerid]];
            
printf("id = %d"id);
            
EditedObjectID[playerid] = id;
            
EditHouse[playerid] = 2;
            new 
obj2 FurnitureInfo[id][fiObject];
            if(!
response) {
                
SCM(playeridCOLOR_YELLOW"{02901a}SERVER:{f9f7ce} Obiectul a fost sters cu succes.");
                
DestroyDynamicObject(FurnitureInfo[id][fiObject]);
                
FurnitureInfo[id][fiHouse] = 0;
                
mysql_format(handle,query,sizeof(query),"DELETE FROM `fobjects` WHERE `ID`='%d'",id);
                
mysql_query(handlequery);
            }
            else {
                
EditHouse[playerid] = 2;
                
SCM(playeridCOLOR_YELLOW"{02901a}SERVER:{f9f7ce} * Obiectul selectat de tine s-a spawnat, tot ce trebuie sa faci este sa ii cauti pozitia unde doresti sa se salveze.");
                
SCM(playeridCOLOR_YELLOW"{02901a}SERVER:{f9f7ce} Pentru a misca camera, apasa tasta {bfc0c2}SPACE{f9f7ce} iar pentru a misca obiectul, apasa click pe acele axe (X,Y,Z).");
                
SCM(playeridCOLOR_YELLOW"{02901a}SERVER:{f9f7ce} Iar pentru a iesi, apasa tasta {bfc0c2}ESC{f9f7ce}. Succes la mobilat!");
                
EditDynamicObject(playeridobj2);
            }
        } 
PHP код:
public OnPlayerEditObject(playeridplayerobjectobjectidresponseFloat:fXFloat:fYFloat:fZFloat:fRotXFloat:fRotYFloat:fRotZ)
{
    new 
Float:oldXFloat:oldYFloat:oldZFloat:oldRotXFloat:oldRotYFloat:oldRotZ;
    
GetDynamicObjectPos(objectidoldXoldYoldZ);
    
GetDynamicObjectRot(objectidoldRotXoldRotYoldRotZ);

    if(
response == EDIT_RESPONSE_FINAL)
    {
        if(
EditHouse[playerid] == 1) {
            new 
szQuery[256];
            
mysql_format(handleszQuery256"INSERT INTO `fobjects` (`House`) VALUES ('0')");
            new 
Cacheresult mysql_query(handleszQuery);
            new 
cache_insert_id();
            
cache_delete(result);
            
FurnitureInfo[i][fiModel] = EditModel[playerid];
            
FurnitureInfo[i][fiX] = fX;
            
FurnitureInfo[i][fiY] = fY;
            
FurnitureInfo[i][fiZ] = fZ;
            
FurnitureInfo[i][fiRotX] = fRotX;
            
FurnitureInfo[i][fiRotY] = fRotY;
            
FurnitureInfo[i][fiRotZ] = fRotZ;
            
FurnitureInfo[i][fiVirtual] = GetPlayerVirtualWorld(playerid);
            
FurnitureInfo[i][fiHouse] = PlayerInfo[playerid][pHouse];
            
SaveObject(i);
            
DestroyDynamicObject(ObjectEdited[playerid]);
            
FurnitureInfo[i][fiObject] = CreateDynamicObject(FurnitureInfo[i][fiModel], FurnitureInfo[i][fiX], FurnitureInfo[i][fiY], FurnitureInfo[i][fiZ], FurnitureInfo[i][fiRotX], FurnitureInfo[i][fiRotY], FurnitureInfo[i][fiRotZ], FurnitureInfo[i][fiVirtual], -1, -1200.0);
            
format(szQuery256"{02901a}SERVER:{f9f7ce} Mobilier adaugat cu succes. Total obiecte:  %d/30.",  GetHouseObjects(PlayerInfo[playerid][pHouse]));
            
SCM(playeridCOLOR_YELLOWszQuery);
            
GivePlayerCash(playerid,-1000);
            
GameTextForPlayer(playerid"~r~-$1,000",500,1);
        }
        else if(
EditHouse[playerid] == 2) {
            new 
EditedObjectID[playerid];
            
FurnitureInfo[i][fiX] = fX;
            
FurnitureInfo[i][fiY] = fY;
            
FurnitureInfo[i][fiZ] = fZ;
            
FurnitureInfo[i][fiRotX] = fRotX;
            
FurnitureInfo[i][fiRotY] = fRotY;
            
FurnitureInfo[i][fiRotZ] = fRotZ;
            
FurnitureInfo[i][fiVirtual] = GetPlayerVirtualWorld(playerid);
            
FurnitureInfo[i][fiHouse] = PlayerInfo[playerid][pHouse];
            
SaveObject(i);
            
DestroyDynamicObject(FurnitureInfo[i][fiObject]);//
            
FurnitureInfo[i][fiObject] = CreateDynamicObject(FurnitureInfo[i][fiModel], FurnitureInfo[i][fiX], FurnitureInfo[i][fiY], FurnitureInfo[i][fiZ], FurnitureInfo[i][fiRotX], FurnitureInfo[i][fiRotY], FurnitureInfo[i][fiRotZ], FurnitureInfo[i][fiVirtual], -1, -1200.0);
            
SCM(playeridCOLOR_YELLOW"{02901a}SERVER:{f9f7ce} Mobilier editat cu succes.");
        }
    }

    if(
response == EDIT_RESPONSE_CANCEL)
    {
        if(
EditHouse[playerid] == 1DestroyDynamicObject(ObjectEdited[playerid]), SCM(playerid, -1"{02901a}SERVER:{f9f7ce} Ai anulat adaugarea mobilierului.");
        if(
EditHouse[playerid] == 2SCM(playerid, -1"{02901a}SERVER:{f9f7ce} Ai anulat adaugarea mobilierului.");
    }
    return 
1;

Reply
#6

Anyone help me please?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)