//Script by Normynator v1.2
prontera,163,172,4 script Guild Reward 79,{
query_sql( "SELECT `guild_id` FROM `rathena`.`char` WHERE `char_id` = "+ getcharid(0) , .@guild_id);
query_sql( "SELECT `name`, `master`, `guild_lv`, `average_lv` FROM `guild` WHERE `guild_id`= '"+ .@guild_id +"'", .@name$, .@master$, .@guild_lv, .@guild_av );
.@size = query_sql( "SELECT `name` FROM `guild_member` WHERE `guild_id`= '"+ .@guild_id +"'", .@name_m$ );
for( .@i = 0; .@i < .@size; .@i++ ){
if( getcharid( 0,.@name_m$[ .@i ] ) ) .@m++;
}
mes "[ "+ strnpcinfo(1) +" ]";
mes "The Guild Package Contains:";
mes .count + "x " + getitemname(.reward);
next;
mes "[ "+ strnpcinfo(1) +" ]";
mes "You need:";
mes "Guild Lv " + .gl;
mes "Average Lv " + .ga;
mes "Members Online " + .gm;
next;
if(.@master$ == strcharinfo(0)){
mes "Guild Name: " + .@name$;
if(.@guild_lv < .gl){
mes "Guild Level: ^FF0000" + .@guild_lv + "^000000 of req " + .gl;
}else mes "Guild Level: ^00FF00" + .@guild_lv + "^000000";
if(.@guild_av < .ga){
mes "Guild Average: ^FF0000" + .@guild_av + "^000000 of req. " + .ga;
}else mes "Guild Average: ^00FF00" + .@guild_av + "^000000";
if(.@m < .gm){
mes "Guild Members online: ^FF0000" + .@m + "^000000 of req. " + .gm;
}else mes "Members online: ^00FF00" + .@m + "^000000";
if(.@guild_lv == .gl && .@m >= .gm && .@guild_av == .ga && $ready != 0){
next;
mes "[ "+ strnpcinfo(1) +" ]";
mes "Do want to get the the reward now?";
if(select("Yes:No") -1) end;
announce "Guild Master " +.@master$ + " of " + .@name$ + " has acquired the Guild Package for his Guild", 0;
set #GuildReward, 1;
set $ready, .@guild_id;
startnpctimer;
for( .@i = 0; .@i < .@size; .@i++ ){
if(attachrid(getcharid(3,.@name_m$[ .@i ]))){
getitem .reward, .count;
}
}
if(#GuildReward != 1){
mes "You get " + .gmcount + "x " + getitemname(.gmreward);
getitem .gmreward, .gmcount;
close;
}else close;
}else mes "This is not possible at the moment!";
}else{
//if($ready == .@guild_id && #GuildReward != 1){
// mes "You get " + .count + "x " + getitemname(.reward);
// getitem .reward, .count;
// set #GuildReward, 1;
// close;
//}else{
mes "Sorry it's not for you.";
close;
//}
}
OnTimer604800:
set $ready, 0;
stopnpctimer;
setnpctimer 0;
end;
OnInit:
.reward = 607; //Reward item#
.gmreward = 607;//Guild Master Reward
.count = 1; //Count
.gmcount = 10; // Guild master count
.gl = 50; //guildlevel
.ga = 99; //guild average_lv
.gm = 1; // members online
end;
}