Jump to content

[REZOLVAT] Problemă furniture - salvare şi stergere


HypCosmin
 Share

Recommended Posts

  • Username : HypCosmin
  • Problema întâlnită: Deci pot spune că am luat sistemul de pe un alt gamemode şi l-am integrat in gamemode-ul meu, totul functioneaza perfect, obiectele pt furniture sunt incarcate pe server, daca vreau sa adaug un obiect il pot adauga, edita chiar si sterge si se salveaza in baza de date dar daca dau un restart la server si intru inapoi pe server pot doar adauga obiecte si lafel le pot sterge/edita dar cele dinainte de restart nu le mai pot edita/sterge, adica pur si simplu nu se, salveaza in baza de date, am postat in vreo 2 locuri pe net dar nimeni nimic.
  • Detalii despre problemă:
  • Ce ai încercat să faci înainte să postezi?: Sincer nici eu nu mai stiu. Dar am uitat sa specific, sistemul este luat de pe un gamemode ce este pe MYSQL R39-3 si eu folosesc MYSQL R41-4....
  • Cod sursa (recomandat pastebin.com) : 
Citat

pc LoadFurnitures() {
    new Cache: db = mysql_query(handle, "SELECT * FROM `fobjects` ORDER BY `fobjects`.`ID` ASC");
    new objects = 0, result[180];
     for(new i, j = cache_num_rows (); i != j; ++i) {
           objects ++;
           cache_get_value_name_int(i, "ID",            FurnitureInfo[fiID]);
           cache_get_value_name_int(i, "Model",         FurnitureInfo[fiModel]);
           cache_get_value_name_float(i, "X",           FurnitureInfo[fiX]);
           cache_get_value_name_float(i, "Y",           FurnitureInfo[fiY]);
           cache_get_value_name_float(i, "Z",           FurnitureInfo[fiZ]);
           cache_get_value_name_float(i, "RotX",        FurnitureInfo[fiRotX]);
           cache_get_value_name_float(i, "RotY",        FurnitureInfo[fiRotY]);
           cache_get_value_name_float(i, "RotZ",        FurnitureInfo[fiRotZ]);
           cache_get_value_name_int(i, "Virtual",       FurnitureInfo[fiVirtual]);
           cache_get_value_name_int(i, "House",         FurnitureInfo[fiHouse]);
           FurnitureInfo[fiObject] = CreateDynamicObject(FurnitureInfo[fiModel], FurnitureInfo[fiX], FurnitureInfo[fiY], FurnitureInfo[fiZ], FurnitureInfo[fiRotX], FurnitureInfo[fiRotY], FurnitureInfo[fiRotZ], FurnitureInfo[fiVirtual], -1, -1, 200.0);
    }
    printf("Furnitures: %d", objects);
    cache_delete(db);
    return 1;
}

 

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(handle, query);
	return 1;
}

stock GetHouseObjects(houseid) 
{
	new x;
    for(new i = 0; i != sizeof(FurnitureInfo); i++)
    {
        if(FurnitureInfo[i][fiHouse] == houseid) x++;
    }
	return x;
}
Citat

//===================================================================================================================
public OnPlayerEditObject(playerid, playerobject, objectid, response, Float:fX, Float:fY, Float:fZ, Float:fRotX, Float:fRotY, Float:fRotZ) // DE EDITAT
{
    new Float:oldX, Float:oldY, Float:oldZ, Float:oldRotX, Float:oldRotY, Float:oldRotZ;
    GetDynamicObjectPos(objectid, oldX, oldY, oldZ);
    GetDynamicObjectRot(objectid, oldRotX, oldRotY, oldRotZ);

    if(response == EDIT_RESPONSE_FINAL)
    {
        if(EditHouse[playerid] == 1) {        
            new szQuery[256];
            mysql_format(handle, szQuery, 256, "INSERT INTO `fobjects` (`House`) VALUES ('0')");
            new Cache: result = mysql_query(handle, szQuery);
            new i = cache_insert_id();
            cache_delete(result);
            FurnitureInfo[fiModel] = EditModel[playerid];
            FurnitureInfo[fiX] = fX;
            FurnitureInfo[fiY] = fY;
            FurnitureInfo[fiZ] = fZ;
            FurnitureInfo[fiRotX] = fRotX;
            FurnitureInfo[fiRotY] = fRotY;
            FurnitureInfo[fiRotZ] = fRotZ;
            FurnitureInfo[fiVirtual] = GetPlayerVirtualWorld(playerid);
            FurnitureInfo[fiHouse] = PlayerInfo[playerid][pHouse];
            SaveObject(i);
            DestroyDynamicObject(ObjectEdited[playerid]);
            FurnitureInfo[fiObject] = CreateDynamicObject(FurnitureInfo[fiModel], FurnitureInfo[fiX], FurnitureInfo[fiY], FurnitureInfo[fiZ], FurnitureInfo[fiRotX], FurnitureInfo[fiRotY], FurnitureInfo[fiRotZ], FurnitureInfo[fiVirtual], -1, -1, 200.0);
            format(szQuery, 256, "Obiect adaugat! Total obiecte: %d/50.",  GetHouseObjects(PlayerInfo[playerid][pHouse]));
            SCM(playerid, COLOR_YELLOW, szQuery);
            GivePlayerCash(playerid, -500);
            EditHouse[playerid] = 0;
        }
        else if(EditHouse[playerid] == 2) {
            new i = EditedObjectID[playerid];
            FurnitureInfo[fiX] = fX;
            FurnitureInfo[fiY] = fY;
            FurnitureInfo[fiZ] = fZ;
            FurnitureInfo[fiRotX] = fRotX;
            FurnitureInfo[fiRotY] = fRotY;
            FurnitureInfo[fiRotZ] = fRotZ;
            FurnitureInfo[fiVirtual] = GetPlayerVirtualWorld(playerid);
            FurnitureInfo[fiHouse] = PlayerInfo[playerid][pHouse];
            DestroyDynamicObject(FurnitureInfo[fiObject]);//
            FurnitureInfo[fiObject] = CreateDynamicObject(FurnitureInfo[fiModel], FurnitureInfo[fiX], FurnitureInfo[fiY], FurnitureInfo[fiZ], FurnitureInfo[fiRotX], FurnitureInfo[fiRotY], FurnitureInfo[fiRotZ], FurnitureInfo[fiVirtual], -1, -1, 200.0);
            SaveObject(i);
            SCM(playerid, COLOR_YELLOW, "Mobiler editat cu succes!");
            EditHouse[playerid] = 0;
        }
    }

    if(response == EDIT_RESPONSE_CANCEL)
    {
        if(EditHouse[playerid] == 1) DestroyDynamicObject(ObjectEdited[playerid]), SCM(playerid, -1, "Ai anulat!");
        if(EditHouse[playerid] == 2) SCM(playerid, -1, "Ai anulat!");
    }
    return 1;
}
 

 

Citat

         switch(dialogid) // DE EDITAT
    {
        case DIALOG_EDITMOBILA: {
            if(!response) return 1;
            SlotSel[playerid] = listitem;
            ShowPlayerDialog(playerid, DIALOG_EDITMOBILA2, DIALOG_STYLE_MSGBOX, "Optiune:", "Ce vrei sa faci cu acest obiect?\nEditezi/Stergi?", "Editeaza", "Sterge");
        }
        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) {
                mysql_format(handle,query,128,"DELETE FROM `fobjects` WHERE `ID`='%d'",id);
                mysql_query(handle, query);
                SCM(playerid, COLOR_YELLOW, "Obiect sters!");
                DestroyDynamicObject(FurnitureInfo[id][fiObject]);
                FurnitureInfo[id][fiHouse] = 0;
            }
            else {
                EditHouse[playerid] = 2;
                SendClientMessage(playerid, COLOR_YELLOW, "Mobilerul ales de tine a fost spawnat. Tot ce trebuie sa faci, este sa-i alegi o pozitie!");
                SendClientMessage(playerid, COLOR_YELLOW, "Pentru a misca camera, apasa tasta SPACE iar pentru a misca obiectul, apasa click pe acele axe (X,Y,Z)");
                EditDynamicObject(playerid, obj2);
            }
        }

 

 

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...