eden,115,64,4 script testingalzz 89,{ if( getgmlevel() >= 99 ){ mes "[^FF0000Server & Map Giveaway NPC^000000]"; mes "Please choose your reward type: Items or Zeny?"; next; switch(select("Item Reward: Zeny Reward")){ case 1: callsub OnItemRewardz; end; case 2: callfunc ("ZenyRewardz"); end; } } if (getgmlevel() <= 1){ if(ClaimReward == 0){ mes "There is no current rewards pending."; close; } else if(ClaimReward >= 1){ ClaimReward--; mes "You have a reward currently pending!"; mes "I will now hand you the reward."; getitem citemid,camount; close; } } OnItemRewardz: if( getgmlevel() >= 99 ){ mes "[^FF0000Server & Map Giveaway 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 { // announce "Come to Prontera, a giveaway is under way!!!",bc_all; dispbottom "Error, pick 'map' or 'all' "; callsub OnItemRewardz; end; } } OnItemID: mes "[^FF0000Server & Map Giveaway NPC^000000]"; mes "Please input the item ID you want."; input .@itemid; if( getitemname( .@itemid ) == "null" ){ mes "Enter valid item id"; close; } next; OnItemAmount: mes "[^FF0000Server & Map Giveaway NPC^000000]"; mes "Now input the amount of the items you want to giveaway."; input .@amount; if(.@amount < 1 ){ mes "Enter valid amount. Please retry."; close; } .@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++; /*if( getitemname( .@itemid ) == "null" || .@amount < 1 ){ mes "Enter valid item id and amount."; close2; end; } */ // announce "[GM] "+strcharinfo(0)+" Gave "+.@amount+" x "+getitemname( .@itemid )+" to "+.@gave+" Player(s).",bc_all; if (attachrid(.@aid[.@i])){ citemid = .@itemid; camount = .@amount; ClaimReward++; } //getitem .@itemid,.@amount,.@aid[.@i]; } }else{ .@gave++; /*if( getitemname( .@itemid ) == "null" || .@amount < 1 ){ mes "Enter valid item id and amount."; close2; end; } */ // announce "[GM] "+strcharinfo(0)+" Gave "+.@amount+" x "+getitemname( .@itemid )+" to "+.@gave+" Player(s).",bc_all; if (attachrid(.@aid[.@i])){ ClaimReward++; citemid = .@itemid; camount = .@amount; } // getitem .@itemid,.@amount,.@aid[.@i]; } } .@count++; .@i++; } .@offset = .@offset + .@size; deletearray .@aid,.@size; deletearray .@name$,.@size; } mes "Gave "+.@amount+" x "+getitemname( .@itemid )+" to "+.@gave+" Player(s)."; close2; end; }