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;
}
break;
DropObject[i] = CreateObject(model, X, Y, Z, RX, RY, RZ, world);
break;
stock CreateItem
new i = 0;
stock CreateItem(model, amount, type, Float:X, Float:Y, Float:Z, Float:RX, Float:RY, Float:RZ, world, interior)
{
if(model != 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);
i++;
}
}
return 1;
}
If it creates 100 items in the same spot, then you need to break the loop once it creates the first item.
Simply put pawn Код:
So: pawn Код:
|
if(Item[i][ItemPosX] == 0 && Item[i][ItemPosY] == 0 && Item[i][ItemPosZ] == 0)
#define ITEM_TYPE_NONE 0 #define ITEM_TYPE_DEAGLE 1 #define ITEM_TYPE_SPAS 2
if(Item[i][ItemType] == ITEM_TYPE_NONE)
stock DropItem(model, amount, type, Float:X, Float:Y, Float:Z, world, interior)
DropObject[i] = CreateObject(model, X, Y, Z, RX, RY, RZ, world);
return i;
Rule of thumb when designing dynamic systems.
- The return value for the creation function should be the INDEX in which the item was created. - All slots full? return -1 Furthermore...... Код:
if(Item[i][ItemPosX] == 0 && Item[i][ItemPosY] == 0 && Item[i][ItemPosZ] == 0) What you should do is this. Define your item types Код:
#define ITEM_TYPE_NONE 0 #define ITEM_TYPE_DEAGLE 1 #define ITEM_TYPE_SPAS 2 Код:
if(Item[i][ItemType] == ITEM_TYPE_NONE) Код:
stock DropItem(model, amount, type, Float:X, Float:Y, Float:Z, world, interior) This belongs in the enum not it's own variable! Код:
DropObject[i] = CreateObject(model, X, Y, Z, RX, RY, RZ, world); Код:
return i; |