Jump to content
  • 0

NPC does not automatically start have player not attached error


AinsLord

Question


  • Group:  Members
  • Topic Count:  257
  • Topics Per Day:  0.08
  • Content Count:  737
  • Reputation:   18
  • Joined:  11/21/15
  • Last Seen:  

this is the NPC script that im using

//===== rAthena Script ======================================= 
//= Find the gm event (hide and seek)
//===== By: ==================================================
//= Mastagoon
//===== Description: =========================================
//= The npc (GM sprite) will teleport to a random location on
//= the map, and will open a waiting room. The first player to
//= join that waiting room will win the round.
//===== Current Version: =====================================
//= 1.0
//===== Featuers: ============================================
//= Can set the number of rounds, map, item&zeny rewards.
//= the event can start manually or automatically.
//= There is another version of this script compatiable with 
//= Stolao's event manager. You can DM me if you want that file.
//============================================================
alexandria,166,155,4	script	GM Masta#findgm	871,{
	if(.status < 2) {
		mes "["+.npcName+"]";
		mes "When the event begins, i will teleport to a random location on this map.";
		mes "And you need to find me to win!";
		close;
	}
	end;

OnInit:
    //SETTINGS
	.rounds = 5; // for how many rounds should the event last?
    .map$ = "prontera"; // the event where the gm will hide
    .itemReward = 1;  
    setarray .rewards[0],6379,5,7227,5;   // [itemId, itemAmount, {....}]
    .zenyReward = 0;
    .zenyAmount = 10000;
    .debugMode = 0;
    .npcName$ = "GM Kiks";
    .countdown = 3; // the time between event announcements and when the event actually starts.
	.automatic = 1;	// automatic event or does it need a gm to run it manually?
	.runEvery = 3;	// (ignore if manual) run the event ever X hours 
	.offset = 1;	// (ignore if manual) sometimes, you might have another event/announcement at the same time as the event announcement. you can set an offset (announce X minutes after event time.)
    // Do not edit the code below.
    if(.countdown < 0) .countdown = 1;
    if(.rounds < 1) .rounds = 1;
    if(.winnersPerRound < 1) .winnersPerRound = 1;
	for(.@i = 0; .@i < getarraysize(.rewards); .@i = .@i+2) {
		if(getitemname(.rewards[.@i]) == "null") {
			debugmes "[Find GM]: Invalid item id provided "+.rewards[.@i]+" removing item from the rewards list..";
			deletearray .rewards[.@i],2;
			.@i -= 2;
		}
	}
    .status = 0;
    bindatcmd("eventstart", strnpcinfo(3)+"::OnEventAnnounce",60,99);
	strnpcinfo(3);
	end;

OnMinute00:
	if(.status || !.automatic || gettime(DT_HOUR) % .runEvery != 0 || agitcheck() || agitcheck2() || agitcheck3()) end;
	sleep .offset * 1000 * 60;

OnEventAnnounce:
	.status = 1;
	for(.@i = .countdown; i > 0; i--) {
    	announce "[Find "+.npcName$+"] : The event will begin in "+callfunc("F_InsertPlural",.@i,"minute")+"!",bc_all|bc_blue;
		sleep .debugMode ? 5000 : 60000;
	}
	announce "[Find "+.npcName$+"] : The event has now begun!",bc_all|bc_blue;

OnEventStart:
	sleep 2000;
	npctalk "I will now teleport to a random location";
	sleep 2000;
	npctalk "You must find me to win the event!";
	sleep 2000;
	npctalk "This event will last for "+callfunc("F_InsertPlural",.rounds,"round");
	sleep 2000;
	npctalk "Goodluck!";
	donpcevent strnpcinfo(3)+"::OnRoundStart";
	.status = 2;
	.round = 1;
	end;

OnRoundStart:
	initnpctimer;
	do {
		.@x = rand(0,450);
		.@y = rand(0,450);
	} while (!checkcell(.map$,.@x,.@y,cell_chkpass));
	unitwarp getnpcid(0),.map$,.@x,.@y;
	debugmes "[Event]: npc is at: "+.@x+" & "+.@y;
	announce "[Find "+.npcName$+"] :"+.npcName$+" is hiding in a random place in "+.map$+", Find him now!",bc_all|bc_blue;
	delwaitingroom;
	waitingroom "Here!", 2, strnpcinfo(3)+"::OnRoundEnd",1;
	.status = 2;
	end;

OnRoundEnd:
	if(.status != 2) end;
	.status = 1; 
	//#TODO the winner should be already attached here no?
	getwaitingroomusers strnpcinfo(3);
	for(.@i = 0; .@i < getarraysize(.@waitingroom_users); .@i++) {
		if(.@waitingroom_users[.@i] > 0) {
			.@winner = .@waitingroom_users[.@i];
		}
	}
	if(!attachrid(.@winner)) {
		.status = 2;
		end;
	}
	specialeffect2 EF_SPHERE;
	announce .npcName$+": I've been found by "+strcharinfo(0)+"!",bc_all|bc_blue;
	if(.itemReward) {
		for(.@i = 0; .@i < getarraysize(.rewards); .@i = .@i +2) {
			getitem .rewards[.@i],.rewards[.@i+1];
		}
	}
	if(.zenyReward) {
		Zeny += .zenyAmount;
		dispbottom "You've gained "+.zenyAmount+" zeny for winning a round in the event.";
	}
	sleep 1000;
	if(.round >= .rounds) {
		donpcevent strnpcinfo(3)+"::OnEventEnd";
		end;
	}
	.round++;
	donpcevent strnpcinfo(3)+"::OnRoundStart";
	end;

OnEventEnd:
	.status = 0;
	announce "[Find "+.npcName$+"]: The event is over! thank you for participating.",bc_all|bc_blue;
	unitwarp getnpcid(0),.map$,195,58;
	delwaitingroom;
	sleep 5000;
	end;

OnTimer1800000:
	if(.status) {
		stopnpctimer;
		donpcevent strnpcinfo(3)+"::OnEventEnd";
	}
	end;
}

this is the error showing when the NPC is trying to automatically start

image.png.b101527132615f1fc1807a615bc79a18.png

and how can i add other map where the NPC hides like randomly maps?

thnx in advance highly appreciate it ❤️

Link to comment
Share on other sites

8 answers to this question

Recommended Posts

  • 0

  • Group:  Members
  • Topic Count:  16
  • Topics Per Day:  0.00
  • Content Count:  657
  • Reputation:   662
  • Joined:  11/12/12
  • Last Seen:  

Heya,

Well, considering the error that is given to you, I'd assume this is the issue:

OnEventAnnounce:
	.status = 1;
	for(.@i = .countdown; i > 0; i--) {

The variable i should be .@i

  • Love 1
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  257
  • Topics Per Day:  0.08
  • Content Count:  737
  • Reputation:   18
  • Joined:  11/21/15
  • Last Seen:  

thanks a lot ill try this one ❤️

42 minutes ago, Tokei said:

Heya,

Well, considering the error that is given to you, I'd assume this is the issue:


OnEventAnnounce:
	.status = 1;
	for(.@i = .countdown; i > 0; i--) {

The variable i should be .@i

PS: @Tokei tested out still has the same error

image.png.b57b1855eb89035a8f0c839cacdb01a8.png

Edited by AinsLord
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  162
  • Topics Per Day:  0.05
  • Content Count:  1546
  • Reputation:   192
  • Joined:  07/23/14
  • Last Seen:  

51 minutes ago, AinsLord said:

thanks a lot ill try this one ❤️

PS: @Tokei tested out still has the same error

image.png.b57b1855eb89035a8f0c839cacdb01a8.png

its .@i not @i

  • Love 1
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  257
  • Topics Per Day:  0.08
  • Content Count:  737
  • Reputation:   18
  • Joined:  11/21/15
  • Last Seen:  

On 5/11/2021 at 6:48 AM, Radian said:

its .@i not @i

thnx thnx

@Radian in addition to this post

On 5/11/2021 at 5:15 AM, AinsLord said:

this is the NPC script that im using


//===== rAthena Script ======================================= 
//= Find the gm event (hide and seek)
//===== By: ==================================================
//= Mastagoon
//===== Description: =========================================
//= The npc (GM sprite) will teleport to a random location on
//= the map, and will open a waiting room. The first player to
//= join that waiting room will win the round.
//===== Current Version: =====================================
//= 1.0
//===== Featuers: ============================================
//= Can set the number of rounds, map, item&zeny rewards.
//= the event can start manually or automatically.
//= There is another version of this script compatiable with 
//= Stolao's event manager. You can DM me if you want that file.
//============================================================
alexandria,166,155,4	script	GM Masta#findgm	871,{
	if(.status < 2) {
		mes "["+.npcName+"]";
		mes "When the event begins, i will teleport to a random location on this map.";
		mes "And you need to find me to win!";
		close;
	}
	end;

OnInit:
    //SETTINGS
	.rounds = 5; // for how many rounds should the event last?
    .map$ = "prontera"; // the event where the gm will hide
    .itemReward = 1;  
    setarray .rewards[0],6379,5,7227,5;   // [itemId, itemAmount, {....}]
    .zenyReward = 0;
    .zenyAmount = 10000;
    .debugMode = 0;
    .npcName$ = "GM Kiks";
    .countdown = 3; // the time between event announcements and when the event actually starts.
	.automatic = 1;	// automatic event or does it need a gm to run it manually?
	.runEvery = 3;	// (ignore if manual) run the event ever X hours 
	.offset = 1;	// (ignore if manual) sometimes, you might have another event/announcement at the same time as the event announcement. you can set an offset (announce X minutes after event time.)
    // Do not edit the code below.
    if(.countdown < 0) .countdown = 1;
    if(.rounds < 1) .rounds = 1;
    if(.winnersPerRound < 1) .winnersPerRound = 1;
	for(.@i = 0; .@i < getarraysize(.rewards); .@i = .@i+2) {
		if(getitemname(.rewards[.@i]) == "null") {
			debugmes "[Find GM]: Invalid item id provided "+.rewards[.@i]+" removing item from the rewards list..";
			deletearray .rewards[.@i],2;
			.@i -= 2;
		}
	}
    .status = 0;
    bindatcmd("eventstart", strnpcinfo(3)+"::OnEventAnnounce",60,99);
	strnpcinfo(3);
	end;

OnMinute00:
	if(.status || !.automatic || gettime(DT_HOUR) % .runEvery != 0 || agitcheck() || agitcheck2() || agitcheck3()) end;
	sleep .offset * 1000 * 60;

OnEventAnnounce:
	.status = 1;
	for(.@i = .countdown; i > 0; i--) {
    	announce "[Find "+.npcName$+"] : The event will begin in "+callfunc("F_InsertPlural",.@i,"minute")+"!",bc_all|bc_blue;
		sleep .debugMode ? 5000 : 60000;
	}
	announce "[Find "+.npcName$+"] : The event has now begun!",bc_all|bc_blue;

OnEventStart:
	sleep 2000;
	npctalk "I will now teleport to a random location";
	sleep 2000;
	npctalk "You must find me to win the event!";
	sleep 2000;
	npctalk "This event will last for "+callfunc("F_InsertPlural",.rounds,"round");
	sleep 2000;
	npctalk "Goodluck!";
	donpcevent strnpcinfo(3)+"::OnRoundStart";
	.status = 2;
	.round = 1;
	end;

OnRoundStart:
	initnpctimer;
	do {
		.@x = rand(0,450);
		.@y = rand(0,450);
	} while (!checkcell(.map$,.@x,.@y,cell_chkpass));
	unitwarp getnpcid(0),.map$,.@x,.@y;
	debugmes "[Event]: npc is at: "+.@x+" & "+.@y;
	announce "[Find "+.npcName$+"] :"+.npcName$+" is hiding in a random place in "+.map$+", Find him now!",bc_all|bc_blue;
	delwaitingroom;
	waitingroom "Here!", 2, strnpcinfo(3)+"::OnRoundEnd",1;
	.status = 2;
	end;

OnRoundEnd:
	if(.status != 2) end;
	.status = 1; 
	//#TODO the winner should be already attached here no?
	getwaitingroomusers strnpcinfo(3);
	for(.@i = 0; .@i < getarraysize(.@waitingroom_users); .@i++) {
		if(.@waitingroom_users[.@i] > 0) {
			.@winner = .@waitingroom_users[.@i];
		}
	}
	if(!attachrid(.@winner)) {
		.status = 2;
		end;
	}
	specialeffect2 EF_SPHERE;
	announce .npcName$+": I've been found by "+strcharinfo(0)+"!",bc_all|bc_blue;
	if(.itemReward) {
		for(.@i = 0; .@i < getarraysize(.rewards); .@i = .@i +2) {
			getitem .rewards[.@i],.rewards[.@i+1];
		}
	}
	if(.zenyReward) {
		Zeny += .zenyAmount;
		dispbottom "You've gained "+.zenyAmount+" zeny for winning a round in the event.";
	}
	sleep 1000;
	if(.round >= .rounds) {
		donpcevent strnpcinfo(3)+"::OnEventEnd";
		end;
	}
	.round++;
	donpcevent strnpcinfo(3)+"::OnRoundStart";
	end;

OnEventEnd:
	.status = 0;
	announce "[Find "+.npcName$+"]: The event is over! thank you for participating.",bc_all|bc_blue;
	unitwarp getnpcid(0),.map$,195,58;
	delwaitingroom;
	sleep 5000;
	end;

OnTimer1800000:
	if(.status) {
		stopnpctimer;
		donpcevent strnpcinfo(3)+"::OnEventEnd";
	}
	end;
}

this is the error showing when the NPC is trying to automatically start

image.png.b101527132615f1fc1807a615bc79a18.png

and how can i add other map where the NPC hides like randomly maps?

thnx in advance highly appreciate it ❤️

how can i add additional maps where the NPC hide like randomly

i was trying to put

.map$ = "prontera"||"izlue"; // the event where the gm will hide

im getting error

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  8
  • Topics Per Day:  0.00
  • Content Count:  63
  • Reputation:   35
  • Joined:  07/04/19
  • Last Seen:  

2 hours ago, AinsLord said:

@Radian in addition to this post

how can i add additional maps where the NPC hide like randomly

i was trying to put


.map$ = "prontera"||"izlue"; // the event where the gm will hide

im getting error

Keep the .map$ line as it was. Then add below it:

setarray .maps$[0], 'prontera', 'izlude', 'geffen';

Then, right below the OnEventStart label, add this line:

.map$ = .maps$[rand(getarraysize(.maps$))];

Now the map will be randomly chosen each time.

goodluck.

Edited by Mastagoon
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  257
  • Topics Per Day:  0.08
  • Content Count:  737
  • Reputation:   18
  • Joined:  11/21/15
  • Last Seen:  

5 hours ago, Mastagoon said:

Keep the .map$ line as it was. Then add below it:


setarray .maps$[0], 'prontera', 'izlude', 'geffen';

Then, right below the OnEventStart label, add this line:


.map$ = .maps$[rand(getarraysize(.maps$))];

Now the map will be randomly chosen each time.

goodluck.

very much thank you i do really appreciate this ❤️

edit:

@Mastagoon i got this error showing on my console

image.png.b885cdf2c993612e1c229e24f0d593d4.png

here was the script i edit i dunno if i put it on wrong place

but i followed the instructions

//===== rAthena Script ======================================= 
//= Find the gm event (hide and seek)
//===== By: ==================================================
//= Mastagoon
//===== Description: =========================================
//= The npc (GM sprite) will teleport to a random location on
//= the map, and will open a waiting room. The first player to
//= join that waiting room will win the round.
//===== Current Version: =====================================
//= 1.0
//===== Featuers: ============================================
//= Can set the number of rounds, map, item&zeny rewards.
//= the event can start manually or automatically.
//= There is another version of this script compatiable with 
//= Stolao's event manager. You can DM me if you want that file.
//============================================================
alexandria,166,155,4	script	GM Masta#findgm	871,{
	if(.status < 2) {
		mes "["+.npcName+"]";
		mes "When the event begins, i will teleport to a random location on this map.";
		mes "And you need to find me to win!";
		close;
	}
	end;

OnInit:
    //SETTINGS
	.rounds = 5; // for how many rounds should the event last?
    .map$ = "prontera"; // the event where the gm will hide
    setarray .maps$[0], 'prontera', 'izlude', 'geffen';
    .itemReward = 1;  
    setarray .rewards[0],6379,5,7227,5;   // [itemId, itemAmount, {....}]
    .zenyReward = 0;
    .zenyAmount = 10000;
    .debugMode = 0;
    .npcName$ = "GM Kiks";
    .countdown = 3; // the time between event announcements and when the event actually starts.
	.automatic = 1;	// automatic event or does it need a gm to run it manually?
	.runEvery = 3;	// (ignore if manual) run the event ever X hours 
	.offset = 1;	// (ignore if manual) sometimes, you might have another event/announcement at the same time as the event announcement. you can set an offset (announce X minutes after event time.)
    // Do not edit the code below.
    if(.countdown < 0) .countdown = 1;
    if(.rounds < 1) .rounds = 1;
    if(.winnersPerRound < 1) .winnersPerRound = 1;
	for(.@i = 0; .@i < getarraysize(.rewards); .@i = .@i+2) {
		if(getitemname(.rewards[.@i]) == "null") {
			debugmes "[Find GM]: Invalid item id provided "+.rewards[.@i]+" removing item from the rewards list..";
			deletearray .rewards[.@i],2;
			.@i -= 2;
		}
	}
    .status = 0;
    bindatcmd("eventstart", strnpcinfo(3)+"::OnEventAnnounce",60,99);
	strnpcinfo(3);
	end;

OnMinute00:
	if(.status || !.automatic || gettime(DT_HOUR) % .runEvery != 0 || agitcheck() || agitcheck2() || agitcheck3()) end;
	sleep .offset * 1000 * 60;

OnEventAnnounce:
	.status = 1;
	for(.@i = .countdown; i > 0; i--) {
    	announce "[Find "+.npcName$+"] : The event will begin in "+callfunc("F_InsertPlural",.@i,"minute")+"!",bc_all|bc_blue;
		sleep .debugMode ? 5000 : 60000;
	}
	announce "[Find "+.npcName$+"] : The event has now begun!",bc_all|bc_blue;

OnEventStart:
	.map$ = .maps$[rand(getarraysize(.maps$))];
	sleep 2000;
	npctalk "I will now teleport to a random location";
	sleep 2000;
	npctalk "You must find me to win the event!";
	sleep 2000;
	npctalk "This event will last for "+callfunc("F_InsertPlural",.rounds,"round");
	sleep 2000;
	npctalk "Goodluck!";
	donpcevent strnpcinfo(3)+"::OnRoundStart";
	.status = 2;
	.round = 1;
	end;

OnRoundStart:
	initnpctimer;
	do {
		.@x = rand(0,450);
		.@y = rand(0,450);
	} while (!checkcell(.map$,.@x,.@y,cell_chkpass));
	unitwarp getnpcid(0),.map$,.@x,.@y;
	debugmes "[Event]: npc is at: "+.@x+" & "+.@y;
	announce "[Find "+.npcName$+"] :"+.npcName$+" is hiding in a random place in "+.map$+", Find him now!",bc_all|bc_blue;
	delwaitingroom;
	waitingroom "Here!", 2, strnpcinfo(3)+"::OnRoundEnd",1;
	.status = 2;
	end;

OnRoundEnd:
	if(.status != 2) end;
	.status = 1; 
	//#TODO the winner should be already attached here no?
	getwaitingroomusers strnpcinfo(3);
	for(.@i = 0; .@i < getarraysize(.@waitingroom_users); .@i++) {
		if(.@waitingroom_users[.@i] > 0) {
			.@winner = .@waitingroom_users[.@i];
		}
	}
	if(!attachrid(.@winner)) {
		.status = 2;
		end;
	}
	specialeffect2 EF_SPHERE;
	announce .npcName$+": I've been found by "+strcharinfo(0)+"!",bc_all|bc_blue;
	if(.itemReward) {
		for(.@i = 0; .@i < getarraysize(.rewards); .@i = .@i +2) {
			getitem .rewards[.@i],.rewards[.@i+1];
		}
	}
	if(.zenyReward) {
		Zeny += .zenyAmount;
		dispbottom "You've gained "+.zenyAmount+" zeny for winning a round in the event.";
	}
	sleep 1000;
	if(.round >= .rounds) {
		donpcevent strnpcinfo(3)+"::OnEventEnd";
		end;
	}
	.round++;
	donpcevent strnpcinfo(3)+"::OnRoundStart";
	end;

OnEventEnd:
	.status = 0;
	announce "[Find "+.npcName$+"]: The event is over! thank you for participating.",bc_all|bc_blue;
	unitwarp getnpcid(0),.map$,195,58;
	delwaitingroom;
	sleep 5000;
	end;

OnTimer1800000:
	if(.status) {
		stopnpctimer;
		donpcevent strnpcinfo(3)+"::OnEventEnd";
	}
	end;
}

thanks again

Edited by AinsLord
more information
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  8
  • Topics Per Day:  0.00
  • Content Count:  63
  • Reputation:   35
  • Joined:  07/04/19
  • Last Seen:  

46 minutes ago, AinsLord said:

very much thank you i do really appreciate this ❤️

edit:

@Mastagoon i got this error showing on my console

image.png.b885cdf2c993612e1c229e24f0d593d4.png

here was the script i edit i dunno if i put it on wrong place

but i followed the instructions


//===== rAthena Script ======================================= 
//= Find the gm event (hide and seek)
//===== By: ==================================================
//= Mastagoon
//===== Description: =========================================
//= The npc (GM sprite) will teleport to a random location on
//= the map, and will open a waiting room. The first player to
//= join that waiting room will win the round.
//===== Current Version: =====================================
//= 1.0
//===== Featuers: ============================================
//= Can set the number of rounds, map, item&zeny rewards.
//= the event can start manually or automatically.
//= There is another version of this script compatiable with 
//= Stolao's event manager. You can DM me if you want that file.
//============================================================
alexandria,166,155,4	script	GM Masta#findgm	871,{
	if(.status < 2) {
		mes "["+.npcName+"]";
		mes "When the event begins, i will teleport to a random location on this map.";
		mes "And you need to find me to win!";
		close;
	}
	end;

OnInit:
    //SETTINGS
	.rounds = 5; // for how many rounds should the event last?
    .map$ = "prontera"; // the event where the gm will hide
    setarray .maps$[0], 'prontera', 'izlude', 'geffen';
    .itemReward = 1;  
    setarray .rewards[0],6379,5,7227,5;   // [itemId, itemAmount, {....}]
    .zenyReward = 0;
    .zenyAmount = 10000;
    .debugMode = 0;
    .npcName$ = "GM Kiks";
    .countdown = 3; // the time between event announcements and when the event actually starts.
	.automatic = 1;	// automatic event or does it need a gm to run it manually?
	.runEvery = 3;	// (ignore if manual) run the event ever X hours 
	.offset = 1;	// (ignore if manual) sometimes, you might have another event/announcement at the same time as the event announcement. you can set an offset (announce X minutes after event time.)
    // Do not edit the code below.
    if(.countdown < 0) .countdown = 1;
    if(.rounds < 1) .rounds = 1;
    if(.winnersPerRound < 1) .winnersPerRound = 1;
	for(.@i = 0; .@i < getarraysize(.rewards); .@i = .@i+2) {
		if(getitemname(.rewards[.@i]) == "null") {
			debugmes "[Find GM]: Invalid item id provided "+.rewards[.@i]+" removing item from the rewards list..";
			deletearray .rewards[.@i],2;
			.@i -= 2;
		}
	}
    .status = 0;
    bindatcmd("eventstart", strnpcinfo(3)+"::OnEventAnnounce",60,99);
	strnpcinfo(3);
	end;

OnMinute00:
	if(.status || !.automatic || gettime(DT_HOUR) % .runEvery != 0 || agitcheck() || agitcheck2() || agitcheck3()) end;
	sleep .offset * 1000 * 60;

OnEventAnnounce:
	.status = 1;
	for(.@i = .countdown; i > 0; i--) {
    	announce "[Find "+.npcName$+"] : The event will begin in "+callfunc("F_InsertPlural",.@i,"minute")+"!",bc_all|bc_blue;
		sleep .debugMode ? 5000 : 60000;
	}
	announce "[Find "+.npcName$+"] : The event has now begun!",bc_all|bc_blue;

OnEventStart:
	.map$ = .maps$[rand(getarraysize(.maps$))];
	sleep 2000;
	npctalk "I will now teleport to a random location";
	sleep 2000;
	npctalk "You must find me to win the event!";
	sleep 2000;
	npctalk "This event will last for "+callfunc("F_InsertPlural",.rounds,"round");
	sleep 2000;
	npctalk "Goodluck!";
	donpcevent strnpcinfo(3)+"::OnRoundStart";
	.status = 2;
	.round = 1;
	end;

OnRoundStart:
	initnpctimer;
	do {
		.@x = rand(0,450);
		.@y = rand(0,450);
	} while (!checkcell(.map$,.@x,.@y,cell_chkpass));
	unitwarp getnpcid(0),.map$,.@x,.@y;
	debugmes "[Event]: npc is at: "+.@x+" & "+.@y;
	announce "[Find "+.npcName$+"] :"+.npcName$+" is hiding in a random place in "+.map$+", Find him now!",bc_all|bc_blue;
	delwaitingroom;
	waitingroom "Here!", 2, strnpcinfo(3)+"::OnRoundEnd",1;
	.status = 2;
	end;

OnRoundEnd:
	if(.status != 2) end;
	.status = 1; 
	//#TODO the winner should be already attached here no?
	getwaitingroomusers strnpcinfo(3);
	for(.@i = 0; .@i < getarraysize(.@waitingroom_users); .@i++) {
		if(.@waitingroom_users[.@i] > 0) {
			.@winner = .@waitingroom_users[.@i];
		}
	}
	if(!attachrid(.@winner)) {
		.status = 2;
		end;
	}
	specialeffect2 EF_SPHERE;
	announce .npcName$+": I've been found by "+strcharinfo(0)+"!",bc_all|bc_blue;
	if(.itemReward) {
		for(.@i = 0; .@i < getarraysize(.rewards); .@i = .@i +2) {
			getitem .rewards[.@i],.rewards[.@i+1];
		}
	}
	if(.zenyReward) {
		Zeny += .zenyAmount;
		dispbottom "You've gained "+.zenyAmount+" zeny for winning a round in the event.";
	}
	sleep 1000;
	if(.round >= .rounds) {
		donpcevent strnpcinfo(3)+"::OnEventEnd";
		end;
	}
	.round++;
	donpcevent strnpcinfo(3)+"::OnRoundStart";
	end;

OnEventEnd:
	.status = 0;
	announce "[Find "+.npcName$+"]: The event is over! thank you for participating.",bc_all|bc_blue;
	unitwarp getnpcid(0),.map$,195,58;
	delwaitingroom;
	sleep 5000;
	end;

OnTimer1800000:
	if(.status) {
		stopnpctimer;
		donpcevent strnpcinfo(3)+"::OnEventEnd";
	}
	end;
}

thanks again

use "" instead of ''

"prontera", "izlude", "geffen", ...etc

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  257
  • Topics Per Day:  0.08
  • Content Count:  737
  • Reputation:   18
  • Joined:  11/21/15
  • Last Seen:  

4 hours ago, Mastagoon said:

use "" instead of ''

"prontera", "izlude", "geffen", ...etc

thnx a lot again

will there be a problem announcing the map where the NPC hides or none?

PS : none XD thanks again

Edited by AinsLord
additional info
Link to comment
Share on other sites

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.

×
×
  • Create New...