Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting > Code Gallery
FAQ Members List Calendar Today's Posts

 
 
Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 05-01-2007, 01:21 AM
Rapidwolve Rapidwolve is offline
Registered User
Join Date: Jul 2006
Posts: 1,241
Rapidwolve is an unknown quantity at this point
Support Center System [Unfinished]

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(complainercategoryseriousnessdescription)
{
  
temp.id NextAvailableID();
  
this.("complaint_" temp.id) = {temp.complainertemp.categorytemp.seriousnesstemp.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.complainertemp.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(messageoverride)
{
  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[0NL
  
"Category: " temp.complaint[1NL
  
"Priority: " temp.complaint[2NL
  
"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.ithis.getDynamicVarNames())
  {
    if (
temp.i[0in 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.ithis.getDynamicVarNames())
  {
    if ((
temp.i[0in 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(idadmin)
  
findPlayer(temp.admin).triggerClient("weapon""-Complaint Reporter""ViewSupportTicket"temp.idthis.("complaint_" temp.id));

public function 
CloseTicket(id){
  
sendMessage(format("%s has closed ticket %i"player.accounttemp.id));
  
this.("complaint_" temp.id)[4] = "Closed";
}

public function 
OpenTicket(id){
  
sendMessage(format("%s has opened ticket %i"player.accounttemp.id));
  
this.("complaint_" temp.id)[4] = "Open";
}

public function 
DeleteTicket(id){
  
sendMessage(format("%s has deleted ticket %i"player.accounttemp.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
Reply With Quote
 


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 10:32 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.