Jey Posted April 12, 2013 Group: Members Topic Count: 5 Topics Per Day: 0.00 Content Count: 249 Reputation: 73 Joined: 10/20/12 Last Seen: August 16, 2018 Share Posted April 12, 2013 I needed this source mod so i suggest to apply it to rAthena. Modification of getusers(): 2 - Count of all characters in the entire server who are idle. 3 - Count of all characters in the entire server who are not idle. So here's the diff: Index: src/map/script.c =================================================================== --- src/map/script.c (revision 17248) +++ src/map/script.c (working copy) @@ -9624,15 +9624,18 @@ BUILDIN_FUNC(getusers) { int flag, val = 0; - struct map_session_data* sd; + bool idle = false; + TBL_PC *sd, *pl_sd; struct block_list* bl = NULL; + struct s_mapiterator* iter; flag = script_getnum(st,2); - switch(flag&0x07) + switch(flag) { - case 0: - if(flag&0x8) + case 0: //Count all characters on the map of the invoking character + case 8: //Count of all characters on the map of the NPC the script is running in + if(flag==8) {// npc bl = map_id2bl(st->oid); } @@ -9646,9 +9649,20 @@ val = map[bl->m].users; } break; - case 1: + case 1: //Count of all characters in the entire server val = map_getusers(); break; + case 2: //Count of all characters in the entire server who are idle + idle = true; + case 3: //Count of all characters in the entire server who are not idle + iter = mapit_getallusers(); + for( val=0, pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) ) + { + if( pc_isidle(pl_sd) == idle ) + val++; + } + mapit_free(iter); + break; default: ShowWarning("buildin_getusers: Unknown type %d.\n", flag); script_pushint(st,0); Index: src/map/party.c =================================================================== --- src/map/party.c (revision 17248) +++ src/map/party.c (working copy) @@ -916,7 +916,7 @@ // count the number of players eligible for exp sharing for (i = c = 0; i < MAX_PARTY; i++) { - if( (sd[c] = p->data[i].sd) == NULL || sd[c]->bl.m != src->m || pc_isdead(sd[c]) || (battle_config.idle_no_share && pc_isidle(sd[c])) ) + if( (sd[c] = p->data[i].sd) == NULL || sd[c]->bl.m != src->m || pc_isdead(sd[c]) || pc_isidle(sd[c]) ) continue; c++; } @@ -980,7 +980,7 @@ if (i >= MAX_PARTY) i = 0; // reset counter to 1st person in party so it'll stop when it reaches "itemc" - if( (psd = p->data[i].sd) == NULL || sd->bl.m != psd->bl.m || pc_isdead(psd) || (battle_config.idle_no_share && pc_isidle(psd)) ) + if( (psd = p->data[i].sd) == NULL || sd->bl.m != psd->bl.m || pc_isdead(psd) || pc_isidle(psd) ) continue; if (pc_additem(psd,item_data,item_data->amount,LOG_TYPE_PICKDROP_PLAYER)) @@ -998,7 +998,7 @@ int count = 0; //Collect pick candidates for (i = 0; i < MAX_PARTY; i++) { - if( (psd[count] = p->data[i].sd) == NULL || psd[count]->bl.m != sd->bl.m || pc_isdead(psd[count]) || (battle_config.idle_no_share && pc_isidle(psd[count])) ) + if( (psd[count] = p->data[i].sd) == NULL || psd[count]->bl.m != sd->bl.m || pc_isdead(psd[count]) || pc_isidle(psd[count]) ) continue; count++; @@ -1046,7 +1046,7 @@ if (sd->state.autotrade) return 0; - if (battle_config.idle_no_share && pc_isidle(sd)) + if ( pc_isidle(sd) ) return 0; return 1; Index: src/map/pc.h =================================================================== --- src/map/pc.h (revision 17248) +++ src/map/pc.h (working copy) @@ -608,7 +608,7 @@ #define pc_setsit(sd) ( (sd)->state.dead_sit = (sd)->vd.dead_sit = 2 ) #define pc_isdead(sd) ( (sd)->state.dead_sit == 1 ) #define pc_issit(sd) ( (sd)->vd.dead_sit == 2 ) -#define pc_isidle(sd) ( (sd)->chatID || (sd)->state.vending || (sd)->state.buyingstore || DIFF_TICK(last_tick, (sd)->idletime) >= battle_config.idle_no_share ) +#define pc_isidle(sd) ( (sd)->chatID || (sd)->state.vending || (sd)->state.buyingstore || (battle_config.idle_no_share && DIFF_TICK(last_tick, (sd)->idletime) >= battle_config.idle_no_share ) ) #define pc_istrading(sd) ( (sd)->npc_id || (sd)->state.vending || (sd)->state.buyingstore || (sd)->state.trading ) #define pc_cant_act(sd) ( (sd)->npc_id || (sd)->state.vending || (sd)->state.buyingstore || (sd)->chatID || ((sd)->sc.opt1 && (sd)->sc.opt1 != OPT1_BURNING) || (sd)->state.trading || (sd)->state.storage_flag || (sd)->state.prevend ) Index: doc/script_commands.txt =================================================================== --- doc/script_commands.txt (revision 17248) +++ doc/script_commands.txt (working copy) @@ -2919,6 +2919,8 @@ 0 - Count of all characters on the map of the invoking character. 1 - Count of all characters in the entire server. + 2 - Count of all characters in the entire server who are idle. + 3 - Count of all characters in the entire server who are not idle. 8 - Count of all characters on the map of the NPC the script is running in. Do you think this is useful for others, too? Quote Link to comment Share on other sites More sharing options...
AnnieRuru Posted April 21, 2013 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 April 21, 2013 in my opinion, counting non-idle players on the server is usually used by event, so its counted map-wide, not server-wide I suggest if implementing this, might as well add this idea into getmapusers as well ... 1 Quote Link to comment Share on other sites More sharing options...
Jey Posted April 22, 2013 Group: Members Topic Count: 5 Topics Per Day: 0.00 Content Count: 249 Reputation: 73 Joined: 10/20/12 Last Seen: August 16, 2018 Author Share Posted April 22, 2013 So we would get something like this: *getmapusers("<map name>",{<type>}) and maybe*getareausers("<map name>",<x1>,<y1>,<x2>,<y2>,{<type>}) Types: 0 - Count all users (Default) 1 - Count idle users 2 - Count users who are'nt idle Did I understand you correctly? Quote Link to comment Share on other sites More sharing options...
Peopleperson49 Posted October 29, 2013 Group: Members Topic Count: 219 Topics Per Day: 0.05 Content Count: 1181 Reputation: 141 Joined: 01/27/12 Last Seen: April 15 Share Posted October 29, 2013 (edited) This is all very similar to getonlinemember which works very well! I use this to give items to everybody on the server for events or stuff. It would be a good thing to impliment! Peopleperson49 http://roug.ragnarok.so/download/getonlinemember.patch Edited October 29, 2013 by Peopleperson49 Quote Link to comment Share on other sites More sharing options...
REKT Posted May 6, 2016 Group: Members Topic Count: 24 Topics Per Day: 0.00 Content Count: 206 Reputation: 11 Joined: 12/06/11 Last Seen: September 13, 2024 Share Posted May 6, 2016 Is this one still open? Any thoughts for the idea? Quote Link to comment Share on other sites More sharing options...
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.