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!

[Release] Give Ammo - Cmd

Initiate Mage
Joined
Nov 9, 2013
Messages
82
Reaction score
57
Heyyo!

How annoying is it, to search for id of your wanted mag and then writing down /gi <itemid of magazine> just to give yourself ONE crappy magazine? How about like 10+ mags? :glare:

I became really frustrated while I had to test something with guns!
Yeez! xD

So here it is.
A simple cmd that will give ya mags for you current weapon that you are holding in your hands.
Completely server-sided with a simple command /ammo


Search in ServerGameLogic.cpp
Code:
if(strncmp(cmd, "/gi", 3) == 0 && plr->profile_.ProfileData.isDevAccount)
      return Cmd_GiveItem(plr, cmd);

Add BELOW
Code:
if(strncmp(cmd, "/ammo", 5) == 0 && plr->profile_.ProfileData.isDevAccount)
      return Cmd_Ammo(plr, cmd);

Search for
Code:
int ServerGameLogic::Cmd_SetVitals(obj_ServerPlayer* plr, const char* cmd)
{

Add ABOVE
Code:
int ServerGameLogic::Cmd_Ammo(obj_ServerPlayer* plr, const char* cmd)
{
    //lets get the weapon config from the selected weapon
    ServerWeapon* wpn = plr->m_WeaponArray[plr->m_SelectedWeapon];
    
    //statements, you might want to add more?
    if(wpn && wpn->getCategory() != storecat_MELEE)
    {
        //get clip config from wpn
        const WeaponAttachmentConfig* clip = wpn->getClipConfig();

        //basicly lets just take the weapon item for our clip item
        wiInventoryItem wi;
        wi = plr->loadout_->Items[plr->loadout_->CHAR_LOADOUT_WEAPON1]; 


        wi.itemID = clip->m_itemID; //now overrides with clip item id
        wi.quantity = 2; //set how many mags per command you want!
        wi.Var1 = clip->m_Clipsize; //set max clipsize from the clip config

        //add it to the backpack
        plr->BackpackAddItem(wi);

    }


    return 0;
}

You might want to add return values. :p

Now search in ServerGameLogic.h
Code:
int          Cmd_GiveItem(obj_ServerPlayer* plr, const char* cmd);

Add BELOW
Code:
int          Cmd_Ammo(obj_ServerPlayer* plr, const char* cmd);

When you use this on Crossbow it will give you 2x Arrow stacked, another statement needed. :eek:tt1:

PS: I will update these codes once I release more stuff later.
 
Last edited:
Junior Spellweaver
Joined
Apr 3, 2014
Messages
135
Reaction score
23
Guy, I did everything right. When I digit / ammo id number, appears only command executed over the item does not arrive in my inventory. What can it be?
 
Last edited:
Initiate Mage
Joined
Apr 10, 2013
Messages
57
Reaction score
6
You aren't supposed to put anything in. You are supposed to type in /ammo when HOLDING the gun that you want to get ammo for.
 
Back
Top