Page 1 of 2

Using a trigger to get ammo 0

Posted: March 29th, 2010, 12:12 pm
by Oi!mel
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

Re: Using a trigger to get ammo 0

Posted: March 29th, 2010, 1:57 pm
by Drofder2004
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.

Re: Using a trigger to get ammo 0

Posted: March 29th, 2010, 2:43 pm
by Oi!mel
Thanks so far =).
With setweaponammostock it says bad syntax, without it says:
Image



hmm.. do you know what to do now?

Re: Using a trigger to get ammo 0

Posted: March 29th, 2010, 7:21 pm
by Drofder2004
" "

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

other setweaponammostock("m16", 0);

Re: Using a trigger to get ammo 0

Posted: March 29th, 2010, 10:34 pm
by Oi!mel
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);


}
}

Re: Using a trigger to get ammo 0

Posted: March 29th, 2010, 10:35 pm
by Oi!mel
We don't have to do it this way. Is there another way to get knife only?

Re: Using a trigger to get ammo 0

Posted: March 30th, 2010, 4:21 am
by Drofder2004

Code: Select all

self waittill( "trigger", other );
other setweaponammoclip("m16", 0);
other setweaponammostock("m16", 0);

Re: Using a trigger to get ammo 0

Posted: March 30th, 2010, 11:32 am
by Oi!mel
Thanks for you help, but I don't understand this here. Isn't that whats in my script actually?

Re: Using a trigger to get ammo 0

Posted: March 30th, 2010, 1:18 pm
by Drofder2004
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.

Re: Using a trigger to get ammo 0

Posted: March 30th, 2010, 2:08 pm
by Oi!mel
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.

Re: Using a trigger to get ammo 0

Posted: March 30th, 2010, 2:24 pm
by Drofder2004
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...

Re: Using a trigger to get ammo 0

Posted: March 30th, 2010, 2:55 pm
by Oi!mel
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.

Re: Using a trigger to get ammo 0

Posted: March 30th, 2010, 5:50 pm
by Drofder2004
sorry, you need to add _mp

so, m16_mp.

---

To simplify things, you could just take all their weapons away?

Re: Using a trigger to get ammo 0

Posted: March 30th, 2010, 6:07 pm
by Oi!mel
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?

Re: Using a trigger to get ammo 0

Posted: March 30th, 2010, 10:24 pm
by Drofder2004
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