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;
}
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;
}
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(playerid, DIALOG_HM, DIALOG_STYLE_TABLIST, "{02901a}Meniu casa",strong, "Select", "Cancel");
stock GetHouseObjects(houseid)
{
for(new i = 0; i != sizeof(FurnitureInfo); i++)
{
if(FurnitureInfo[i][fiHouse] == houseid) i++;
}
return 1;
}
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; }
cache_get_value_int(i, "ID", FurnitureInfo[x][fiID]);
cache_get_value_int(i, "ID", FurnitureInfo[i][fiID]);
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; } 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]); Код:
cache_get_value_int(i, "ID", FurnitureInfo[i][fiID]); |
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, -1, 200.0);
}
print("=============================================================");
printf("[GAMEMODE]: Furniture Sistem Loaded %d object's", objects);
print("=============================================================\n");
return 1;
}
switch(dialogid)
{
case DIALOG_EDITMOBILA: {
if(!response) return 1;
SlotSel[playerid] = listitem;
ShowPlayerDialog(playerid, DIALOG_EDITMOBILA2, DIALOG_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(playerid, COLOR_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(handle, query);
}
else {
EditHouse[playerid] = 2;
SCM(playerid, COLOR_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(playerid, COLOR_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(playerid, COLOR_YELLOW, "{02901a}SERVER:{f9f7ce} Iar pentru a iesi, apasa tasta {bfc0c2}ESC{f9f7ce}. Succes la mobilat!");
EditDynamicObject(playerid, obj2);
}
}
public OnPlayerEditObject(playerid, playerobject, objectid, response, Float:fX, Float:fY, Float:fZ, Float:fRotX, Float:fRotY, Float:fRotZ)
{
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[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, -1, 200.0);
format(szQuery, 256, "{02901a}SERVER:{f9f7ce} Mobilier adaugat cu succes. Total obiecte: %d/30.", GetHouseObjects(PlayerInfo[playerid][pHouse]));
SCM(playerid, COLOR_YELLOW, szQuery);
GivePlayerCash(playerid,-1000);
GameTextForPlayer(playerid, "~r~-$1,000",500,1);
}
else if(EditHouse[playerid] == 2) {
new i = 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, -1, 200.0);
SCM(playerid, COLOR_YELLOW, "{02901a}SERVER:{f9f7ce} Mobilier editat cu succes.");
}
}
if(response == EDIT_RESPONSE_CANCEL)
{
if(EditHouse[playerid] == 1) DestroyDynamicObject(ObjectEdited[playerid]), SCM(playerid, -1, "{02901a}SERVER:{f9f7ce} Ai anulat adaugarea mobilierului.");
if(EditHouse[playerid] == 2) SCM(playerid, -1, "{02901a}SERVER:{f9f7ce} Ai anulat adaugarea mobilierului.");
}
return 1;
}