Forum

> > CS2D > Scripts > no knife in each respawn
Forums overviewCS2D overview Scripts overviewLog in to reply

English no knife in each respawn

8 replies
To the start Previous 1 Next To the start

old no knife in each respawn

Help Needer
User Off Offline

Quote
hi there

i just need a script that disables the knife in each respawn
because i am using the classes script and i dont want knife to be added in the classes' iteams

can someone help me ?
thanks in advance ...

old Re: no knife in each respawn

D-D3ADxPro
User Off Offline

Quote
1
parse("strip "..id.." 50")

You can't really add a spawn hook to this code because it doesn't work. You need to have a primary weapon before stripping or else the game will crash.

EDIT: Can you give us the whole class script?

old Re: no knife in each respawn

Avo
User Off Offline

Quote
No problemo:

1
2
3
4
addhook("spawn","OnSpawn")
OnSpawn = function(id)
	timer(100, "parse", "strip "..id.." 50")
end

You can't simply strip knife in spawn hook function, because while function of the spawn hook is called, player "is spawning", so he doesn't have any weapon. After execution of this function player gets spawn weapons (usp/glock, knife), so we need to strip knife after very short period of time. That's why you have to use timer function. √

old Re: no knife in each respawn

Patron14
User Off Offline

Quote
in spawn, if each player gets a primary weapon or a pistol,
you can remove knife becose the player have other weapons

old Re: no knife in each respawn

Avo
User Off Offline

Quote
user Patron14 has written
in spawn, if each player gets a primary weapon or a pistol,
you can remove knife becose the player have other weapons
After spawn.

old Re: no knife in each respawn

EngiN33R
Moderator Off Offline

Quote
user D-D3ADxPro has written
You need to have a primary weapon before stripping or else the game will crash.

It's not that dramatic, but if you try to strip the knife and the player has no other weapon except for the knife it just won't work.

However, there is a way to strip the knife and leave the player with no weapons. You need to spawn the player using cs2d cmd spawnplayer in the same moment they die.

This code works and strips all weapons, including the knife, from the player when they press F2:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
addhook("serveraction","stripall")
function stripall(id,a)
	if (a==1) then
		local x,y = player(id,"x"), player(id,"y")
		
		stripknife = function(ply)
			if (ply==id) then
				parse("spawnplayer "..id.." "..x.." "..y)
				freehook("die","stripknife")
				stripknife = nil
			end
		end
		addhook("die","stripknife")
		parse("killplayer "..id)
	end
end

As you can see the code is pretty hacky and it's not very optimized. cs2d cmd spawnplayer directly after cs2d cmd killplayer doesn't work, whereas this does for some reason. I'd really like for stripping the knife and leaving the player with no weapons to be legal.
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview