DUNGEON RECORD TIME

MikZ

New member
Messages
461
Points
0
Hi Hercules master scripters,

I would like to ask seek support on how to add in any instance like OrcsMemory.txt a record time.
For example:

Party 1 finish the instance @ 20mins and 1 sec - will announce " Congratulation to @party Name: @playername1, @playername2 and @Playername3. for clearing the dungeon for 00:21:01

then if another Party will finish the lesser 00:20:01 mins it will override the first record then announce and if higher nothing changes.

 
Before I start, I need to let you know a few things about my potential solution.

  1. I have never tried this before.
  2. I don't know how initnpctimer() interacts with instance NPCs.
  3. I don't have time to test. This might help you get started / understanding the process.
Code:
// Add this NPC script to the OrcsMemory.txt instance script.
	2@orcs,1,1,0    script    Orcs_Memory_Timer    FAKE_NPC,{
    end;
}
/*************
* Notes
**************
Immediately after the instance is created, add
this line below it:
	initnpctimer("Orcs_Memory_Timer");

I don't know how the Orc's Memory instance ends, but
when it ends (maybe you need to add an event for when
the mob is killed), add these lines:
	stopnpctimer("Orcs_Memory_Timer");
	.@time = getnpctimer("Orcs_Memory_Timer") / 1000;
	if (.@time < $Orcs_Memory_Record)
	{
   		// This next bit will display time as 00:00:00 format
        .@hour$ = .@time % (24*60*60) / (60*60) + "";
        .@min$  = .@time % (24*60*60) % (60*60) / (60) + "";
        .@sec$  = .@time % (24*60*60) % (60*60) % (60) + "";
        .@time$ = "" +(getstrlen(.@hour$) == 1 ? "0" : "")+ "" + .@hour$ + ":" +(getstrlen(.@min$) == 1 ? "0" : "")+ "" + .@min$ + ":" +(getstrlen(.@sec$) == 1 ? "0" : "")+ "" + .@sec$ + "";
        announce("The " + getpartyname(CHAR_ID_PARTY) + " party cleared the dungeon in " + .@time$ + ", a new record!", bc_all);
        $Orcs_Memory_Record = .@time;
	}

You will need to set the $Orcs_Memory_Timer to
something really high before the first party
does the instance. This is so the first party
to clear the dungeon will be the first record.
I advise going in-game and using the following
atcommand:
	@set $Orcs_Memory_Timer 1000000000
	(that's 1 billion seconds lol)
*************/
 
Last edited by a moderator:
Before I start, I need to let you know a few things about my potential solution.

  1. I have never tried this before.
  2. I don't know how initnpctimer() interacts with instance NPCs.
  3. I don't have time to test. This might help you get started / understanding the process.
Code:
// Add this NPC script to the OrcsMemory.txt instance script.
	2@orcs,1,1,0    script    Orcs_Memory_Timer    FAKE_NPC,{
    end;
}
/*************
* Notes
**************
Immediately after the instance is created, add
this line below it:
	initnpctimer("Orcs_Memory_Timer");

I don't know how the Orc's Memory instance ends, but
when it ends (maybe you need to add an event for when
the mob is killed), add these lines:
	stopnpctimer("Orcs_Memory_Timer");
	.@time = getnpctimer("Orcs_Memory_Timer") / 1000;
	if (.@time < $Orcs_Memory_Record)
	{
   		// This next bit will display time as 00:00:00 format
        .@hour$ = .@time % (24*60*60) / (60*60) + "";
        .@min$  = .@time % (24*60*60) % (60*60) / (60) + "";
        .@sec$  = .@time % (24*60*60) % (60*60) % (60) + "";
        .@time$ = "" +(getstrlen(.@hour$) == 1 ? "0" : "")+ "" + .@hour$ + ":" +(getstrlen(.@min$) == 1 ? "0" : "")+ "" + .@min$ + ":" +(getstrlen(.@sec$) == 1 ? "0" : "")+ "" + .@sec$ + "";
        announce("The " + getpartyname(CHAR_ID_PARTY) + " party cleared the dungeon in " + .@time$ + ", a new record!", bc_all);
        $Orcs_Memory_Record = .@time;
	}

You will need to set the $Orcs_Memory_Timer to
something really high before the first party
does the instance. This is so the first party
to clear the dungeon will be the first record.
I advise going in-game and using the following
atcommand:
	@set $Orcs_Memory_Timer 1000000000
	(that's 1 billion seconds lol)
*************/
Hi is there a way to query it to SQL?
Cuz I want to create NPCs where player can check dungeon record time with "Party Name and the Members"

 
First create a table, perhaps called orcs_memory
Btw, this is just off the top of my head. I cannot confirm works.

Code:
Create table with the following columns:

party_id (needs to be integer)
party_name (needs to be string)
time (needs to be string)

Then, the moment your instance completes,
you can the add following script:

.@PID = getcharid(CHAR_ID_PARTY);
.@PN$ = getpartyname(.@PID);
.@time$ = ...(I wrote in the last post how to get this)

query_sql("INSERT INTO `orcs_memory` VALUES (" + .@PID + ", '" + escape_sql(.@PN$) + "', '" + .@time$ + "')");

And then for your npc, the sql query:

prontera,150,150,3	script	Orcs Memory Rank	CLEAR_NPC,{
	query_sql("SELECT `party_name`, `time` FROM `orcs_memory` ORDER BY `time` ASC LIMIT 10", .@pname$, .@rank$);
	mes("Orcs Memory Rank");
	for (.@i = 0; .@i < getarraysize(.@rank$); ++.@i)
		mes("" + .@pname$[.@i] + " - " + .@rank$[.@i] + "");
	close;
}
 
First create a table, perhaps called orcs_memory
Btw, this is just off the top of my head. I cannot confirm w

Create table with the following columns:

party_id (needs to be integer)
party_name (needs to be string)
time (needs to be string)

Sorry, I'm still noob.
wanted to have 5 members only in party.

so that in checking NPC

Dungeon Record holder

Partyname: Member1, member2, member3, member4, member5.
I have this,
Is this correct?

CREATE TABLE IF NOT EXISTS `Orcs` (
`party_id` MEDIUMINT(7) NOT NULL DEFAULT '0',
`party_name` VARCHAR(24) NOT NULL,
`Name1` MEDIUMINT(6) NOT NULL DEFAULT '0',
`Name2` MEDIUMINT(6) NOT NULL DEFAULT '0',
`Name3` MEDIUMINT(6) NOT NULL DEFAULT '0',
`Name4` MEDIUMINT(6) NOT NULL DEFAULT '0',
`Name5` MEDIUMINT(6) NOT NULL DEFAULT '0',
`date_time` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
UNIQUE KEY `date` (`date_time`,`party_id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;


I have error,
Added this:

//== Entrance ==============================================
2@orcs,1,1,0 script Orcs_Memory_Timer FAKE_NPC,{
end;
}
gef_fild10,242,202,0 script Dimensional Gorge Piece 2_MONEMUS,{

.@party_id = getcharid(CHAR_ID_PARTY);
.@p_name$ = getpartyname(.@party_id);
.@md_name$ = "Orc's Memory";

Code:
OnMyMobDead:
	stopnpctimer("Orcs_Memory_Timer");
	.@PID = getcharid(CHAR_ID_PARTY);
	.@PN$ = getpartyname(.@PID);
	.@time = getnpctimer("Orcs_Memory_Timer") / 1000;
	if (.@time < $Orcs_Memory_Record)
	{
   		// This next bit will display time as 00:00:00 format
        .@hour$ = .@time % (24*60*60) / (60*60) + "";
        .@min$  = .@time % (24*60*60) % (60*60) / (60) + "";
        .@sec$  = .@time % (24*60*60) % (60*60) % (60) + "";
        .@time$ = "" +(getstrlen(.@hour$) == 1 ? "0" : "")+ "" + .@hour$ + ":" +(getstrlen(.@min$) == 1 ? "0" : "")+ "" + .@min$ + ":" +(getstrlen(.@sec$) == 1 ? "0" : "")+ "" + .@sec$ + "";
        announce("The " + getpartyname(CHAR_ID_PARTY) + " party cleared the dungeon in " + .@time$ + ", a new record!", bc_all);
        $Orcs_Memory_Record = .@time;
	}
	query_sql("INSERT INTO `orcs_memory` VALUES (" + .@PID + ", '" + escape_sql(.@PN$) + "', '" + .@time$ + "')");
	donpcevent instance_npcname("Kruger#")+"::OnEnable";
	.@map$ = instance_mapname("2@orcs");
	.@mob_ran = rand(1,5);
	if (.@mob_ran == 1) {
		mapannounce .@map$, "Shaman Cargalache: How... How could this be... How could someone like you...!!",bc_map,"0xffff00";
	}
	else if (.@mob_ran == 2) {
		mapannounce .@map$, "Shaman Cargalache: How is it that I've been overpowered by mere humans!",bc_map,"0xffff00";
	}
	else if (.@mob_ran == 3) {
		mapannounce .@map$, "Shaman Cargalache: This... This can't be the end...",bc_map,"0xffff00";
	}
	else if (.@mob_ran == 4) {
		mapannounce .@map$, "Shaman Cargalache: I... Can't die... Yet...!",bc_map,"0xffff00";
	}
	else {
		mapannounce .@map$, "Shaman Cargalache: Defeated by these fools... It can't be happening...!",bc_map,"0xffff00";
	}
	donpcevent instance_npcname("#2Resurrect Monsters1")+"::OnDisable";
	donpcevent instance_npcname("#2Resurrect Monsters3")+"::OnDisable";
	donpcevent instance_npcname("#Warp Outside Orc Dun")+"::OnEnable";
	end;
}

Resulted to

Code:
[Warning]: Unexpected type for argument 1. Expected number.
[Debug]: Data: string value="Orcs_Memory_Timer"
[Debug]: Function: getnpctimer
[Debug]: Source (NPC): #Boss Control at 0002@orcs (36,171)
[SQL]: DB error - Column count doesn't match value count at row 1
[Debug]: at d:\rao\hercules-master\src\map\script.c:17167 - INSERT INTO `orcs_memory` VALUES (0, '', '')
[Debug]: Source (NPC): #Boss Control at 0002@orcs (36,171)
 
Last edited by a moderator:
Hm well now you got a few more columns in your sql table. To get those party members, you can do this:
 

Code:
Add this... below .@PN$ = ...
	deletearray($@partymembername$[0]);
	getpartymember(.@PID, 0);


Run this SQL query to add the table to your DB...

CREATE TABLE IF NOT EXISTS `Orcs` (
  `party_id` INT(11) NOT NULL DEFAULT '0',
  `party_name` VARCHAR(24) NOT NULL,
  `name1` VARCHAR(24) NOT NULL,
  `name2` VARCHAR(24) NOT NULL,
  `name3` VARCHAR(24) NOT NULL,
  `name4` VARCHAR(24) NOT NULL,
  `name5` VARCHAR(24) NOT NULL,
  `time` VARCHAR(24) NOT NULL DEFAULT '00:00:00',
  `date` DATE NOT NULL DEFAULT CURRENT_TIMESTAMP
) ENGINE = MyISAM DEFAULT CHARSET=latin1;)

Replace your current insert query with this:

query_sql("INSERT INTO `Orcs` VALUES (" + .@PID + ", '" + escape_sql(.@PN$) + "', '" + escape_sql($@partymembername$[0] + "', '" + escape_sql($@partymembername$[1] + "', '" + escape_sql($@partymembername$[2] + "', '" + escape_sql($@partymembername$[3] + "', '" + escape_sql($@partymembername$[4] + "', '" + .@time$ + "', NOW())");

 
Last edited by a moderator:
Back
Top