Jump to content
  • 0

Time problem


Hyoru

Question


  • Group:  Members
  • Topic Count:  45
  • Topics Per Day:  0.01
  • Content Count:  122
  • Reputation:   11
  • Joined:  01/30/12
  • Last Seen:  

Hello, I have an NPC that teleports a person to a room with a time limit of 5 minutes, and one person per room. The problem is, when a person dies and another enters the room, if the last person time isn't over, the time will be counted by the new person...I need to stop this time when the map get 0 players

maybe use:

if ( getmapusers("quiz_02") == 0 )

stopnpctimer;

if someone know, please help me. Thanks advanced.

Link to comment
Share on other sites

11 answers to this question

Recommended Posts


  • Group:  Members
  • Topic Count:  2
  • Topics Per Day:  0.00
  • Content Count:  23
  • Reputation:   2
  • Joined:  02/17/12
  • Last Seen:  

I'm still new to scripting, but perhaps you can try OnPCDieEvent? I believe this label's effect is global, which means every player who dies will trigger this label.

Adjust it by adding certain condition checks. The one below checks if the player is on quiz_02. Only if it is, the script within the brackets will run.

And uh, I'm assuming the map can only be accessed by one person at a time, not sure if your 'one person per room' means that. :)

OnPCDieEvent:

if (strcharinfo(3) == "quiz_02") {

// do this

}

end;

Again, I'm new to scripting, so maybe my idea isn't a good one and others might have a better solution. I hope it at least shines a little light for you /lv

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  10
  • Topics Per Day:  0.00
  • Content Count:  392
  • Reputation:   47
  • Joined:  11/18/11
  • Last Seen:  

Both can be used. But does the map has the GvG flag that warps them out of it automatically when they die?

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  45
  • Topics Per Day:  0.01
  • Content Count:  122
  • Reputation:   11
  • Joined:  01/30/12
  • Last Seen:  

Yeah, is one person per map, sorry :)

And Slim, i added the mapflag (:

take a look:

OnPCDieEvent:

if (strcharinfo(3) == "quiz_02") {

stopnpctimer;

killmonster "quiz_02","All";

}

end;

the time isnt stopping yet

:/

Edited by Hyoru
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  2
  • Topics Per Day:  0.00
  • Content Count:  23
  • Reputation:   2
  • Joined:  02/17/12
  • Last Seen:  

I'm unsure of this, but your mapflag may be obstructing, due to the nature that it warps the player immediately after his/her character's death. OnPCDieEvent may then be running, but the player is warped out before the if statement is accessed, hence your timer not stopping.

I'm outside now, I'll help you test it when I get home, if you haven't solved it already =]

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  45
  • Topics Per Day:  0.01
  • Content Count:  122
  • Reputation:   11
  • Joined:  01/30/12
  • Last Seen:  

how about If I put a delay of 5 minutes after someone enter in the room? maybe this can solve the problem. but I don't know how to put it :s

Edited by Hyoru
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  2
  • Topics Per Day:  0.00
  • Content Count:  23
  • Reputation:   2
  • Joined:  02/17/12
  • Last Seen:  

Is there a need for your GvG mapflag? Or any other mapflags that causes you to be teleported out upon death. Because if there's no need for them, removing the mapflags might just solve your problem.

It is also possible to put a delay, but if the mapflags serve no purposes, removing them is the better option. Delays may reduce the availability of the event, even if it's only for a short duration.

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  45
  • Topics Per Day:  0.01
  • Content Count:  122
  • Reputation:   11
  • Joined:  01/30/12
  • Last Seen:  

no needs for gvg mapflag, but i've tested without the gvg mapflag and still don't stop the time. And i guess won't be a problem this delay.

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  2
  • Topics Per Day:  0.00
  • Content Count:  23
  • Reputation:   2
  • Joined:  02/17/12
  • Last Seen:  

Can I request for the script? Because I can't really tell what's going on. I tested with this code and it works for me.

I get teleported out the minute I died, and my timer stops.

prontera,150,255,4	script	Party Master::test_pm	46,{

warp "quiz_02",0,0;
initnpctimer;
end;

OnPCDieEvent:
if (strcharinfo(3) == "quiz_02") {
	sleep2 500;
	warp "prontera",0,0;
	percentheal 100,100;
	stopnpctimer;
}
end;

OnTimer10000:
announce "Timer not stopped.",0;
end;
}

Edited by deltadestiny
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  45
  • Topics Per Day:  0.01
  • Content Count:  122
  • Reputation:   11
  • Joined:  01/30/12
  • Last Seen:  

I've changed the map.

ps: im noob with script (:

here is:

prontera,180,150,5 script Teleport guy 61,{

addtimer 300000, strnpcinfo(3)+"::On5Minutes";
set .@map$,"prt_are_in";
set .@id,13760;

mes "[Teleportador]";
mes "want enter in the room?  ~~ ~";
mes "blablablabla....";
next;
mes "[Teleport guy]";
mes "Wanna get in now??";
 next;
 if( select("Yep:Nope") == 2 )
 {
  mes "[Teleport guy]";
  mes "...";
  close;
 }
if(countitem(.@id) < 1) {
mes "[Teleport guy]";
mes "you need the passport to enter";
close;
}
if (getmapusers(.@map$) >= 1 ){
mes "[Teleport guy]";
mes "Sorry, someone is using the room.";
close;}
delitem .@id,1;
warp .@map$,21,128;
dispbottom "You have 5 minutes to stay here.";
initnpctimer;
end;

On5Minutes:
dispbottom "Time out.";
killmonster "prt_are_in","All";
mapwarp "prt_are_in","prontera",156,178;
end;

OnPCDieEvent:
if (strcharinfo(3) == "prt_are_in") {
stopnpctimer;
killmonster "prt_are_in","All";
}
end;

}
//Mapflags
prt_are_in mapflag nowarp
prt_are_in mapflag nowarpto
prt_are_in mapflag noteleport
prt_are_in mapflag nomemo
prt_are_in mapflag nosave SavePoint
prt_are_in mapflag noreturn
prt_are_in mapflag noicewall
prt_are_in mapflag nopenalty
prt_are_in mapflag noexp

Edited by Hyoru
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  2
  • Topics Per Day:  0.00
  • Content Count:  23
  • Reputation:   2
  • Joined:  02/17/12
  • Last Seen:  

Here, try this one.

prontera,180,150,5	script	Teleport guy	61,{

set .@map$,"prt_are_in";
set .@id,13760;

mes "[Teleportador]";
mes "want enter in the room?  ~~ ~";
mes "blablablabla....";
next;
mes "[Teleport guy]";
mes "Wanna get in now??";
 	next;
if( select("Yep:Nope") == 2 ) {
	mes "[Teleport guy]";
	mes "...";
	close;
}

if(countitem(.@id) < 1) {
	mes "[Teleport guy]";
	mes "you need the passport to enter";
	close;
}
if (getmapusers(.@map$) >= 1 ){
	mes "[Teleport guy]";
	mes "Sorry, someone is using the room.";
	close;
}
delitem .@id,1;
warp .@map$,21,128;
dispbottom "You have 5 minutes to stay here.";

//attachnpctimer strcharinfo(0); // attach timer to current character
initnpctimer;
end;

OnTimer300000:
//OnTimer5000: // used for shorter time testing
stopnpctimer;
killmonster "prt_are_in","All";
mapwarp "prt_are_in","prontera",156,178;
announce getnpctimer(0,"Teleport guy"),0;
sleep2 2000;
announce getnpctimer(0,"Teleport guy"),0;
end;


OnPCDieEvent:
if (strcharinfo(3) == "prt_are_in") {
	stopnpctimer;
	sleep2 500;
	killmonster "prt_are_in","All";
	warp "prontera", 179,150;
	percentheal 100,100;
	announce getnpctimer(0,"Teleport guy"),0;
	sleep2 2000;
	announce getnpctimer(0,"Teleport guy"),0;
}
end;
}


//Mapflags
prt_are_in	mapflag	nowarp
prt_are_in	mapflag	nowarpto
prt_are_in	mapflag	noteleport
prt_are_in	mapflag	nomemo
prt_are_in	mapflag	nosave
prt_are_in	mapflag	noreturn
prt_are_in	mapflag	noicewall
prt_are_in	mapflag	nopenalty
prt_are_in	mapflag	noexp

Let me know if there's anything not working =)

  • Upvote 1
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  45
  • Topics Per Day:  0.01
  • Content Count:  122
  • Reputation:   11
  • Joined:  01/30/12
  • Last Seen:  

Thank you so much Deltadestiny! It's perfect now (: I own you one.

[solved].

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...