Just so you know, we don't know the file format for every file. If it's just a bunch of random characters, it's probably a .zip or .jar.
on load:
create dir "contactlogs"
function leaveoncontact(p: player) :: text:
set {_id} to {_p}'s uuid
if {contactstaff::%{_id}%} is true:
delete {contactstaff::%{_id}%}
stop
set {_cid} to {contactstaff::%{_id}%}
delete {contactstaff::%{contactstaff::%{_cid}%::staffid}%}
delete {contactstaff::%{contactstaff::%{_cid}%::id}%}
send "&cStaffChat &fThe other party has left the server, this ticket has been closed." to {contactstaff::%{_cid}%::staff}
send "&cStaffChat &fThe other party has left the server, this ticket has been closed." to {contactstaff::%{_cid}%::user}
function stopcontact(p: player) :: text:
set {_id} to {_p}'s uuid
set {_cid} to {contactstaff::%{_id}%}
delete {contactstaff::%{contactstaff::%{_cid}%::staffid}%}
delete {contactstaff::%{contactstaff::%{_cid}%::id}%}
send "&cStaffChat &fThe contact chat room has been closed." to {contactstaff::%{_cid}%::staff}
send "&cStaffChat &fThe contact chat room has been closed." to {contactstaff::%{_cid}%::user}
command contact [<string>]:
trigger:
delete {_m}
delete {_a}
if {contactstaff::%uuid of player%} is true:
message "&cYou are already trying to contact a staff member"
stop
loop all players:
broadcast "%loop-player%"
if loop-player has permission "ContactStaff.admin":
add 1 to {_a}
add loop-player to {_tt::*}
else if loop-player has permission "ContactStaff.moderator":
broadcast "%loop-player%2"
add 1 to {_m}
add loop-player to {_tt::*}
set {_t} to {_a} + {_m}
wait 1 tick
if arg-1 is "staff":
if {_t} is 0:
message "&cThere is no staff currently online"
stop
message "&aTrying to contact staff member for 30 seconds"
set {contactstaff::%uuid of player%} to true
add 1 to {contactstaff::total}
set {contactstaff::%{contactstaff::total}%::user} to player
set {contactstaff::%{contactstaff::total}%::id} to uuid of player
add 1 to {contactstaff::%uuid of player%::times}
loop {_tt::*}:
send "" to loop-value
command "/tellraw %loop-value% ["""",{""text"":""---------------------------------------"",""color"":""green"",""clickEvent"":{""action"":""run_command"",""value"":""/contactaccept %{contactstaff::total}%""}}]"
command "/tellraw %loop-value% ["""",{""text"":""ContactStaff >> %player%"",""color"":""white"",""clickEvent"":{""action"":""run_command"",""value"":""/contactaccept %{contactstaff::total}%""}}]"
command "/tellraw %loop-value% ["""",{""text"":""---------------------------------------"",""color"":""green"",""clickEvent"":{""action"":""run_command"",""value"":""/contactaccept %{contactstaff::total}%""}}]"
send "" to loop-value
while {contactstaff::%uuid of player%} is true:
wait 1 second
add 1 to {_tries}
if {contactstaff::%uuid of player%} is set:
if {contactstaff::%uuid of player%} is not true:
stop
if {_tries} is 30:
delete {contactstaff::%uuid of player%}
message "&cAll staff members seem to be currently busy, you can try again later"
stop
stop
if {_t} is 0:
message "&cThere is no staff currently online"
stop
if {_a} is not set:
delete {_a}
set {_a} to 0
if {_m} is not set:
delete {_m}
set {_m} to 0
set {_afunnyname} to " "
if {_a} > 1:
set {_afunnyname} to "s"
if {_a} < 1:
set {_afunnyname} to "s"
send "&aThere are currently &f%{_a}%&a administrator%{_afunnyname}%"
set {_afunnyname} to " "
if {_m} > 1:
set {_afunnyname} to "s "
if {_m} < 1:
set {_afunnyname} to "s "
message "&a and &f%{_m}% &amoderator%{_afunnyname}%online"
command "/tellraw %player% ["""",{""text"":""Click "",""color"":""green""},{""text"":""here "",""color"":""gold"",""bold"":true,""italic"":true,""clickEvent"":{""action"":""run_command"",""value"":""/contact staff""}},{""text"":""to contact staff"",""color"":""green"",""bold"":false,""italic"":false}]"
on chat:
"%message%" starts with "!c"
cancel the event
{contactstaff::%uuid of player%} is set
if {contactstaff::%uuid of player%} is true:
message "&fNo one has responded to your request."
cancel the event
stop
set {_m} to "%message%"
replace all "!c" with "" in {_m}
set {_m2} to "%message%"
replace all "!c " with "" in {_m2}
if "%{_m2}%" is "[stop]":
stopcontact(player)
stop
if {contactstaff::%{contactstaff::%uuid of player%}%::staffid} is uuid of player:
if {rank::%uuid of player%} is "admins":
set {_r} to "Administrator"
else:
set {_r} to "Moderator"
send "&cStaffChat &a%{_r}% &f%{_m}%" to {contactstaff::%{contactstaff::%uuid of player%}%::staff}
send "&cStaffChat &a%{_r}% &f%{_m}%" to {contactstaff::%{contactstaff::%uuid of player%}%::user}
else if {contactstaff::%{contactstaff::%uuid of player%}%::id} is uuid of player:
send "&cStaffChat &a%player% &f%{_m}%" to {contactstaff::%{contactstaff::%uuid of player%}%::staff}
send "&cStaffChat &a%player% &f%{_m}%" to {contactstaff::%{contactstaff::%uuid of player%}%::user}
else:
message "&cAn error has occurred"
add 1 to {contactstaff::%{contactstaff::%uuid of player%}%::messages}
set {_unix} to convert date now to unix
write "%{contactstaff::%{contactstaff::%uuid of player%}%::messages}% - %{_unix}% - %player% >> %{_m}%" at line {contactstaff::%{contactstaff::%uuid of player%}%::messages} to file "contactlogs/%{contactstaff::%uuid of player%}%.txt"
on disconnect:
{contactstaff::%uuid of player%} is set
leaveoncontact(player)
on join:
{contactstaff::%uuid of player%} is set
leaveoncontact(player)
command contactaccept <integer>:
trigger:
player has permission "ContactStaff.admin" or "ContactStaff.moderator"
if {contactstaff::%arg-1%::id} is not set:
message "&cThere is an error in the contacting code, or you entered the command manually"
stop
if {contactstaff::%{contactstaff::%arg-1%::id}%} is not set:
message "&cThis request has already expired"
stop
if {contactstaff::%{contactstaff::%arg-1%::id}%} is not true:
message "&cThis request has already been taken by %{contactstaff::%arg-1%::staff}%"
stop
set {contactstaff::%uuid of player%} to arg-1
set {contactstaff::%{contactstaff::%arg-1%::id}%} to arg-1
set {contactstaff::%arg-1%::staff} to player
set {contactstaff::%arg-1%::staffid} to uuid of player
if {rank::%uuid of player%} is "admins":
send "" to {contactstaff::%arg-1%::user}
send "&7&m-----------------" to {contactstaff::%arg-1%::user}
send " &fAn administrator has responded to your contact request" to {contactstaff::%arg-1%::user}
send " &fYou can chat by putting ""!c"" in front of your message" to {contactstaff::%arg-1%::user}
send "" to {contactstaff::%arg-1%::user}
send " &8(ex. !c Hello)" to {contactstaff::%arg-1%::user}
send "" to {contactstaff::%arg-1%::user}
send " &fAnd you can close the contact room by typing" to {contactstaff::%arg-1%::user}
send " &8!c [stop]" to {contactstaff::%arg-1%::user}
send "&7&m-----------------" to {contactstaff::%arg-1%::user}
send "" to {contactstaff::%arg-1%::user}
send "" to player
send "&7&m-----------------" to player
send " &fYou can chat by putting ""!c"" in front of your message" to player
send "" to player
send " &8(ex. !c Hello)" to player
send "" to player
send " &fAnd you can close the contact room by typing" to player
send " &8!c [stop]" to player
send "&7&m-----------------" to player
send "" to player
else:
send "" to {contactstaff::%arg-1%::user}
send "&7&m-----------------" to {contactstaff::%arg-1%::user}
send " &fA moderator has responded to your contact request" to {contactstaff::%arg-1%::user}
send " &fYou can chat by putting ""!c"" in front of your message" to {contactstaff::%arg-1%::user}
send "" to {contactstaff::%arg-1%::user}
send " &8(ex. !c Hello)" to {contactstaff::%arg-1%::user}
send "" to {contactstaff::%arg-1%::user}
send " &fAnd you can close the contact room by typing" to {contactstaff::%arg-1%::user}
send " &8!c [stop]" to {contactstaff::%arg-1%::user}
send "&7&m-----------------" to {contactstaff::%arg-1%::user}
send "" to {contactstaff::%arg-1%::user}
send "" to player
send "&7&m-----------------" to player
send " &fYou can chat by putting ""!c"" in front of your message" to player
send "" to player
send " &8(ex. !c Hello)" to player
send "" to player
send " &fAnd you can close the contact room by typing" to player
send " &8!c [stop]" to player
send "&7&m-----------------" to player
send "" to player
create file "contactlogs/%{contactstaff::%uuid of player%}%.txt"