Forum

> > CS2D > Scripts > Error using the say hook
Forums overviewCS2D overview Scripts overviewLog in to reply

English Error using the say hook

21 replies
Page
To the start Previous 1 2 Next To the start

old Error using the say hook

SpriNG
User Off Offline

Quote
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

old Re: Error using the say hook

Starkkz
Moderator Off Offline

Quote
You missed a parameter in the say function.
Quote
function admsay(id,text)
edited 1×, last 10.05.13 07:30:03 pm

old Re: Error using the say hook

SpriNG
User Off Offline

Quote
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 >
edited 1×, last 10.05.13 07:44:06 pm

old Re: Error using the say hook

Gajos
BANNED Off Offline

Quote
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

old Complex Admin Say Script

_Yank
User Off Offline

Quote
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

old Re: Error using the say hook

sheeL
User Off Offline

Quote
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

old Re: Error using the say hook

DiC
User Off Offline

Quote
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

old maybe

SpriNG
User Off Offline

Quote
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 ..

old Re: Error using the say hook

Avo
User Off Offline

Quote
1
bad argument #1 to pairs(table exepted,got nil)
Means that table isn't declared, you have to declare it:
1
admin = {usgnshere}

old Re: Error using the say hook

Gajos
BANNED Off Offline

Quote
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

old Re: Error using the say hook

DiC
User Off Offline

Quote
user 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

old Re: Error using the say hook

Avo
User Off Offline

Quote
@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.

old Re: Error using the say hook

Alistaire
User Off Offline

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

old Re: Error using the say hook

Gajos
BANNED Off Offline

Quote
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

old Re: Error using the say hook

Alistaire
User Off Offline

Quote
user 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.

old Re: Error using the say hook

Avo
User Off Offline

Quote
user Gajos has written
not tested, only Bolt can edit it[...]

I feel so badass.
Spoiler >

Alistaire's is probably the best and here you are my idea:

Spoiler >

old Re: Error using the say hook

Avo
User Off Offline

Quote
@user 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
To the start Previous 1 2 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview