Skip to content

Instantly share code, notes, and snippets.

@akiyamamio16
Last active May 16, 2019 16:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save akiyamamio16/2c5e53bf7f70bb82e89461cdb1fd7264 to your computer and use it in GitHub Desktop.
Save akiyamamio16/2c5e53bf7f70bb82e89461cdb1fd7264 to your computer and use it in GitHub Desktop.
Item Sale Auto Random
/////////////////////////////
//ITEM SALE AUTO RANDOM//////
//by: Haruka Mayumi//////////
//Version: 1.0///////////////
//Initial Script/////////////
//Version: 1.1///////////////
//Added Hour Option//////////
/////////////////////////////
prontera,155,181,5 script Item Sale 811,{
function CheckCost;
if(getgmlevel() >=99){goto Admin_Panel;}
goto CheckShop;
CheckShop:
mes "[Item Sale]";
mes "Hello ^0000FF"+strcharinfo(0)+"^000000, We are having Item Sales!";
mes "You can buy the following items!.";
if( getitemname( atoi( .Currency$ ) ) != "null" ){
mes "Currency - [~^0000FF"+getitemname( atoi( .Currency$ ) )+"^000000~]";
}else{
mes "Currency - [~^0000FF"+.Currency$+"^000000~]";}
npcshopitem "Item_Sale",501,100;
npcshopdelitem "Item_Sale",501;
for(set .@i,0; .@i < getarraysize( .ShopItem ); .@i++)
npcshopadditem "Item_Sale",.ShopItem[.@i],.ShopCost[.@i];
callshop "Item_Sale",1;
npcshopattach "Item_Sale";
end;
OnBuyItem:
mes "[Item Sale]";
mes "This is your Bill:";
for(set @i,0; @i < getarraysize( @bought_nameid ); set @i,@i+1){
for(set @j,0; @j < getarraysize( .ShopItem ); set @j,@j+1){
if( .ShopItem[@j] == @bought_nameid[@i] ){
set .@TotalCost,.@TotalCost + ( .ShopCost[@j] * @bought_quantity[@i] );
}
}
}
for( set @i,0; @i < getarraysize( @bought_nameid ); set @i,@i+1 ){
mes "^FF0000"+@bought_quantity[@i]+" x ^0000FF"+getitemname( @bought_nameid[@i] )+"^000000";
}
mes "Total Cost: "+.@TotalCost;
if( CheckCost(.Currency$,.@TotalCost)){
if(getitemname(atoi(.Currency$)) != "null" ){
mes "~Insufficient ^0000FF"+getitemname( atoi( .Currency$ ) )+"^000000";
}else{
mes "~Insufficient ^0000FF"+.Currency$+"^000000";
}
}else{
next;
if( select( "^0000FFPurchase^000000:Cancel" ) == 1 ){
if( getitemname( atoi( .Currency$ ) ) != "null" )
delitem atoi( .Currency$ ),.@TotalCost;
else{
set getd( .Currency$ ),getd( .Currency$ ) - .@TotalCost;
}
for(set @i,0; @i < getarraysize( @bought_nameid ); set @i,@i+1)
getitem @bought_nameid[@i],@bought_quantity[@i];
mes "[Item Sale]";
mes "Thank you for shopping.";
mes "Hope to see you againa!";
}
}
end;
OnChangeItems:
for(.@i=0;.@i<.TotalShopItems;.@i++){
set .rand,rand(0,getarraysize(.ItemLists));
for(set .@l,0;.@l<.TotalShopItems;set .@l,.@l+1){
if(.ItemLists[.rand]==.ShopItem[.@l]){
set .rand,rand(0,getarraysize(.ItemLists));
set .@l,-1;
}
}
sleep2 100;
set .ShopItem[.@i],.ItemLists[.rand];
set .ShopCost[.@i],.ItemCost[.rand];
}
announce "Item Sales has been Changed! Come Check out the Items!",0;
end;
Admin_Panel:
switch(select("Check Shop:Randomize Items:Cancel")){
case 1:
goto CheckShop;
case 2:
mes "[Item Sale]";
mes "Please Wait for a while..";
mes "Randomizing the items now..";
goto OnChangeItems;
case 3:
end;
}
end;
function CheckCost {
if( getitemname(atoi(getarg(0)))!= "null" ){
if(countitem(atoi(getarg(0)))< getarg(1) ) return 1;
}else{
if(getd(getarg(0))< getarg(1)) return 1;
}
return 0;
}
OnMinute00: //CHANGE HERE FOR MINUTE
for(.@a=0;.@a<getarraysize(.Time);.@a++){
if(gettime(3)==.Time[.@a]){
for(.@i=0;.@i<getarraysize(.Days);.@i++){
if(gettime(DT_DAYOFWEEK)==.Days[.@i]){
goto OnChangeItems;
}
}
}
}
end;
OnInit:
//ITEM ID or #CASH/#PVPPOINTS
set .Currency$,"7720";
//TOTAL ITEMS YOU WANT TO SEE IN THE SHOP- MAKE SURE THAT ITS COUNT IS LOWER THAN ITEMLIST
set .TotalShopItems,5;
//DAYS YOU WANT TO RESET at TICK Time 12:00AM e.g 0= Sunday, 1=Monday, 2=Tuesday and so on.
setarray .Days[0],1,3;
//TIME TICK BY HOURS. e.g 1= 1am, 8=8am, 14=2pm.
setarray .Time[0],0,4,8,12,16,20; //12am,4am,8am,12pm,4pm,8pm
//ITEMS LIST FOR RANDOM ITEMS SALE
setarray .ItemLists[0],501,502,503,504,505,506,507,508,509,510,511,512;
//COST OF ITEMS
setarray .ItemCost[0],1,2,3,4,5,6,7,8,9,10,11,12;
end;
}
- shop Item_Sale -1,501:100
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment