viewing paste topic/4446- guildjoin.diff | 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
 src/map/script.c | 29 +++++++++++++++++++++++++++++
 1 file changed, 29 insertions(+)
 
diff --git a/src/map/script.c b/src/map/script.c
index 2c89321..90b551d 100644
--- a/src/map/script.c
+++ b/src/map/script.c
@@ -18735,10 +18735,39 @@ bool script_hp_add(char *name, char *args, bool (*func)(struct script_state *st)
        return script->add_builtin(&buildin, true);
 }
 
+BUILDIN(guildjoin) {
+       int guild_id = script_getnum(st,2), i, count = 0;
+       TBL_PC * sd;
+       struct guild * g;
+       if ( !( sd = map->charid2sd( script_getnum(st,3) ) ) ) {
+               script_pushint(st,-1);
+               return false;
+       }
+       if ( sd->status.guild_id ) {
+               script_pushint(st,-2);
+               return false;
+       }
+       if ( !( g = guild->search( guild_id ) ) ) {
+               script_pushint(st,-3);
+               return false;
+       }
+       for ( i = 0; i < g->max_member; i++ )
+               if ( g->member[i].account_id )
+                       count++;
+       if ( count >= g->max_member ) {
+               script_pushint(st,-4);
+               return false;
+       }
+       sd->guild_invite = guild_id;
+       script_pushint( st, guild->reply_invite( sd, guild_id, 1 ) );
+       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(guildjoin,"ii"),
                // NPC interaction
                BUILDIN_DEF(mes,"s*"),
                BUILDIN_DEF(next,""),
 
Viewed 814 times, submitted by AnnieRuru.