edited 1×, last 31.05.25 03:58:13 am
Forum




Jail Script for Roleplay
9 replies



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
37
38
39
40
41
42
43
44
45
46
47
48
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
37
38
39
40
41
42
43
44
45
46
47
48
function string.split(str,pat) local t = {} for word in string.gmatch(str,pat or "[^%s]+") do t[#t+1] = word end return t end jail = { x = 30, y = 50, adm = 15476 } addhook("join","_j") function _j(id) 	jail[id] = {} 	jail[id].jailed = false 	jail[id].pos = {} end addhook("say","_s") function _s(id,txt) 	local say = txt:split() 	local ply = tonumber(say[2]) 	if say[1] == "!jail" then 		if player(id,"usgn") == jail.adm then 			jail[ply].pos.x = player(ply,"x") 			jail[ply].pos.y = player(ply,"y") 			parse("setpos "..ply.." "..jail.x*32+16 .." "..jail.y*32+16) 			timer(tonumber(say[3]),"parse","setpos "..ply.." "..jail[ply].pos.x.." "..jail[ply].pos.y) 			timer(tonumber(say[3],"parse","lua jail["..ply.."].jailed=false") 			jail[id].jailed = true 			return 1 		end 	elseif say[1] == "!unjail" then 		if player(id,"usgn") == jail.adm then 			if jail[ply].jailed then 				jail[ply].jailed = false 				parse("setpos "..ply.." "..jail[ply].pos.x.." "..jail[ply].pos.y) 			end 		end 		return 1 	end 	if jail[id].jailed then 		msg2(id,"Imagine this is bold text -> You can't talk in jail!") 		return 1 	end end
A lot of writing and I feel fairly sleepy so I'll give you a base. The rest is more or less copy pasting. You can do it. All you need to do is to find a string.split function somewhere (they're nearly in every script) and put it in your code. I can't be bothered to dig my dropbox until I find that function but if you can wait till morning, I'll probably update my code later.
// See if that's satisfactory for you.
/// Fixed a bit. Timer should work unless something was changed in latest CS2D version (which I highly doubt).
edited 5×, last 18.10.15 11:09:26 pm
edited 2×, last 31.05.25 03:58:01 am
edited 2×, last 18.05.16 06:31:47 am
Admin/mod comment

edited 1×, last 31.05.25 03:57:46 am
edited 1×, last 31.05.25 03:57:39 am
I change string to number the same way for time like the player ID.
Unless you wrote something like
"!jail 2" it should work.
Try writing
"!jail 1 15000" when you're ID 1 and in any team (and alive of course). It should teleport you properly and bring you back 15 seconds later.
edited 1×, last 31.05.25 03:57:29 am



