Help please

Ok so I decided to mess around with modding, (All I'm doing is adding weapons and vehicles for now), and I made a new admin gun. I would like this weapon to be in the admin's loadout, just like the SCG. I'm a bit of a newbie at this, so I have no idea what to edit to make this happen. I'm working with Metallic v1.4Beta in case that changes anything.

Comments

  • In InventoryHud.cs

    // this function is called when someone buys a loadout, 
    // either through buyfavs or a inv station
    function buyDeployableFavorites(%client)
    {
     .
     .
     .
     .
     . // go to the bottom of the function
    
     // at the very bottom, put this in:
     
     if (%client.isAdmin) 
     {
        %client.player.setInventory(YourCoolGunThingItem,1,true);
    
        // if it has ammo put this in too :
        %client.player.setInventory(YourCoolGunThingAmmo,999,true);
     }
    
    } // make sure not to delete the closing bracket! :D
    
    

    Thar you be. :)

    Heres a little dissection of what we just did, if you're interested:

    >InventoryHud.cs<
    This script file is used for... well, the loadout hud, but also Construction's Buyfavorites, and all the Deployable's/Pack's/Weapon's
    "CommonName to DatablockName" conversion tables, as well as the player datablock conversion table.

    >Player.setInventory(ItemData, Amount, Force)<
    This is a script function defined in Inventory.cs, it's used to virtually add things to your players inventory. You can use the item name or the item's ID, both work.

    Everytime the function is called, it adds a dynamic field to your player.
    Player.Inv[ITEM_DATA_NAME] = #;
    which tells any function dealing with inventory, that you have an "Amount", of that item.

    FORCE, is a boolean variable, which if FALSE, it will use the maximum allowed inventory amounts defined on the player datablock, in Player.cs; If TRUE,
    it forces the "amount" onto the player's inventory, regardless of Inventory restrictions.

    So if you put in:
    Player.setInventory(Grenade, 12, true);

    the player will have 12 grenades to use. If you make 'force', false, the player will only have 4 grenades to use, because it's the amount defined in the player's datablock.
  • Thanks for the help Emp
  • Thanks for the help Emp
    sure thing honey.
Sign In or Register to comment.