Advertisement
Skorm

Guild Warehouse w/ Password/Position Based Restrictions v1

Jun 2nd, 2013
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 5.02 KB | None | 0 0
  1. //Version 1.1
  2. prontera,165,188,4  script  Guild Warehouse 112,{
  3. //NPC file here!
  4.     cutin "kafra_06",2;
  5.  
  6.     mes "[Guild Warehouse Coupler]";
  7.     mes "This is the guild warehouse coupler service.";
  8.     next;
  9.     menu "Access Guild Warehouse", GS_OPEN, "Set Guild Warehouse Password", GS_PASS, "Exit", GS_EXIT3;
  10.  
  11. GS_OPEN:
  12.     if(getd("$gscurb"+getcharid(2))){
  13.         query_sql("SELECT `char_id` FROM `guild_member` WHERE `position` "+escape_sql(getd("$gscurb"+getcharid(2)+"$"))+" "+escape_sql(getd("$gscurb"+getcharid(2)))+" AND `guild_id` = "+getcharid(2)+" AND `char_id` = "+getcharid(0)+";",.@b);
  14.         if(getcharid(0)!=.@b) {
  15.             mes "Guild storage is restricted by guild position.";
  16.             mes "Contact your guild master for information regarding the guild positions.";
  17.             goto GS_EXIT4;
  18.         }
  19.     }
  20.     if(getd("$gspass"+getcharid(2)+"$")!=""){
  21.         mes "Please input your guilds password."; input(.@gspass$);
  22.         if(.@gspass$==getd("$gspass"+getcharid(2)+"$")){ mes "Welcome!"; } else { mes "I'm sorry but that's incorrect, please try again later."; goto GS_EXIT4; }
  23.     }
  24.     set @flag,guildopenstorage;
  25.     if(@flag == 1) goto GS_EXIT1;
  26.     if(@flag == 2) goto GS_EXIT2;
  27.     goto GS_EXIT4;
  28.  
  29. GS_PASS:
  30.     if(!getcharid(2)) { mes "I'm sorry but you don't have a guild."; goto GS_EXIT4; }
  31.     set .@b,getguildmasterid(getcharid(2));
  32.     if(.@b!=getcharid(0)){ mes "I'm sorry but you're not the leader of "+strcharinfo(2)+"."; goto GS_EXIT4; }
  33.     if(getd("$gspass"+getcharid(2)+"$")!=""){ mes "Did you forget, your guild password is "+getd("$gspass"+getcharid(2)+"$")+". Do you still want to change it?"; if(select("Yes:No")-1) goto GS_EXIT4; }
  34.     mes "Please Input your new guild password.";
  35.     input(.@gspass1$);
  36.     while(.@gspass1$!=.@gspass2$){
  37.         mes "Again.";   input(.@gspass2$);  set .@p,.@p+1;
  38.         if(.@p>1){
  39.             mes "I'm sorry, but your passwords didn't match, please try again."; goto GS_PASS;
  40.         }
  41.     }
  42.     setd "$gspass"+getcharid(2)+"$",.@gspass1$;
  43.     mes getd("$gspass"+getcharid(2)+"$")+", has been set as your password.";
  44.     goto GS_EXIT4;
  45.    
  46. GS_EXIT1:
  47.     mes "[Guild Warehouse]";
  48.     mes "The guild warehouse is being used right now.";
  49.     mes "Please wait a while, then come back.";
  50.     goto GS_EXIT4;
  51.  
  52. GS_EXIT2:
  53.     mes "[Guild Warehouse]";
  54.     mes "You can't use this service if you're not in a guild!";
  55.     goto GS_EXIT4;
  56.  
  57. GS_EXIT3:
  58.     mes "[Guild Warehouser]";
  59.     mes "Come back whenever you want.";
  60.  
  61. GS_EXIT4:
  62.     cutin "kafra_06",255;
  63.     close;
  64.  
  65. //Add to other guildstorage npcs.
  66. //donpcevent "Guild Warehouse::GS_OPEN";
  67.  
  68. //@command part starts here!
  69.  
  70. OnInit:
  71.     bindatcmd "gspw",strnpcinfo(3)+"::OnPassword";
  72.     bindatcmd "gscurb",strnpcinfo(3)+"::OnRestriction";
  73.     bindatcmd "guildstorage",strnpcinfo(3)+"::OnStorage";
  74.     end;
  75.  
  76. OnPassword:
  77.     if(getguildmasterid(getcharid(2))!=getcharid(0)){
  78.         dispbottom "Only a guild leader may use this command.";
  79.     } else {
  80.         if(.@atcmd_parameters$[0]!=""){
  81.             set .@pass$, escape_sql(.@atcmd_parameters$[0]);
  82.             dispbottom "Updated Guild Storage Password: "+.@pass$+".";
  83.             setd "$gspass"+getcharid(2)+"$",.@pass$;
  84.         } else {
  85.             setd "$gspass"+getcharid(2)+"$",.@pass$;
  86.             dispbottom "Guild password has been reset!";
  87.         }
  88.     }
  89.     end;
  90.  
  91. OnRestriction:
  92.     if(getguildmasterid(getcharid(2))!=getcharid(0)){
  93.         dispbottom "Only a guild leader may use this command.";
  94.     } else {
  95.         query_sql("SELECT `name` FROM `guild_position` WHERE `position` = '"+ .@atcmd_parameters$[1] +"' AND `guild_id` = '"+ getcharid(2) +"';",.@b$);
  96.         setarray .@p$[0],">","=","<",">=","<=","";
  97.         while(.@atcmd_parameters$[0]!=.@p$[.@i]){
  98.             if(.@i==getarraysize(.@p$)){
  99.                 dispbottom .@atcmd_parameters$[0]+" isn't a valid parameter try: >, =, <, >=, <=";
  100.                 dispbottom "Try: @gscurb <operator> <position#>";
  101.                 end;
  102.             }
  103.             set .@i,.@i+1;
  104.         }
  105.         if(.@atcmd_parameters$[1]!=""&&.@atcmd_parameters$[0]!=""){
  106.             dispbottom "Positions "+.@p$[.@i]+" ["+.@b$+"] have access to guild storage.";
  107.             setd "$gscurb"+getcharid(2),escape_sql(.@atcmd_parameters$[1]);
  108.             setd "$gscurb"+getcharid(2)+"$",escape_sql(.@atcmd_parameters$[0]);
  109.         } else {
  110.             setd "$gscurb"+getcharid(2),"";
  111.             setd "$gscurb"+getcharid(2)+"$","";
  112.             dispbottom "Guild storage restriction has been lifted!";
  113.             dispbottom "Try: @gscurb <operator> <position#>";
  114.         }
  115.     }
  116.     end;
  117.  
  118. OnStorage:
  119.     if(!getcharid(2)) { dispbottom "You need a guild to use this command."; end; }
  120.     if(getd("$gscurb"+getcharid(2))){
  121.         query_sql("SELECT `char_id` FROM `guild_member` WHERE `position` "+escape_sql(getd("$gscurb"+getcharid(2)+"$"))+" "+escape_sql(getd("$gscurb"+getcharid(2)))+" AND `guild_id` = "+getcharid(2)+" AND `char_id` = "+getcharid(0)+";",.@b);
  122.         if(getcharid(0)!=.@b) {
  123.             dispbottom "Guild storage is restricted by guild position.";
  124.             dispbottom "Contact your guild master for information regarding the guild positions.";
  125.             end;
  126.         }
  127.     }
  128.     if(getd("$gspass"+getcharid(2)+"$")!=""){
  129.         if(.@atcmd_parameters$[0]==getd("$gspass"+getcharid(2)+"$")){
  130.             guildopenstorage();
  131.         } else {
  132.             dispbottom "Wrong password.";
  133.             dispbottom "Contact your guild master for information regarding the guild password.";
  134.         }
  135.     } else {
  136.         guildopenstorage();
  137.     }
  138.     end;
  139. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement