Forum

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

English Reported Lua

3 replies
To the start Previous 1 Next To the start

old Reported Lua

Skill
User Off Offline

Quote
I need Reported System is Lua .

!reported (BLA BLA)

!lookForReported
= Reports List

old Re: Reported Lua

Talented Doge
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
33
34
35
36
37
USGN = {}
dir = "sys/lua/data/"

addhook("join", "_j")
addhook("say", "_say")

function _j(id)
    USGN[id] = player(id, "usgn")
end

function reportuser(id, res, reporter)
    local file = io.open (dir.."report.txt", "a+")
    if USGN[reporter] > 0 then
        if USGN[id] > 0 then
            file:write("#Date: "..os.date().." #Reported USGN: "..player(id, "usgn").." #Reported IP: "..player(id, "ip").." #Reason: "..res.." #Reporter name: "..player(reporter, "name").." #Reporter USGN: "..player(reporter, "usgn").."\n")
        else
            file:write("#Date: "..os.date().." #Reported Name: "..player(id, "name").." #Reported IP: "..player(id, "ip").." #Reason: "..res.." #Reporter name: "..player(reporter, "name").." #Reporter USGN: "..player(reporter, "usgn").."\n")
        end
        msg2(reporter, "Report is sent!")
        file:close()
    else
        msg2(reporter, "You must be logged in to usgn to report a player!")
    end
end

function _say(p, t)
    if t:sub(1, 7) == "!report" then
		local r = tonumber(t:sub(9,10))
		local rs = t:sub(11)
        if player(r, "exists") then
            reportuser(r, rs, p)
        else
            msg2(p, "Reported user doesn't exist!")
        end
		return 1
    end
end

Example:
The file has written
#Date: 09/13/15 18:41:30 #Reported Name: [b]m00h #Reported IP: 0.0.0.0 #Reason: TOO HANDSOME #Reporter name: Dr.Faggot #Reporter USGN: 131785
edited 2×, last 13.09.15 12:42:43 pm

old Re: Reported Lua

TopNotch
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
path = "sys/lua/reports.txt"

pl = {}
addhook("join", "_join")
function _join(id)
	pl[id] = {}
	pl[id].usgn = player(id,"usgn")
end

addhook("say","_say")
function _say(id, txt)
	if txt:sub(1,7)=="!report" then
		t = tonumber(txt:sub(8,9))
		r = txt:sub(10)
		if t~=nil and r~= nil then
			if t~=id then 
				if pl[id].usgn > 0 then
					if player(id,"exists") then
						if not player(t,"bot") then
							if r:len() > 5 then
								report(id, t, r)
								return 1
							else
								msg2(id,"\169255150150Error: \169255255255Please enter a valid reason")
								return 1
							end
						else
							msg2(id,"\169255150150Error: \169255255255You cannot report a bot")
							return 1
						end
					else
						msg2(id,"\169255150150Error: \169255255255Player does not exist")
						return 1
					end
				else
					msg2(id,"\169255150150Error: \169255255255You have to be logged into USGN to report a player")
					return 1
				end
			else
				msg2(id,"\169255150150Error: \169255255255You cannot report yourself")
				return 1
			end
		else
			msg2(id,"\169255150150Usage: \169255255255!report <id> <reason>")
			return 1
		end
	end
end

function report(id, t, r)
	f = io.open(path, "a+")
	f:write(os.date().. ": "..player(id,"name").." ("..pl[id].usgn..") reported "..player(t,"name").." ("..pl[t].usgn.."|"..player(t,"ip")..") Reason: "..r.."\n")
	f:close()
	msg2(id,"\169255255255Info: You successfully reported \169175255100"..player(t,"name"))
end
(a lot of if statements, avoids most of abuse)

Example output of reports.txt:
IMG:https://screenshootereu.blob.core.windows.net/engine4files/lhifqmzcmjwbsreduzjnbvsxxphnhnvolfytqqgvrudyqifqtfjfvvgojtxdfmgxyrdzaowyiojdekrgwbdbrzixvewnluptvmvq
edited 1×, last 13.09.15 01:38:07 pm
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview