Chickenpiedude Posted November 6, 2022 Share Posted November 6, 2022 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 [spoiler][code] 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. OnZombieDead.Add("Base.Pistol") OnZombieDead.Add("Base.Holster") GetZed:reload elseif weapon = 1 then OnZombieDead.Add("Base.Pistol2") OnZombieDead.Add("Base.Holster") GetZed:reload elseif weapon = 2 then OnZombieDead.Add("Base.Pistol3") OnZombieDead.Add("Base.Holster") GetZed:reload elseif weapon = 3 then OnZombieDead.Add("Base.Revolver_Short") OnZombieDead.Add("Base.Holster") GetZed:reload elseif weapon = 4 then OnZombieDead.Add("Base.Revolver") OnZombieDead.Add("Base.Holster") GetZed:reload elseif weapon = 5 then OnZombieDead.Add("Base.Revolver_Long") OnZombieDead.Add("Base.Holster") GetZed:reload end end end end Events.EveryOneMinute.Add(ROE_give_gear) --Checks every min, and changes if needed [/code][/spoiler] Link to comment Share on other sites More sharing options...
Hugo Qwerty Posted November 6, 2022 Share Posted November 6, 2022 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 More sharing options...
Chickenpiedude Posted November 6, 2022 Author Share Posted November 6, 2022 Thank you for the quick response! I didnt know you could change that. I'll change it now and I'll see if it changes anything. Thanks again 👍🏻 Link to comment Share on other sites More sharing options...
Chickenpiedude Posted November 6, 2022 Author Share Posted November 6, 2022 It worked! Every officer I spawn in has either a pistol/revolver and a nightstick or a shotgun and a nightstuck. I changed the option you said above and I also increased the chance for officers to have at least one holster, one shotgun and a nightstuck (the option at the bottom). Thank you for your help Hugo Qwerty 1 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now