Greetings!
On my server, when mining ore, a box spawns, but for some reason they appear immediately 2 instead of 1
Box spawn code
public void SpawnLoot(BaseEntity entity, BasePlayer player,Vector3 position,int countBox = 0)
{
Vector3 pos = new Vector3(UnityEngine.Random.Range(-0.3f, 0.3f), UnityEngine.Random.Range(0, 0), UnityEngine.Random.Range(-1, 1));
BaseEntity boxed = GameManager.server.CreateEntity(_config.lootBox.PrefabBox, position + pos);
if(boxed == null)
{
return;
}
Puts(boxed.ToString());
boxed.Spawn();
boxed.SendNetworkUpdateImmediate();
}
The code in which the method is called
void findEntityCashe(BaseEntity entity, BasePlayer player)
{
foreach (BaseEntity resource in oreCashe)
{
if (resource is OreResourceEntity)
{
var position = entity.transform.position;
if(_config.Lootdrop)
{
if(_config.GiveItem)
{
SendReply(player,"Твоя руда была разбита");
DropLoot(player,position);
return;
}
else{
SendReply(player,"Твоя руда была разбита");
GiveLoot(player);
return;
}
}
else
{
if(entity == null)
{
return;
}
SpawnLoot(entity,player,position);
}
}
}
}