Jump to content

Help with adding items to a zombies inventory and seeing them when the zombie dies.


Recommended Posts

Hello, Im new to modding and I am trying to add a pistol or revolver to every zombie police officer's inventory to make the game more realistic. Ive used some code from Small Town Responders and from the wiki but nothing seems to be working. I think ive selected zombies using the GetZedX and GetZedY variables and I made an if statement checking if the zombie has either a police outfit, police state outfit or a police riot outfit. Im not sure how to carry on from there, I gave it a go though.

The code I used us below. Thanks :)

local function ROE_give_gear()
    -- Gets variables used
    local GetZed;
    local GetZedX;
    local GetZedY;
    local GetZedOutfitName;
    --Gets Zombies from world
    local GetZedList = getWorld():getCell():getZombieLost();
    if GetZedList ~= nil then
    for i=0, GetZedList:size()-1 do
        -- Get Zombie
        GetZed = GetZedList:get(i);
        -- Get Zombie X
        GetZedX = GetZed:getX();
        -- Get Zombie Y
        GetZedY = GetZed:getY();
        -- Get The Outfit The Zombie Is Wearing
        GetZedOutfitName = GetZed:getOutfitName();
        --Checks if Zombie is wearing a police outfit
        if GetZedX and GetZedY GetZedOutfitName == "Police" or GetZedOutfitName == "PoliceState" or GetZedOutfitName == "PoliceRiot" then
            local weapon = random(0,5) --generates a random num from 0 to 6
            if weapon = 0 then --Gives zed a sidearm and holster depending on number.
            elseif weapon = 1 then
            elseif weapon = 2 then
            elseif weapon = 3 then
            elseif weapon = 4 then
            elseif weapon = 5 then

Events.EveryOneMinute.Add(ROE_give_gear) --Checks every min, and changes if needed

Link to comment
Share on other sites

That code will probably cause performance issues.  Hydrocraft used to do something similar for 'aging' items (and replacing them, e.g. replacing a cow with a hungry cow, or replacing a hungry cow with a dead cow) - and the performance hit was horrid on my machine.

You might be able to achieve what you want by editing the data in /media/lua/shared/Definitions/AttachedWeaponDefinitions.lua


Something like a lua file with the following code (untested):


AttachedWeaponDefinitions.handgunHolster.chance = 100


(The vanilla value is 50)

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Create New...