forward LootRespawn();
public LootRespawn()
{
new res = randomEx(1, 2);
new amount = randomEx(1, 10);
new Locs = random(sizeof(TestSpawns));
if(res == 1)
{
CreateItem(1580, amount, 1, TestSpawns[Locs][0], TestSpawns[Locs][1], TestSpawns[Locs][2], 0, 0);
CreateItem(1577, amount, 1, TestSpawns[Locs][0], TestSpawns[Locs][1], TestSpawns[Locs][2], 0, 0);
CreateItem(373, amount, 1, TestSpawns[Locs][0], TestSpawns[Locs][1], TestSpawns[Locs][2], 0, 0);
CreateItem(348, 1, 1, TestSpawns[Locs][0], TestSpawns[Locs][1], TestSpawns[Locs][2], 0, 0);
}
if(res == 2)
{
CreateItem(2806, amount, 1, TestSpawns[Locs][0], TestSpawns[Locs][1], TestSpawns[Locs][2], 0, 0);
CreateItem(2663, amount, 1, TestSpawns[Locs][0], TestSpawns[Locs][1], TestSpawns[Locs][2], 0, 0);
CreateItem(335, 1, 1, TestSpawns[Locs][0], TestSpawns[Locs][1], TestSpawns[Locs][2], 0, 0);
CreateItem(2358, amount, 1, TestSpawns[Locs][0], TestSpawns[Locs][1], TestSpawns[Locs][2], 0, 0);
}
new Float: TestSpawns[][] =
{
{377.64130, 2542.36963, 15.53980},
{381.50552, 2542.74146, 15.53976},
{381.19205, 2539.23486, 15.54050},
{378.27368, 2539.07715, 15.54048}
};
forward LootRespawn(); public LootRespawn() { new res = randomEx(1, 2); new ItemRes[][4] = { {1580, 1577, 373, 348}, // items for res == 1 {2806, 2663, 335, 2358} // items for res == 2 }; for(new i = 0; i < sizeof(ItemRes); i++) // This will do loop 4 times { if((res == 1 && i == 3) || (res == 2 && i == 2)) amount = 1; // The 4th (i+1) item (res == 1) which is model 348 should only have 1 amount. // OR the 3rd (i+1) item (res == 2) which is model 335 should only have 1 amount too. else amount = randomEx(1, 10); // Otherwise, randomize the amount. Locs = random(sizeof(TestSpawns)); CreateItem(ItemRes[res][i], amount, 1, TestSpawns[Locs][0], TestSpawns[Locs][1], TestSpawns[Locs][2], 0, 0); /* res is already randomized so no need to check if it's equal to one or two since the function is mostly doing the same for both res, which is just differences with the items that we have to separate it in ItemRes array now. */ }
forward LootRespawn(); public LootRespawn() { new res = randomEx(1, 2); new ItemRes[][4] = { {1580, 1577, 373, 348}, // items for res == 1 {2806, 2663, 335, 2358} // items for res == 2 }; // THIS WILL ONLY DO ONCE if((res == 1 && i == 3) || (res == 2 && i == 2)) amount = 1; // The 4th (i+1) item (res == 1) which is model 348 should only have 1 amount. // OR the 3rd (i+1) item (res == 2) which is model 335 should only have 1 amount too. else amount = randomEx(1, 10); // Otherwise, randomize the amount. for(new i = 0; i < sizeof(ItemRes); i++) // This will do loop 4 times { Locs = random(sizeof(TestSpawns)); CreateItem(ItemRes[res][i], amount, 1, TestSpawns[Locs][0], TestSpawns[Locs][1], TestSpawns[Locs][2], 0, 0); /* res is already randomized so no need to check if it's equal to one or two since the function is mostly doing the same for both res, which is just differences with the items that we have to separated it in ItemRes array now. */ }
Here's what the issue is, you can see all the items are spawning on top of each other when they shouldn't.
|
I do understand that issue now, to fix that, you shouldn't use random, but use the loop or mark the position that is already used. |
But you haven't explained the use of "res" and the amount, should it be same OR random?? |
//all the current items you can get
new ItemSpawns[][2] =
{
{2806, 1}, //meat
{2806, 2}, //steak
{2663, 1}, //cram
{2663, 2}, //mac cheese
{2769, 1}, //iguana
{2769, 2}, //squirrel
{1580, 1}, //stimpak
{1580, 2}, //doc bag
{1575, 1}, //jet
{1575, 2}, //psycho
{1575, 3}, //mentats
{1575, 4}, //buffout
{2647, 1}, //dirty water
{2647, 2}, //pure water
{1484, 1}, //nuka
{1577, 1}, //radaway
{373, 1}, //armor
{333, 1}, //golf club
{334, 1}, //baton
{335, 1}, //combat knife
{336, 1}, //bat
{337, 1}, //shovel
{338, 1}, //pool cue
{339, 1}, //katana
{346, 1}, //colt 45
{348, 1}, //deagle
{349, 1}, //shotgun
{351, 1}, //spaz
{353, 1}, //smg
{356, 1}, //m4
{357, 1}, //rifle
{358, 1}, //sniper
{2358, 1}, //pistol ammo
{2358, 2}, //shotgun ammo
{2358, 3}, //smg ammo
{2358, 4}, //assault rifle ammo
{2358, 5} //rifle ammo
};
forward LootRespawn();
public LootRespawn()
{
new Items = random(sizeof(ItemSpawns));
new amount = randomEx(1, 10);
for(new i=0; i<MAX_ITEMS; i++)
{
DeleteAllItems(i);
if(ItemSpawns[Items][0] == 333 || ItemSpawns[Items][0] == 334 || ItemSpawns[Items][0] == 335 || ItemSpawns[Items][0] == 336 || ItemSpawns[Items][0] == 337 || ItemSpawns[Items][0] == 338 || ItemSpawns[Items][0] == 339 ||
ItemSpawns[Items][0] == 346 || ItemSpawns[Items][0] == 348 || ItemSpawns[Items][0] == 349 || ItemSpawns[Items][0] == 351 || ItemSpawns[Items][0] == 353 || ItemSpawns[Items][0] == 356 || ItemSpawns[Items][0] == 357 ||
ItemSpawns[Items][0] == 338) amount = 1;
CreateItem(ItemSpawns[Items][0], amount, ItemSpawns[Items][1], 377.64130, 2542.36963, 15.53980, 0, 0);
CreateItem(ItemSpawns[Items][0], amount, ItemSpawns[Items][1], 381.50552, 2542.74146, 15.53976, 0, 0);
CreateItem(ItemSpawns[Items][0], amount, ItemSpawns[Items][1], 381.19205, 2539.23486, 15.54050, 0, 0);
CreateItem(ItemSpawns[Items][0], amount, ItemSpawns[Items][1], 378.27368, 2539.07715, 15.54048, 0, 0);
LoadItemVisual(i);
}
return 1;
}
forward LootRespawn();
public LootRespawn()
{
new Items, amount;
for(new i=0; i<MAX_ITEMS; i++)
{
DeleteAllItems(i);
Items = random(sizeof(ItemSpawns));
amount = randomEx(1, 10);
if(ItemSpawns[Items][0] == 333 || ItemSpawns[Items][0] == 334 || ItemSpawns[Items][0] == 335 || ItemSpawns[Items][0] == 336 || ItemSpawns[Items][0] == 337 || ItemSpawns[Items][0] == 338 || ItemSpawns[Items][0] == 339 ||
ItemSpawns[Items][0] == 346 || ItemSpawns[Items][0] == 348 || ItemSpawns[Items][0] == 349 || ItemSpawns[Items][0] == 351 || ItemSpawns[Items][0] == 353 || ItemSpawns[Items][0] == 356 || ItemSpawns[Items][0] == 357 ||
ItemSpawns[Items][0] == 338) amount = 1;
CreateItem(ItemSpawns[Items][0], amount, ItemSpawns[Items][1], 377.64130, 2542.36963, 15.53980, 0, 0);
CreateItem(ItemSpawns[Items][0], amount, ItemSpawns[Items][1], 381.50552, 2542.74146, 15.53976, 0, 0);
CreateItem(ItemSpawns[Items][0], amount, ItemSpawns[Items][1], 381.19205, 2539.23486, 15.54050, 0, 0);
CreateItem(ItemSpawns[Items][0], amount, ItemSpawns[Items][1], 378.27368, 2539.07715, 15.54048, 0, 0);
LoadItemVisual(i);
}
return 1;
}
pawn Код:
|
forward LootRespawn();
public LootRespawn()
{
new amount = randomEx(1, 5);
for(new i=0; i<MAX_ITEMS; i++)
{
DeleteAllItems(i);
}
for(new i=0; i<sizeof(ItemSpawns); i++)
{
for(new j=0; j<sizeof(RandomItems); j++)
{
CreateItem(RandomItems[j][0], amount, RandomItems[j][1], ItemSpawns[i][0], ItemSpawns[i][1], ItemSpawns[i][2], 0, 1);
}
}
for(new i=0; i<MAX_ITEMS; i++)
{
LoadItemVisual(i);
}
return 1;
}
[connection] 127.0.0.1:63958 request connection cookie. Kicking 127.0.0.1 because they didn't logon to the game.
//The code for reference
forward UpdateHouseData();
public UpdateHouseData()
{
foreach(Player, i)
{
for(new j = 0; j<MAX_HOUSES; j++)
{
if(fexist(HousePath(i)))
{
if(IsPlayerInRangeOfPoint(i, 1, House[j][ExtPosX], House[j][ExtPosY], House[j][ExtPosZ]))
{
ShowHouseInfo(i, j, 2000);
}
}
}
}
return 1;
}