Welcome!

Join our community of MMO enthusiasts and game developers! By registering, you'll gain access to discussions on the latest developments in MMO server files and collaborate with like-minded individuals. Join us today and unlock the potential of MMO server development!

Join Today!

[Tutorial] Drop all item

Junior Spellweaver
Joined
Oct 25, 2017
Messages
158
Reaction score
17
Hello all this 2 times when I put something, just say the code is not mine!

So, let's begin

Open:
WarZ.sln

Search: void DropItem(int slotFrom);
add below
Code:
void DropAllItem(int slotFrom);//drop all

Search: void HUDPause::eventContextMenu_Action
add above

Code:
if (!plr->IsSwimming() )//drop all   
 {       
 var[0].SetString("$FR_PAUSE_INVENTORY_DROP_ALL_ITEM");        var[1].SetInt(HPA_DROP_ALL_ITEM);        gfxMovie.Invoke("_root.api.Main.Inventory.addContextMenuOption", var, 2);   
 }
Search: if(actionID == HPA_DROP_ITEM)
add below
Code:
else if (actionID == HPA_DROP_ALL_ITEM)//drop all   
 {        
plr->DropAllItem(slotID);        updateSurvivorTotalWeight();        gfxMovie.Invoke("_root.api.backpackGridSwapSuccess", "");   
 }
  if (CurLoadout.Items[i].itemID == itemID)				quantity += CurLoadout.Items[i].quantity;
  }
if (quantity == 0) // check if that attm is equipped and if yes, remove it from weapon
Search: HPA_DISASSEMBLE_ITEM,
add below
Code:
HPA_DROP_ALL_ITEM, //drop all
Search: PKT_C2S_BackpackDrop,
add below
Code:
PKT_C2S_BackpackDropAll,        //drop all


Search:void obj_Player::RemoveWpnAttm
add above
Code:
void obj_Player::DropAllItem(int slotFrom)
{
        PKT_C2S_BackpackDropAll_s n;	n.SlotFrom = slotFrom;	n.pos = GetPosition() + GetvForw()*0.1f;	p2pSendToHost(this, &n, sizeof(n));
    
        int itemID = CurLoadout.Items[slotFrom].itemID;

        //local logic	//CurLoadout.Items[slotFrom].quantity--;	CurLoadout.Items[slotFrom].Reset();	if (CurLoadout.Items[slotFrom].quantity <= 0) {		CurLoadout.Items[slotFrom].Reset();
        }

        // fucked up attachment design!

       const WeaponAttachmentConfig* wac = g_pWeaponArmory->getAttachmentConfig(itemID);
if (wac)
{
int quantity = CurLoadout.Items[slotFrom].quantity; // if attm is droppen, then here will be zero	for (int i = 0; i < CurLoadout.BackpackSize; ++i)
{
if (quantity == 0) // check if that attm is equipped and if yes, remove it from weapon
{
uint32_t curAttm[WPN_ATTM_MAX] = { 0 };
if (m_Weapons[0])
{
        m_Weapons[0]->getCurrentAttachmentIDs(curAttm);				if (curAttm[wac->m_type] == itemID)					RemoveWpnAttm(0, wac->m_type);
}
          if (m_Weapons[1])
          {
          m_Weapons[1]->getCurrentAttachmentIDs(curAttm);
          if (curAttm[wac->m_type] == itemID)
          RemoveWpnAttm(1, wac->m_type);
          }
      }
   }
   
OnBackpackChanged(slotFrom);

if(NetworkLocal)
   {
    const WeaponConfig* wc = g_pWeaponArmory->getWeaponConfig(itemID);
    if(wc)
         SoundSys.PlayAndForget(SoundSys.GetEventIDByPath("Sounds/WarZ/PlayerSounds/PLAYER_DROPGUN"), GetPosition());
   else
   SoundSys.PlayAndForget(SoundSys.GetEventIDByPath("Sounds/WarZ/PlayerSounds/PLAYER_  DROPITEM"), GetPosition());
    }
}

Search: struct PKT_C2S_BackpackDrop_s
add below
Code:
struct PKT_C2S_BackpackDropAll_s : public DefaultPacketMixin<PKT_C2S_BackpackDropAll>{    BYTE        SlotFrom;    r3dPoint3D    pos;};
Build and Close WarZ.sln

Step 2
Open WarZ_Servers

Search:void obj_ServerPlayer::OnNetPacket
add above
Code:
void obj_ServerPlayer::OnNetPacket(const PKT_C2S_BackpackDropAll_s& n){    if (!r3d_vector_isFinite(n.pos))            return;        if (n.SlotFrom >= loadout_->BackpackSize) {        gServerLogic.LogCheat(peerId_, PKT_S2C_CheatWarning_s::CHEAT_Protocol, true, "backpack",            "slot: %d", n.SlotFrom);        return;    }    float dropLength = (GetPosition() - n.pos).Length();    if (dropLength > 20.0f)    {        gServerLogic.LogCheat(peerId_, PKT_S2C_CheatWarning_s::CHEAT_Protocol, true, "backpack",            "dlen: %f", dropLength);        return;    }    wiInventoryItem& wi = loadout_->Items[n.SlotFrom];    if (wi.itemID == 0 || wi.quantity < 1)    {        gServerLogic.LogCheat(peerId_, PKT_S2C_CheatWarning_s::CHEAT_Protocol, true, "backpack",            "id: %d %d %d", n.SlotFrom, wi.itemID, wi.quantity);        return;    }    // create network object    obj_DroppedItem* obj = (obj_DroppedItem*)srv_CreateGameObject("obj_DroppedItem", "obj_DroppedItem", n.pos);    SetupPlayerNetworkItem(obj);    // vars    obj->m_Item = wi;    obj->m_Item.quantity = wi.quantity;    // modify backpack (need after item creation)    for (; wi.quantity > 0;)        wi.quantity--;    if (wi.quantity <= 0)        wi.Reset();    OnBackpackChanged(n.SlotFrom);    return;}

Search:DEFINE_GAMEOBJ_PACKET_HANDLER
add below
Code:
DEFINE_GAMEOBJ_PACKET_HANDLER(PKT_C2S_BackpackDropAll);//drop all

Search:void OnNetPacket
add below
Code:
void        OnNetPacket(const PKT_C2S_BackpackDropAll_s& n);//drop all

Build and Close WarZ_Server.

Step 3

Go LangPack and open you language

Search $FR_PAUSE_INVENTORY_BACKPACK_TYPE=TYPE and add above
Code:
$FR_PAUSE_INVENTORY_DROP_ALL_ITEM=DROP ALL

Done!!!! Sorry for my English :D

Credits AlexRedd.
 
Last edited:
Back
Top