nolanri Posted October 6, 2016 Share Posted October 6, 2016 (edited) player:getPrimaryHandItem():LoadGun() I want to give the gun ammo, whether its reloading the gun from ammo in inventory or just setting the current bullet count to 999, I don't care which I just need to give ammo to a gun in the players primary hand. Help please Edited October 20, 2016 by nolanri Link to comment Share on other sites More sharing options...
nolanri Posted October 6, 2016 Author Share Posted October 6, 2016 There is a getProjectileCount() method but for some reason no setProjectileCount(int newCount) method??? Link to comment Share on other sites More sharing options...
tommysticks Posted October 7, 2016 Share Posted October 7, 2016 Sup dude, I think you can use this: local function reloadWeapon() local player = getPlayer(); local primary = player:getPrimaryHandItem(); primary:getModData().currentCapacity = primary:getModData().maxCapacity; end Link to comment Share on other sites More sharing options...
nolanri Posted October 7, 2016 Author Share Posted October 7, 2016 4 minutes ago, tommysticks said: Sup dude, I think you can use this: local function reloadWeapon() local player = getPlayer(); local primary = player:getPrimaryHandItem(); primary:getModData().currentCapacity = primary:getModData().maxCapacity; end Thanks for replying but this just does not seem to work. Link to comment Share on other sites More sharing options...
tommysticks Posted October 7, 2016 Share Posted October 7, 2016 I'm checkin it out right now, I'll let you know what I come up with. Link to comment Share on other sites More sharing options...
nolanri Posted October 7, 2016 Author Share Posted October 7, 2016 actually it did sort of work. seems like it triggers a normal timed action reload, but it only seems to work when there is 0 ammo in the gun. if there is 1 round still left it does nothing. And its not working on my clones. which was the whole point of my question. I want to give my clones loaded guns and spawn in ranks like a fireing squad or something. Link to comment Share on other sites More sharing options...
tommysticks Posted October 7, 2016 Share Posted October 7, 2016 This worked fine for me: local function pressTest(_keyPressed) local key = _keyPressed; if key == 209 then -- PG DOWN getPlayer():getPrimaryHandItem():getModData().currentCapacity = getPlayer():getPrimaryHandItem():getModData().maxCapacity; end end Events.OnKeyPressed.Add(pressTest); Link to comment Share on other sites More sharing options...
tommysticks Posted October 7, 2016 Share Posted October 7, 2016 It reloads with any amount. Link to comment Share on other sites More sharing options...
nolanri Posted October 7, 2016 Author Share Posted October 7, 2016 4 minutes ago, tommysticks said: It reloads with any amount. Right i see it does now. it also triggers the timed action reload IF it has 0 ammo loaded. But this only seems to work for the Local player. I'm trying to give loaded guns to additionally spawned players. Replacing getPlayer() with their player instance doesnt work. Link to comment Share on other sites More sharing options...
tommysticks Posted October 7, 2016 Share Posted October 7, 2016 I looked at the video for the mod you're working on, without seeing how you are adding the weapons I can only make a guess, you might be able to use something like this to make the weapons have 1000 rounds when they are spawned: local startGun = player:getInventory():AddItem("Base.Shotgun"); startGun:getModData().currentCapacity = 1000; ...or some variation of that by storing the weapon in a variable before it's added. Link to comment Share on other sites More sharing options...
nolanri Posted October 19, 2016 Author Share Posted October 19, 2016 On 2016-10-07 at 4:22 PM, tommysticks said: I looked at the video for the mod you're working on, without seeing how you are adding the weapons I can only make a guess, you might be able to use something like this to make the weapons have 1000 rounds when they are spawned: local startGun = player:getInventory():AddItem("Base.Shotgun"); startGun:getModData().currentCapacity = 1000; ...or some variation of that by storing the weapon in a variable before it's added. It worked when i first loaded the gun in my local players hand AND THEN passed the item class instance to my clones. 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