SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 17/01/2019, 12:40 PM   #1
HypCosmin
Little Clucker
 
Join Date: Nov 2018
Posts: 9
Reputation: 0
Default Help furniture

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 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, -1200.0);
    }
    print(
"=============================================================");
    
printf("[GAMEMODE]:         Furniture Sistem Loaded %d object's"objects);
    print(
"=============================================================\n");
    return 
1;

PHP Code:
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 Code:
stock GetHouseObjects(houseid
{
    new 
x;
    for(new 
0!= sizeof(FurnitureInfo); i++)
    {
        if(
FurnitureInfo[i][fiHouse] == houseidx++;
    }
    return 
x;

and

PHP Code:
 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.
HypCosmin is offline   Reply With Quote
Old 17/01/2019, 03:25 PM   #2
HypCosmin
Little Clucker
 
Join Date: Nov 2018
Posts: 9
Reputation: 0
Default Re: Help furniture

Quote:
Originally Posted by ****** View Post
Where do you set x?
No where, I've modified it, and it's the same problem

PHP Code:
stock GetHouseObjects(houseid)  

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


Last edited by HypCosmin; 17/01/2019 at 06:51 PM.
HypCosmin is offline   Reply With Quote
Old 17/01/2019, 03:30 PM   #3
Chyakka
Big Clucker
 
Join Date: Jul 2015
Location: England
Posts: 61
Reputation: 10
Default Re: Help furniture

I believe he means in this code:
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
Code:
           cache_get_value_int(i, "ID",            FurnitureInfo[x][fiID]);
would become
Code:
           cache_get_value_int(i, "ID",            FurnitureInfo[i][fiID]);
so on and so forth for each of your variables.
Chyakka is offline   Reply With Quote
Old 17/01/2019, 03:40 PM   #4
HypCosmin
Little Clucker
 
Join Date: Nov 2018
Posts: 9
Reputation: 0
Default Re: Help furniture

Quote:
Originally Posted by Chyakka View Post
I believe he means in this code:
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
Code:
           cache_get_value_int(i, "ID",            FurnitureInfo[x][fiID]);
would become
Code:
           cache_get_value_int(i, "ID",            FurnitureInfo[i][fiID]);
so on and so forth for each of your variables.
Thx, problem solved!
HypCosmin is offline   Reply With Quote
Old 17/01/2019, 05:12 PM   #5
HypCosmin
Little Clucker
 
Join Date: Nov 2018
Posts: 9
Reputation: 0
Default Re: Help furniture

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

PHP 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[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 Code:
     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 Code:
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;

HypCosmin is offline   Reply With Quote
Old 18/01/2019, 10:05 AM   #6
HypCosmin
Little Clucker
 
Join Date: Nov 2018
Posts: 9
Reputation: 0
Default Re: Help furniture

Anyone help me please?
HypCosmin is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Help with furniture Nru Scripting Help 1 08/04/2018 11:50 PM
[HELP] Furniture Davidmkd123 Scripting Help 8 22/02/2018 01:56 PM
Max Furniture JasonRiggs Scripting Help 2 09/07/2017 11:14 PM
Help on creating a furniture on furniture system barbarbar1 Scripting Help 1 09/08/2016 09:07 PM
[FilterScript] Furniture System-Carring the furniture and place it to your house,garden and everywhere chencong Filterscripts 18 13/05/2014 12:09 PM


All times are GMT. The time now is 07:29 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.