#LasoPhaser

[HELP] Reports System

Recommended Posts

hey guys

how to make a cmd for send message to online admins ?

and admins can see all reports by /reports on a gui

just give me functions or simple code 😊

Share this post


Link to post
1 minute ago, XaskeL said:

Describe the task more specifically

I mean, the players who report are in a gui

There is a window in gui that shows all the reports
Did you understand me?

@XaskeL

Share this post


Link to post
38 minutes ago, #LasoPhaser said:

I mean, the players who report are in a gui

There is a window in gui that shows all the reports
Did you understand me?

@XaskeL

It's edited function from some chat script.

-- meta.xml
<meta>
	<script src="server.lua" type="server"/>
</meta>

-- server.lua

function reportFunction(thePlayer, _,...)
	local word = {...}
	local message = table.concat(word, " ")
	local players = getElementsByType("player")

	for i = 1, #players do
		local account = getPlayerAccount(players[i])
		if isObjectInACLGroup("user."..getAccountName(account), aclGetGroup("Admin")) or isObjectInACLGroup("user."..getAccountName(account), aclGetGroup("Moderator")) then
				outputChatBox("Report from "..getPlayerName(thePlayer)..": "..message, players[i], 255, 255, 255, true)
		end
	end
end
addCommandHandler("reportmessage", reportFunction)

 

Should work, do not forget to implement antiflood thing for this.

And about gui, i can't help you with that, i don't like to make it :D

Share this post


Link to post
Just now, majqq said:

It's edited function from some chat script.


-- meta.xml
<meta>
	<script src="server.lua" type="server"/>
</meta>

-- server.lua

function reportFunction(thePlayer, _,...)
	local word = {...}
	local message = table.concat(word, " ")
	local players = getElementsByType("player")

	for i = 1, #players do
		local account = getPlayerAccount(players[i])
		if isObjectInACLGroup("user."..getAccountName(account), aclGetGroup("Admin")) or isObjectInACLGroup("user."..getAccountName(account), aclGetGroup("Moderator")) then
				outputChatBox("Report from "..getPlayerName(thePlayer)..": "..message, players[i], 255, 255, 255, true)
		end
	end
end
addCommandHandler("reportmessage", reportFunction)

 

Should work, do not forget to implement antiflood thing for this.

And about gui, i can't help you with that, i don't like to make it :D

now how to show reports on a gui window ?

Share this post


Link to post
Just now, #LasoPhaser said:

now how to show reports on a gui window ?

If script wouldn't be restarted, i would use tables to store them, it's fast + efficient, temporary storage (script keeps data, and after restart it recreates a table)

 

Share this post


Link to post
Just now, majqq said:

If script wouldn't be restarted, i would use tables to store them, it's fast + efficient, temporary storage (script keeps data, and after restart it recreates a table)

 

how ?

Share this post


Link to post
10 minutes ago, #LasoPhaser said:

how ?

Use loop.

An example, of course it can be done better, but you should learn how to use some things.

local playerReports = {}

function reportFunction(thePlayer, _,...)
	local word = {...}
	local message = table.concat(word, " ")
	local players = getElementsByType("player")

	for i = 1, #players do
		local account = getPlayerAccount(players[i])
		if isObjectInACLGroup("user."..getAccountName(account), aclGetGroup("Admin")) or isObjectInACLGroup("user."..getAccountName(account), aclGetGroup("Moderator")) then
				outputChatBox("Report from "..getPlayerName(thePlayer)..": "..message, players[i], 255, 255, 255, true)
				playerReports[getPlayerName(thePlayer)] = message
		end
	end
end
addCommandHandler("reportmessage", reportFunction)

function checkReports()
	for k, v in pairs(playerReports) do
		outputChatBox("Player name: "..k..", reports: "..v)
	end
end
addCommandHandler("reports", checkReports)

 

I suggest you to read tutorials:

 

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.