20.04.2015, 16:08
I followed a tutorial on how to make items that you can pickup/drop from the ground, but I've run into an issue.
The maximum amount of items is 100, so when I want to control an individual item, I have to run it through a loop, which ends up creating 100 items in one place. I'm not sure how to fix it.
I suspect it has something to do with creating an item as it will create 100 items at the first X,Y,Z coords, but like I said, I have no clue what's wrong or how to fix it.
The maximum amount of items is 100, so when I want to control an individual item, I have to run it through a loop, which ends up creating 100 items in one place. I'm not sure how to fix it.
pawn Код:
stock CreateItem(model, amount, type, Float:X, Float:Y, Float:Z, Float:RX, Float:RY, Float:RZ, world, interior)
{
if(model != 0)
{
for(new i=0; i<MAX_ITEMS; i++)
{
if(Item[i][ItemPosX] == 0 && Item[i][ItemPosY] == 0 && Item[i][ItemPosZ] == 0)
{
Item[i][ItemModel] = model;
Item[i][ItemAmount] = amount;
Item[i][ItemType] = type;
Item[i][ItemPosX] = X;
Item[i][ItemPosY] = Y;
Item[i][ItemPosZ] = Z;
Item[i][ItemRotX] = RX;
Item[i][ItemRotY] = RY;
Item[i][ItemRotZ] = RZ;
Item[i][ItemVWorld] = world;
Item[i][ItemInterior] = interior;
LoadItemVisual();
//ItemLabel[i] = Create3DTextLabel("ItemName", COLOR_BLUE, X, Y, Z, 5, world, 0);
DropObject[i] = CreateObject(model, X, Y, Z, RX, RY, RZ, world);
}
}
}
return 1;
}
stock DropItem(model, amount, type, Float:X, Float:Y, Float:Z, world, interior)
{
if(model != 0)
{
for(new i=0; i<MAX_ITEMS; i++)
{
if(Item[i][ItemPosX] == 0 && Item[i][ItemPosY] == 0 && Item[i][ItemPosZ] == 0)
{
Item[i][ItemModel] = model;
Item[i][ItemAmount] = amount;
Item[i][ItemType] = type;
Item[i][ItemPosX] = X;
Item[i][ItemPosY] = Y;
Item[i][ItemPosZ] = Z;
Item[i][ItemVWorld] = world;
Item[i][ItemInterior] = interior;
LoadItemVisual();
//ItemLabel[i] = Create3DTextLabel("ItemName", COLOR_BLUE, X, Y, Z, 5, world, 0);
DropObject[i] = CreateObject(model, X, Y, Z-1, 0, 0, 0, world);
}
}
}
return 1;
}
stock LoadItems()
{
CreateItem(2806, 1, 1, 346.54266, 2507.15649, 15.47086, 0.00000, 0.00000, 0.00000, 0, 0);
CreateItem(2806, 1, 2, 351.54187, 2507.21704, 15.47086, 0.00000, 0.00000, 0.00000, 0, 0);
CreateItem(2806, 1, 1, 351.48746, 2499.85474, 15.47086, 0.00000, 0.00000, 0.00000, 0, 0);
CreateItem(2806, 1, 2, 345.39008, 2499.46338, 15.47086, 0.00000, 0.00000, 0.00000, 0, 0);
return 1;
}