Jump to content

skReport by Sorbon


Sorbon

Recommended Posts

Sorbon's Report Skript

Update;

No Tuske 

1.16 fixes

Plugins needed:

Skript

 

Features:

  • Reports are sorted by Date
  • Reports can be seen in a GUI
  • You can directly Teleport to the reported player
  • Cooldown
  • infinity pages

Pictures:

image.png.002b009a9eaef9a30d61010f0a7b191c.png

Listed by Each User:

image.png.c7fa1b6a8d5992efbf3c4e05d44d3ff7.png

When you Click on it, you can see all reports:
by clicking on 1 report, it gets deleted, or you use the delete all button

image.png.148f5ae7732611b60e3838f1e49d3194.png

image.png.ce9f7a56312a44b984da260581eb4eb9.png

 

Command:

/report <player> <reason>

/reports to view the reports

 

I hope you like it, if you find any bugs or have any Suggestions, be sure you let me know of it 😄

 

CODE:

options:
	permission: report.Admin   # Permission
	Prefix: &6Server &7        # Prefix
	NoPermMessage: &cYou don't have the permissions to use this Command!

	cooldown: 15 seconds       # Cooldown, so people cant spam it
	CooldownMessage: &7Please wait &7[&c%remaining time%&7]   
	CooldownBypass: report.bypass

command /report [<offline player>] [<text>]:
	cooldown: {@cooldown}
	cooldown message: {@CooldownMessage}
	cooldown bypass: {@CooldownBypass}
	trigger:
		if arg-1 is not set:
			send "&cUsage: /report <player> <reason>"
		else:
			if arg-2 is not set:
				send "&cUsage: /report <player> <reason>"
			else: 
				set {_hasPlayed} to 1 if arg-1 has played before
				set {_hasPlayed} to 1 if arg-1 is online
				if {_hasPlayed} is set:
					add arg-1 to {reports::list::*} if {reports::list::*} does not contain arg-1
					add arg-2 to {reports::%arg-1%::reason::*}
					add player to {reports::%arg-1%::reporter::*}
					add now to {reports::%arg-1%::time::*}
					set {reports::%arg-1%::last} to now
					set {_p} to player
					
					#Report Message:
					send "{@Prefix} &7You have reported [%arg-1%&7]" 
					send "{@Prefix} [%player%&7] &7has reported [&c%arg-1%&7] &7[<command:/reports>&aClick me<reset>&7]" to all players where [input has permission "{@permission}"]
				else:
					send "{@Prefix} This Player has never played here before"

command /reports [<offline player>]:
	trigger:
		if player has permission "{@permission}":
			if arg-1 is offline player:
				playerReport(player,arg-1)
			else:
				reports(player)
		else:
			send "{@NoPermMessage}"
			send "&7[&cReport&7] &cMade by Sorbon"


# Reports is the Main GUI with the player listed
# playerReport is the GUI where the Reports of a player are listed




# Create the default layout for GUI 			
function gui(p:player,s:string,n:string):
	set metadata tag {_s} of {_p} to chest inventory with 6 rows named {_n}
	set slot (all numbers between 0 and 54) of metadata tag {_s} of {_p} to light gray stained glass pane named ""
	set slot 0,1,2,3,4,5,6,7,8,36,37,38,39,40,41,42,43 and 44 of metadata tag {_s} of {_p} to gray stained glass pane named ""

# This function allows me to split a list at a certain value, so its used for the pagination
# also allows me to say how many values it should return ({_i})
function listSplit(o:objects,i:number,offset:number = 0) :: objects:
	loop {_i} times:
		set {_l::%loop-number%} to (loop-number+{_offset})th element of {_o::*}
	return {_l::*}


# main Gui, where the players are listed
function reports(p:player,page:number=0):
	set {_b} to ({_page}+1)*27 # small calculation, so i can test if the GUI needs another page 
	gui({_p},"Reports","&7Reports")
	set {_l::*} to listSplit({reports::list::*},27,{_page}*27) # Page starts at 0
	loop {_l::*}:
		set slot loop-index parsed as number+8 of metadata tag "Reports" of {_p} to skull of loop-value named "%loop-value%"
	set slot 45 of metadata tag "Reports" of {_p} to arrow named "Page %{_page}%" if {_page} > 0
	set slot 49 of metadata tag "Reports" of {_p} to barrier named "&cClose"
	set slot 53 of metadata tag "Reports" of {_p} to arrow named "Page %{_page}+2%" if {reports::list::%{_b}%} is set # This checks if the list is set at that integer, so I don't have useless arrows in it :*
	open (metadata tag "Reports" of {_p}) to {_p}


function playerReport(p:player,pr:offline player,page:number=0):
	set {_b} to ({_page}+1)*27 # for the next Page
	gui({_p},"PlayerReport","%{_pr}'s name%'s reports")
	# I need to reverse the list so i can get the newest reports first
	set {_reports::*} to listSplit((reversed {reports::%{_pr}%::reason::*}),27,{_page}*27)
	set {_reporter::*} to listSplit((reversed {reports::%{_pr}%::reporter::*}),27,{_page}*27)
	set {_time::*} to listSplit((reversed {reports::%{_pr}%::time::*}),27,{_page}*27)
	loop {_reports::*}:
		set slot loop-index parsed as number +8 of metadata tag "PlayerReport" of {_p} to paper named "&6Report ##%loop-index parsed as number+ ({_page}*27)%" with lore "","&7Reason: %loop-index%", split({_reports::%loop-index%}),"", "&7Reported by: %{_reporter::%loop-index%}%" and "&7Date: %{_time::%loop-index%}%"
	set slot 4 of metadata tag "PlayerReport" of {_p} to skull of {_pr} named "%{_pr}%"
	set slot 45 of metadata tag "PlayerReport" of {_p} to arrow named "Page %{_page}%" if {_page} > 0
	set slot 47 of metadata tag "PlayerReport" of {_p} to structure void named "&cDelete all Reports"
	set slot 49 of metadata tag "PlayerReport" of {_p} to book and quill named "&cBack to reports"
	set slot 51 of metadata tag "PlayerReport" of {_p} to light gray glass pane named "&7Suggest features :*"
	set slot 53 of metadata tag "PlayerReport" of {_p} to arrow named "Page %{_page}+2%" if {reports::%{_pr}%::reason::%{_b}%} is set
	open (metadata tag "PlayerReport" of {_p}) to {_p}

# This basicly makes the lore more readable, i tried to make it nicer and readable, but it always broke
# live with it.... xD

# it basicly create splits a string at words, and tries to create strings which arent longer than 30 characters
# if a word is longer than 30 characters, it splits that word

function split(list:string) :: strings:
	set {_list::*} to {_list} split at " "
	set {_n} to "&7"
	loop {_list::*}:
		set {_m} to loop-value
		while length of {_m} > 30:
			set {_n} to  "%{_n}% %first (30 - length of {_n}) characters of {_m}%"
			add {_n} to {_n::*}
			set {_n} to "&7"
			replace all first 30 characters of  {_m} with "" in {_m}
		set {_n} to "%{_n}% %{_m}%"
		if length of {_n} > 30:
			add {_n} to {_n::*}
			set {_n} to "&7"	
	add {_n} to {_n::*} if {_n} is not ""
	return {_n::*}


function verify(p:player,p2:offline player,id:integer):
	set metadata tag "verify" of {_p} to chest inventory with 3 rows named "&7Do you want to delete this Report?"
	set slot (all numbers between 0 and 26) of metadata tag "verify" of {_p} to light gray stained glass pane named ""
	set slot 10 and 11 of metadata tag "verify" of {_p} to lime glass pane named "&aYES"
	set slot 15 and 16 of metadata tag "verify" of {_p} to red glass pane named "&cNo"
	set slot 4 of metadata tag "verify" of {_p} to skull of {_p2} named "%{_p2}%"
	set slot 13 of metadata tag "verify" of {_p} to paper named "&cAre you sure?"  with lore "&7Are you sure you want", "&7to delete Report ##%{_id}%?"
	open (metadata tag "verify" of {_p}) to {_p}


function deleteReport(pr:player,p:offline player,id:integer):
	# since the ID are reversed inside the gui, to show the newset, i have to calulate which report it actually wants to delete
	# so i take the size+1 and subtract the ID  
	set {_id} to size of {reports::%{_p}%::reason::*}+1-{_id} if {_id} != -1 # -1 is basicly to delete all reports 
	delete {reports::%{_p}%::reason::%{_id}%}
	delete {reports::%{_p}%::reporter::%{_id}%}
	delete {reports::%{_p}%::time::%{_id}%}
	delete {reports::%{_p}%::*} if {_id} = -1 # deletes all of them
	playerReport({_pr},{_p}) 
	# if player has no reports to show, it shows the main page
	if size of {reports::%{_p}%::reason::*} = 0:
		remove {_p} from {reports::list::*}
		reports({_pr},0)
	fixVariable({_p}) 

# lists index get messed up when you delete a variable in it, so i reset it here
function fixVariable(p:player):
	set {reports::%{_p}%::reason::*} to {reports::%{_p}%::reason::*}
	set {reports::%{_p}%::reporter::*} to {reports::%{_p}%::reporter::*}
	set {reports::%{_p}%::time::*} to {reports::%{_p}%::time::*}

on inventory click:
	if event-inventory = (metadata tag "Reports" of player):
		cancel event

		reports(player,(2th element out of (name of event-slot split at " ") parsed as number-1)) if name of event-slot contains "Page"
		close player's inventory if name of event-slot is "&cClose" 
		playerReport(player,name of event-slot parsed as offline player) if size of {reports::%name of event-slot%::reason::*} > 0		
	if event-inventory = (metadata tag "PlayerReport" of player):
		cancel event
		reports(player,0) if name of event-slot is "&cBack to Reports" 
		deleteReport(player,(slot 4 of player's current inventory's name parsed as offline player),-1) if name of event-slot is "&cDelete all Reports" 
		if name of event-slot contains "Report ##":
			# gets the ID of the event-slot 
			set {_n} to 2th element out of (name of event-slot split at " ")
			replace all "##" with "" in {_n}
			verify(player,slot 4 of player's current inventory's name parsed as offline player,( {_n} parsed as integer)) 
		playerReport(player,slot 4 of player's current inventory's name parsed as offline player,(2th element out of (name of event-slot split at " ") parsed as number-1)) if name of event-slot contains "Page"
	if event-inventory = (metadata tag "verify" of player):	
		cancel event
		playerReport(player,slot 4 of player's current inventory's name parsed as offline player) if name of event-slot is "&cNO"
		if name of event-slot is "&aYES":
			# Need to get the ID secretly :3
			set {_n} to last element of (line 2 of lore of slot 13 of player's current inventory split at " ")
			replace all "##" and "?" with "" in {_n}
			deleteReport(player,slot 4 of player's current inventory's name parsed as offline player,{_n} parsed as integer)

on inventory close:
	# 1.16.1 came with a new feature, that you can press F inside a gui, i made a temp fix here for that 
	set offhand tool to {offhand::%player%} if event-inventory = (metadata tag "Reports" of player)
	set offhand tool to {offhand::%player%} if event-inventory = (metadata tag "PlayerReport" of player)

 

 

 

 

 

skReport.sk

Edited by Sorbon
2.0
  • Like 1
Link to comment
Share on other sites

checking all offline players causes a BIG lag spike on big servers. It's a cheap workaround, but this will only check all offline players when the player that's reported isn't online. Increasing preformance a lot when reporting while the reported player is online. It still works for offline players but that still causes lag.

				set {_on} to false
				loop all players:
					if "%player%" is "%arg-1%":
						set {_on} to true
				
				if {_on} is true:
					add arg-1 to {reports::list::*} if {reports::list::*} does not contain arg-1
					add arg-2 to {reports::%arg-1%::reason::*}
					add player to {reports::%arg-1%::reporter::*}
					add now to {reports::%arg-1%::time::*}
					set {reports::%arg-1%::last} to now
					set {_p} to player
					
					#Report Message:
					send "{@Prefix} &eYou have reported %arg-1%" 
					send "{@Prefix} &6%player% &ehas reported &6%arg-1% &e<command:/reports>&6&lCLICK<reset>" to all players where [input has permission "{@permission}"]
				else:
					if "%all offline players%" contains "%arg-1%":
						add arg-1 to {reports::list::*} if {reports::list::*} does not contain arg-1
						add arg-2 to {reports::%arg-1%::reason::*}
						add player to {reports::%arg-1%::reporter::*}
						add now to {reports::%arg-1%::time::*}
						set {reports::%arg-1%::last} to now
						set {_p} to player
						
						#Report Message:
						send "{@Prefix} &eYou have reported %arg-1%" 
						send "{@Prefix} &6%player% &ehas reported &6%arg-1% &e<command:/reports>&6&lCLICK<reset>" to all players where [input has permission "{@permission}"]
					else:
						send "{@Prefix} &cThis Player has never played here before"
						
						#set cooldown even when an invalid player was given to prevent people spamming it and causing massive lag
						set {reports::%arg-1%::last} to now

 

 

Edited by Ikbenmathijs
Link to comment
Share on other sites

4 hours ago, Ikbenmathijs said:

checking all offline players causes a BIG lag spike on big servers. It's a cheap workaround, but this will only check all offline players when the player that's reported isn't online. Increasing preformance a lot when reporting while the reported player is online. It still works for offline players but that still causes lag.


				set {_on} to false
				loop all players:
					if "%player%" is "%arg-1%":
						set {_on} to true
				
				if {_on} is true:
					add arg-1 to {reports::list::*} if {reports::list::*} does not contain arg-1
					add arg-2 to {reports::%arg-1%::reason::*}
					add player to {reports::%arg-1%::reporter::*}
					add now to {reports::%arg-1%::time::*}
					set {reports::%arg-1%::last} to now
					set {_p} to player
					
					#Report Message:
					send "{@Prefix} &eYou have reported %arg-1%" 
					send "{@Prefix} &6%player% &ehas reported &6%arg-1% &e<command:/reports>&6&lCLICK<reset>" to all players where [input has permission "{@permission}"]
				else:
					if "%all offline players%" contains "%arg-1%":
						add arg-1 to {reports::list::*} if {reports::list::*} does not contain arg-1
						add arg-2 to {reports::%arg-1%::reason::*}
						add player to {reports::%arg-1%::reporter::*}
						add now to {reports::%arg-1%::time::*}
						set {reports::%arg-1%::last} to now
						set {_p} to player
						
						#Report Message:
						send "{@Prefix} &eYou have reported %arg-1%" 
						send "{@Prefix} &6%player% &ehas reported &6%arg-1% &e<command:/reports>&6&lCLICK<reset>" to all players where [input has permission "{@permission}"]
					else:
						send "{@Prefix} &cThis Player has never played here before"
						
						#set cooldown even when an invalid player was given to prevent people spamming it and causing massive lag
						set {reports::%arg-1%::last} to now

 

 

Thank you very much for your comment


"%all offline players%" has been replaced with another way;


 

                set {_hasPlayed} to 1 if arg-1 has played before
                set {_hasPlayed} to 1 if arg-1 is online
                if {_hasPlayed} is set:

 

  • Like 1
Link to comment
Share on other sites

On 2/19/2020 at 9:49 PM, Sorbon said:

Thank you very much for your comment


"%all offline players%" has been replaced with another way;


 


                set {_hasPlayed} to 1 if arg-1 has played before
                set {_hasPlayed} to 1 if arg-1 is online
                if {_hasPlayed} is set:

 

Thanks for the update! Now it doesn't lag even when reporting an offline player!

 

Link to comment
Share on other sites

command /report [<offline player>] [<text>]:
	cooldown: {@cooldown}
	cooldown message: {@CooldownMessage}
	cooldown bypass: {@CooldownBypass}
	trigger:
		if arg-1 is not set:
			send "&cUsage: /report <player> <reason>"
		else:
			if arg-2 is not set:
				send "&cUsage: /report <player> <reason>"
			else: 

you can just put

usage: &cUsage: /report <player> <reason>

before the trigger, no need for any of that "if arg-1 is not set" stuff

VIP since January 7th, 2020

Support since September 19th, 2020

Helper since November 3rd, 2020

Moderator since March 8th, 2021

unknown.png

5.png.e14b1bf83edf0ac2edc1bfb822177184.png

image.png.fe30b7b2c0be5a541ba4ed2187b23030.png

Link to comment
Share on other sites

On 7/13/2020 at 3:35 PM, Sorbon said:

Good morning/evening

For the people who use this Skript, pls use the new version now
It contains some fixes for the 1.16 and also doesnt need TuSke anymore

 

 

skReport.sk 8.35 kB · 6 downloads

Thanks for the update! I really like that you're using vanilla GUIs now, because they're way less buggy than TuSke GUIs! The code is also much cleaner, though I reccomend making more comments in the code with public scripts so people can read what's happening :p.

 

Anyways it gave a warning about line 119. You forgot to use "and" instead of ",".

Link to comment
Share on other sites

4 hours ago, Ikbenmathijs said:

Thanks for the update! I really like that you're using vanilla GUIs now, because they're way less buggy than TuSke GUIs! The code is also much cleaner, though I reccomend making more comments in the code with public scripts so people can read what's happening :p.

 

Anyways it gave a warning about line 119. You forgot to use "and" instead of ",".

i added some comments in the code which shows in the post

not in the  file yet, but I will do that and fix the List error (I had disabled them xD) 

when i find the time, thanks for saying 

Edited by Sorbon
Link to comment
Share on other sites

23 hours ago, Sorbon said:

i added some comments in the code which shows in the post

not in the  file yet, but I will do that and fix the List error (I had disabled them xD) 

when i find the time, thanks for saying 

Wait you can disable them?!?

 

I should REALLY do that because it's really annoying (and I don't want to be reminded every time that my code sucks :p)

Edited by Ikbenmathijs
Link to comment
Share on other sites

On 7/13/2020 at 10:31 PM, TheGoose said:

command /report [<offline player>] [<text>]:
	cooldown: {@cooldown}
	cooldown message: {@CooldownMessage}
	cooldown bypass: {@CooldownBypass}
	trigger:
		if arg-1 is not set:
			send "&cUsage: /report <player> <reason>"
		else:
			if arg-2 is not set:
				send "&cUsage: /report <player> <reason>"
			else: 

you can just put


usage: &cUsage: /report <player> <reason>

before the trigger, no need for any of that "if arg-1 is not set" stuff

the default usage message for skript is very inflexible, although there are better ways of doing what he's done

  • Like 1
Link to comment
Share on other sites

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