SHARE
TWEET

Mailbox code

bobisunreal Feb 7th, 2016 6 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. function getmail(playerpawn p)
  3. {
  4. local string localbs,values;
  5. local int i,mailcount;
  6. localbs = dbobject.concatgroups (getplayername(p)$".inbox");
  7. ExecuteCommand(localbs);
  8.  
  9.  
  10.       // getiing mail is broken due to the return having spaces in it.
  11.      For( i = 0; i <  200 ; i++  )
  12.      {
  13.        if (wordlist[i] != "" && wordlist[i] != " " && wordlist[i] != "nil")
  14.        {
  15.         log (wordlist[i] ,stringtoname("[mailsrv]"));
  16.          values =  dbobject.getdatavalue (getplayername(p)$".inbox" , wordlist[i]);
  17.          if (values != "nil") //&& values == "unread")
  18.          {
  19.          mailcount ++;
  20.          p.ClientMessage("Inbox -" $ wordlist[i]);
  21.          }
  22.        }
  23.      }
  24.  
  25. if (mailcount > 0)
  26. {
  27. p.ClientMessage("Inbox you have " $ mailcount $ "unread messages in your inbox , chat /inbox markread to ignore them");
  28. }else{
  29. //p.ClientMessage("Inbox you have " $ mailcount  " messages in your inbox");
  30. }
  31.  
  32.  
  33.  
  34. }
  35.  
  36. function sendmail(playerpawn p,string target,string message)
  37. {
  38. local string localbs;
  39. local int i,mailcount;
  40. local bool isuser,userpassed;
  41.  
  42. // lookup if a player was ever here
  43. localbs = dbobject.concatgroups ("loggedplayer");
  44. ExecuteCommand(localbs);
  45.  
  46.  
  47.    //  check if  the user has been here
  48.  
  49.      For( i = 0; i <  200 ; i++  )
  50.      {
  51.        if (wordlist[i] != "" && wordlist[i] != " " && wordlist[i] != "nil")
  52.        {
  53.           if (wordlist[i] == target)
  54.           {
  55.            isuser = true;
  56.           }
  57.  
  58.        }
  59.      }
  60.  
  61.  
  62.  
  63.      if (!isuser )
  64.        {
  65.          // not been here
  66.          p.ClientMessage("The user you requested has probably never been on this server!");
  67.  
  68.          if (dbobject.getdatavalue (target $".nickserv" ,"password") == "nil")
  69.          {
  70.           // no account
  71.            p.ClientMessage("The user you requested to leave a message for has never setup a account!");
  72.          }else{
  73.            //  account but not logged at prelogin ? lol
  74.            // i lul - but this can happen becuase we only started logging
  75.            // prelogin later on
  76.            userpassed  = true;
  77.          }
  78.  
  79.        }else{
  80.           // been here
  81.  
  82.          if (dbobject.getdatavalue (target $".nickserv" ,"password") == "nil")
  83.          {
  84.           //  no account here
  85.          p.ClientMessage("The user you requested to leave a message for has never setup a account!");
  86.          }else{
  87.           //  account !
  88.           userpassed  = true;
  89.          }
  90.  
  91.  
  92.        }
  93.  
  94.  
  95.   if (userpassed)
  96.   {
  97.   // some user exists
  98.  
  99.  
  100.   dbobject.updatedatavalue (target$".inbox" , "message~~~from~~~" $ getplayername(p) $ "~~~" $ stripspaces(message) ,"unread");
  101.   p.ClientMessage("message saved, the user will see it next time he/she logs in!");
  102.   }
  103.  
  104.  
  105. }
  106.  
  107.  
  108. // delimiter avoidance nonsence
  109. function string stripspaces(string inputstr)
  110. {
  111. local int p,lenn;
  112. lenn = len(inputstr);
  113. For(p = 0; p <  lenn ; p++  )
  114.                        {
  115.                        inputstr = ReplaceStr(inputstr, " ", "~~~");
  116.  
  117.  
  118.                        }
  119.  return inputstr;
  120. }
  121.  
  122. function string putbackspaces(string inputstr)
  123. {
  124. local int p,lenn;
  125. lenn = len(inputstr);
  126. For(p = 0; p <  lenn ; p++  )
  127.                        {
  128.                        inputstr = ReplaceStr(inputstr, "~~~", " ");
  129.                        }
  130. return inputstr;
  131. }
RAW Paste Data
Pastebin PRO Summer Special!
Get 40% OFF on Pastebin PRO accounts!
Top