Bueno, primero que nada, revisando el foro de scripting de eAthena consegui esto...
Para implementarlo, debe vaciarse primero el script sql para modificar la BD... (tambien pueden hacer los cambios manualmente).
.sql que debe ser importado:USE `ragnarok`;
CREATE TABLE `support_response` (
`ticket_id` int(11) NOT NULL,
`reply_number` int(11) NOT NULL default '1',
`char_name` varchar(24) NOT NULL default '',
`char_id` int(11) unsigned NOT NULL default '0',
`message` varchar(80) NOT NULL default '',
`status_change` decimal(10,0) NOT NULL default '-1',
`date` datetime NULL
) TYPE=InnoDB;
CREATE TABLE `support_ticket` (
`ticket_id` int(11) NOT NULL auto_increment,
`status` tinyint(1) NOT NULL default '0',
`char_name` varchar(24) NOT NULL default '',
`char_id` int(11) unsigned NOT NULL default '0',
`title` varchar(45) NOT NULL default '',
`message` varchar(80) NOT NULL default '',
`date` datetime NULL,
PRIMARY KEY (`ticket_id`)
) TYPE=InnoDB;
Esto permite que sea agregado el NPC como tal en la carpeta "
npc/custom/" del emulador.
El codigo del npc es el siguiente:
//===== eAthena Unofficial Script ============================
//= Support Ticket System
//===== By: ==================================================
//= [GM]Xeon
//===== Current Version: =====================================
//= 1.2
//===== Compatible With: =====================================
//= Latest versions of SQL, stable and trunk?
//===== Description: =========================================
//= The core engine for the Support Ticket system, please
//= ensure you first installed the MySQL script located at
//= http://svn.massemu.com/ro/branches/script/ST_1.1.sql
//===== Additional Comments: =================================
//= 1.0 Script created ;D [[GM]Xeon]
//= 1.1 Added missed character name display, fixed a couple
//= other bugs [[GM]Xeon]
//= 1.2 Optimized and added delete tickets function [[GM]Xeon]
//============================================================
prontera.gat,171,178,1 script Support Tickets 806,{
if (getgmlevel() >= 40) goto L_GM;
L_Main:
mes "[Tickets de Soporte]";
mes "Hola, Soy el NPC de Tickets de Soporte, ¿Como puedo ayudarte?";
next;
switch(select("Publicar un Ticket","Ver Ticket(s)","Salir")) {
case 1:
goto L_NewTicket;
case 2:
goto L_ListTickets;
case 3:
close;
}
L_NewTicket:
mes "[Tickets de Soporte]";
mes "Introduce el Titulo del Ticket (Max 24 caracteres.), o introduce un espacio para cancelar.";
next;
input @msg_title$;
set @msg_title$, escape_sql(@msg_title$);
if (@msg_title$ == " ") goto L_Main;
mes "[Tickets de Soporte]";
mes "Introduce el mensaje del ticket, o un espacio para cancelar.";
next;
input @msg_base$;
set @msg_base$, escape_sql(@msg_base$);
if (@msg_base$ == " ") goto L_Main;
query_sql "insert into `support_ticket` (char_name,char_id,title,message,date) values ('"+escape_sql(strcharinfo(0))+"',"+getcharid(0)+",'"+@msg_title$+"','"+@msg_base$+"', now())";
mes "[Tickets de Soporte]";
mes "Ticket de Soporte fue publicado correctamente";
next;
goto L_Main;
L_ListTickets:
set @tickets, query_sql("select ticket_id,status,title,message,date from `support_ticket` where char_id = "+getcharid(0)+" order by date desc limit 10",@ticket_id,@status,@title$,@message$,@date$);
mes "[Support Tickets]";
if (@tickets > 0) mes "Selecciona un Ticket para observarlo.";
if (@tickets == 0) {
mes "Actualmente no tienes tickets.";
next;
goto L_Main;
}
set @temp,0;
while (@temp < @tickets) {
if (@status[@temp] == 0) set @title2$[@temp], "^339900"+@title$[@temp]+"^000000";
if (@status[@temp] == 1) set @title2$[@temp], "^FF0000"+@title$[@temp]+"^000000";
if (@status[@temp] > 1) set @title2$[@temp], "^FF9900"+@title$[@temp]+"^000000";
set @temp,@temp+1;
}
next;
switch(select("Back",@title2$[0],@title2$[1],@title2$[2],@title2$[3],@title2$[4],@title2$[5],@title2$[6],@title2$[7],@title2$[8],@title2$[9])) {
case 1:
goto L_Main;
case 2:
set @view, 0;
goto L_ViewTicket;
case 3:
set @view, 1;
goto L_ViewTicket;
case 4:
set @view, 2;
goto L_ViewTicket;
case 5:
set @view, 3;
goto L_ViewTicket;
case 6:
set @view, 4;
goto L_ViewTicket;
case 7:
set @view, 5;
goto L_ViewTicket;
case 8:
set @view, 6;
goto L_ViewTicket;
case 9:
set @view, 7;
goto L_ViewTicket;
case 10:
set @view, 8;
goto L_ViewTicket;
case 11:
set @view, 9;
goto L_ViewTicket;
}
L_ViewTicket:
mes "[Tickets de Soporte]";
mes "^808080Titulo: ^9900CC"+@title$[@view]+"^000000";
mes "^808080Mensaje: ^9900CC"+@message$[@view]+"^000000";
set @replies, query_sql("select reply_number,char_name,message,status_change from `support_response` where ticket_id = "+@ticket_id[@view]+" order by reply_number asc",@reply_number,@char_name$,@message_reply$,@status_change);
set @temp, 0;
while (@temp < @replies) {
mes "^C9C9C9-^000000";
if (@message$[@view] == "†" && @char_name$[@temp] == strcharinfo(0)) mes "^808080Cambio de Status de: ^339900"+@char_name$[@temp]+"^000000";
if (@message$[@view] == "†" && @char_name$[@temp] != strcharinfo(0)) mes "^808080Cambio de Status de: ^0066FF"+@char_name$[@temp]+"^000000";
if (@message$[@view] != "†" && @char_name$[@temp] == strcharinfo(0)) {
mes "^808080Respuesta de: ^339900"+@char_name$[@temp]+"^000000";
mes "^808080Mensaje: ^339900"+@message_reply$[@temp]+"^000000";
}
if (@message$[@view] != "†" && @char_name$[@temp] != strcharinfo(0)) {
mes "^808080Respuesta de: ^0066FF"+@char_name$[@temp]+"^000000";
mes "^808080Mensaje: ^0066FF"+@message_reply$[@temp]+"^000000";
}
if (@status_change[@temp] == 0) mes "^FF9900>Status cambiado a ^339900ABIERTO^000000";
if (@status_change[@temp] == 1) mes "^FF9900>Status cambiado a ^FF0000CERRADO^000000";
if (@status_change[@temp] == 2) mes "^FF9900>Status cambiado a ESPERANDO^000000";
if (@status_change[@temp] == 3) mes "^FF9900>Status cambiado a ASIMIENTO^000000";
set @temp,@temp+1;
}
next;
switch(select(((@status[@view]==1)?"^C9C9C9":"")+"Responder^000000",((@status[@view]==1)?"^C9C9C9":"")+"Cerrar Ticket^000000","Atras")) {
case 1:
if (@status[@view] == 1) {
mes "[Tickets de Soporte]";
mes "No puedes responder a tickets cerrados!";
next;
goto L_ViewTicket;
}
mes "[Tickets de Soporte]";
mes "Introduce la respuesta, o un espacio para cancelar.";
input @msg$;
set @msg$, escape_sql(@msg$);
if (@msg$ == " ") {
next;
goto L_ViewTicket;
}
if (@status[@view] == 2) {
query_sql "insert into `support_response` values ("+@ticket_id[@view]+","+(@replies+1)+",'"+escape_sql(strcharinfo(0))+"',"+getcharid(0)+",'"+@msg$+"',0,now())";
query_sql "update `support_ticket` set status = 0 where ticket_id = "+@ticket_id[@view];
} else {
query_sql "insert into `support_response` values ("+@ticket_id[@view]+","+(@replies+1)+",'"+escape_sql(strcharinfo(0))+"',"+getcharid(0)+",'"+@msg$+"','-1',now())";
}
mes "[Tickets de Soporte]";
mes "Respuesta publicada";
next;
goto L_ListTickets;
case 2:
if (@status[@view] == 1) {
mes "[Tickets de Soporte]";
mes "Este ticket ya esta cerrado!";
next;
goto L_ViewTicket;
}
query_sql "insert into `support_response` values ("+@ticket_id[@view]+","+(@replies+1)+",'"+escape_sql(strcharinfo(0))+"',"+getcharid(0)+",'†',1,now())";
query_sql "update `support_ticket` set status = 1 where ticket_id = "+@ticket_id[@view];
mes "[Tickets de Soporte]";
mes "Ticket de Soporte ha sido cerrado!";
next;
goto L_ListTickets;
case 3:
next;
goto L_ListTickets;
}
L_GM:
mes "[Tickets de Soporte]";
mes "Hola GM, en que puedo ayudar?";
next;
switch(select("Ver tickets","Buscar Tickets","Salir","Probar")) {
case 1:
set @open, query_sql("select ticket_id,status,title,message,date from `support_ticket` where status = 0 order by date desc limit 128",@open_ticket_id,@open_status,@open_title$,@open_message$,@open_date$);
set @waiting, query_sql("select ticket_id,status,title,message,date from `support_ticket` where status = 2 order by date desc limit 128",@waiting_ticket_id,@waiting_status,@waiting_title$,@waiting_message$,@waiting_date$);
set @onhold, query_sql("select ticket_id,status,title,message,date from `support_ticket` where status = 3 order by date desc limit 128",@onhold_ticket_id,@onhold_status,@onhold_title$,@onhold_message$,@onhold_date$);
set @closed, query_sql("select ticket_id,status,title,message,date from `support_ticket` where status = 1 order by date desc limit 128",@closed_ticket_id,@closed_status,@closed_title$,@closed_message$,@closed_date$);
switch(select("^339900View Open ["+@open+"]","^FF9900View Waiting ["+@waiting+"]","^FF9900View On Hold ["+@onhold+"]","^FF0000View Closed ["+@closed+"]","^000000Back")) {
case 1:
set @temptic, 0;
goto L_GMListTickets;
case 2:
set @temptic, 1;
goto L_GMListTickets;
case 3:
set @temptic, 2;
goto L_GMListTickets;
case 4:
set @temptic, 3;
goto L_GMListTickets;
case 5:
}
case 2:
switch(select("Por Titulo","Por contenido","Por ID de ticket","Por nombre de Usuario","Por Char ID","Atras")) {
case 1:
mes "[Tickets de Soporte]";
mes "Introduce parte o todo del titulo a buscar.";
input @input$;
next;
set @tickets, query_sql("select ticket_id,char_name,char_id,status,title,message,date from `support_ticket` where title regexp = '"+escape_sql(@input$)+"' order by date desc limit 128",@ticket_id,@charname$,@charid,@status,@title$,@message$,@date$);
goto L_GMListTickets;
case 2:
mes "[Tickets de Soporte]";
mes "Introduce Parte o Todo del contenido a buscar.";
input @input$;
next;
set @tickets, query_sql("select ticket_id,char_name,char_id,status,title,message,date from `support_ticket` where message regexp = '"+escape_sql(@input$)+"' order by date desc limit 128",@ticket_id,@charname$,@charid,@status,@title$,@message$,@date$);
goto L_GMListTickets;
case 3:
mes "[Tickets de Soporte]";
mes "Introduce el ID del Ticket a buscar";
input @input;
next;
set @tickets, query_sql("select ticket_id,char_name,char_id,status,title,message,date from `support_ticket` where ticket_id = "+@input+" order by date desc limit 128",@ticket_id,@charname$,@charid,@status,@title$,@message$,@date$);
goto L_GMListTickets;
case 4:
mes "[Tickets de Soporte]";
mes "Introduce parte o todo el nombre del jugador.";
input @input$;
next;
set @tickets, query_sql("select ticket_id,char_name,char_id,status,title,message,date from `support_ticket` where char_name regexp = '"+escape_sql(@input$)+"' order by date desc limit 128",@ticket_id,@charname$,@charid,@status,@char_name$,@title$,@message$,@date$);
set @search, 1;
goto L_GMListTickets;
case 5:
mes "[Tickets de Soporte]";
mes "Introduce el Char ID a buscar";
input @input;
next;
set @tickets, query_sql("select ticket_id,char_name,char_id,status,title,message,date from `support_ticket` where char_id = "+@input+" order by date desc limit 128",@ticket_id,@charname$,@charid,@status,@title$,@message$,@date$);
goto L_GMListTickets;
case 6:
}
case 3:
close;
case 4:
next;
goto L_Main;
}
L_GMListTickets:
//cleararray ??
if (@temptic == 0) {
set @tickets, @open;
copyarray @ticket_id[0],@open_ticket_id[0],128;
copyarray @charname$[0],@open_charname$[0],128;
copyarray @charid[0],@open_charid[0],128;
copyarray @status[0],@open_status[0],128;
copyarray @title$[0],@open_title$[0],128;
copyarray @message$[0],@open_message$[0],128;
copyarray @date$[0],@open_date$[0],128;
}
if (@temptic == 1) {
set @tickets, @waiting;
copyarray @ticket_id[0],@waiting_ticket_id[0],128;
copyarray @charname$[0],@waiting_charname$[0],128;
copyarray @charid[0],@waiting_charid[0],128;
copyarray @status[0],@waiting_status[0],128;
copyarray @title$[0],@waiting_title$[0],128;
copyarray @message$[0],@waiting_message$[0],128;
copyarray @date$[0],@waiting_date$[0],128;
}
if (@temptic == 2) {
set @tickets, @onhold;
copyarray @ticket_id[0],@onhold_ticket_id[0],128;
copyarray @charname$[0],@onhold_charname$[0],128;
copyarray @charid[0],@onhold_charid[0],128;
copyarray @status[0],@onhold_status[0],128;
copyarray @title$[0],@onhold_title$[0],128;
copyarray @message$[0],@onhold_message$[0],128;
copyarray @date$[0],@onhold_date$[0],128;
}
if (@temptic == 3) {
set @tickets, @closed;
copyarray @ticket_id[0],@closed_ticket_id[0],128;
copyarray @charname$[0],@closed_charname$[0],128;
copyarray @charid[0],@closed_charid[0],128;
copyarray @status[0],@closed_status[0],128;
copyarray @title$[0],@closed_title$[0],128;
copyarray @message$[0],@closed_message$[0],128;
copyarray @date$[0],@closed_date$[0],128;
}
L_GMListTickets2:
if (@tickets == 0) {
mes "[Tickes de Soporte]";
mes "No hay tickets para mostrar en esta categoria.";
next;
goto L_GM;
}
mes "[Tickets de Soporte]";
mes "Selecciona un ticket para ver, borrar, editar o responder.";
set @temp,0;
while (@temp < @tickets) {
if (@status[@temp] == 0) set @title2$[@temp], "^339900"+@title$[@temp]+"^000000";
if (@status[@temp] == 1) set @title2$[@temp], "^FF0000"+@title$[@temp]+"^000000";
if (@status[@temp] > 1) set @title2$[@temp], "^FF9900"+@title$[@temp]+"^000000";
set @temp,@temp+1;
}
next;
set @temp, 0;
L_GMMore:
set @temp2, @temp+11;
if (@temp2 > @tickets) set @temp2, @tickets;
if (@temp+1 != @temp2) {
mes "Viendo Tickets ["+(@temp+1)+"-"+@temp2+"]";
} else {
mes "Viendo Ticket "+(@temp+1);
}
if (@search == 0) {
set @display$[0], @title2$[@temp];
set @display$[1], @title2$[@temp+1];
set @display$[2], @title2$[@temp+2];
set @display$[3], @title2$[@temp+3];
set @display$[4], @title2$[@temp+4];
set @display$[5], @title2$[@temp+5];
set @display$[6], @title2$[@temp+6];
set @display$[7], @title2$[@temp+7];
set @display$[8], @title2$[@temp+8];
set @display$[9], @title2$[@temp+9];
}
if (@search == 1) {
set @display$[0], @charname$[@temp] + ", " + @title2$[@temp];
set @display$[1], @charname$[@temp+1] + ", " + @title2$[@temp+1];
set @display$[2], @charname$[@temp+2] + ", " + @title2$[@temp+2];
set @display$[3], @charname$[@temp+3] + ", " + @title2$[@temp+3];
set @display$[4], @charname$[@temp+4] + ", " + @title2$[@temp+4];
set @display$[5], @charname$[@temp+5] + ", " + @title2$[@temp+5];
set @display$[6], @charname$[@temp+6] + ", " + @title2$[@temp+6];
set @display$[7], @charname$[@temp+7] + ", " + @title2$[@temp+7];
set @display$[8], @charname$[@temp+8] + ", " + @title2$[@temp+8];
set @display$[9], @charname$[@temp+9] + ", " + @title2$[@temp+9];
}
set @search, 0;
switch(select("Atras","Mas",@display$[0],@display$[1],@display$[2],@display$[3],@display$[4],@display$[5],@display$[6],@display$[7],@display$[8],@display$[9])) {
case 1:
goto L_GM;
case 2:
if (@temp2 < 120) {
set @temp, @temp+10;
} else {
mes "[Tickets de Soporte]";
mes "Solo puedes ver 128 Tickets por categoria sin cambiar su Status.";
next;
goto L_GM;
}
if (@temp2 + 10 >= @tickets) {
mes "[Tickets de Soporte]";
mes "No hay mas tickets que mostrar.";
next;
goto L_GM;
}
set @temp, @temp+10;
goto L_GMMore;
case 3:
set @view, @temp;
goto L_GMViewTicket;
case 4:
set @view, @temp+1;
goto L_GMViewTicket;
case 5:
set @view, @temp+2;
goto L_GMViewTicket;
case 6:
set @view, @temp+3;
goto L_GMViewTicket;
case 7:
set @view, @temp+4;
goto L_GMViewTicket;
case 8:
set @view, @temp+5;
goto L_GMViewTicket;
case 9:
set @view, @temp+6;
goto L_GMViewTicket;
case 10:
set @view, @temp+7;
goto L_GMViewTicket;
case 11:
set @view, @temp+8;
goto L_GMViewTicket;
case 12:
set @view, @temp+9;
goto L_GMViewTicket;
}
L_GMViewTicket:
mes "[Tickets de Soporte]";
mes "^808080Publicado por: ^9900CC"+@charname$[@view]+" ["+@charid[@view]+"]^000000";
mes "^808080Titulo: ^9900CC"+@title$[@view]+"^000000";
mes "^808080Mensaje: ^9900CC"+@message$[@view]+"^000000";
set @replies, query_sql("select reply_number,char_name,message,status_change from `support_response` where ticket_id = "+@ticket_id[@view]+" order by reply_number asc",@reply_number,@char_name$,@message_reply$,@status_change);
set @temp, 0;
while (@temp < @replies) {
mes "^C9C9C9-^000000";
if (@message$[@view] == "†" && @char_name$[@temp] == strcharinfo(0)) mes "^808080Status Cambiado de: ^339900"+@char_name$[@temp]+"^000000";
if (@message$[@view] == "†" && @char_name$[@temp] != strcharinfo(0)) mes "^808080Status Cambiado de: ^0066FF"+@char_name$[@temp]+"^000000";
if (@message$[@view] != "†" && @char_name$[@temp] == strcharinfo(0)) {
mes "^808080Respuesta de: ^0066FF"+@char_name$[@temp]+"^000000";
mes "^808080Mensaje: ^0066FF"+@message_reply$[@temp]+"^000000";
}
if (@message$[@view] != "†" && @char_name$[@temp] != strcharinfo(0)) {
mes "^808080Respuesta de: ^339900"+@char_name$[@temp]+"^000000";
mes "^808080Mensaje: ^339900"+@message_reply$[@temp]+"^000000";
}
if (@status_change[@temp] == 0) mes "^FF9900>Status cambiado a ^339900Abierto^000000";
if (@status_change[@temp] == 1) mes "^FF9900>Status cambiado a ^FF0000Cerrado^000000";
if (@status_change[@temp] == 2) mes "^FF9900>Status cambiado a Esperando^000000";
if (@status_change[@temp] == 3) mes "^FF9900>Status cambiado a Asimiento^000000";
set @temp,@temp+1;
}
next;
switch(select("Responder","Cambiar Status [Sin Responder]","Borrar Ticket","Atras")) {
case 1:
mes "[Tickets de Soporte]";
mes "Introduce la respuesta, o un espacio para cancelar";
input @msg$;
set @msg$, escape_sql(@msg$);
if (@msg$ == " ") {
next;
goto L_GMViewTickets2;
}
next;
mes "[Tickets de Soporte]";
mes "Introduce el nuevo Status";
next;
menu "^FF9900Esperando",-,"^FF0000Cerrado",-,"^FF9900Asimiento",-,"^339900Abierto",-,"^000000No Cambiar",-;
if (@menu == 1) set @stat, 2;
if (@menu == 2) set @stat, 1;
if (@menu == 3) set @stat, 3;
if (@menu == 4) set @stat, 0;
if (@menu == 5) set @stat, -1;
if (@stat > -1 && @stat != @status[@view]) {
query_sql "insert into `support_response` values ("+@ticket_id[@view]+","+(@replies+1)+",'"+escape_sql(strcharinfo(0))+"',"+getcharid(0)+",'"+@msg$+"',"+@stat+",now())";
query_sql "update `support_ticket` set status = "+@stat+" where ticket_id = "+@ticket_id[@view];
} else {
query_sql "insert into `support_response` values ("+@ticket_id[@view]+","+(@replies+1)+",'"+escape_sql(strcharinfo(0))+"',"+getcharid(0)+",'"+@msg$+"','-1',now())";
}
mes "[Tickets de Soporte]";
mes "Respuesta publicada.";
next;
goto L_GMListTickets;
case 2:
mes "[Tickets de Soporte]";
mes "Introduce el nuevo Status";
next;
menu "^FF9900Esperando",-,"^FF0000Cerrado",-,"^FF9900Asimiento",-,"^339900Abierto",-,"^000000No cambiar",-;
if (@menu == 1) set @stat, 2;
if (@menu == 2) set @stat, 1;
if (@menu == 3) set @stat, 3;
if (@menu == 4) set @stat, 0;
if (@menu == 5) set @stat, -1;
if (@stat > -1 && @stat != @status[@view]) {
query_sql "insert into `support_response` values ("+@ticket_id[@view]+","+(@replies+1)+",'"+escape_sql(strcharinfo(0))+"',"+getcharid(0)+",'†',"+@stat+",now())";
query_sql "update `support_ticket` set status = "+@stat+" where ticket_id = "+@ticket_id[@view];
}
mes "[Tickets de Soporte]";
mes "Status Cambiado";
next;
goto L_GMListTickets2;
case 3:
mes "[Tickets de Soporte]";
mes "Estas SEGURO que quieres borrar este Ticket?!";
next;
switch(select("No","Si")) {
case 1:
goto L_GMViewTickets2;
case 2:
query_sql "delete from `support_ticket` where ticket_id = "+@ticket_id[@view];
query_sql "delete from `support_response` where ticket_id = "+@ticket_id[@view];
deletearray @ticket_id[@view],1;
deletearray @charname$[@view],1;
deletearray @charid[@view],1;
deletearray @status[@view],1;
deletearray @title$[@view],1;
deletearray @message$[@view],1;
deletearray @date$[@view],1;
goto L_GMListTickets2;
}
case 4:
next;
goto L_GMListTickets2;
}
OnWhisperGlobal:
if (getgmlevel() < 40) goto L_Main;
goto L_GM;
}
PD: Ahora mismo lo estoy traduciendo al español.
Este archivo debe ser guardado en la carpeta /npc/custom/ Y luego agregar la siguiente linea al archivo ./npc/scripts_custom.conf
npc: npc/custom/NOMBREDELARCHIVO.txt
Cambiese NOMBREDELARCHIVO por el nombre del txt que le dimos al codigo anteriormente mencionado.
Fuente:
eAthena ForumPD2: estoy traduciendo, luego publico los cambios.
Saludos.