Forum

> > CS2D > Scripts > Admin say error
Forums overviewCS2D overview Scripts overviewLog in to reply

English Admin say error

3 replies
To the start Previous 1 Next To the start

old Admin say error

MAX-russia
User Off Offline

Quote
I was trying to make an admin say script, but it doesn't work at all and the console shows me the error in 6th line with "ipairs" saying: "LUA ERROR: sys/lua/autorun/ml.lua:6: bad argument #1 to 'ipairs' (table expected, got number)". I don't understend what do I have to change.

1
2
3
4
5
6
7
8
9
10
11
-- made by me
admin = (35281)

addhook("say","adminsay")
function adminsay(id, txt)
	for _, usgn in ipairs(admin) do
		if player(id,"usgn") == 35281 then
		msg("©255230000Admin: "..txts)
		end
	end
end

This code supposed to show "admin:" in yellow instead of my name when I say something

old Re: Admin say error

Gajos
BANNED Off Offline

Quote
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
-- made by me
admin = (35281)

addhook("say","adminsay")
function adminsay(id,txt)
	if isAdmin(id) then
		msg("©255230000"..player(id,"name").."[Admin]: ©255220000"..txt)
	end
end

function isAdmin(id)
	for _, usgn in pairs(admin) do
		if player(id,"usgn") == usgn then
			return true
		end
	end
	return false
end

You have to many bugs.
ipairs to pairs
txts to txt
player(id,"usgn") == 35281 to player(id,"usgn") == usgn

old Re: Admin say error

MAX-russia
User Off Offline

Quote
I change the message a little bit but thanks for helping me guys, everything works very well.
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview