Forum

> > CS2D > Scripts > Command "setammo" not working
Forums overviewCS2D overview Scripts overviewLog in to reply

English Command "setammo" not working

8 replies
To the start Previous 1 Next To the start

old Command "setammo" not working

Bogey
User Off Offline

Quote
Hello, as topic says I wanted to use command "setammo" which is shown in the command reference at page

http://cs2d.com/help.php?cat=all&cmd=setammo#cmd

The command though, appears to not work and also cant be found in cs2d console. Is there anything I can do about it?

If not then is there any way to prevent player from shooting? I thought about this command but as it doesnt work then what can I use? I would prefer to not use "strip".

old Re: Command "setammo" not working

Inflexion
User Off Offline

Quote
No. To prevent a few players from shooting. That says and answer Lua work.
Well. Setammo command is bugged a bit. Just follow my steps.

1/ Re-start CS2D
2/ Re-install CS2D.

If this two suggestions did nothing to fix it. Means , that's it's from the computer that you use.

old Re: Command "setammo" not working

Bogey
User Off Offline

Quote
My bad, I was used to wrapper functions and tried to use "setammo" command the same way. I couldn't also find this command in console and wrapper file so I thought that it's removed but it is working now.


It is still not this what I want though. My idea is to prevent player from shooting when a certain condition is met. Statement is all working but there is no way to prevent player from shooting. I thought about removing ammo from weapon but then "attack" hook isn't detecting any press.

So do you have some ideas to accomplish it?

old Re: Command "setammo" not working

MikuAuahDark
User Off Offline

Quote
Wraper function for setammo(my verson)

1
2
3
4
5
6
function setammo(id,w,ain,a)
	if id==0 and w==0 then error("id is 0 and weapon type is 0") end
	ain=ain or 1000
	a=a or 1000
	parse("setammo "..id.." "..w.." "..ain.." "..a)
end
set ain, a to nil is equal to 1000

bdw cs2d lua hook attack is triggered after player is shooting.

So the solution is to remove the ammo before player press attack.

old Re: Command "setammo" not working

Bogey
User Off Offline

Quote
I should have added that I must also detect left mouse button click. So removing ammo isnt solution because it doesnt active "attack" hook

old Re: Command "setammo" not working

MikuAuahDark
User Off Offline

Quote
Then you can't do that(unless you write some DLL that trigger function before hook attack and inject them into cs2d dedicated which is forbidden!).

The only dirty solution is to remove player weapon ammo when condition is met and set them back when the condition is not met.

old Re: Command "setammo" not working

MikuAuahDark
User Off Offline

Quote
Ok, the cs2d cmd setammo is fully working. But you put it at cs2d lua hook attack which triggered after player attack(left click)

Example code below.
1
2
3
4
5
6
-- Player has 30 ammo in(before hook attack).
addhook("attack","setammo_test")
function setammo_test(id)
	-- In here, player already have 29 ammo in. That means player already firing it's weapon
	parse("setammo "..id.." "..player(id,"weapon").." 0 0")		-- You're late.
end

That's it. That's NOT possible(unless maybe user DC add hook that trigger before player press attack)

Try to use cs2d lua hook always instead(but it would cause slowdown if your code is not fast enough), and of course cs2d lua hook attack won't triggered while player ammo in is 0.
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview