viewing paste topic/4374- getservermember | Diff

Posted on the
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
 src/map/script.c | 32 ++++++++++++++++++++++++++++++++
 1 file changed, 32 insertions(+)
 
diff --git a/src/map/script.c b/src/map/script.c
index 4fb4e72..608ff08 100644
--- a/src/map/script.c
+++ b/src/map/script.c
@@ -18502,10 +18502,42 @@ bool script_hp_add(char *name, char *args, bool (*func)(struct script_state *st)
        return script->add_builtin(&buildin, true);
 }
 
+BUILDIN(getservermember) {
+       struct map_session_data *pl_sd;
+       struct s_mapiterator* iter = mapit_getallusers();
+       int i = 0, type = 0;
+       if ( script_hasdata(st,2) )
+               type = script_getnum(st,2);
+       switch (type) {
+       default:
+               for ( pl_sd = (TBL_PC*)mapit->first(iter); mapit->exists(iter); pl_sd = (TBL_PC*)mapit->next(iter) ) {
+                       mapreg->setregstr( reference_uid( script->add_str("$@servermembername$"), i ), pl_sd->status.name );
+                       i++;
+               }
+               break;
+       case 1:
+               for ( pl_sd = (TBL_PC*)mapit->first(iter); mapit->exists(iter); pl_sd = (TBL_PC*)mapit->next(iter) ) {
+                       mapreg->setreg( reference_uid( script->add_str("$@servermembercid"), i ), pl_sd->status.char_id );
+                       i++;
+               }
+               break;
+       case 2:
+               for ( pl_sd = (TBL_PC*)mapit->first(iter); mapit->exists(iter); pl_sd = (TBL_PC*)mapit->next(iter) ) {
+                       mapreg->setreg( reference_uid( script->add_str("$@servermemberaid"), i ), pl_sd->status.account_id );
+                       i++;
+               }
+               break;
+       }
+       mapreg->setreg( script->add_str("$@servermembercount"), i );
+       mapit->free(iter);
+       return true;
+}
+
 #define BUILDIN_DEF(x,args) { buildin_ ## x , #x , args }
 #define BUILDIN_DEF2(x,x2,args) { buildin_ ## x , x2 , args }
 void script_parse_builtin(void) {
        struct script_function BUILDIN[] = {
+               BUILDIN_DEF(getservermember,"i"),
                // NPC interaction
                BUILDIN_DEF(mes,"s*"),
                BUILDIN_DEF(next,""),
 
Viewed 644 times, submitted by AnnieRuru.