So you know those wood loot boxes that spawn a random item? Where here's the tutorial for them (Finally)
So here we go.
Start off in WarZ.SLN
Search for
Replace that function too:
And. Well. That's it (The Code) If you need any help, post in this thread, anyone who PM's me will be ignored. ILY.
Forgot to give credits to CodexPo I'm going to be posting a lot of tutorials with you snippet of code, and edit them
So here we go.
Start off in WarZ.SLN
Search for
Code:
BOOL obj_DroppedItem::OnCreate()
Replace that function too:
Code:
BOOL obj_DroppedItem::OnCreate()
{
r3d_assert(m_Item.itemID);
const char* cpMeshName = "";
if(m_Item.itemID == 'GOLD')
{
cpMeshName = "Data\\ObjectsDepot\\Weapons\\Item_Money_Stack_01.sco";
}
else
{
const ModelItemConfig* cfg = (const ModelItemConfig*)g_pWeaponArmory->getConfig(m_Item.itemID);
switch(cfg->category)
{
case storecat_Account:
case storecat_Boost:
case storecat_LootBox:
case storecat_HeroPackage:
r3dError("spawned item is not model");
break;
}
if (SpawnedItem == true)
{
switch(gClientLogic().m_gameInfo.mapId)
{
c[COLOR=#ff0000]ase GBGameInfo::[/COLOR][COLOR=#0000ff]MAPID_CaliWood[/COLOR][COLOR=#ff0000]:[/COLOR]
[COLOR=#ff0000] if (LootID != cfg->m_itemID) // For all LootIDs[/COLOR]
[COLOR=#ff0000] {[/COLOR]
[COLOR=#ff0000] cpMeshName = "data/objectsdepot/Weapons/item_lootcrate_01.sco";[/COLOR]
[COLOR=#ff0000] }[/COLOR]
[COLOR=#ff0000] else {[/COLOR]
[COLOR=#ff0000] cpMeshName = cfg->m_ModelPath;[/COLOR]
[COLOR=#ff0000] SpawnedItem=false;[/COLOR]
[COLOR=#ff0000] }[/COLOR]
[COLOR=#ff0000] break;[/COLOR]
[COLOR=#ff0000]
[/COLOR]
[COLOR=#ff0000] default:[/COLOR]
[COLOR=#ff0000] switch(LootID) // Specific lootID for other maps[/COLOR]
[COLOR=#ff0000] {[/COLOR]
[COLOR=#ff0000] case 301117:[/COLOR]
[COLOR=#ff0000] cpMeshName = "data/objectsdepot/Weapons/item_lootcrate_01.sco";[/COLOR]
[COLOR=#ff0000] break;[/COLOR]
[COLOR=#ff0000] default:[/COLOR]
[COLOR=#ff0000] cpMeshName = cfg->m_ModelPath;[/COLOR]
[COLOR=#ff0000] SpawnedItem=false;[/COLOR]
[COLOR=#ff0000] }[/COLOR]
[COLOR=#ff0000] }[/COLOR]
}
else {
cpMeshName = cfg->m_ModelPath;
}
}
if(!parent::Load(cpMeshName))
return FALSE;
if(m_Item.itemID == 'GOLD')
{
m_ActionUI_Title = gLangMngr.getString("Money");
m_ActionUI_Msg = gLangMngr.getString("HoldEToPickUpMoney");
}
else if (SpawnedItem == true)
{
m_ActionUI_Title = gLangMngr.getString("ITEM");//$FR_PAUSE_USE_ITEM");
m_ActionUI_Msg = gLangMngr.getString("HoldEToPickUpMoney");
}
else
{
const BaseItemConfig* cfg = g_pWeaponArmory->getConfig(m_Item.itemID);
m_ActionUI_Title = cfg->m_StoreNameW;
m_ActionUI_Msg = gLangMngr.getString("HoldEToPickUpItem");
}
ReadPhysicsConfig();
PhysicsConfig.group = PHYSCOLL_TINY_GEOMETRY; // skip collision with players
PhysicsConfig.requireNoBounceMaterial = true;
PhysicsConfig.isFastMoving = true;
//m_bEnablePhysics = false;
SetPosition(GetPosition()+r3dPoint3D(0,0.25f,0));
m_spawnPos = GetPosition();
parent::OnCreate();
UpdateObjectPositionAfterCreation();
return 1;
}
And. Well. That's it (The Code) If you need any help, post in this thread, anyone who PM's me will be ignored. ILY.
Forgot to give credits to CodexPo I'm going to be posting a lot of tutorials with you snippet of code, and edit them
Last edited:

