Forum

> > CS2D > Scripts > LFS 4: Anti-suicide/Anti-spawnkill
Forums overviewCS2D overview Scripts overviewLog in to reply

English LFS 4: Anti-suicide/Anti-spawnkill

4 replies
To the start Previous 1 Next To the start

old LFS 4: Anti-suicide/Anti-spawnkill

Ace Howl
User Off Offline

Quote
Hello!
1. How to block command cs2d cmd kill in client's console? It is used to prevent quick Mine planting. Moreover I used class script which one of the menu have Mines equipped.

2. Is it possible to make a spawned player will have a protection for 3 seconds(to prevent spawnkill)? In that period, protected player will neither shoot or being harmed.

Hope that someone solve this problem (and in the future).

old Re: LFS 4: Anti-suicide/Anti-spawnkill

DC
Admin Off Offline

Quote
1. this is not possible. You can track these kills with the hooks cs2d lua hook kill and cs2d lua hook die though. killer and weapon should both be 0 in these cases. However there are probably other cases were both of these values are 0.
You can't block it but you could punish the player for doing it (kick/ban for example).
(btw cs2d lua hook parse as suggested by user Rainoth won't work because it is only executed on the server and not for clients)

2. is in the game already. Well, at least half. You can shoot but you are invulnerable after spawn for a short time (only active in game modes with respawning).
edited 2×, last 09.12.13 03:16:09 pm

old Re: LFS 4: Anti-suicide/Anti-spawnkill

Rainoth
Moderator Off Offline

Quote
1
2
3
4
5
6
7
8
9
10
11
12
13
14
tbl = {}

addhook("hit","nohit")
function nohit(id,sour)
	if tbl[id] == 1 then
		return 1
	end
end

addhook("spawn","eh")
function eh(id)
	tbl[id] = 1
	timer(3200,"parse","lua tbl[id]=0")
end

For the suicide, I'm not sure. Maybe say or parse hook...

old Re: LFS 4: Anti-suicide/Anti-spawnkill

Ace Howl
User Off Offline

Quote
For 1, I will find the solution as I could and thanks user Rainoth for 2 but... it's working. Weird though .
Console has written
LUA ERROR: [string "tbl[id]=0"]:1: table index is nil


Note: I know that the first 1/2 second is protection, I just wanted to extend its invincibility instead killed too quickly.

old Re: LFS 4: Anti-suicide/Anti-spawnkill

VaiN
User Off Offline

Quote
AFAIK you can't call Lua code from the parse() function anymore, or maybe that was just for rCon..
Anyway, I'll expand on user Rainoth's post with another example that might make things more clear:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
invincible = {}
for id=1,32 do invincible[id] = false end

addhook("hit","check_invincibility")
function check_invincibility(id)
	if invincible[id] == true then
		return 1
	end
end

function clear_invincibility(id)
	-- convert id to number
	-- because timer() passes parameters as a string
	id = tonumber(id)
	invincible[id] = false
end

addhook("spawn","make_invincible")
function make_invincible(id)
	invincible[id] = true
	-- clear invincibility in 3 seconds
	timer(3000,"clear_invincibility",id)
end
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview