English Error using the say hook

21 replies
Goto Page
To the start Previous 1 2 Next To the start
10.05.13 07:28:13 pm
Up
SpriNG
User
Offline Off
sorry if i am wrong but add anyway lets head to the problem

problem:
i added hook about adminsay idk what is wrong

Code:
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

Code:
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
10.05.13 07:29:40 pm
Up
Starkkz
Moderator
Offline Off
You missed a parameter in the say function.
Quote:
function admsay(id,text)
edited 1×, last 10.05.13 07:30:03 pm
lol
10.05.13 07:32:00 pm
Up
SpriNG
User
Offline Off
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
10.05.13 07:50:40 pm
Up
Gajos
BANNED
Offline Off
Code:
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
Banned for Hacking/Cheating in CS2D /DC
10.05.13 08:42:07 pm
Up
_Yank
User
Offline Off
I recommend you to use this because it has the most of new cs2d features and it dont show messages started by "!" or "@".

Code:
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
10.05.13 10:27:03 pm
Up
sheeL
User
Offline Off
Code:
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
11.05.13 01:07:18 am
Up
DiC
User
Offline Off
Code:
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
11.05.13 01:31:56 pm
Up
SpriNG
User
Offline Off
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 :
Code:
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]
Code:
1
bad argument #1 to ipairs(table exepted,got nil)




and when the code is :
Code:
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]
Code:
1
bad argument #1 to pairs(table exepted,got nil)
[/code]

whats the big damn me ..
11.05.13 02:45:38 pm
Up
Avo
User
Offline Off
Code:
1
bad argument #1 to pairs(table exepted,got nil)
Means that table isn't declared, you have to declare it:
Code:
1
admin = {usgnshere}
Trust me, I'm an engineer | user DC approved file cs2d Super extra mod for CS2D (64), yeah!
11.05.13 05:11:56 pm
Up
Gajos
BANNED
Offline Off
Why don't you first learn how to read all a posts, bitch?
Code:
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
Banned for Hacking/Cheating in CS2D /DC
12.05.13 12:13:44 am
Up
DiC
User
Offline Off
user SpriNG has written:
Code:
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,
Code:
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
12.05.13 12:54:47 am
Up
Avo
User
Offline Off
@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.
Trust me, I'm an engineer | user DC approved file cs2d Super extra mod for CS2D (64), yeah!
12.05.13 08:37:43 am
Up
SpriNG
User
Offline Off
@polish coder : bitch everyone's code has the same error
12.05.13 08:51:33 am
Up
Alistaire
User
Offline Off
Code:
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
IMG:http://i.imgur.com/5zhwOTP.png
12.05.13 11:20:46 am
Up
Gajos
BANNED
Offline Off
It's tested and work!
Code:
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
Banned for Hacking/Cheating in CS2D /DC
12.05.13 11:53:37 am
Up
Alistaire
User
Offline Off
user Gajos has written:
not tested, only Bolt can edit it:
Code:
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.
IMG:http://i.imgur.com/5zhwOTP.png
12.05.13 02:04:08 pm
Up
Avo
User
Offline Off
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 >
Trust me, I'm an engineer | user DC approved file cs2d Super extra mod for CS2D (64), yeah!
12.05.13 05:12:20 pm
Up
sheeL
User
Offline Off
stupids, why post more codes, if already have other working?
12.05.13 05:34:47 pm
Up
Avo
User
Offline Off
@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
Trust me, I'm an engineer | user DC approved file cs2d Super extra mod for CS2D (64), yeah!
To the start Previous 1 2 Next To the start