Jump to content
  • 0

Auto Summon treasure and Kill


Question

Posted

hi, i have a problem with this script .... me loads without problems, but it does not work, you tell me where I'm wrong?

-	script	Trasure Coin		-1,{
	OnClock0300:
		announce "A rare Treasure Box will be spawned in Prontera",0;
		monster "prontera",0,0"Treasure Box Coin",1845,5,"TreasureBoxSummonerCoin::OnCoinBoxKilled";
		startnpctimer;
		end;
		
		OnTimer1000:
			announce "All treasure in Prontera are destroyed",0;
			killmonster "prontera","TreasureBoxSummonerCoin::OnCoinBoxKilled";
			setnpctimer,0;
			end;
			
	OnClock1600:
		announce "A rare Treasure Box will be spawned in Prontera",0;
		monster "prontera",0,0"Treasure Box Coin",1845,5,"TreasureBoxSummonerCoin::OnCoinBoxKilled";
		startnpctimer;
		end;
		
		OnTimer1000:
			announce "All treasure in Prontera are destroyed",0;
			killmonster "prontera","TreasureBoxSummonerCoin::OnCoinBoxKilled";
			setnpctimer,0;
			end;
	OnClock2400:
		announce "A rare Treasure Box will be spawned in Prontera",0;
		monster "prontera",0,0"Treasure Box Coin",1845,5,"TreasureBoxSummonerCoin::OnCoinBoxKilled";
		startnpctimer;
		end;
		
		OnTimer1000:
			announce "All treasure in Prontera are destroyed",0;
			killmonster "prontera","TreasureBoxSummonerCoin::OnCoinBoxKilled";
			setnpctimer,0;
			end;

	OnCoinBoxKilled:
		announce "The rare Treasure Box has been found and destroyed by "+strcharinfo(0)+"!", bc_all;
		getitem 7539,1; // Change your prize here 7539 Poring Coin
		end;
}

11 answers to this question

Recommended Posts

  • 0
Posted
Sorry for my English as colonial xD. You have an error in line 4, has missed you put      ,
 
 

 

monster "prontera",0,0          ,       "Treasure Box Coin",1845,5,"TreasureBoxSummonerCoin::OnCoinBoxKilled";

 

 
 
replace it by this

 

        monster "prontera",0,0,"Treasure Box Coin",1845,5,"TreasureBoxSummonerCoin::OnCoinBoxKilled";

  • 0
Posted


- script Trasure Coin -1,{

OnClock0300:

OnClock1600:

OnClock2400:

announce "A rare Treasure Box will be spawned in Prontera",0;

/*

- you miss a comma after ,0,0

- TreasureBoxSummonerCoin unknown NPC

*/

monster "prontera",0,0"Treasure Box Coin",1845,5,"TreasureBoxSummonerCoin::OnCoinBoxKilled";

startnpctimer;// better to use initnpctimer;

end;

OnTimer1000:

announce "All treasure in Prontera are destroyed",0;

killmonster "prontera","TreasureBoxSummonerCoin::OnCoinBoxKilled";// TreasureBoxSummonerCoin unknown NPC

setnpctimer,0;// Typo error ; It's better to use stopnpctimer;

end;

OnCoinBoxKilled:

announce "The rare Treasure Box has been found and destroyed by "+strcharinfo(0)+"!", bc_all;

getitem 7539,1; // Change your prize here 7539 Poring Coin

end;

}

  • 0
Posted (edited)

thank you, it works perfectly now :)

-	script	TreasureBoxSummonerCoin		-1,{
OnClock0300:
OnClock1600:
OnClock2230:
	announce "A rare Treasure Box will be spawned in Prontera",0;
	/*
		
	*/
	monster "prontera",0,0,"Treasure Box Coin",1845,5,"TreasureBoxSummonerCoin::OnCoinBoxKilled";
	initnpctimer;// better to use initnpctimer;
	end;
	
OnTimer1000:
	announce "All treasure in Prontera are destroyed",0;
	killmonster "prontera","TreasureBoxSummonerCoin::OnCoinBoxKilled";// TreasureBoxSummonerCoin unknown NPC
	stopnpctimer;// Typo error ; It's better to use stopnpctimer;
	end;

OnCoinBoxKilled:
	announce "The rare Treasure Box has been found and destroyed by "+strcharinfo(0)+"!", bc_all;
	getitem 7539,1; // Change your prize here 7539 Poring Coin
	end;
}

EDIT -------------------------

 

I have a small problem, when charge the npc rAthena gives me this error:
(Set_label: dup label)

Edited by Valcars
  • 0
Posted

You have an error when you load this NPC ?

dup label means you used a same label name in the npc (like OnTimer1000: twice or OnCoinBoxKilled: twice). Please post a ss of the error displayed by mapserv

 

And :

OnCoinBoxKilled:
	announce "The rare Treasure Box has been found and destroyed by "+strcharinfo(0)+"!", bc_all;
	getitem 7539,1; // Change your prize here 7539 Poring Coin
	stopnpctimer;// <-- add this
	end;
  • 0
Posted
OnCoinBoxKilled:

    set .@boxkills, .@boxkills +1; //how about this..
    announce "The rare Treasure Box has been found and destroyed by "+strcharinfo(0)+"!", bc_all;
    getitem 7539,1; // Change your prize here 7539 Poring Coin
    if (.@boxkills > 4) stopnpctimer;// <-- ..and this?
    end;

wouldn't the stopnpctimer in OnCoinBoxKilled prevent the killmonster event in label OnTimer1000 as soon as one box gets killed? Not sure if this here does the trick, the idea is ofc to count the kills of the 5 treasure boxes, so the timer stops only in case all of them are killed :) (maybe set .@boxkills to 0 when new boxes are spawned?).

  • 0
Posted
into practice it is like saying @Capuche, there are duplicates of the OnTimer variable.
I solved this way:
 
-	script	TreasureBoxSummonerCoin		-1,{
	
	
	
OnClock1500:
	set $@ran, rand(1,9);
	if ($@ran == 9) set $@jmpmap$,"hugel";
	if ($@ran == 8) set $@jmpmap$,"yuno";
	if ($@ran == 7) set $@jmpmap$,"comodo";
	if ($@ran == 6) set $@jmpmap$,"aldebaran";
	if ($@ran == 5) set $@jmpmap$,"izlude";
	if ($@ran == 4) set $@jmpmap$,"payon";
	if ($@ran == 3) set $@jmpmap$,"geffen";
	if ($@ran == 2) set $@jmpmap$,"morocc";
	if ($@ran == 1) set $@jmpmap$,"prontera";
	
	
	announce "A rare Treasure Box will be spawned in "+ $@jmpmap$ +".",bc_all|bc_npc;
	monster $@jmpmap$,0,0,"Treasure Box Coin",1845,5,"TreasureBoxSummonerCoin::OnCoinBoxKilled";
	initnpctimer;
	end;
	
OnTimer1800000: //30min
	announce "All treasure in "+ $@jmpmap$ +" are destroyed",bc_all|bc_npc;
	killmonster $@jmpmap$,"TreasureBoxSummonerCoin::OnCoinBoxKilled";// TreasureBoxSummonerCoin unknown NPC
	stopnpctimer;
	end;
	
	

OnClock1600:
	set $@ran, rand(1,9);
	if ($@ran == 9) set $@jmpmap$,"hugel";
	if ($@ran == 8) set $@jmpmap$,"yuno";
	if ($@ran == 7) set $@jmpmap$,"comodo";
	if ($@ran == 6) set $@jmpmap$,"aldebaran";
	if ($@ran == 5) set $@jmpmap$,"izlude";
	if ($@ran == 4) set $@jmpmap$,"payon";
	if ($@ran == 3) set $@jmpmap$,"geffen";
	if ($@ran == 2) set $@jmpmap$,"morocc";
	if ($@ran == 1) set $@jmpmap$,"prontera";
	
	
	announce "A rare Treasure Box will be spawned in "+ $@jmpmap$ +".",bc_all|bc_npc;
	monster $@jmpmap$,0,0,"Treasure Box Coin",1845,5,"TreasureBoxSummonerCoin::OnCoinBoxKilled";
	initnpctimer;
	end;
	
OnTimer1800001: //30min
	announce "All treasure in "+ $@jmpmap$ +" are destroyed",bc_all|bc_npc;
	killmonster $@jmpmap$,"TreasureBoxSummonerCoin::OnCoinBoxKilled";// TreasureBoxSummonerCoin unknown NPC
	stopnpctimer;
	end;
	
	

OnClock2400:

	set $@ran, rand(1,9);
	if ($@ran == 9) set $@jmpmap$,"hugel";
	if ($@ran == 8) set $@jmpmap$,"yuno";
	if ($@ran == 7) set $@jmpmap$,"comodo";
	if ($@ran == 6) set $@jmpmap$,"aldebaran";
	if ($@ran == 5) set $@jmpmap$,"izlude";
	if ($@ran == 4) set $@jmpmap$,"payon";
	if ($@ran == 3) set $@jmpmap$,"geffen";
	if ($@ran == 2) set $@jmpmap$,"morocc";
	if ($@ran == 1) set $@jmpmap$,"prontera";
	
	
	announce "A rare Treasure Box will be spawned in "+ $@jmpmap$ +".",bc_all|bc_npc;
	monster $@jmpmap$,0,0,"Treasure Box Coin",1845,5,"TreasureBoxSummonerCoin::OnCoinBoxKilled";
	initnpctimer;
	end;
	
OnTimer1800002: //30min
	announce "All treasure in "+ $@jmpmap$ +" are destroyed",bc_all|bc_npc;
	killmonster $@jmpmap$,"TreasureBoxSummonerCoin::OnCoinBoxKilled";// TreasureBoxSummonerCoin unknown NPC
	stopnpctimer;
	end;




OnCoinBoxKilled:
	announce "The rare Treasure Box has been found and destroyed by "+strcharinfo(0)+"!", bc_all;
	getitem 7539,1; // Change your prize here 7539 Poring Coin
	end;
}

but I'm thinking about a better solution .....

anyway @Capuche unnecessary screen that place .... the problem is that!

  • 0
Posted

Ha ok btw you did the same event under the others label, what about group them ?

-	script	TreasureBoxSummonerCoin		-1,{

OnClock1500:
OnClock1600:
OnClock2400:
	set $@ran, rand(1,9);// use .@ran (temporary variable only attached to this npc) instead of $@ran
	/*
	- what about an array ?
	setarray .@jmpmap$[1],
		"hugel",
		"yuno",
		"comodo",
		"aldebaran",
		"izlude",
		"payon",
		"geffen",
		"morocc",
		"prontera";
	- Then save you map name into a .variable$ (npc variable)
	.map_name$ = .@jmpmap$[.@ran];
	*/
	if ($@ran == 9) set $@jmpmap$,"hugel";
	if ($@ran == 8) set $@jmpmap$,"yuno";
	if ($@ran == 7) set $@jmpmap$,"comodo";
	if ($@ran == 6) set $@jmpmap$,"aldebaran";
	if ($@ran == 5) set $@jmpmap$,"izlude";
	if ($@ran == 4) set $@jmpmap$,"payon";
	if ($@ran == 3) set $@jmpmap$,"geffen";
	if ($@ran == 2) set $@jmpmap$,"morocc";
	if ($@ran == 1) set $@jmpmap$,"prontera";

	announce "A rare Treasure Box will be spawned in "+ $@jmpmap$ +".",bc_all|bc_npc;
	monster $@jmpmap$,0,0,"Treasure Box Coin",1845,5,"TreasureBoxSummonerCoin::OnCoinBoxKilled";
	initnpctimer;
	end;
	
OnTimer1800000: //30min
	announce "All treasure in "+ $@jmpmap$ +" are destroyed",bc_all|bc_npc;
	killmonster $@jmpmap$,"TreasureBoxSummonerCoin::OnCoinBoxKilled";// TreasureBoxSummonerCoin unknown NPC
	stopnpctimer;
	end;

OnCoinBoxKilled:
	announce "The rare Treasure Box has been found and destroyed by "+strcharinfo(0)+"!", bc_all;
	getitem 7539,1; // Change your prize here 7539 Poring Coin
	end;
}

and yes moik is right (I got screwed by the "A rare"), there is 5 box. You should stop the timer if someone kill all the box to avoid to display the message after 30mins (just make a count like moik suggested but with npc var)

  • 0
Posted
-	script	TreasureBoxSummonerCoin		-1,{
	
	
	
OnClock1500:
OnClock1600:
OnClock2400:

	set $@ran, rand(1,9);
	if ($@ran == 9) set $@jmpmap$,"hugel";
	if ($@ran == 8) set $@jmpmap$,"yuno";
	if ($@ran == 7) set $@jmpmap$,"comodo";
	if ($@ran == 6) set $@jmpmap$,"aldebaran";
	if ($@ran == 5) set $@jmpmap$,"izlude";
	if ($@ran == 4) set $@jmpmap$,"payon";
	if ($@ran == 3) set $@jmpmap$,"geffen";
	if ($@ran == 2) set $@jmpmap$,"morocc";
	if ($@ran == 1) set $@jmpmap$,"prontera";
	
	
	announce "A rare Treasure Box will be spawned in "+ $@jmpmap$ +".",bc_all|bc_npc;
	monster $@jmpmap$,0,0,"Treasure Box Coin",1845,5,"TreasureBoxSummonerCoin::OnCoinBoxKilled";
	initnpctimer;
	end;
	
OnTimer1800000: //30min
	announce "All treasure in "+ $@jmpmap$ +" are destroyed",bc_all|bc_npc;
	killmonster $@jmpmap$,"TreasureBoxSummonerCoin::OnCoinBoxKilled";// TreasureBoxSummonerCoin unknown NPC
	stopnpctimer;
	end;

OnCoinBoxKilled:
	announce "The rare Treasure Box has been found and destroyed by "+strcharinfo(0)+"!", bc_all;
	getitem 7539,1; // Change your prize here 7539 Poring Coin
	end;
}

That's what Capuche said, works totally fine on my server :)

  • 0
Posted (edited)

ah @moik you're right, I have not really thought through, however I changed the script so I did not have time to try it, do you think that's okay?

-	script	TreasureBoxSummonerCoin		-1,{

OnClock1500:
OnClock1600:
OnClock2400:
	set .@ran, rand(1,9);
	setarray .@jmpmap$[1],
		"hugel",
		"yuno",
		"comodo",
		"aldebaran",
		"izlude",
		"payon",
		 "geffen",
		"morocc",
		"prontera";
	.map_name$ = .@jmpmap$[.@ran];
	

	announce "A rare Treasure Box will be spawned in "+ .map_name$ +".",bc_all|bc_npc;
	monster .map_name$,0,0,"Treasure Box Coin",1845,5,"TreasureBoxSummonerCoin::OnCoinBoxKilled";
	initnpctimer;
	end;
	
OnTimer1800000: //30min
	announce "All treasure in "+ .map_name$ +" are destroyed",bc_all|bc_npc;
	killmonster .map_name$,"TreasureBoxSummonerCoin::OnCoinBoxKilled";// TreasureBoxSummonerCoin unknown NPC
	stopnpctimer;
	end;


OnCoinBoxKilled:
        set .@boxkills, .@boxkills +1; 
        announce "The rare Treasure Box has been found and destroyed by "+strcharinfo(0)+"!", bc_all;
        getitem 7539,1; // Change your prize here 7539 Poring Coin
        if (.@boxkills > 4) stopnpctimer;
	end;
}
Edited by Valcars
  • 0
Posted
-	script	TreasureBoxSummonerCoin		-1,{

OnClock1500:
OnClock1600:
OnClock2400:
	set .boxkills, 0;
	set .@ran, rand(1,9);
	setarray .@jmpmap$[1],
		"hugel",
		"yuno",
		"comodo",
		"aldebaran",
		"izlude",
		"payon",
		 "geffen",
		"morocc",
		"prontera";
	.map_name$ = .@jmpmap$[.@ran];
	

	announce "A rare Treasure Box will be spawned in "+ .map_name$ +".",bc_all|bc_npc;
	monster .map_name$,0,0,"Treasure Box Coin",1845,5,"TreasureBoxSummonerCoin::OnCoinBoxKilled";
	initnpctimer;
	end;
	
OnTimer1800000: //30min
	announce "All treasure in "+ .map_name$ +" are destroyed",bc_all|bc_npc;
	killmonster .map_name$,"TreasureBoxSummonerCoin::OnCoinBoxKilled";// TreasureBoxSummonerCoin unknown NPC
	stopnpctimer;
	end;


OnCoinBoxKilled:
        set .boxkills, .boxkills +1; 
		if (.boxkills > 4) {
			announce "All rare Treasure Boxes have been destroyed!", bc_all;
			stopnpctimer;
		}
        else announce "The rare Treasure Box has been found and destroyed by "+strcharinfo(0)+"!", bc_all;
        getitem 7539,1; // Change your prize here 7539 Poring Coin
	end;
}

here you go, if all boxes are killed, timer stops and an annoucement will be made. Everything works fine on my server. Enjoy and don't forget Capuche helped a lot here :)

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...