Here's another unfinished script of mine (that I don't plan on finishing). Features right now include submitting tickets, and admins can view, delete, open, or close tickets. Never got around to scripting responses.
Modify NPC (Control-NPC):
PHP Code:
function onRCChat()
{
if (params[0] == "viewcomplaint")
findNPC("Complaint-Database").ViewComplaint(params[1]);
}
Create NPC (Complaint-Database):
PHP Code:
/*
NPC by Rapidwolve
*/
function onCreated()
createVariables();
function createVariables()
{
this.skip_flags = {"alerts_highlevel", "skip_flags", "registered_complaints", "allowed_admincenter", "debug_mode"};
this.alerts_highlevel = {"High", "Serious"};
this.debug_mode = false; // Output all actions to NC
this.allowed_admincenter = {"rapidwolve", "Frotter"}; // People allowed to the admin center
}
public function RegisterComplaint(complainer, category, seriousness, description)
{
temp.id = NextAvailableID();
this.("complaint_" @ temp.id) = {temp.complainer, temp.category, temp.seriousness, temp.description, "Open"};
findPlayer(temp.complainer).triggerClient("weapon", "-Complaint Reporter", "SentComplaint", temp.id);
if(temp.seriousness in this.alerts_highlevel)
sendMessage(format("New high priority ticket submitted by, %s. Index: %i", temp.complainer, temp.id), true);
this.registered_complaints ++;
}
public function NextAvailableID()
{
temp.currentid = 1;
while (this.("complaint_" @ temp.currentid)[0])
temp.currentid ++;
return (temp.currentid);
}
public function sendMessage(message, override)
{
if (this.debug_mode || temp.override)
echo(format("[Support Center]: %s", temp.message));
}
public function ViewComplaint(id)
{
temp.complaint = this.("complaint_" @ temp.id);
if (!temp.complaint[0]) return sendMessage("No such complaint index. " @ temp.id);
sendpm("--Viewing complaint (Index-" SPC temp.id @ ")--:" NL
"Complainer: " @ temp.complaint[0] NL
"Category: " @ temp.complaint[1] NL
"Priority: " @ temp.complaint[2] NL
"Description: " @ temp.complaint[3]);
}
public function GetSupportTickets(admin)
{
if (!(temp.admin in this.allowed_admincenter) && !(temp.admin == this.allowed_admincenter))
return findPlayer(temp.admin).triggerClient("weapon", "-Complaint Reporter", "NotAllowed");
temp.list.clear();
for (temp.i: this.getDynamicVarNames())
{
if (temp.i[0] in this.skip_flags) continue;
temp.idlist.add(temp.i.substring(("complaint_").length()));
temp.list.add((this.(@temp.i)));
}
findPlayer(temp.admin).triggerClient("weapon", "-Complaint Reporter", "RefreshTicketsList", temp.list, temp.idlist);
}
public function GetPlayerSupportTickets(account)
{
temp.list.clear();
for (temp.i: this.getDynamicVarNames())
{
if ((temp.i[0] in this.skip_flags) || (this.(@temp.i)[0] != temp.account)) continue;
temp.idlist.add(temp.i.substring(("complaint_").length()));
temp.list.add((this.(@temp.i)));
}
findPlayer(temp.account).triggerClient("weapon", "-Complaint Reporter", "RefreshMyTicketsList", temp.list, temp.idlist);
}
public function GetSupportTicket(id, admin)
findPlayer(temp.admin).triggerClient("weapon", "-Complaint Reporter", "ViewSupportTicket", temp.id, this.("complaint_" @ temp.id));
public function CloseTicket(id){
sendMessage(format("%s has closed ticket %i", player.account, temp.id));
this.("complaint_" @ temp.id)[4] = "Closed";
}
public function OpenTicket(id){
sendMessage(format("%s has opened ticket %i", player.account, temp.id));
this.("complaint_" @ temp.id)[4] = "Open";
}
public function DeleteTicket(id){
sendMessage(format("%s has deleted ticket %i", player.account, temp.id));
this.("complaint_" @ temp.id).clear();
this.("complaint_" @ temp.id) == ""; // double check
}
public function toggleTicketStatus(id){
temp.ticket = this.("complaint_" @ temp.id)[4];
((temp.ticket == "Open") ? CloseTicket(temp.id):OpenTicket(temp.id));
}
Images can be found at:
http://forums.graal2001.com/forums/s...ad.php?t=73510