Page 1 of 1

weapons with unlimited ammo

Posted: May 5th, 2011, 3:50 pm
by steveuk
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?

Re: weapons with unlimited ammo

Posted: May 5th, 2011, 4:32 pm
by rB|Liam*
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. :)

Re: weapons with unlimited ammo

Posted: May 5th, 2011, 5:13 pm
by steveuk
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

Re: weapons with unlimited ammo

Posted: May 5th, 2011, 5:49 pm
by <LT>YosemiteSam[NL]
To my knowledge the only way of doing that is to change the weapon files.
It's very easy .. give it a try.

Re: weapons with unlimited ammo

Posted: May 5th, 2011, 6:54 pm
by Stealth
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.

Re: weapons with unlimited ammo

Posted: May 5th, 2011, 10:49 pm
by Lawless
Stealth wrote:it works nicely for me.
Ohh thats good.
Stealth wrote:however i havnt tested it, i just quickly coded it.
Lol nevermind =/

Re: weapons with unlimited ammo

Posted: May 5th, 2011, 11:35 pm
by Qauntumz
^

Re: weapons with unlimited ammo

Posted: May 6th, 2011, 10:18 am
by IzNoGoD
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.

Re: weapons with unlimited ammo

Posted: May 6th, 2011, 1:20 pm
by steveuk
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?

Re: weapons with unlimited ammo

Posted: May 6th, 2011, 1:24 pm
by steveuk
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 );