Forum

> > CS2D > Scripts > Admin say error
ForenübersichtCS2D-Übersicht Scripts-ÜbersichtEinloggen, um zu antworten

Englisch Admin say error

3 Antworten
Zum Anfang Vorherige 1 Nächste Zum Anfang

alt Admin say error

MAX-russia
User Off Offline

Zitieren
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

alt Re: Admin say error

Gajos
BANNED Off Offline

Zitieren
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

alt Re: Admin say error

MAX-russia
User Off Offline

Zitieren
I change the message a little bit but thanks for helping me guys, everything works very well.
Zum Anfang Vorherige 1 Nächste Zum Anfang
Einloggen, um zu antworten Scripts-ÜbersichtCS2D-ÜbersichtForenübersicht