Saving and loading dropped items
#1

I did create something to save and load dropped items but it doesn't work correctly.
It doesn't save in like item1.ini,item2.ini etc but it creates like 50 files when dropping 1 item.
If i change return 0; to break; at saving it only saves item0 over and over again.
Loading doesnt work at all while the settings are saved correctly:
ItemPosX=2195
ItemPosY=-1670
ItemPosZ=13
ItemVWorld=0
ItemInterior=0
ItemModelID=849

Also when i check my server console.
printf("Dropped Items loaded: [%d items out of %d]", items_Loaded, MAX_DROP_ITEMS);
It displays the correct amount of items that are in the folder.

What am i doing wrong?

code:
Код:
//under ongamemodeinit
for(new i=0; i<MAX_DROP_ITEMS; i++)
	{
	    if(fexist(LootPath(i)))
	    {
	        LoadDroppedItems(i);
	        items_Loaded ++;
	    }
	}
printf("Dropped Items loaded: [%d items out of %d]", items_Loaded, MAX_DROP_ITEMS);
//==============================================================================
SaveDroppedItem(lootid)
{
    for(new i=0; i < MAX_DROP_ITEMS; i++)
    {
		if(!fexist(LootPath(lootid))) { INI_Create(LootPath(lootid)); }
		INI_IntSet(LootPath(lootid),"ItemPosX", floatround(ItemInfo[i][ItemPosX]));
		INI_IntSet(LootPath(lootid),"ItemPosY", floatround(ItemInfo[i][ItemPosY]));
		INI_IntSet(LootPath(lootid),"ItemPosZ", floatround(ItemInfo[i][ItemPosZ]));
		INI_IntSet(LootPath(lootid),"ItemVWorld", ItemInfo[i][ItemVWorld]);
		INI_IntSet(LootPath(lootid),"ItemInterior", ItemInfo[i][ItemInterior]);
		INI_IntSet(LootPath(lootid),"ItemModelID", ItemInfo[i][ItemModelID]);
		return 0;
	}
	return 1;
}
//==============================================================================
LoadDroppedItems(lootid)
{
    for(new i=0; i < MAX_DROP_ITEMS; i++)
    {
		new string[128], Float:X, Float:Y, Float:Z, world,modelid;
        if(!fexist(LootPath(lootid)))return 0;
		ItemInfo[i][ItemPosX]=INI_Int(LootPath(lootid),"ItemPosX");
        ItemInfo[i][ItemPosY]=INI_Int(LootPath(lootid),"ItemPosY");
        ItemInfo[i][ItemPosZ]=INI_Int(LootPath(lootid),"ItemPosZ");
        ItemInfo[i][ItemVWorld]=INI_Int(LootPath(lootid),"ItemVWorld");
		ItemInfo[i][ItemInterior]=INI_Int(LootPath(lootid),"ItemInterior");
		ItemInfo[i][ItemModelID]=INI_Int(LootPath(lootid),"ItemModelID");
        X = ItemInfo[i][ItemPosX];
        Y = ItemInfo[i][ItemPosY];
        Z = ItemInfo[i][ItemPosZ];
        world = ItemInfo[i][ItemVWorld];
		modelid = ItemInfo[i][ItemModelID];
		format(string,sizeof(string),"%s (Press 'H' to pick up)",GetItemName(modelid));
        Label2[i] = Create3DTextLabel(string, COLOR_YELLOW,X,Y,Z, 3.0,world, 0);
        Item[i] = CreateDynamicObject(modelid, X, Y, Z,272,0,0, world);
        return 1;
    }
	return 1;
}
Thanks in advance
Reply
#2

pawn Код:
SaveDroppedItem(lootid)
{
    if(!fexist(LootPath(lootid))) { INI_Create(LootPath(lootid)); }
    INI_IntSet(LootPath(lootid),"ItemPosX", floatround(ItemInfo[lootid][ItemPosX]));
    INI_IntSet(LootPath(lootid),"ItemPosY", floatround(ItemInfo[lootid][ItemPosY]));
    INI_IntSet(LootPath(lootid),"ItemPosZ", floatround(ItemInfo[lootid][ItemPosZ]));
    INI_IntSet(LootPath(lootid),"ItemVWorld", ItemInfo[lootid][ItemVWorld]);
    INI_IntSet(LootPath(lootid),"ItemInterior", ItemInfo[lootid][ItemInterior]);
    INI_IntSet(LootPath(lootid),"ItemModelID", ItemInfo[lootid][ItemModelID]);
    return 1;
}
Reply
#3

Thanks
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)