Forum

> > CS2D > Scripts > 3 seconds on telekill script?
Forums overviewCS2D overview Scripts overviewLog in to reply

English 3 seconds on telekill script?

5 replies
To the start Previous 1 Next To the start

old 3 seconds on telekill script?

francis007
BANNED Off Offline

Quote
Hello everyone!

I have a anti telekill script and i want if a player stay on a teleport more than 3 seconds then the players can kill he without get any punish.

Here is the script:
Spoiler >


I hope anyone can do it. Thanks!

old Re: 3 seconds on telekill script?

Rainoth
Moderator Off Offline

Quote
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
telekill = {}

addhook("join", "_j")
addhook("kill", "_k")
addhook("movetile", "_mt")

function _mt(id,x,y)
	if entity(x,y,"type") == 70 then
		telekill[id] = true
		freetimer("parse","lua telekill["..id.."]=false")
		timer(3000,"parse","lua telekill["..id.."]=false")
		end
end

function _j(p)
	telekill[p] = false
end

function _k(k, v, w, x, y)
	if entity(math.floor(x/32), math.floor(y/32), "type") == 70 then
		local killTileX = math.floor(x/32)
		local killTileY = math.floor(y/32)
		if not ((player(k, "tilex") > killTileX+12) or (player(k, "tilex") < killTileX-12) or (player(k, "tiley") > killTileY+12) or (player(k, "tiley") < killTileY-12)) then
			--telekill[k] = telekill[k] + 1
			if telekill[v] then
				parse("killplayer "..k)
			end
			msg("\169255048048"..player(k, "name").." has been punished for tele-camping.")
		end
	end
end

Did not understand why you needed line 23 so I left it. I might have screwed up with the timers since I haven't used them for a long time and didn't bother to look up. Anyways, the concept is simple:
When a player steps on teleport entity he will me marked as "teleport kill victim" and after 3000 miliseconds he will be unmarked (notice the slight change from "if telekill[k]" into "if telekill[v]"

I am not aware if integers work that way in lua but if you write
"if something then" it checks if the variable exists or if it's true/false
Since you had it set to 0, it would work everytime so I changed it into true/false

old Re: 3 seconds on telekill script?

Cure Pikachu
User Off Offline

Quote
1
2
3
4
5
6
7
8
9
10
11
12
13
function _k(k,v,w,x,y)
	local killTileX, killTileY = math.floor(x/32), math.floor(y/32)
	if entity(killTileX,killTileY,"type") == 70 then
		if (player(k,"tilex") >= killTileX-12 and player(k,"tilex") <= killTileX+12 and player(k,"tiley") >= killTileY-12 and player(k,"tiley") <= killTileY+12) then
		-- if not ((player(k,"tilex") > killTileX+12) or (player(k,"tilex") < killTileX-12) or (player(k,"tiley") > killTileY+12) or (player(k,"tiley") < killTileY-12)) then
			-- telekill[k] = telekill[k] + 1
			if telekill[v] then
				parse("killplayer "..k)
				msg("\169255048048"..player(k, "name").." has been punished for tele-camping.")
			end
		end
	end
end
Fixed this function. But what about players standing on the destination of a one-way teleport?
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview