Advertisement
Guest User

dropswapper interface

a guest
Aug 20th, 2019
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function int String2Int(String pff)
  2. {
  3.  local String digits[24];
  4.  local int i, counter, result;
  5. i=0;
  6. while ((len(pff)) > 0)  // while there is stuff to munch on
  7. {
  8. digits[i]=right(pff,1);
  9. pff=left(pff,len(pff)-1);
  10. i++;}
  11. counter=i;
  12. result=0;
  13.  
  14.  for(i=0; i<counter; i++)
  15.     result+=String2IntSingle(digits[i])*(exp_s(10,i));
  16.  return(result);
  17. }
  18.  
  19.  
  20. function int String2IntSingle(String s)
  21. {
  22.  switch(s)
  23.  {
  24.  case("9"):return(9);break;
  25.  case("8"):return(8);break;
  26.  case("7"):return(7);break;
  27.  case("6"):return(6);break;
  28.  case("5"):return(5);break;
  29.  case("4"):return(4);break;
  30.  case("3"):return(3);break;
  31.  case("2"):return(2);break;
  32.  case("1"):return(1);break;
  33.  case("0"):case(" "):case(""):return(0);break;
  34.  };
  35. }
  36.  
  37.  
  38. function int exp_s(int base, int h)
  39. {
  40.  local int i, result;
  41.  if (h==0) return(1);
  42.  if (h==1) return(base);
  43.  if (h<0) return (-1); // illegal!!!
  44.  result=1;
  45.  for(i=0;i<h;i++) result*=base;
  46.  return(result);
  47. }
  48.  
  49.  
  50. function bool IsNumeric(string str)
  51. {
  52. switch(str)
  53.  {
  54.  case("0"):return true;break;
  55.  case("1"):return true;break;
  56.  case("2"):return true;break;
  57.  case("3"):return true;break;
  58.  case("4"):return true;break;
  59.  case("5"):return true;break;
  60.  case("6"):return true;break;
  61.  case("7"):return true;break;
  62.  case("8"):return true;break;
  63.  case("9"):return true;break;
  64.  case("10"):return true;break;
  65.  case("11"):return true;break;
  66.  case("12"):return true;break;
  67.  case("13"):return true;break;
  68.  case("14"):return true;break;
  69.  case("15"):return true;break;
  70.  case("16"):return true;break;
  71.  case("17"):return true;break;
  72. case("18"):return true;break;
  73. case("19"):return true;break;
  74. case("20"):return true;break;
  75. case("21"):return true;break;
  76. case("22"):return true;break;
  77. case("23"):return true;break;
  78. case("24"):return true;break;
  79.   default:
  80.   return false;
  81.   break;
  82.  };
  83.  
  84. }
  85.  
  86.  
  87. function ExecuteCommand(string cmd)
  88. {
  89.     local int i, words;
  90.    cmd=cmd$" ";
  91.    // cleaning wordlist
  92.    log("msg " $ cmd);
  93.    log("msgx " $ wordlist[0]$ "," $ wordlist[1]  $ "," $ wordlist[2]);
  94.    for(i=0;i<500;i++)
  95.    {
  96.      if (i > 499) break;
  97.      WordList[i]="";
  98.    }
  99.  // parsing command into wordlist
  100.   while ((len(cmd)) > 1)  // while there is stuff to munch on
  101.    {      while(left(cmd,1) != " " )  // delimeter not yet found, adding letter
  102.        { wordlist[words]=wordlist[words]$left(cmd,1);
  103.         cmd=right(cmd,len(cmd)-1);}
  104.      // found one word....
  105.      cmd=right(cmd,len(cmd)-1);
  106.      // reasons to stop further analysis
  107.      if ( (wordlist[words]!=" ")&&(wordlist[words]!="") )  words++;  // ignore " " / "" as word itself
  108.    } // end while len(Command) > 1)
  109.   cmd="";
  110.   // executing commands
  111.   log("msgx1 " $ wordlist[0]$ "," $ wordlist[1]  $ "," $ wordlist[2]);
  112.  
  113.    switch(wordlist[0])
  114.   {// internal parse calls, do NOT do ANYTHING, ONLY WANTED A WORDLIST
  115.    case("/swapdropper"):                sdpro();break;
  116.    case("swapdropper"):                 sdpro();break;
  117.    break;
  118.   }
  119. }
  120.  
  121.  
  122.  
  123. function sdpro()
  124. {
  125. local int i;
  126. log("msgloop " $ wordlist[0]$ "," $ wordlist[1]  $ "," $ wordlist[2]);
  127.  
  128. if (wordlist[1] =="" || wordlist[1] ==" " || wordlist[1] =="help")
  129.        { // usage situation help
  130.        chattinghold.ClientMessage("usage : dropswapper  editdrop | editdropcount | editname ",'Event',true);
  131.        }
  132.  
  133.  
  134.  
  135. if (wordlist[1] =="list" )
  136.        {
  137.        listruleztochat(chattinghold);
  138.        }
  139.  
  140.  
  141.  
  142.  
  143.  
  144. //---------------------
  145.        if (wordlist[1] =="editname" )
  146.        {        //   editdrop command
  147.          
  148.           if (wordlist[2] =="" || wordlist[2] ==" " || wordlist[2] =="help")
  149.               {
  150.                      if (!IsNumeric(wordlist[2]))
  151.                      {
  152.                      chattinghold.ClientMessage(" [!] Editname , missng argument 2 (numeral)",'Event',true);
  153.                      }else{
  154.                      chattinghold.ClientMessage(" [!] Editname , missng argument 2 ",'Event',true);
  155.                      }
  156.               }else{
  157.               chattinghold.ClientMessage("  Editname existing data:" $  pawndwklist[String2Int(wordlist[2])].pawnname,'Event',true);
  158.                     if (String2Int(wordlist[2]) > Array_Size(pawndwklist))
  159.                     {
  160.                     // we need to create a new row.
  161.                     chattinghold.ClientMessage(" [!] Editname ,invalid row. " $ i,'Event',true);
  162.                    
  163.                       if (wordlist[3] =="" || wordlist[3] ==" " || wordlist[3] =="help"  )
  164.                       { // also check for a simple valid classname
  165.                        chattinghold.ClientMessage(" [!] Editname , missing argument 3 (format as a name 'krall' etc)",'Event',true);
  166.                       }else{
  167.                       // we already have this row.  
  168.                        i = Array_Size(pawndwklist) -1;
  169.                        Array_Insert(pawndwklist,Array_Size(pawndwklist),1);
  170.                        pawndwklist[i].dwkthing="unreali.pupae";
  171.                        pawndwklist[i].pawnname=wordlist[3];
  172.                        pawndwklist[i].dropcondional="isa";
  173.                        pawndwklist[i].howmany=1;
  174.                        pawndwklist[i].isenabled=true;
  175.                        chattinghold.ClientMessage("  [ok] Editname ,New row added at " $ i,'Event',true);
  176.                        chattinghold.ClientMessage("  [ok] Editname ,Setting commited.",'Event',true);
  177.                        saveconfig();
  178.                        }
  179.  
  180.  
  181.                    }else{ // array size
  182.  
  183.                      if (wordlist[3] =="" || wordlist[3] ==" " || wordlist[3] =="help"  )
  184.                      { // also check for a simple valid classname
  185.                      chattinghold.ClientMessage(" [!] Editname , Missing argument 3 (format as NAME 'krall' )",'Event',true);
  186.                      }else{
  187.                      pawndwklist[String2Int(wordlist[2])].pawnname = wordlist[3];
  188.                      chattinghold.ClientMessage(" [!] Editname ,Setting commited.",'Event',true);
  189.                      saveconfig();
  190.                      }
  191.  
  192.  
  193.  
  194.  
  195.                    }
  196.  
  197.  
  198.               }
  199.  
  200.        }
  201.  
  202.  
  203.  
  204.  
  205.  
  206.  
  207. //-----------------------
  208. if (wordlist[1] =="editcount" )
  209.        {        //   editdrop command
  210.          
  211.           if (wordlist[2] =="" || wordlist[2] ==" " || wordlist[2] =="help")
  212.               {
  213.                 // unreasonable  data? !IsNumeric(wordlist[2])
  214.                  if (!IsNumeric(wordlist[2]))
  215.                     {
  216.                     chattinghold.ClientMessage(" [!] Editcount , missng argument 2 (numeral)",'Event',true);
  217.                     }else{
  218.                     chattinghold.ClientMessage(" [!] Editcount , missng argument 2 ",'Event',true);
  219.                     }
  220.                    
  221.                }else{
  222.                     chattinghold.ClientMessage("  Editcount existing data:" $  pawndwklist[String2Int(wordlist[2])].howmany,'Event',true);
  223.                       if (wordlist[2] =="" || wordlist[2] ==" " || wordlist[2] =="help")
  224.                       {
  225.                          if (!IsNumeric(wordlist[3]))
  226.                          {
  227.                          chattinghold.ClientMessage(" [!] Editcount , missng argument 3 (numeral)",'Event',true);
  228.                          }else{
  229.                          chattinghold.ClientMessage(" [!] Editcount , missng argument 3 ",'Event',true);
  230.                          }
  231.                       }else{
  232.                       pawndwklist[String2Int(wordlist[2])].howmany = String2Int(wordlist[3]);
  233.                       chattinghold.ClientMessage("  [ok] Editcount ,Setting commited.",'Event',true);
  234.                       }
  235.                    
  236.               }
  237.            
  238.       }
  239.  
  240.  
  241.  
  242.  
  243.  
  244.  
  245.  
  246.  
  247. //-----------------------------
  248.        if (wordlist[1] =="editdrop" )
  249.        {        //   editdrop command
  250.          
  251.           if (wordlist[2] =="" || wordlist[2] ==" " || wordlist[2] =="help")
  252.               {
  253.                 // unreasonable  data? !IsNumeric(wordlist[2])
  254.                  if (!IsNumeric(wordlist[2]))
  255.                     {
  256.                     chattinghold.ClientMessage(" [!] Editdrop , missng argument 2 (numeral)",'Event',true);
  257.                     }else{
  258.                     chattinghold.ClientMessage(" [!] Editdrop , missng argument 2 ",'Event',true);
  259.                     }
  260.                     }else{
  261.                 // reasonable date?
  262.                 chattinghold.ClientMessage("  Editdrop existing data:" $  pawndwklist[String2Int(wordlist[2])].dwkthing,'Event',true);
  263.                
  264.                    if (String2Int(wordlist[2]) > Array_Size(pawndwklist))
  265.                    {
  266.                    // we need to create a new row.
  267.                     chattinghold.ClientMessage(" [!] Editdrop ,invalid row. " $ i,'Event',true);
  268.  
  269.                       if (wordlist[3] =="" || wordlist[3] ==" " || wordlist[3] =="help" || InStr(wordlist[3],".")==-1 )
  270.                       { // also check for a simple valid classname
  271.                       chattinghold.ClientMessage(" [!] Editdrop , missing argument 3 (format as 'unreali.krall' etc)",'Event',true);
  272.                       }else{
  273.                     // we already have this row.  
  274.                        i = Array_Size(pawndwklist) -1;
  275.                        Array_Insert(pawndwklist,Array_Size(pawndwklist),1);
  276.                        pawndwklist[i].dwkthing=wordlist[3];
  277.                        pawndwklist[i].pawnname="pupae";
  278.                        pawndwklist[i].dropcondional="isa";
  279.                        pawndwklist[i].howmany=1;
  280.                        pawndwklist[i].isenabled=true;
  281.                        chattinghold.ClientMessage("  [ok] Editdrop ,New row added at " $ i,'Event',true);
  282.                        chattinghold.ClientMessage("  [ok] Editdrop ,Setting commited.",'Event',true);
  283.                        saveconfig();
  284.                        }
  285.  
  286.  
  287.  
  288.  
  289.                    
  290.                    }else{
  291.  
  292.                      if (wordlist[3] =="" || wordlist[3] ==" " || wordlist[3] =="help" || InStr(wordlist[3],".")==-1 )
  293.                      { // also check for a simple valid classname
  294.                      chattinghold.ClientMessage(" [!] Editdrop , Missing argument 3 (format as 'unreali.krall' etc)",'Event',true);
  295.                      }else{
  296.                      pawndwklist[String2Int(wordlist[2])].dwkthing = wordlist[3];
  297.                      chattinghold.ClientMessage(" [!] Editdrop ,Setting commited.",'Event',true);
  298.                      saveconfig();
  299.                      }
  300.  
  301.              
  302.  
  303.                 }  
  304.  
  305.  
  306.  
  307.                
  308.               }
  309.        }
  310.  
  311.  
  312.        if (wordlist[1] =="editdropcount" )
  313.        {
  314.        chattinghold.ClientMessage("editdropcount # , new actor",'Event',true);
  315.        }
  316.  
  317.        if (wordlist[1] =="editcount" )
  318.        {
  319.        chattinghold.ClientMessage("editdropcount # , new actor",'Event',true);
  320.        }
  321.  
  322.  
  323.  
  324.  
  325. //listruleztochat(Chattinghold);
  326. }
  327.  
  328.  
  329. //
  330.  
  331.  
  332.  
  333.  
  334.  
  335.  
  336. function AddGameRules()
  337. {
  338.     local swapdropper_GR gr;
  339.  
  340.     gr = Spawn(class'swapdropper_GR');
  341.     gr.MutatorPtr = self;
  342.  
  343.     if (Level.Game.GameRules == None)
  344.         Level.Game.GameRules = gr;
  345.     else if (gr != None)
  346.         Level.Game.GameRules.AddRules(gr);
  347. }
  348.  
  349. function listrulez()
  350. {
  351.   local int z;
  352.   local bool bfoundanythingatall;
  353.         For( z = 0; z < Array_Size(pawndwklist) ; z++ )
  354.         {
  355.              if ( pawndwklist[z].pawnname != "" )
  356.              {
  357.                  log( "Rule If " $ pawndwklist[z].dropcondional $ " "$ pawndwklist[z].pawnname $ " Drop " $ pawndwklist[z].howmany $ "  "$  pawndwklist[z].dwkthing ,stringtoname("[Swapdropper]"));    
  358.                  bfoundanythingatall = true;
  359.              }  
  360.         }
  361.  
  362. if (!bfoundanythingatall)
  363. {
  364. log( "No DWK Rules found! Goto settings>Swapdropper>pandwklist and set some up!" ,stringtoname("[Swapdropper]"));
  365. }
  366.        
  367. }
  368.  
  369.  
  370.  
  371.  
  372.  
  373.  
  374.  
  375. function bool handleChat( PlayerPawn Chatting, out string Msg )
  376. {
  377. local int i;
  378.           chattinghold = chatting;
  379.           if (msg == "/help")
  380.           {
  381.           Chatting.ClientMessage("[Swapdropper]: The dead will have its revenge! Build 2019.8.20", 'event');
  382.           return true;
  383.           }
  384.  
  385.           if(InStr(msg,"swapdropper")!=-1)   {   ExecuteCommand(msg); return false; }
  386. return true;// pass it on
  387. }
  388.  
  389.  
  390.  
  391. function listruleztochat(playerpawn him)
  392. {
  393.   local int z;
  394.   local bool bfoundanythingatall;
  395.         For( z = 0; z < Array_Size(pawndwklist) ; z++ )
  396.         {
  397.              if ( pawndwklist[z].pawnname != "" )
  398.              {
  399.  him.ClientMessage("    > Rule " $ z $ " : If (" $ pawndwklist[z].dropcondional $ " " $ pawndwklist[z].pawnname $ ") Dies , Spawn  " $ pawndwklist[z].howmany $ "  of class  "$  pawndwklist[z].dwkthing, 'event');
  400.               bfoundanythingatall = true;
  401.              }  
  402.         }
  403.  
  404. if (!bfoundanythingatall)
  405. {
  406. him.ClientMessage("[Swapdropper]: the sderver has no configure drop rules", 'event');
  407. }
  408.        
  409. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement