Forum

> > CS2D > Scripts > Jail Script for Roleplay
Forums overviewCS2D overview Scripts overviewLog in to reply

English Jail Script for Roleplay

9 replies
To the start Previous 1 Next To the start

old Jail Script for Roleplay

SeanHoca
User Off Offline

Quote
Hey US.de us !

I need a Jail Script for my Roleplay project.
What I want is Timed Jail System w/ multiple jails and mute system

Examples;

Jail Command(s) >

Mute System >


THANKS!

EDIT: Before someone even say, I found nothing from searching.

old Re: Jail Script for Roleplay

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
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

old Re: Jail Script for Roleplay

SeanHoca
User Off Offline

Quote
Well...

It worked fine but when someone is in jail, he can talk normally.
I looked at the console and there is the same error like the admin script one.
thread cs2d Error in Admin Script [Timer]

EDIT: Seems like unjail is not working too, and if someone just teamchange, it just spawns you back in spawn.

old Re: Jail Script for Roleplay

Rainoth
Moderator Off Offline

Quote
That's not possible.
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.

old Re: Jail Script for Roleplay

Rainoth
Moderator Off Offline

Quote
That's because you did not define something like that to happen so I didn't code it. I find it increasingly bigger with every single detail so I won't code everything. You'll have to wait or to get someone else to complete it.
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview