MeWhoMustNotBeNamed Posted January 24, 2014 Group: Members Topic Count: 2 Topics Per Day: 0.00 Content Count: 20 Reputation: 2 Joined: 03/01/13 Last Seen: March 9, 2014 Share Posted January 24, 2014 is it possible to get the number of player in a certain map excluding those gm account? Link to comment Share on other sites More sharing options...
Skorm Posted January 24, 2014 Group: Forum Moderator Topic Count: 33 Topics Per Day: 0.01 Content Count: 1282 Reputation: 393 Joined: 02/03/12 Last Seen: 21 hours ago Share Posted January 24, 2014 (edited) Doesn't the @whomap commands already do that? Anyways this will work like an @command warp to the map you'd like to know how many normal players are on and do @getusers... If you want to just input the map name that would probably require surfing your sqldb via script or something. - script user_count -1,{ OnUserGet: attachrid(.aid); addrid(1); if(getgmlevel()>20) end; set(.a,.a+1); end; OnEventDo: set(.aid, getcharid(3)); donpcevent "user_count::OnUserGet"; dispbottom(.a+" User(s) found on "+strcharinfo(3)+"."); set(.a,0); end; OnInit: bindatcmd "getusers","user_count::OnEventDo",99,99; } Remove ",99,99" if this command was intended for normal player use. Edited January 24, 2014 by Skorm Small Fix Etc... 1 Link to comment Share on other sites More sharing options...
AnnieRuru Posted January 24, 2014 Group: Members Topic Count: 18 Topics Per Day: 0.00 Content Count: 2044 Reputation: 682 Joined: 10/09/12 Last Seen: December 20, 2020 Share Posted January 24, 2014 hahaha, I'm just about to point out that bug xD anyway, optimized ~ - script user_count -1,{ OnInit: bindatcmd "getusers", strnpcinfo(0)+"::OnCommand"; end; OnCommand: .@origin = getcharid(3); addrid 1; if ( getgmlevel() <= 20 ) // GM level here .count++; if ( getcharid(3) != .@origin ) end; dispbottom .count +" User"+( .count > 1 ? "s" : "" )+" found on "+strcharinfo(3)+"."; .count = 0; end; }tested@MeWhoMustNotBeNamed if you are writing an event script like last man standing, its better to store them in an array http://rathena.org/board/topic/91723-please-help-this-script-about-mac-address/?p=240887 Link to comment Share on other sites More sharing options...
QQfoolsorellina Posted January 24, 2014 Group: Members Topic Count: 40 Topics Per Day: 0.01 Content Count: 587 Reputation: 105 Joined: 11/19/11 Last Seen: July 7, 2019 Share Posted January 24, 2014 (edited) - script user_count -1,{ OnInit: bindatcmd "getusers", strnpcinfo(0)+"::OnCommand"; end; OnCommand: .@origin = getcharid(3); addrid 1; if ( getgmlevel() <= 20 ) // GM level here .count++; if ( getcharid(3) != .@origin ) end; dispbottom .count +" User"+( .count > 1 ? "s" : "" )+" found on "+strcharinfo(3)+"."; .count = 0; end; } As I remember, Variable prefix with .@ will be lost when script use addrid. I think that except for the player who used that command, no one has var .@origin http://rathena.org/board/topic/88331-addrid-addition/?p=226484 Edited January 24, 2014 by QQfoolsorellina Link to comment Share on other sites More sharing options...
Skorm Posted January 24, 2014 Group: Forum Moderator Topic Count: 33 Topics Per Day: 0.01 Content Count: 1282 Reputation: 393 Joined: 02/03/12 Last Seen: 21 hours ago Share Posted January 24, 2014 hahaha, I'm just about to point out that bug xD anyway, optimized ~ - script user_count -1,{ OnInit: bindatcmd "getusers", strnpcinfo(0)+"::OnCommand"; end; OnCommand: .@origin = getcharid(3); addrid 1; if ( getgmlevel() <= 20 ) // GM level here .count++; if ( getcharid(3) != .@origin ) end; dispbottom .count +" User"+( .count > 1 ? "s" : "" )+" found on "+strcharinfo(3)+"."; .count = 0; end; }tested@MeWhoMustNotBeNamed if you are writing an event script like last man standing, its better to store them in an array http://rathena.org/board/topic/91723-please-help-this-script-about-mac-address/?p=240887 In all honestly I think this would actually be slower than my version... You're running the entire map through more checks. I attached the main player called a new event then re-attached him to get the map location but all other players only go through 1 check and one condition. Instead of 2 checks with a subsequent conditional count. Link to comment Share on other sites More sharing options...
AnnieRuru Posted January 24, 2014 Group: Members Topic Count: 18 Topics Per Day: 0.00 Content Count: 2044 Reputation: 682 Joined: 10/09/12 Last Seen: December 20, 2020 Share Posted January 24, 2014 (edited) I was the one who keep bringing up addrid in rathena forum until it was added months later run a search "addrid" in rathena confirm this I knew the existance of addrid while I was still on eathena forum playing around with Brainstorm http://www.eathena.ws/board/index.php?s=&showtopic=271105&view=findpost&p=1484769 @QQfoolsorellina the .@scope variable is not persistent after attachrid on other players but its still available to the current player so actually its possible to set a .@scope variable with just anything, other attached player will actually just return .@origin as 0 - script user_count -1,{ OnInit: bindatcmd "getusers", strnpcinfo(0)+"::OnCommand"; end; OnCommand: .@attached = 1; addrid 1; if ( getgmlevel() <= 20 ) // GM level here .count++; if ( !.@attached ) end; dispbottom .count +" User"+( .count > 1 ? "s" : "" )+" found on "+strcharinfo(3)+"."; .count = 0; end; }also worksthe .@origin has been stuck to my scripting style, so don't mind that so yeah, the dispbottom will only display on the attached player, not anyone else @Skorm http://www.eathena.ws/board/index.php?s=&showtopic=186459&view=findpost&p=1038374 weird, what I did was actually a method from the author himself ... I have read through addrid source code many times to confirm this https://github.com/rathena/rathena/blob/master/src/map/script.c#L10668 Edited January 24, 2014 by AnnieRuru Link to comment Share on other sites More sharing options...
Skorm Posted January 24, 2014 Group: Forum Moderator Topic Count: 33 Topics Per Day: 0.01 Content Count: 1282 Reputation: 393 Joined: 02/03/12 Last Seen: 21 hours ago Share Posted January 24, 2014 @Skorm http://www.eathena.ws/board/index.php?s=&showtopic=186459&view=findpost&p=1038374 weird, what I did was actually a method from the author himself ... I have read through addrid source code many times to confirm this https://github.com/rathena/rathena/blob/master/src/map/script.c#L10668 X_X Link to comment Share on other sites More sharing options...
MeWhoMustNotBeNamed Posted January 25, 2014 Group: Members Topic Count: 2 Topics Per Day: 0.00 Content Count: 20 Reputation: 2 Joined: 03/01/13 Last Seen: March 9, 2014 Author Share Posted January 25, 2014 thanks for the response. what if i just have to get those players[non GM] that are still alive on a certain map. example prontera. @skorm i was trying to make an event npc thats why im asking. @annieruru yeah i was making an event npc. i was just wondering if i have to used array. what if someobe got disconnected due to connection errors does tge script if lms is not bug? Link to comment Share on other sites More sharing options...
AnnieRuru Posted January 25, 2014 Group: Members Topic Count: 18 Topics Per Day: 0.00 Content Count: 2044 Reputation: 682 Joined: 10/09/12 Last Seen: December 20, 2020 Share Posted January 25, 2014 http://rathena.org/board/topic/90441-last-man-standing/?p=236642 that's the latest lms script I wrote if the player logout, it should be countered by OnPCLogoutEvent search for index in the array and deduct it Link to comment Share on other sites More sharing options...
Question
MeWhoMustNotBeNamed
is it possible to get the number of player in a certain map excluding those gm account?
Link to comment
Share on other sites
8 answers to this question
Recommended Posts