Forum

> > CS2D > Scripts > Lua, -Spectator Lock
Forums overviewCS2D overview Scripts overviewLog in to reply

English Lua, -Spectator Lock

8 replies
To the start Previous 1 Next To the start

old Lua, -Spectator Lock

Cirium
User Off Offline

Quote
I was wondering if someone here could help me, ive been looking for A spectator lock script, tried making one and it seems impossible to me.

I'm not to much looking for a script, that I can lock someone In Game, but a script / that would act as a bit of a replacement for a "BAN" .

maybe sorta like a part of the script, that you could maybe add the USGN's to.

--Example--

--
Speclock = {1234,4567.7890}
--

could someone please help me.
edited 1×, last 26.03.12 03:43:03 am

old Re: Lua, -Spectator Lock

EngiN33R
Moderator Off Offline

Quote
You Really Don't Have To Write Everything From Capital Letters.

What do you mean "lock"? You mean they can only be spectators and can't join any other team?

old Re: Lua, -Spectator Lock

EngiN33R
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
function initArray2(f,v)
	local cmd={}
	for c=1,f do
		cmd[c]=v
	end
	return cmd
end

isLockedInSpec=initArray2(32,false)
admin=1 -- YOUR USGN ID

addhook("say","SpecLock")
function SpecLock(id,t)
	if (player(id,"usgn")==admin and t:sub(1,5)=="!lock") then
		local lockedID=tonumber(t:sub(6))
		if (lockedID>0 and lockedID<=32 and player(lockedID,"exists")) then
			isLockedInSpec[lockedID]=true
			msg(player(id,"name").." has locked "..player(lockedID,"name").." in spectators!")
		end
	end
	if (player(id,"usgn")==admin and t:sub(1,7)=="!unlock") then
		local unlockID=tonumber(t:sub(8))
		if (unlockID>0 and unlockID<=32 and player(unlockID,"exists") and isLockedInSpec[unlockID]) then
			isLockedInSpec[unlockID]=false
			msg(player(id,"name").." has unlocked "..player(lockedID,"name").." from spectators!")
		end
	end
end

addhook("team","noRejoinWhenLocked")
function noRejoinWhenLocked(id,t)
	if (isLockedInSpec[id]) then
		if (t~=0) then
			return 1
			msg2(id,"You are locked in spectators - you can't join any other team!")
		end
	end
end

You gotta write "!lock ID", where ID is player ID, to lock the player in spectators, and "!unlock ID" to unlock the player.

Tell me if this works or not.

old USGN'S

Cirium
User Off Offline

Quote
Hmmm, There Are A Couple end Errors

old Re: Lua, -Spectator Lock

Cirium
User Off Offline

Quote
I'm Getting The Error,

LUA ERROR: sys/lua/server.lua:35: 'end' expected (to close 'if' at line 33) near 'msg2'

old Re: Lua, -Spectator Lock

Lee
Moderator Off Offline

Quote
1
2
3
4
if (t~=0) then
	return 1
	msg2(id,"You are locked in spectators - you can't join any other team!")
end

should be

1
2
3
4
if (t~=0) then
	msg2(id,"You are locked in spectators - you can't join any other team!")
	return 1
end

It's a syntax error to return a value from a function and then expect to have more statements to execute.

old Re: Lua, -Spectator Lock

Cirium
User Off Offline

Quote
I was wondering if you could try it maybe, i tried it and it works well,

I had a couple friends, and i tried lokcing them in spec, they were able to get out?!

after a couple tries...


Thx For The Help.
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview