weapons with unlimited ammo

Have questions about CoD4 mapping that aren't covered in the tutorials section? Post here!

Moderator: Core Staff

Post Reply
steveuk
CJ G0D!
CJ G0D!
Posts: 1330
Joined: November 21st, 2006, 12:51 pm

weapons with unlimited ammo

Post by steveuk » May 5th, 2011, 3:50 pm

how can i place a weapon with unlimited ammo, in my jump map i am placing weapons in secret locations, but though i can add the weapon without any problems, when you pick up the weapon,it only has a few rounds in it weapon clip, so how do i make it have unlimited ammo in each weapon.? do i need to build a weapon mod.?? hope not as im no good at scripting?

rB|Liam*
CJ Fan
CJ Fan
Posts: 172
Joined: October 21st, 2010, 7:45 pm
Location: England
Contact:

Re: weapons with unlimited ammo

Post by rB|Liam* » May 5th, 2011, 4:32 pm

im not sure unlimited ammo is possible, but all i do is place the weapon where i want it and copy and paste quite a few times then when u pick up the weapon it will also pick up ammo from the copied and pasted weapons. :)

steveuk
CJ G0D!
CJ G0D!
Posts: 1330
Joined: November 21st, 2006, 12:51 pm

Re: weapons with unlimited ammo

Post by steveuk » May 5th, 2011, 5:13 pm

xrgz wrote:im not sure unlimited ammo is possible, but all i do is place the weapon where i want it and copy and paste quite a few times then when u pick up the weapon it will also pick up ammo from the copied and pasted weapons. :)
thats what im using right now, but been on maps where you pick up 1 weapon and it full,unlimited ammo.? thats what i want, save keep placing 50 weapons ect all over the map.lol

User avatar
<LT>YosemiteSam[NL]
Core Staff
Core Staff
Posts: 2155
Joined: December 7th, 2004, 2:07 am
Location: Netherlands
Contact:

Re: weapons with unlimited ammo

Post by <LT>YosemiteSam[NL] » May 5th, 2011, 5:49 pm

To my knowledge the only way of doing that is to change the weapon files.
It's very easy .. give it a try.

Stealth
CJ Wannabe
CJ Wannabe
Posts: 9
Joined: March 17th, 2010, 12:20 am

Re: weapons with unlimited ammo

Post by Stealth » May 5th, 2011, 6:54 pm

its possable to pick up any weapon, and run a script on that weapon to give it unlimited ammo. you can do this with a trigger or menu activated. what the code does is waits for the weapon to be fired and then resets your ammo to max again ---> infinite ammo. it works nicely for me

Code: Select all

infinite_ammo()
{
player.nolimit = undefined
trigger = getent("ammo_trigger", "targetname");
while(1)
	{
	trigger waittill("trigger", player);
		{
		if(!isdefined( player.nolimit ))
		{
		player.nolimit = true;
		//threaded
		player thread infinite_ammo_threaded();
		player iprintlnbold("Infinite ammo ^2ON");
		}
		
		else if(isdefined( player.nolimit ))
		{
		player.nolimit = undefined;
		player iprintlnbold("Infinite ammo ^1OFF");
		}
		}
	}
}
infinite_ammo_threaded()
{
while(isdefined( self.nolimit ))
	{
	self waittill( "weapon_fired" );
	currentweapon = self GetCurrentWeapon();
	wait 0.0001;
	self SetWeaponAmmoClip( (currentweapon), 30 );
	self SetWeaponAmmoStock( (currentweapon), 300 );
	}
}	
just simply place a trigger with a targetname "ammo_trigger" and thread this code in your gsc and your done

however i havnt tested it, i just quickly coded it.

Lawless
CJ Fan
CJ Fan
Posts: 110
Joined: January 25th, 2011, 7:11 pm
Gamertag: x STRAF3Zz v2

Re: weapons with unlimited ammo

Post by Lawless » May 5th, 2011, 10:49 pm

Stealth wrote:it works nicely for me.
Ohh thats good.
Stealth wrote:however i havnt tested it, i just quickly coded it.
Lol nevermind =/
Join my server @ 217.163.22.223:28960

Qauntumz
CJ Newbie
CJ Newbie
Posts: 90
Joined: January 27th, 2011, 4:27 pm
Gamertag: QuaNnTuM HD
Location: Sacramento, CA

Re: weapons with unlimited ammo

Post by Qauntumz » May 5th, 2011, 11:35 pm

^

IzNoGoD
CJ Worshipper
CJ Worshipper
Posts: 343
Joined: January 6th, 2009, 8:39 pm
Location: Netherlands/Holland

Re: weapons with unlimited ammo

Post by IzNoGoD » May 6th, 2011, 10:18 am

Stealth wrote:

Code: Select all

player.nolimit = undefined

Code: Select all

	wait 0.0001;
	self SetWeaponAmmoClip( (currentweapon), 30 );
	self SetWeaponAmmoStock( (currentweapon), 300 );
1. that first line is bad in 2 ways: player is undefined, and you dont end the line with a ; You can basically remove the line, and have the same effect, as the var is not defined when a player connects. Maybe you should set it to undefined too when a player spawns.

2. The wait is way too short, but it would work. The sv_fps is 20, thus the minimal waitingtime is 0.05 (1/20) seconds. Using anything smaller than that will result in a 0.05 second waittime. Even so when you use wait 0.06, it will wait 0.10 seconds.

3. You can easily set the weapon(clip) ammo to 999, as cod will auto limit the number of bullets in a gun, and then the amount of ammo will be maxed.

4. Add a self endon disconnect to the player thread, as it should stop running when a player disconnects.
LMGTFY!

Its not a glitch... Its the future!

steveuk
CJ G0D!
CJ G0D!
Posts: 1330
Joined: November 21st, 2006, 12:51 pm

Re: weapons with unlimited ammo

Post by steveuk » May 6th, 2011, 1:20 pm

Stealth wrote:its possable to pick up any weapon, and run a script on that weapon to give it unlimited ammo. you can do this with a trigger or menu activated. what the code does is waits for the weapon to be fired and then resets your ammo to max again ---> infinite ammo. it works nicely for me

Code: Select all

infinite_ammo()
{
player.nolimit = undefined
trigger = getent("ammo_trigger", "targetname");
while(1)
	{
	trigger waittill("trigger", player);
		{
		if(!isdefined( player.nolimit ))
		{
		player.nolimit = true;
		//threaded
		player thread infinite_ammo_threaded();
		player iprintlnbold("Infinite ammo ^2ON");
		}
		
		else if(isdefined( player.nolimit ))
		{
		player.nolimit = undefined;
		player iprintlnbold("Infinite ammo ^1OFF");
		}
		}
	}
}
infinite_ammo_threaded()
{
while(isdefined( self.nolimit ))
	{
	self waittill( "weapon_fired" );
	currentweapon = self GetCurrentWeapon();
	wait 0.0001;
	self SetWeaponAmmoClip( (currentweapon), 30 );
	self SetWeaponAmmoStock( (currentweapon), 300 );
	}
}	
just simply place a trigger with a targetname "ammo_trigger" and thread this code in your gsc and your done

however i havnt tested it, i just quickly coded it.


SORRY, DONT WORK, and messed up my map again, more repair work?

steveuk
CJ G0D!
CJ G0D!
Posts: 1330
Joined: November 21st, 2006, 12:51 pm

Re: weapons with unlimited ammo

Post by steveuk » May 6th, 2011, 1:24 pm

IzNoGoD wrote:
Stealth wrote:

Code: Select all

player.nolimit = undefined

Code: Select all

	wait 0.0001;
	self SetWeaponAmmoClip( (currentweapon), 30 );
	self SetWeaponAmmoStock( (currentweapon), 300 );
1. that first line is bad in 2 ways: player is undefined, and you dont end the line with a ; You can basically remove the line, and have the same effect, as the var is not defined when a player connects. Maybe you should set it to undefined too when a player spawns.

2. The wait is way too short, but it would work. The sv_fps is 20, thus the minimal waitingtime is 0.05 (1/20) seconds. Using anything smaller than that will result in a 0.05 second waittime. Even so when you use wait 0.06, it will wait 0.10 seconds.

3. You can easily set the weapon(clip) ammo to 999, as cod will auto limit the number of bullets in a gun, and then the amount of ammo will be maxed.

4. Add a self endon disconnect to the player thread, as it should stop running when a player disconnects.

is this all i need? and do i put it in m main gsc file..??

player.nolimit = undefined
wait 0.0001;
self SetWeaponAmmoClip( (currentweapon), 30 );
self SetWeaponAmmoStock( (currentweapon), 300 );


Post Reply

Who is online

Users browsing this forum: No registered users and 6 guests