Forum

> > CS2D > Scripts > Item Lua
Forums overviewCS2D overview Scripts overviewLog in to reply

English Item Lua

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

old Re: Item Lua

wotaan
User Off Offline

Quote
1
2
3
4
5
6
7
8
9
10
11
12
13
elseif string.sub(txt,1,4) == "!res" then
local resetti = string.sub(txt,6)
for _, usgn in pairs(members) do
	if player(id,"usgn") == usgn then
		for __,pid in pairs(player(0,"table")) do
			if player(pid,"usgn")==usgn then
			msg2(pid,"©255000000"..player(id,"name").." "..resetti.. "Saniyelik Restart Atti ")
			end
		end
	parse("restart "..resetti) 
	end
end
return 1

old Re: Item Lua

limonata
User Off Offline

Quote
Engin33r I put the lua into my server my I used some commands but my members didnt see any message like

limonata kicked (playerName)

My other commands are continues like this. Where is the mistake ?

1
2
3
4
5
6
7
8
9
10
11
local p = totable(txt)
local cmd = tostring(p[1])
local pl = tonumber(p[2])
if cmd == "!k" then
for __,pid in pairs(player(0,"table")) do
                    if player(pid,"usgn")==usgn then
                         msg2(pid,"©200000000"..player(id,"name").." [Kicked]  "..player(pl,"name"))
                    end
               end
parse("kick "..pl)
return 1

old Re: Item Lua

EngiN33R
Moderator Off Offline

Quote
I don't see a loop that goes through all entries in the members table. Either you didn't show it - in which case I need to see the full code - or you omitted it, in which case you need to make one.

old Re: Item Lua

sheeL
User Off Offline

Quote
you can try this, works perfect

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
members = {xxxxx}
function split(string)
     local c = {}
     for word in string.gmatch(string, '[^%s]+') do
          table.insert(c, word)
     end
     return c
end

addhook("say","OnSay")
function OnSay(id,text)
local v = split(text)
for _, usgn in pairs(members) do
if player(id,"usgn") == usgn then
	if v[1] == "!k"  and player(v[2],"exists") then
		MessageToAdmins(id,v[2])
			parse("kick "..v[2]) end
			end
		return 1
	end
end

function MessageToAdmins(id,a) -- function to all admins
for _, usgn in pairs(members) do
		for __,pid in pairs(player(0,"table")) do
			if player(pid,"usgn")==usgn then
				msg2(pid,"©000255000Admin "..player(pid,"name").." Kicked "..player(a,"name"))
			end
		end
	end
end
edited 1×, last 07.02.13 05:25:08 am

old Re: Item Lua

wotaan
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
22
23
24
25
26
27
28
29
30
31
32
members = {xxxxx}
function split(string)
     local c = {}
     for word in string.gmatch(string, '[^%s]+') do
          table.insert(c, word)
     end
     return c
end

addhook("say","OnSay")
function OnSay(id,text)
	local v = split(text)
	for _,usgn in pairs(members) do
		if player(id,"usgn") == usgn then
			if v[1] == "!k"  and player(tonumber(v[2]),"exists") then
			MessageToAdmins(id,v[2])
			parse("kick "..v[2])
			return 1
			end
		end
    end
end

function MessageToAdmins(id,a) -- function to all admins
for _,usgn in pairs(members) do
          for __,pid in pairs(player(0,"table")) do
               if player(pid,"usgn")==usgn then
                    msg2(pid,"©000255000Admin "..player(id,"name").." Kicked "..player(tonumber(a),"name"))
               end
          end
     end
end

old Re: Item Lua

omg
User Off Offline

Quote
how are you writing members={}...it should be like {1337,16384,65336}

old Re: Item Lua

wotaan
User Off Offline

Quote
@user sheeL: if u look close u will see. Return 1's position is wrong.
1
2
3
4
5
6
7
8
9
10
11
12
13
addhook("say","OnSay")
function OnSay(id,text)
local v = split(text)
for _, usgn in pairs(members) do
if player(id,"usgn") == usgn then
     if v[1] == "!k"  and player(v[2],"exists") then
          MessageToAdmins(id,v[2])
               parse("kick "..v[2])
	       end
     end
     return 1
end
end
because of this this mistake, "!k" command can usable for just member[1]

old Re: Item Lua

EngiN33R
Moderator Off Offline

Quote
God damn it, people. If you can't write proper Lua, please don't.

@user sheeL: No, your script doesn't work perfectly. It hides the chat of any player if the members table isn't empty and only works for the first entry in the members table. user wotaan actually fixed your code in many places, such as the MessageToAdmins function, which you failed to realise. I won't even talk about tabbing.

This is the code that I propose, you may use it or user wotaan's - as far as I can see, his code is correct.

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
32
33
34
35
36
37
38
39
members = {}
function split(string)
	local c = {}
	for word in string.gmatch(string, '[^%s]+') do
		table.insert(c, word)
	end
	return c
end

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

addhook("say","OnSay")
function OnSay(id,text)
	local v = split(text)
	if IsAdmin(id) then
		if v[1] == "!k"  and player(v[2],"exists") then
			MessageToAdmins(string.char(169).."000255000Admin "..player(id,"name").." kicked "..player(v[2],"name"))
			parse("kick "..v[2])
			return 1
		end
	end
end

function MessageToAdmins(msg) -- message to all admins
	for _, usgn in pairs(members) do
		for __,pid in pairs(player(0,"table")) do
			if player(pid,"usgn")==usgn then
				msg2(pid,msg)
			end
		end
	end
end

old Re: Item Lua

sheeL
User Off Offline

Quote
user EngiN33R has written
God damn it, people. If you can't write proper Lua, please don't.

@user sheeL: No, your script doesn't work perfectly. It hides the chat of any player if the members table isn't empty and only works for the first entry in the members table. user wotaan actually fixed your code in many places, such as the MessageToAdmins function, which you failed to realise. I won't even talk about tabbing.

This is the code that I propose, you may use it or user wotaan's - as far as I can see, his code is correct.

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
32
33
34
35
36
37
38
39
members = {}
function split(string)
	local c = {}
	for word in string.gmatch(string, '[^%s]+') do
		table.insert(c, word)
	end
	return c
end

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

addhook("say","OnSay")
function OnSay(id,text)
	local v = split(text)
	if IsAdmin(id) then
		if v[1] == "!k"  and player(v[2],"exists") then
			MessageToAdmins(string.char(169).."000255000Admin "..player(id,"name").." kicked "..player(v[2],"name"))
			parse("kick "..v[2])
			return 1
		end
	end
end

function MessageToAdmins(msg) -- message to all admins
	for _, usgn in pairs(members) do
		for __,pid in pairs(player(0,"table")) do
			if player(pid,"usgn")==usgn then
				msg2(pid,msg)
			end
		end
	end
end


You are right, Oo'
To the start Previous 1 2 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview