Jump to content

[HELP] Reports System


Recommended Posts

  • Scripting Moderators
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

Link to comment
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 ?

Link to comment
  • Scripting Moderators
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)

 

Link to comment
  • Scripting Moderators
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:

 

Link to comment

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.
×
×
  • Create New...