04.01.2018, 22:13
I have a problem with loading saved items.
All items get loaded correctly, but some of them cannot be picked up after server restart.
for example if there are 2 dropped items saved, one of em will be available to pickup.
The other item is there, just like other items, but when picking it up, it simply doesn't do anything.
If i pick up the item i can pick up, and then restart the server, i can pick up the item which i couldnt pickup before.
It seems that only 1 item will be available to pickup.
What is causing this?
code:
Thanks in advance
All items get loaded correctly, but some of them cannot be picked up after server restart.
for example if there are 2 dropped items saved, one of em will be available to pickup.
The other item is there, just like other items, but when picking it up, it simply doesn't do anything.
If i pick up the item i can pick up, and then restart the server, i can pick up the item which i couldnt pickup before.
It seems that only 1 item will be available to pickup.
What is causing this?
code:
Код:
//============================================================================== stock DropItem(Float:X, Float:Y, Float:Z, world,interior,modelid) { for(new i = 0; i < sizeof(ItemInfo); i++) { if(ItemInfo[i][ItemPosX] == 0.0 && ItemInfo[i][ItemPosY] == 0.0 && ItemInfo[i][ItemPosZ] == 0.0) { new string[128]; ItemInfo[i][ItemPosX] = X; ItemInfo[i][ItemPosY] = Y; ItemInfo[i][ItemPosZ] = Z; ItemInfo[i][ItemVWorld] = world; ItemInfo[i][ItemInterior] = interior; ItemInfo[i][ItemModelID] = modelid; 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); new file[64]; format(file, sizeof(file), "Loot/item%d.ini", i); if(!fexist(file)) { INI_Create(file); } ItemInfo[i][ItemID] = i; INI_IntSet(file,"ItemPosX", floatround(ItemInfo[i][ItemPosX])); INI_IntSet(file,"ItemPosY", floatround(ItemInfo[i][ItemPosY])); INI_IntSet(file,"ItemPosZ", floatround(ItemInfo[i][ItemPosZ])); INI_IntSet(file,"ItemVWorld", ItemInfo[i][ItemVWorld]); INI_IntSet(file,"ItemInterior", ItemInfo[i][ItemInterior]); INI_IntSet(file,"ItemModelID", ItemInfo[i][ItemModelID]); INI_IntSet(file,"ItemID", ItemInfo[i][ItemID]); 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"); ItemInfo[i][ItemID]=INI_Int(LootPath(lootid),"ItemID"); 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; } //pickup up item - onplayerkey for(new i = 0; i < sizeof(ItemInfo); i++) { if (IsPlayerInRangeOfPoint(playerid, 2.0,ItemInfo[i][ItemPosX],ItemInfo[i][ItemPosY],ItemInfo[i][ItemPosZ])) { if(GetPlayerVirtualWorld(playerid) == ItemInfo[i][ItemVWorld] && GetPlayerInterior(playerid) == ItemInfo[i][ItemInterior]) { if(ItemInfo[i][Toggled] == 0) { if(Inventory[playerid][InvBag] == 0) { if(Inventory[playerid][InvSlots] > 19) return SendClientMessage(playerid,RED,"Your inventory is full, purchase a bag to obtain more slots."); } if(Inventory[playerid][InvBag] >= 1) { if(Inventory[playerid][InvSlots] > 39) return SendClientMessage(playerid,RED,"Your inventory is full."); } new modelid = ItemInfo[i][ItemModelID]; new lootid = ItemInfo[i][ItemID]; new str[128]; new x,y,z,w,in,m; x = 0; y = 0; z = 0; w = 0; in = 0; m = 0; INI_IntSet(LootPath(lootid),"ItemPosX", x); INI_IntSet(LootPath(lootid),"ItemPosY", y); INI_IntSet(LootPath(lootid),"ItemPosZ", z); INI_IntSet(LootPath(lootid),"ItemVWorld", w); INI_IntSet(LootPath(lootid),"ItemInterior", in); INI_IntSet(LootPath(lootid),"ItemModelID", m); fremove(LootPath(lootid)); ApplyAnimation(playerid, "CARRY", "putdwn",4.1,0,1,1,0,0); PickupItemTimer(playerid); format(str,sizeof(str),"%s(%i) has picked up %s from their surroundings. Item ID %d has been removed.",PlayerName(playerid),playerid,GetItemName(modelid),lootid); SendNearbyMessage(playerid,30.0,str,ORANGE); AddItem(playerid,modelid); ItemInfo[i][Toggled] = 1; Delete3DTextLabel(Label2[i]); DestroyDynamicObject(Item[i]); NoCheat[playerid] = 1; Crouch[playerid] = 1; SaveInventory(playerid); Inventory[playerid][InvSlots] += 1; return 1; } }else return 0; } }