integral Posted February 15, 2012 Group: Members Topic Count: 51 Topics Per Day: 0.01 Content Count: 167 Reputation: 4 Joined: 02/01/12 Last Seen: August 20, 2017 Share Posted February 15, 2012 (edited) 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 February 15, 2012 by integral Quote Link to comment Share on other sites More sharing options...
llchrisll Posted February 16, 2012 Group: Members Topic Count: 12 Topics Per Day: 0.00 Content Count: 626 Reputation: 189 Joined: 11/19/11 Last Seen: March 25 Share Posted February 16, 2012 @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 Quote Link to comment Share on other sites More sharing options...
llchrisll Posted February 15, 2012 Group: Members Topic Count: 12 Topics Per Day: 0.00 Content Count: 626 Reputation: 189 Joined: 11/19/11 Last Seen: March 25 Share Posted February 15, 2012 (edited) 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 February 15, 2012 by llchrisll Quote Link to comment Share on other sites More sharing options...
integral Posted February 16, 2012 Group: Members Topic Count: 51 Topics Per Day: 0.01 Content Count: 167 Reputation: 4 Joined: 02/01/12 Last Seen: August 20, 2017 Author Share Posted February 16, 2012 (edited) @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 February 16, 2012 by integral Quote Link to comment Share on other sites More sharing options...
Emistry Posted February 16, 2012 Group: Forum Moderator Topic Count: 93 Topics Per Day: 0.02 Content Count: 10018 Reputation: 2369 Joined: 10/28/11 Last Seen: Sunday at 05:32 PM Share Posted February 16, 2012 @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 ? if(getmapusers("map") < .player_limit) @integral.. we dunno how you write your code.. if you want support for your script..then show it... Quote Link to comment Share on other sites More sharing options...
integral Posted February 16, 2012 Group: Members Topic Count: 51 Topics Per Day: 0.01 Content Count: 167 Reputation: 4 Joined: 02/01/12 Last Seen: August 20, 2017 Author Share Posted February 16, 2012 @Emistry I'm using the script posted above, then I added the addtimer below the warp "map.gat". Quote Link to comment Share on other sites More sharing options...
Question
integral
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 integralLink to comment
Share on other sites
5 answers to this question
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.