Jump to content

Pistol Reload .lua


Japer

Recommended Posts

I need help with custom pistols, my ones currently work in game but they have unlimited ammo. What I need it to do is use the vanilla pistol ammo with my weapon. I have custom reloading/clips with my created weapons and ammo but I can't get it to use vanilla ammo.

 

Here is my code, I have tried 9mmbullets,pistol magazine and baretta clip in all different variations and can't seem to get it to work.

Any help would be great, thanks

 

 

local pistolstars = {name = getItemText("S.T.A.R.S. Pistol"),moduleName = 'ResidentEvilWeapons',reloadClass = 'ISSemiAutoWeapon',ammoType = 'Bullets9mm',clipName = '9mm Magazine',clipIcon = 'BerettaClip',shootSound = '',clickSound = '',ejectSound = '',insertSound = '',rackSound = '',containsClip = 1,maxCapacity = 17,reloadTime = 15,rackTime = 10,clipData = Bullets9mm};ReloadUtil:addMagazineType(pistolstars)
 
 

Link to comment
Share on other sites

What is this file's name and location in your mod folder structure?

Since I also suffered from the 'infinite ammo' glitch, what I did to get mine to work was to rename the reloading .lua so it is 'alphabetically lower', that is, later in the alphabet than the other files it references. So call it something like this: "Z_MyPistolReloading.lua".

That way, it loads after all the other reloading lua files have done so, and that way your code gets inserted into the main game.

 

Something else I noticed, is this code for a pistol or its magazine? You've named it "STARS Pistol"  and then reloadClass = 'ISSemiAutoWeapon',

but at the bottom it says

"ReloadUtil:addMagazineType(pistolstars)"

So which is it? A pistol or its magazine?

 

You'll also need to add the sound effects into your code, but I guess you already knew that... ;)

Link to comment
Share on other sites

In the lua folder it's called Reload (Which is least alphabetically) and within the same code 2 weapons reloading work.
It is a weapon, trying to use the vanilla pistol ammo,The line "ReloadUtil:addMagazineType(pistolstars)" is probably just an error from the last phase of testing I done and it is set under Mods\Resident Evil Weapons\media\lua\ResidentEvilWeapons_Reload

It's just specifically the lines;
 

ammoType = 'Bullets9mm',clipName = '9mm Magazine',clipIcon = 'BerettaClip',clipData = Bullets9mm};

That I can't get to access the vanilla pistol ammo, as you can see there are 3 different names for the clip/ammo. I tried putting in the code for a pistol mag in case it needed it to reference from but even that didn't work

Link to comment
Share on other sites

I'm a bit lost.

The item in your first post is called 'S.T.A.R.S. Pistol', so it's a pistol, right?

So, presumably there is a line in that file that says,

ReloadUtil:addWeaponType(pistolstars)

Because if there isn't, then PZ is going to think it's a magazine and add it to the MagazineType list.

Link to comment
Share on other sites

Yes, it's a pistol, and that line is there at the bottom

I just can't however make it use the vanilla pistol ammo, as im not sure how it's named for ammo type, clip name and clip data.

The game just crashes when you try to reload that gun because it cannot find the ammo type/clip specified

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...