Jump to content
  • 0

Teleport NPC with chat room


integral

Question


  • Group:  Members
  • Topic Count:  51
  • Topics Per Day:  0.01
  • Content Count:  167
  • Reputation:   4
  • Joined:  02/01/12
  • Last Seen:  

So I am making an npc that teleports you when you enter in its chat room.

How do I make it check the number of players inside the map without actually talking to the npc?

And is it possible to add an if/else statement in labels?

+How to put timer on labels?

That's all for now. Thank you.

Edited by integral
Link to comment
Share on other sites

5 answers to this question

Recommended Posts


  • Group:  Members
  • Topic Count:  12
  • Topics Per Day:  0.00
  • Content Count:  626
  • Reputation:   188
  • Joined:  11/19/11
  • Last Seen:  

@Emistry

That wasn't supposed to be an variable ^^.

@integral

You don't require initnpctimer; after you the addtimer

Still it would be the best to post your script.

Because if you didn't add "{" and "}" at the warp part:

OnWarp:
if(getmapusers("map") < player_limit)
warp "map.gat",x,y;
else dispbottom strnpcinfo(1)+": This map has reached the maximum players which can stay on this map.";
end;

should be then this:

OnWarp:
if(getmapusers("map") < player_limit) {
addtimer 300000,strnpcinfo(3)+"::On5Minutes";
warp "map.gat",x,y;
} else dispbottom strnpcinfo(1)+": This map has reached the maximum players which can stay on this map.";
end;

before only the next command would have been executed.

another one would have been ignored.

Regards,

Chris

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  12
  • Topics Per Day:  0.00
  • Content Count:  626
  • Reputation:   188
  • Joined:  11/19/11
  • Last Seen:  

To create an chat room:

*waitingroom "",{,,};

This command will create a chat room, owned by the NPC object running this

script and displayed above the NPC sprite.

The maximum length of a chatroom name is 60 letters.

The limit is the maximum number of people allowed to enter the chat room. If the

optional event and trigger parameters are given, the event label

("::") will be invoked as if with a 'doevent' upon

the number of people in the chat room reaching the given triggering amount.

It's funny, but for compatibility with jAthena, you can swap the event label and

the trigger parameters, and it will still work.

Example:

OnInit:
while(1) {
waitingroom "Teleporter - Users: "+getmapusers("map"),20,strnpcinfo(0)+"::OnWarp",1;
sleep 2000;
delwaitingroom;
}
end;

OnWarp:
if(getmapusers("map") < player_limit)
warp "map.gat",x,y;
else dispbottom strnpcinfo(1)+": This map has reached the maximum players which can stay on this map.";
end;

As for the timer there are different ways to do.

It depends on what do you want to do, but the easiest way would be using this:

*addtimer ,"::";

*deltimer "::";

*addtimercount ,"::";;

These commands will create and manage a player-based timer: 'addtimer' to

create, 'deltimer' to destroy and 'addtimercount' to delay it by the specified

number of ticks. For all three cases, the event label given is the identifier of

that timer. A player can have multiple timers running at the same time, and

there can even be multiple timers referencing the same label.

When this timer runs out, a new execution thread will start in the specified NPC

object at the specified label, and the script will run attached to that player.

If the specified label is not found, the map server will happily print an error.

The ticks are given in 1/1000ths of a second.

One more thing. These timers are stored as part of player data. If the player

logs out, all of these get immediately deleted, without executing the script.

If this behavior is undesirable, use some other timer mechanism (like 'sleep').

The script above is only an snippet ^^.

Regards,

Chris

Edit: o.o Somehow the paramters of those scripts won't be posted, though it's in the editor self, why is that?

Edited by llchrisll
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  51
  • Topics Per Day:  0.01
  • Content Count:  167
  • Reputation:   4
  • Joined:  02/01/12
  • Last Seen:  

@Chris

Hi, thank you for your post, but it doesn't work when I add an add timer plus an initnpctimer.

	addtimer 300000, strnpcinfo(3)+"::On5Minutes";
   initnpctimer;

Here's the message that I receive.

[Error]: script_rid2sd: fatal error ! player not attached!
[Debug]: Function: addtimer (2 parameters):
[Debug]: Data: number value=300000
[Debug]: Data: string value="PvP Warper::On5Minutes"
[Debug]: Source (NPC): PvP Warper at prontera (144,175)

Thank you.

Edited by integral
Link to comment
Share on other sites


  • Group:  Forum Moderator
  • Topic Count:  93
  • Topics Per Day:  0.02
  • Content Count:  10015
  • Reputation:   2348
  • Joined:  10/28/11
  • Last Seen:  

@chris

there is some mistake typo in your above post..

perhap you are using a wrong Variable ??

if(getmapusers("map") < player_limit)

i think it should be this right ? /hmm

if(getmapusers("map") < .player_limit)

@integral..

we dunno how you write your code..

if you want support for your script..then show it...

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  51
  • Topics Per Day:  0.01
  • Content Count:  167
  • Reputation:   4
  • Joined:  02/01/12
  • Last Seen:  

@Emistry

I'm using the script posted above, then I added the addtimer below the warp "map.gat".

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