Using a trigger to get ammo 0

Tutorials for Call of Duty 4 mapping

Moderator: Core Staff

User avatar
Oi!mel
CJ Fan
CJ Fan
Posts: 132
Joined: January 17th, 2010, 9:26 pm
Location: Germany/Bavaria
Contact:

Using a trigger to get ammo 0

Post by Oi!mel » March 29th, 2010, 12:12 pm

Hello all.
At the moment am working on my new map. Its not a jump map.
My problem is, I wanna make a part in the map, where you only can use knife, so I want to set ammo to 0 on primary and secondary weapon. The things I tried did not work. I hope someone can help me here.

Code: Select all

ammotouch()
{
noammo = getentarray( "noammo", "targetname" );
for( lp=0; lp < noammo.size; lp++ )
noammo[lp] thread knifeonly();
}

knifeonly()
{
while(1)
{
self waittill( "trigger", other );
other setweaponslotammo("primary", 0);

}
}
It says "unknown command other setweaponslotammo("primary", 0);"

So.. what is wrong? Or how I can get it working?
Thanks
Oi!mel
Image Image Image

User avatar
Drofder2004
Core Staff
Core Staff
Posts: 13316
Joined: April 13th, 2005, 8:22 pm
Location: UK, London

Re: Using a trigger to get ammo 0

Post by Drofder2004 » March 29th, 2010, 1:57 pm

setweaponammoclip(<gun>, <#>)
setweaponammostock


clip - whats currently in the gun.
stock - what is left to reload.

<gun> is the name of the gun, i.e. "m16"
<#> is count.
Image
Virgin Media 20Mb Broadband:
"Perfect for families going online at the same time, downloading movies, online gaming and more."
Borked internet since: 22-07-2010

User avatar
Oi!mel
CJ Fan
CJ Fan
Posts: 132
Joined: January 17th, 2010, 9:26 pm
Location: Germany/Bavaria
Contact:

Re: Using a trigger to get ammo 0

Post by Oi!mel » March 29th, 2010, 2:43 pm

Thanks so far =).
With setweaponammostock it says bad syntax, without it says:
Image



hmm.. do you know what to do now?
Image Image Image

User avatar
Drofder2004
Core Staff
Core Staff
Posts: 13316
Joined: April 13th, 2005, 8:22 pm
Location: UK, London

Re: Using a trigger to get ammo 0

Post by Drofder2004 » March 29th, 2010, 7:21 pm

" "

m16 should be enclosed as a string, not an object.

other setweaponammostock("m16", 0);
Image
Virgin Media 20Mb Broadband:
"Perfect for families going online at the same time, downloading movies, online gaming and more."
Borked internet since: 22-07-2010

User avatar
Oi!mel
CJ Fan
CJ Fan
Posts: 132
Joined: January 17th, 2010, 9:26 pm
Location: Germany/Bavaria
Contact:

Re: Using a trigger to get ammo 0

Post by Oi!mel » March 29th, 2010, 10:34 pm

hmm. So when I touch the trigger nothing is happening.

This is my actuall script:

Code: Select all

ammotouch()
{
noammo = getentarray( "noammo", "targetname" );
for( lp=0; lp < noammo.size; lp++ )
noammo[lp] thread knifeonly();
}

knifeonly()
{
while(1)
{
self waittill( "trigger", other );
setweaponammoclip("m16", 0);
setweaponammostock("m16", 0);


}
}
Image Image Image

User avatar
Oi!mel
CJ Fan
CJ Fan
Posts: 132
Joined: January 17th, 2010, 9:26 pm
Location: Germany/Bavaria
Contact:

Re: Using a trigger to get ammo 0

Post by Oi!mel » March 29th, 2010, 10:35 pm

We don't have to do it this way. Is there another way to get knife only?
Image Image Image

User avatar
Drofder2004
Core Staff
Core Staff
Posts: 13316
Joined: April 13th, 2005, 8:22 pm
Location: UK, London

Re: Using a trigger to get ammo 0

Post by Drofder2004 » March 30th, 2010, 4:21 am

Code: Select all

self waittill( "trigger", other );
other setweaponammoclip("m16", 0);
other setweaponammostock("m16", 0);
Image
Virgin Media 20Mb Broadband:
"Perfect for families going online at the same time, downloading movies, online gaming and more."
Borked internet since: 22-07-2010

User avatar
Oi!mel
CJ Fan
CJ Fan
Posts: 132
Joined: January 17th, 2010, 9:26 pm
Location: Germany/Bavaria
Contact:

Re: Using a trigger to get ammo 0

Post by Oi!mel » March 30th, 2010, 11:32 am

Thanks for you help, but I don't understand this here. Isn't that whats in my script actually?
Image Image Image

User avatar
Drofder2004
Core Staff
Core Staff
Posts: 13316
Joined: April 13th, 2005, 8:22 pm
Location: UK, London

Re: Using a trigger to get ammo 0

Post by Drofder2004 » March 30th, 2010, 1:18 pm

No.

You forgot the 'other'

Your script has not got a defined entity to call the functions on, so you are simply calling the function on the level itself. And obviosuly the level doesn't have a gun...

Review your "knifeonly" function, you will notice the difference between my last post and your code.
Image
Virgin Media 20Mb Broadband:
"Perfect for families going online at the same time, downloading movies, online gaming and more."
Borked internet since: 22-07-2010

User avatar
Oi!mel
CJ Fan
CJ Fan
Posts: 132
Joined: January 17th, 2010, 9:26 pm
Location: Germany/Bavaria
Contact:

Re: Using a trigger to get ammo 0

Post by Oi!mel » March 30th, 2010, 2:08 pm

hu? In my script there is the 'other'. Nothing happens when I touch the trigger. Just to test I've used SetMoveSpeedScale( 0.1 ); and it worked. But the ammo doesn't change while touching the trigger.
Image Image Image

User avatar
Drofder2004
Core Staff
Core Staff
Posts: 13316
Joined: April 13th, 2005, 8:22 pm
Location: UK, London

Re: Using a trigger to get ammo 0

Post by Drofder2004 » March 30th, 2010, 2:24 pm

Oi!mel wrote:ammotouch()
{
noammo = getentarray( "noammo", "targetname" );
for( lp=0; lp < noammo.size; lp++ )
noammo[lp] thread knifeonly();
}

knifeonly()
{
while(1)
{
self waittill( "trigger", other );
setweaponammoclip("m16", 0);
setweaponammostock("m16", 0);



}
}

You NEED "other" infront of these two (see bold in quote)

If you do not declare an entity for the thread to be called on, then the game defaults to the 'level' entity.
So, you are currently removing ammo from the guns of a non-playing entity.

Also, are you actually using the m16 gun? This will not remove the ammo from the primary gun, but only the 'm16' if the player is carrying it...
Image
Virgin Media 20Mb Broadband:
"Perfect for families going online at the same time, downloading movies, online gaming and more."
Borked internet since: 22-07-2010

User avatar
Oi!mel
CJ Fan
CJ Fan
Posts: 132
Joined: January 17th, 2010, 9:26 pm
Location: Germany/Bavaria
Contact:

Re: Using a trigger to get ammo 0

Post by Oi!mel » March 30th, 2010, 2:55 pm

sorry if im writing not clearly, my english is bad.
I ment that I got the 'others' in the script how you wrote it here.

Code: Select all

knifeonly()
{
	while(1)
	{
		self waittill( "trigger", other );
		other setweaponammoclip("m16", 0);
		other setweaponammostock("m16", 0);
	}
}
Also, are you actually using the m16 gun? This will not remove the ammo from the primary gun, but only the 'm16' if the player is carrying it...
How can i get the primary gun? other setweaponammoclip("primary", 0);?
When im using the m16 my ammo is normal... not 0.

Thanks for your help so far.
Image Image Image

User avatar
Drofder2004
Core Staff
Core Staff
Posts: 13316
Joined: April 13th, 2005, 8:22 pm
Location: UK, London

Re: Using a trigger to get ammo 0

Post by Drofder2004 » March 30th, 2010, 5:50 pm

sorry, you need to add _mp

so, m16_mp.

---

To simplify things, you could just take all their weapons away?
Image
Virgin Media 20Mb Broadband:
"Perfect for families going online at the same time, downloading movies, online gaming and more."
Borked internet since: 22-07-2010

User avatar
Oi!mel
CJ Fan
CJ Fan
Posts: 132
Joined: January 17th, 2010, 9:26 pm
Location: Germany/Bavaria
Contact:

Re: Using a trigger to get ammo 0

Post by Oi!mel » March 30th, 2010, 6:07 pm

Hey, thanks. Now I get ammo 0. But one problem stays. The shots in the current magazine are still there. So you can shot 30 times befor its knife only. hmm. Do you know how to fix it?
Image Image Image

User avatar
Drofder2004
Core Staff
Core Staff
Posts: 13316
Joined: April 13th, 2005, 8:22 pm
Location: UK, London

Re: Using a trigger to get ammo 0

Post by Drofder2004 » March 30th, 2010, 10:24 pm

Oi!mel wrote:Hey, thanks. Now I get ammo 0. But one problem stays. The shots in the current magazine are still there. So you can shot 30 times befor its knife only. hmm. Do you know how to fix it?
Yo uset them both to m16_mp?

ammoclip should remove the contents of the clip :S
Image
Virgin Media 20Mb Broadband:
"Perfect for families going online at the same time, downloading movies, online gaming and more."
Borked internet since: 22-07-2010

Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests