Forum

> > CS2D > Scripts > Jail teleporter script
Forums overviewCS2D overview Scripts overviewLog in to reply

English Jail teleporter script

19 replies
To the start Previous 1 Next To the start

old Jail teleporter script

_-098-
GAME BANNED Off Offline

Quote
Is there a lua script where when u shoot someone with a specific gun, u teleport the one shot at, to a specific place?(in my case, a ct gun that ct can use to teleport ts criminals to a specific location, like a jail)

old Re: Jail teleporter script

Talented Doge
User Off Offline

Quote
I'd love to do it.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
weaponhit = 4
teleport_hit_damage = false

position = {
{86, 75};
}

addhook("hit", "_hit")

function _hit(v, s, w)
	if player(s, "team") == 2 and player(v, "team") == 1 and w == weaponhit then
		local randomnum = math.random (1, #position)
		local x = position[randomnum][1] *32+16
		local y = position[randomnum][2] *32+16
		parse ("setpos "..v.." "..x.." "..y)
		if teleport_hit_damage then return 0 else return 1 end
	end
end

How the code works:
Every time you hit a terrorist with p228 when you are a counter-terrorist, the script will find a random place from the table called position and teleport the terrorist to that place. If teleport_hit_damage is true then the hit deals damage, otherwise it will not deal any damage to the teleported terrorist.

∗ Make sure you add
1
;
after each bracket.

old Re: Jail teleporter script

Mora
User Off Offline

Quote
Will be hard with phone
1
2
3
4
5
6
7
8
9
10
11
xjail = 1
yjail = 1

addhook("hit","huit")
function huit(id,s,x,y)
 local wpn = player(id,"weapontype")
  if wpn==6 then
parse("setpos "..id.." "..xjail*32-16 .." "..yjail*32-16)
  return 1
  end
end
Replace these xjail ans yjail to your x and y,
Change 6 number to your weapon id
hope there is no errors
/oh i was too slow.
edited 1×, last 30.05.15 07:14:27 pm

old Re: Jail teleporter script

Rainoth
Moderator Off Offline

Quote
@user Mora: Of course it works. Is it good? No.
That's what user Talented Doge is concerned about. You place a player and then move him to the center of tile BEFORE it.

For example, the way user Talented Doge, the person would be put to the middle of tile 86|75 whereas you write position as 1|1 but the player is actually placed to 0|0. In most cases it's not a problem but it can lead to confusion (or even getting stuck in a wall) so writing +16 is better than -16

old Re: Jail teleporter script

Talented Doge
User Off Offline

Quote
If you use *32-16, you will probably encounter strange errors like this

IMG:https://i.imgbox.com/88byHPfv.png


----------------
Edited a bit, now players can disable the teleport function by himself.

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
32
33
34
35
36
use = {}

weaponhit = 4
teleport_hit_damage = false

position = {
{86, 75};
}

addhook("hit", "_hit")
addhook("join", "_join")
addhook("serveraction", "_sva")

function _hit(v, s, w)
     if player(s, "team") == 2 and player(v, "team") == 1 and w == weaponhit and use[s] then
          local randomnum = math.random (1, #position)
          local x = position[randomnum][1] *32+16
          local y = position[randomnum][2] *32+16
          parse ("setpos "..v.." "..x.." "..y)
          if teleport_hit_damage then return 0 else return 1 end
     end
end

function _sva(p, b)
	if b == 1 and use[p] and player(p, "team") == 2 then
		use[p] = false
		msg2(p, "Teleport gun off!")
	elseif b == 1 and player(p, "team") == 2 then
		use[p] = true
		msg2(p, "Teleport gun on!")
	end
end

function _join(p)
	use[p] = true
end

old Re: Jail teleporter script

J192
User Off Offline

Quote
A small question, what's the point of playing on the server if people will just teleport you around and prevent you from actually enjoying the game?

old Re: Jail teleporter script

Mora
User Off Offline

Quote
@J192 maybe there will be a rp game with police that may got money or something for punish killers, stealers or whatever..
And will be better if here will be timer, i dont remember but Rainoth or someone else helped me with the same problem.

old Re: Jail teleporter script

_-098-
GAME BANNED Off Offline

Quote
wow, thanks!
everyone is so supportive and helpful!
thank you!
very much appreciated!
---
oh and i furgot!
if you still can:
i actually needed it to be a glock that has the 2 functions-
func 1: teleport to x;y
func 2: stun/freeze (speedmod- 0)
--
if u still can!
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview