/*
Created by: Aeromesi
Version: 1.0
Comments: None
Built for Hercules
*/
function script ClaimRewardz {
if(ClaimReward >= 2) {
ClaimReward = 1;
}
if(ClaimZReward >= 2) {
ClaimZReward = 1;
}
mes "[^FF0000Giveaway Reward NPC^000000]";
mes "Current Rewards Pending:";
next;
switch(select("Items Pending - "+((ClaimReward == 0)?"^f94a32":"^0000ff")+""+ClaimReward+"^000000","Zeny Pending - "+((ClaimZReward == 0)?"^f94a32":"^0000ff")+""+ClaimZReward+"^000000"))
{
case 1:
if(ClaimReward == 0){
mes "[^FF0000Giveaway Reward NPC^000000]";
mes "There is no item rewards currently pending.";
close;
} else if(ClaimReward == 1){
ClaimReward--;
mes "[^FF0000Giveaway Reward NPC^000000]";
mes "You have a reward currently pending!";
mes "I will now hand you the reward.";
getitem citemid,camount;
close;
}
case 2:
if(ClaimZReward == 0){
mes "[^FF0000Giveaway Reward NPC^000000]";
mes "There is no Zeny rewards currently pending.";
close;
} else if(ClaimZReward == 1){
ClaimZReward--;
mes "[^FF0000Giveaway Reward NPC^000000]";
mes "You have a reward currently pending!";
mes "I will now hand you the reward.";
dispbottom "Gained a total of "+zamount+" Zeny!";
Zeny = Zeny+zamount;
close;
}
}
}
eden,115,64,4 script Giveaway Reward NPC 89,{
if( getgmlevel() >= 99 ){
mes "[^FF0000Giveaway Reward NPC^000000]";
mes "Please choose your reward type: Items or Zeny?";
next;
switch(select("Item Reward: Zeny Reward")){
case 1:
callfunc ("ItemReward");
end;
case 2:
callfunc ("ZenyReward");
end;
}
}
if (getgmlevel() <= 1){
callfunc ("ClaimRewardz");
end;
}
}
function script ItemReward {
OnItemRewardz:
if( getgmlevel() >= 99 ){
mes "[^FF0000Giveaway Reward NPC^000000]";
mes "Please choose your input type. Type 'map' to give items on the current map you're on or 'all' to reward all players in the server.";
input @whispervar0$;
next;
// check map
if( @whispervar0$ == "all" ) .@type$ = "";
else if( @whispervar0$ == "map" ) .@type$ = strcharinfo(3);
else {
dispbottom "Error, pick 'map' or 'all' ";
callsub OnItemRewardz;
end;
}
}
OnItemID:
mes "[^FF0000Giveaway Reward NPC^000000]";
mes "Please input the item ID you want.";
input .@itemid;
if( getitemname( .@itemid ) == "null" ){
dispbottom "Enter valid item id";
close2;
end;
}
next;
OnItemAmount:
mes "[^FF0000Giveaway Reward NPC^000000]";
mes "Now input the amount of the items you want to giveaway.";
input .@amount;
if(.@amount < 1 ){
dispbottom "Enter valid amount. Please retry.";
close2;
end;
}
close2;
.@self_id = getcharid(3);
query_sql( "SELECT COUNT(`account_id`) FROM `char` WHERE `online` = 1 ", .@total );
while( .@count < .@total ){
query_sql( "SELECT `account_id`,`name` FROM `char` WHERE `online` = 1 ORDER BY `account_id` LIMIT 128 OFFSET "+.@offset, .@aid,.@name$ );
.@i = 0;
.@size = getarraysize( .@aid );
while( .@i < .@size ){
if( .@aid[.@i] != .@self_id ){
if( .@type$ != "" ){
getmapxy( .@map$,.@x,.@y,0,.@name$[.@i] );
if( .@map$ == .@type$ ){
.@gave++;
announce "[GM] "+strcharinfo(0)+" Gave "+.@amount+" x "+getitemname( .@itemid )+" to "+.@gave+" Player(s). Proceed to the Giveaway Rewards NPC to claim your reward!",bc_all;
if (attachrid(.@aid[.@i])){
if ( !checkcell( .@map$, .@x, .@y, cell_water )) {
dispbottom "you have to stand on a body of water";
} else
if ( checkcell( .@map$, .@x, .@y, cell_water )) {
dispbottom "activated";
citemid = .@itemid;
camount = .@amount;
ClaimReward++;
end;
}
}
end;
}else{
.@gave++;
announce "[GM] "+strcharinfo(0)+" Gave "+.@amount+" x "+getitemname( .@itemid )+" to "+.@gave+" Player(s). Proceed to the Giveaway Rewards NPC to claim your reward!",bc_all;
if (attachrid(.@aid[.@i])){
ClaimReward++;
citemid = .@itemid;
camount = .@amount;
}
}
}
.@count++;
.@i++;
}
.@offset = .@offset + .@size;
deletearray .@aid,.@size;
deletearray .@name$,.@size;
}
end;
}
}
function script ZenyReward {
OnZenyRewardz:
if( getgmlevel() >= 99 ){
mes "[^FF0000Giveaway Reward NPC^000000]";
mes "Please choose your input type. Type 'map' to give items on the current map you're on or 'all' to reward all players in the server.";
input @whispervar0$;
next;
// check map
if( @whispervar0$ == "all" ) .@type$ = "";
else if( @whispervar0$ == "map" ) .@type$ = strcharinfo(3);
else {
dispbottom "Error, pick 'map' or 'all' ";
callsub OnZenyRewardz;
end;
}
}
// next;
OnZenyAmount:
mes "[^FF0000Giveaway Reward NPC^000000]";
mes "Now input the amount of the Zeny you want to giveaway.";
input .@Zamount;
if(.@Zamount < 1 ){
dispbottom "Enter valid amount. Please retry.";
close2;
end;
}
if(.@Zamount == MAX_ZENY) {
dispbottom "You cannot input that much Zeny, as it exceeds the servers MAX_ZENY integer.";
end;
}
close2;
.@self_id = getcharid(3);
query_sql( "SELECT COUNT(`account_id`) FROM `char` WHERE `online` = 1 ", .@total );
while( .@count < .@total ){
query_sql( "SELECT `account_id`,`name` FROM `char` WHERE `online` = 1 ORDER BY `account_id` LIMIT 128 OFFSET "+.@offset, .@aid,.@name$ );
.@i = 0;
.@size = getarraysize( .@aid );
while( .@i < .@size ){
if( .@aid[.@i] != .@self_id ){
if( .@type$ != "" ){
getmapxy( .@map$,.@x,.@y,0,.@name$[.@i] );
if( .@map$ == .@type$ ){
.@gave++;
announce "[GM] "+strcharinfo(0)+" Gave "+.@Zamount+" Zeny to "+.@gave+" Player(s). Proceed to the Giveaway Rewards NPC to claim your reward!",bc_all;
if (attachrid(.@aid[.@i])){
zamount = .@Zamount;
ClaimZReward++;
}
}
}else{
.@gave++;
announce "[GM] "+strcharinfo(0)+" Gave "+.@Zamount+" Zeny to "+.@gave+" Player(s). Proceed to the Giveaway Rewards NPC to claim your reward!",bc_all;
if (attachrid(.@aid[.@i])){
ClaimZReward++;
zamount = .@Zamount;
}
}
}
.@count++;
.@i++;
}
.@offset = .@offset + .@size;
deletearray .@aid,.@size;
deletearray .@name$,.@size;
}
end;
}
eden,112,58,4 script DipaDoo 89,{
getmapxy .@map$, .@x, .@y, 0;
if ( !checkcell( .@map$, .@x, .@y, cell_water ) ) {
dispbottom "Not in water!";
end;
}
dispbottom "In Water";
end;
OnInit:
setitemscript Red_Potion, "{ getmapxy .@map$, .@x, .@y, 0; if ( !checkcell( .@map$, .@x, .@y, call_water ) ) { dispbottom \"you have to stand on a body of water\"; end; } else dispbottom \"let's go fishing\"; }", 0;
}