sorry if i am wrong but add anyway lets head to the problem
problem:
i added hook about adminsay idk what is wrong
1
2
3
4
5
6
7
addhook("say","admsay")
function admsay(id)
if isAdmin then
	 msg("©255000000admin"..player(id,"name").."[[%ADMIN%]]:"..text)
	return 1
	end
	end
but in cansole it says
1
ATTEMT TO CONCATENATE GLOBAL TEXT(A NIL VALUE)
now it is ok sorry edited 1×, last 12.05.13 08:44:58 am
Admin/mod comment
Fixed the title. /Starkkz You missed a parameter in the say function.
Quote
function admsay(id,text)
edited 1×, last 10.05.13 07:30:03 pm
yo thanks starkzz
but what the heck i am admin and wheni say something then it says adminplayer [%admin%]:my text
and the hook is
Spoiler addhook("say","admsay")
function admsay(id,text)
if isAdmin then
msg("©255000000admin"..player(id,"name").."[[%ADMIN%]]:"..text)
return 1
end
end
edited 1×, last 10.05.13 07:44:06 pm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
admin = {95895}
addhook("say","adminsay")
function adminsay(id,txt)
if isAdmin(id) then
msg("©255230000"..player(id,"name").."[Admin]: ©255220000"..txt)
return 1
end
end
function isAdmin(id)
for _, usgn in pairs(admin) do
if player(id,"usgn") == usgn then
return true
end
end
return false
end
I recommend you to use this because it has the most of new cs2d features and it dont show messages started by "!" or "@".
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
bosslist = {94235}
addhook("say","bosssay")
function bosssay(id,txt)
for _, usgn in ipairs(bosslist) do
if (txt =="rank") then
parse(id,"say rank")
end
if (txt:sub(1,1)=="!") then
return 1
elseif (txt:sub(1,1)=="@") then
return 1
elseif player(id,'usgn') == usgn then
msg("©124252000"..player(id,"name").." ©255255255[%Admin%]: ©255000000"..txt)
return 1
end
end
end
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
admin = {12345,54321}
function isAdmin(id)
for _, usgn in pairs(admin) do
if player(id,"usgn") == usgn then
return true
end
end
return false
end
addhook("say","_say")
function _say(id,text)
if isAdmin(id) then
	if string.lower(text) == "!" or string.lower(text) == "@" then
	local text = tonumber(text:sub(2))
		 msg("©124252000"..player(id,"name").." ©255255255[Admin]: ©255000000"..text)
		return 1
		end
	end
end
DiC User Offline
1
2
3
4
5
6
7
addhook("say","admsay")
function admsay(id,text)
	if player(id,"usgn") == 95895 then
msg("©255000000 "..player(id,"name").." [Admin]:"..text)
return 1
end
end
Lmaybe i think it is problem with isAdmin because first it was working but not showing my name when i tried your's then in is not even show the tag
so the is admin code is :
1
2
3
4
5
6
7
8
function isAdmin(id)
for _, usgn in ipairs(admin) do
if player(id,"usgn") == 95895 then
return true
end
end
return false
end
and the error is :
[/code] 1
bad argument #1 to ipairs(table exepted,got nil)
and when the code is :
1
2
3
4
5
6
7
8
9
10
11
function isAdmin(id)
for _, usgn in pairs(admin) do
if player(id,"usgn") == 95895 then
return true
end
end
return false
end
and the error is :
[code]
1
bad argument #1 to pairs(table exepted,got nil)
[/code]
whats the big damn me .. Avo User Offline
1
bad argument #1 to pairs(table exepted,got nil)
Means that table isn't declared, you have to declare it:
Why don't you first learn how to read all a posts, bitch?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
admin = {95895}
addhook("say","adminsay")
function adminsay(id,txt)
if isAdmin(id) then
msg("©255230000"..player(id,"name").."[Admin]: ©255220000"..txt)
return 1
end
end
function isAdmin(id)
for _, usgn in pairs(admin) do
if player(id,"usgn") == usgn then
return true
end
end
return false
end
DiC User Offline
SpriNG has written
1
2
3
4
5
6
7
8
function isAdmin(id)
for _, usgn in pairs(admin) do
if player(id,"usgn") == 95895 then
return true
end
end
return false
end
Please, 1
2
3
4
5
6
7
8
9
10
11
12
admin == {} --(only if you don't had the admin == {} line.)
adhook("say","isAdmin")
function isAdmin(id)
for _, usgn in pairs(admin) do
if player(id,"usgn") == usgn then
msg("©255000000 "..player(id,"name").." [Admin]:"..text)
return true
end
end
return false
end
this mus work, but i don't test it edited 1×, last 12.05.13 12:29:29 am
Avo User Offline
@zHeadFucker: I don´t have to test it to say it won´t work. Don´t post if don´t have any knowledge about the topic. Thanks. @polish coder : bitch everyone's code has the same error 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
admin = {
	[95895] = '©255230000'
}
sayColor = '©255220000'
addhook('say', 'sayHook')
function sayHook(id, txt)
	local a = admin[player(id, 'usgn')]
	if a then
		msg(a..player(id, 'name')..'[Adm]: 'sayColor..txt)
		return 1;
	end
end
It's tested and work!
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
adm = {
admins = {95895,108942};
hook = {
say = function(id,txt)
if adm.func.isAdmin(id) then
msg('©000255220'..player(id,'name')..' [Admin]: ©255220000'..txt)
return 1
end
end;
};
func = {
isAdmin = function(id)
for _, i in pairs(adm.admins) do
if player(id,'usgn') == i then
return true
end
end
return false
end;
addhooks = function()
for i in pairs(adm.hook) do
addhook(tostring(i),'adm.hook.'..tostring(i))
end
end;
};
}
adm.func.addhooks()
edited 1×, last 12.05.13 05:15:33 pm
Gajos has written
not tested, only Bolt can edit it:
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
adm = {
	admins = {95895};
	
	hook = {
		say = function(id,txt)
			if adm.func.isAdmin(id) then
				msg('©255230000'..player(id,'name')..'[Admin]: ©255220000'..txt)
				return 1
			end
		end;
	};
	
	func = {
		isAdmin = function(id)
			for _, i in pairs(adm.admins) do
				if player(id,'usgn') == i then
					return true
				end
			end
			return false
		end;
		
		addhooks = function()
			for i in pairs(adm.hook) do
				addhook(tostring(i),'adm.hook.'..tostring(i))
			end
		end;
	};
}
adm.addhooks()
Dafuq.
Just make admins[] a table with usgns as keys instead of values. Avo User Offline
Gajos has written
not tested, only Bolt can edit it[...]
I feel so badass.
Spoiler Quote
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
admin = {
[95895] = '©255230000'
}
sayColor = '©255220000'
addhook('say', 'sayHook')
function sayHook(id, txt)
local a = admin[player(id, 'usgn')]
if a then
msg(a..player(id, 'name')..'[Adm]: 'sayColor..txt)
return 1;
end
end
Alistaire's is probably the best and here you are my idea:
Spoiler 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
UserPrefix = {
	[1] = string.char(169).."255000255[ADMIN]"
}
UserType = {	
	[95895] = 1
}
addhook("say", "OnSay", -999)
OnSay = function(id, txt)
	local P = player
	local M = UserType[P(id, "usgn")] or false
	if M then
		msg(UserPrefix[M]..P(id, "name")..": "..txt)
		return 1
	end
end
stupids, why post more codes, if already have other working? Avo User Offline
@ sheeL: Chill out, we're just showing other possibilities. In my opinion, nothing is as annoying as replies with code-tags without spoiler- tags what makes post long as shit and hard to scroll. edited 1×, last 12.05.13 05:47:48 pm