Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //script.c
- +static int buildin_areascript_sub(struct block_list *bl,va_list ap)
- +{
- + char *bonus_script = va_arg(ap,char *);
- + struct script_code *script = parse_script(bonus_script, "script4each", 0, 0);
- +
- + run_script(script,0,bl->id,0);
- +
- + return 0;
- +}
- +BUILDIN_FUNC(script4each)
- +{
- + int type;
- + const char *bonus_script;
- + struct map_session_data* pl_sd;
- + struct s_mapiterator* iter;
- + struct script_code *script;
- +
- + bonus_script = script_getstr(st,2);
- + type = script_getnum(st,3);
- +
- + script = parse_script(bonus_script, "script4each", 0, 0);
- +
- + iter = mapit_getallusers();
- +
- + switch (type)
- + {
- + case 0:
- + for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
- + run_script(script,0,pl_sd->bl.id,0);
- + break;
- +
- + case 1:
- + {
- + int map_index;
- +
- + if(!script_hasdata(st, 4))
- + break;
- + if(map_mapname2mapid(script_getstr(st,4)) < 0)
- + break;
- +
- + map_index = map_mapname2mapid(script_getstr(st,4));
- + for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
- + {
- + if(pl_sd->bl.m == map_index)
- + run_script(script,0,pl_sd->bl.id,0);
- + }
- +
- + }
- + break;
- +
- + case 2:
- + {
- + int map_index,x,y,range;
- + struct block_list center;
- +
- + if(!script_hasdata(st, 4) || !script_hasdata(st, 5) || !script_hasdata(st, 6) || !script_hasdata(st, 7))
- + break;
- + else
- + {
- + if(map_mapname2mapid(script_getstr(st,4)) < 0)
- + break;
- +
- + x = script_getnum(st,5);
- + y = script_getnum(st,6);
- + range = script_getnum(st,7);
- +
- + map_index = map_mapname2mapid(script_getstr(st,4));
- + center.m = map_index;
- + center.x = x;
- + center.y = y;
- +
- + map_foreachinrange(buildin_areascript_sub, ¢er, range, BL_PC, bonus_script);
- + }
- + }
- + break;
- +
- + case 3:
- + {
- + TBL_PC *sd;
- + int char_id, party_id;
- +
- + if(!script_hasdata(st, 4))
- + break;
- + else
- + char_id = script_getnum(st,4);
- +
- + sd = map_charid2sd(char_id);
- + if (!sd) break;
- + party_id = sd->status.party_id;
- +
- + if(party_id == 0)
- + break;
- +
- + for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
- + {
- + if(pl_sd->status.party_id == party_id)
- + run_script(script,0,pl_sd->bl.id,0);
- + }
- + }
- + break;
- +
- + case 4:
- + {
- + TBL_PC *sd;
- + int char_id, guild_id;
- +
- + if(!script_hasdata(st, 4))
- + break;
- + else
- + char_id = script_getnum(st,4);
- +
- + sd = map_charid2sd(char_id);
- + if (!sd) break;
- + guild_id = sd->status.guild_id;
- +
- + if(guild_id == 0)
- + break;
- +
- + for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
- + {
- + if(pl_sd->status.guild_id == guild_id)
- + run_script(script,0,pl_sd->bl.id,0);
- + }
- + }
- + break;
- +
- + case 5:
- + {
- + int map_index,x0,y0,x1,y1;
- +
- + if(!script_hasdata(st, 4) || !script_hasdata(st, 5) || !script_hasdata(st, 6) || !script_hasdata(st, 7) || !script_hasdata(st, 8))
- + break;
- + else
- + {
- + if(map_mapname2mapid(script_getstr(st,4)) < 0)
- + break;
- +
- + x0 = script_getnum(st,5);
- + y0 = script_getnum(st,6);
- + x1 = script_getnum(st,7);
- + y1 = script_getnum(st,8);
- + map_index = map_mapname2mapid(script_getstr(st,4));
- + map_foreachinarea(buildin_areascript_sub,map_index,x0,y0,x1,y1,BL_PC,bonus_script);
- + }
- + }
- + break;
- +
- + case 6:
- + {
- + int party_id;
- +
- + if(!script_hasdata(st, 4))
- + break;
- + else
- + party_id = script_getnum(st,4);
- +
- + for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
- + {
- + if(pl_sd->status.party_id == party_id)
- + run_script(script,0,pl_sd->bl.id,0);
- + }
- + }
- + break;
- +
- + case 7:
- + {
- + int guild_id;
- +
- + if(!script_hasdata(st, 4))
- + break;
- + else
- + guild_id = script_getnum(st,4);
- +
- + for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
- + {
- + if(pl_sd->status.guild_id == guild_id)
- + run_script(script,0,pl_sd->bl.id,0);
- + }
- + }
- + break;
- +
- + default:
- + //ShowError("script4each : %d %s!\n",type,sys_msg(390));
- + ShowError("script4each : %d 是一個錯誤的類型!\n",type);
- + break;
- + }
- +
- + if(script)
- + script_free_code(script);
- +
- + return 0;
- +}
- +BUILDIN_DEF(script4each,"si?????"),
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement