/*
CREATE TABLE `changelog` (
`id` INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
`changelog` VARCHAR(300) NOT NULL,
`date` VARCHAR(30) NOT NULL,
`author` VARCHAR(24) NOT NULL,
PRIMARY KEY (`id`)
)
ENGINE = InnoDB;
*/
maintown,115,85,6 script Changelogs 837,{
if (getgmlevel() >= .minGMLevel) goto chlog_GM;
// -- Player Menu --
chlog_Player:
mes .npcname$;
mes "Hey choose the Changelog you want to read.";
// --- Generating Menu ---
query_sql "SELECT id FROM changelog ORDER BY id DESC LIMIT 1",@chamt;
@menu$ = "";
@limit = 0;
for (@i = @chamt; @i >= 1; @i=@i-1 ) {
query_sql "SELECT id,changelog,date,author FROM `changelog` WHERE id='"+@i+"'",@id,@changelog$,@date$,@author$;
query_sql "SELECT COUNT(*) FROM `changelog` WHERE id='"+@i+"'",@check;
if (@check == 0) continue;
@id2 = 1+(@id/10);
@id$ = @id2+"."+(@id%10);
set @menu$,""+@menu$+"Changelog "+@id$+" [ "+@date$+" ]";
if (@i >= 1) set @menu$,@menu$+":";
@limit=@limit+1;
if(@limit == .loglimit) break;
}
// -----------------------
@pick = select(@menu$);
next;
query_sql "SELECT id FROM `changelog` ORDER by id DESC LIMIT 1 OFFSET "+(@pick-1)+"",@pick;
query_sql "SELECT id,changelog,date,author FROM `changelog` WHERE id='"+@pick+"'",@id,@changelog$,@date$,@author$;
@id2 = 1+(@id/10);
@id$ = @id2+"."+(@id%10);
@chcount = countstr(@changelog$, "|");
explode(@changelog$, @changelog$, "|");
mes "[Changelog "+@id$+"]";
for (@i = 0; @i < @chcount; @i=@i+1) mes "ï "+@changelog$[@i];
mes " ";
mes "By : "+@author$+"";
next;
mes .npcname$;
mes "Do you want to read other logs ?";
next;
if(select("Yes:No")==1) goto chlog_Player;
mes .npcname$;
mes "Ok, Happy RO ^^";
close;
// -----------------
// -- GM Menu --
chlog_GM:
@a = 0;
@finish = 0;
mes .npcname$;
mes "Hello Mr. "+strcharinfo(0)+".";
mes "How can I assist you ?";
next;
menu "~ Add a Change Log",chlog_add,
"~ Edit a Change Log",chlog_edit,
"~ Remove a Change Log",chlog_rm,
"~ Clear all the Change Logs",chlog_clear,
"~ Open Player Menu",chlog_Player;
chlog_add:
// --- Tutorial about adding Change Log --
if (#ch_tutorial != 1) {
ch_tutor:
mes .npcname$;
mes "Okay I guess it's your first time adding changelog. I'll throw you an example.";
next;
mes .npcname$;
mes "This is the example: ";
mes " ";
mes "[^FF0000Changelog 1.1^000000]";
mes "ï ^3661deAdded new monster 'Poring'^000000";
mes "ï ^de8229Pressure now deals 3000 fixed damage^000000";
mes "ï ^3661deRune Knight now rides Lunatic instead of Peco^000000";
mes " ";
mes " ------------- ";
mes "^515151Author: 2essy2killu^000000";
mes "^515151Date: 12-07-1997^000000";
next;
mes .npcname$;
mes "First you are going to add the change points";
mes "From the previous example you are going to add 3 Point";
mes "Added New monster 'poring";
mes " ";
mes "Pressure now deals 3000 fixed damage";
mes " ";
mes "Rune Knight now rides Lunatic instead of Peco";
next;
mes .npcname$;
mes "Date and Author can be removed from the Changelog though from the Configuration menu";
next;
mes .npcname$;
mes "Do you want to hear the tutorial again ?";
next;
menu "Yes",ch_tutor,"No",ch_tutor_x;
ch_tutor_x:
#ch_tutorial = 1;
}
// -----------------------------------------
do {
mes .npcname$;
mes "Input a note:";
if (@a > 0) mes "You have added "+@a+" note(s).";
if (@a > 0) mes "Previous Point : "+@point$[@a-1]+".";
mes " ";
mes " - Commands -";
mes "input 0 to cancel the whole thing";
mes "input 1 to finish and save";
mes "input 2 to delete the last point";
input @point$[@a];
if(@point$[@a] == "0") { end; }
else if(@point$[@a] == "1") { set @finish,1; }
else if(@point$[@a] == "2") {
@a=@a-1;
}
else { @a=@a+1; }
next;
} while (@finish != 1);
@pointmerge$ = "";
for( @i = 0; @i < @a; @i=@i+1 ) {
set @pointmerge$,@pointmerge$+""+@point$[@i];
if (@i < @a) set @pointmerge$,@pointmerge$+"|";
}
set @date$,""+gettime(5)+"-"+gettime(6)+"-"+gettime(7)+"";
query_sql "INSERT INTO `changelog` (changelog, date, author) VALUES ('"+@pointmerge$+"','"+@date$+"','"+strcharinfo(0)+"')";
if(.broadcast == 1) announce strcharinfo(0)+" has added a new changelog.",bc_all;
mes .npcname$;
mes "You've successfully added a Change Log";
end;
chlog_edit:
mes .npcname$;
mes "Hey choose the Changelog you want to edit.";
// --- Generating Menu ---
query_sql "SELECT id FROM changelog ORDER BY id DESC LIMIT 1",@chamt;
@menu$ = "";
for (@i = 1; @i <= @chamt; @i=@i+1 ) {
query_sql "SELECT id,changelog,date,author FROM `changelog` WHERE id='"+@i+"'",@id,@changelog$,@date$,@author$;
query_sql "SELECT COUNT(*) FROM `changelog` WHERE id='"+@i+"'",@check;
if (@check == 0) continue;
@id2 = 1+(@id/10);
@id$ = @id2+"."+(@id%10);
set @menu$,""+@menu$+"Changelog "+@id$+" [ "+@date$+" ]";
if (@i < @chamt) set @menu$,@menu$+":";
}
// -----------------------
@pick = select(@menu$);
next;
do {
mes .npcname$;
mes "Input a note:";
if (@a > 0) mes "You have added "+@a+" note(s).";
if (@a > 0) mes "Previous Point : "+@point$[@a-1]+".";
mes " ";
mes " - Commands -";
mes "input 0 to cancel the whole thing";
mes "input 1 to finish and save";
mes "input 2 to delete the last point";
input @point$[@a];
if(@point$[@a] == "0") { end; }
else if(@point$[@a] == "1") { set @finish,1; }
else if(@point$[@a] == "2") {
@a=@a-1;
}
else { @a=@a+1; }
next;
} while (@finish != 1);
@pointmerge$ = "";
for( @i = 0; @i < @a; @i=@i+1 ) {
set @pointmerge$,@pointmerge$+""+@point$[@i];
if (@i < @a) set @pointmerge$,@pointmerge$+"|";
}
set @date$,""+gettime(5)+"-"+gettime(6)+"-"+gettime(7)+"";
query_sql "SELECT * FROM `changelog` LIMIT 1 OFFSET "+(@pick-1)+"",@pick;
query_sql "UPDATE `changelog` SET changelog='"+@pointmerge$+"' WHERE id='"+@pick+"'";
query_sql "SELECT id,changelog,date,author FROM `changelog` WHERE id='"+@pick+"'",@id,@changelog$,@date$,@author$;
@id2 = 1+(@id/10);
@id$ = @id2+"."+(@id%10);
if(.broadcast == 1) announce strcharinfo(0)+" has edited the Changelog "+@id$+".",bc_all;
mes .npcname$;
mes "You've successfully edited a Changelog";
end;
chlog_rm:
mes "Hey choose the Changelog you want to edit.";
// --- Generating Menu ---
query_sql "SELECT id FROM changelog ORDER BY id DESC LIMIT 1",@chamt;
@menu$ = "";
for (@i = 1; @i <= @chamt; @i=@i+1 ) {
query_sql "SELECT id,changelog,date,author FROM `changelog` WHERE id='"+@i+"'",@id,@changelog$,@date$,@author$;
query_sql "SELECT COUNT(*) FROM `changelog` WHERE id='"+@i+"'",@check;
if (@check == 0) continue;
@id2 = 1+(@id/10);
@id$ = @id2+"."+(@id%10);
set @menu$,""+@menu$+"Changelog "+@id$+" [ "+@date$+" ]";
if (@i < @chamt) set @menu$,@menu$+":";
}
// -----------------------
next;
@pick = select(@menu$);
query_sql "SELECT * FROM `changelog` LIMIT 1 OFFSET "+(@pick-1)+"",@pick;
query_sql "SELECT id,changelog,date,author FROM `changelog` WHERE id='"+@pick+"'",@id,@changelog$,@date$,@author$;
@id2 = 1+(@id/10);
@id$ = @id2+"."+(@id%10);
query_sql "DELETE from `changelog` WHERE id='"+@pick+"'";
mes .npcname$;
mes "You've successfully deleted a Changelog";
end;
chlog_clear:
mes .npcname$;
mes "^FF0000YOU ARE ABOUT TO REMOVE THE ENTIRE CHANGELOGS YOU'VE MADE";
mes "THIS CAN'T BE REVERTED OR RECOVERED^000000";
mes "Are you sure about this ?";
if(select("No:Yes") == 1) end;
query_sql "DELETE from `changelog` WHERE id>0";
next;
mes .npcname$;
mes "You've successfully deleted the whole changelog.";
end;
// -----------------
OnInit:
// ------------- Inline Configuration -----------------
set .npcname$,"[ ^3a68ffChangelog^000000 ]";
set .minGMLevel,99; // The minimum level of GM to make, edit, or remove a log.
set .broadcast,1; // 0=Disabled || 1=Enabled, broadcast when a GM edit / add a Change Log.
set .loglimit,5; // The Limit of Changelogs displayed
end;
// ----------------------------------------------------
}
Question
awesomazingxed
And how can i add this.
Thanks in advance.
Link to comment
Share on other sites
3 answers to this question
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.