Forum

> > CS2D > Scripts > LUA Report Code
Forums overviewCS2D overview Scripts overviewLog in to reply

English LUA Report Code

4 replies
To the start Previous 1 Next To the start

Poll Poll

Will my code works properly?

Only registered users are allowed to vote
Yes.
0.00% (0)
No.
100.00% (5)
5 votes cast

old Poll LUA Report Code

Baloon
GAME BANNED Off Offline

Quote
Sup guys, i wanna to make a report command which be logged in a .txt file. But, will my code works?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
dir = "sys/lua/report/log.txt"
cmd = "!"

addhook("say","reportcmd")
addhook("sayteam","reportcmd")

function reportcmd(id,txt)
 t=string.lower(txt)
 if string.sub(t,1,1)==cmd then
  if string.sub(t,2,7}=="report" then
   i = tonumber(string.sub(t,9,10))
   r = string.sub(t,11)
   if player(i,"exists") then
    from = player(id,"name") name = player(i,"name") usgn = player(i,"usgn") ip = player(i,"ip")
    local file = dir
    msg2(id,"success report "..name)
    msg2(i,"you are reported by "..from)
    io.open(file,"w")
    file:write(from.." reports "..name.." and "..name.." uses IP "..ip..",                              uses USGN "..usgn.." because "..r)
    file:close()
   end
  end
 end
end

I can't test it because I am using my phone.

old Re: LUA Report Code

TrialAndError
User Off Offline

Quote
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
function reportcmd(id,txt)
	t=string.lower(txt)
	if string.sub(t,1,1)==cmd then
		if string.sub(t,2,7)=="report" then
			i = tonumber(string.sub(t,9,10))
			r = string.sub(t,11)
			if player(i,"exists") then
				from = player(id,"name") name = player(i,"name") usgn = player(i,"usgn") ip = player(i,"ip")
				local file = io.open (dir, "a+")
				msg2(id,"success report "..name)
				msg2(i,"you are reported by "..from)
				file:write("Report: "..from.." is reporting "..name..". "..name.." uses "..ip.." (IP) and has #"..usgn..". Reason: "..r.."\n")
				file:close()
			end
		end
	end
end

This can be improved alot, there is:
http://unrealsoftware.de/forum_posts.php?post=394461

to help you understand it a bit better and think of the spam.

old Re: LUA Report Code

EngiN33R
Moderator Off Offline

Quote
user TrialAndError's code should work, although I personally disapprove of some of the coding style details he uses. I'd also remove the "you are reported by" notification.

What I really need to ask, user Baloon, is why you found it necessary to include a poll in the thread. It contributes nothing to the discussion.
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview