Forum

> > CS2D > Scripts > Confuse Script
Forums overviewCS2D overview Scripts overviewLog in to reply

English Confuse Script

3 replies
To the start Previous 1 Next To the start

old Confuse Script

Ace Howl
User Off Offline

Quote
Hello.
My first script is having problem. It is confusing. Can you fix it?

Here:
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
addhook("say","p_cmd")


admin = {109296}
vip = {}



function Admin(id)
	return table.find(admin, player(id,"usgn"))
end

function VIP(id)
	return table.find(vip, player(id,"usgn"))
end

function PlayerLevel(id)
	if Admin(id) then
		return 5
	elseif VIP(id) then
		return 3
	end
	return 0
end

function p_cmd(id,txt,message)
	if string.sub(txt, 1, 7) == "@freeze" then
		if PlayerLevel(id) >= 5 then
			local p = tonumber(string.match(txt , "@freeze (%d+)"))
			if (p ~= nil) and (player(p,"exist")) then
				parse("speedmod "..p.." -100")
				return 1
			end
		else
			msg2(id,"©125125255ADMINISTRATOR COMMAND")
			return 1
		end
	end
end

In console, it is written:
Quote
[14:44:44] LUA ERROR: sys/lua/first.lua:10: attempt to call field 'find' (a nil value)

The End.

old Re: Confuse Script

Starkkz
Moderator Off Offline

Quote
1
2
3
4
5
6
7
8
function table.find(t,v)
	for key, value in pairs(t) do
		if value == v then
			return key
		end
	end
	return false
end
There's your missing function.
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview