Advertisement
JustinRoller

dprops reupload

Aug 2nd, 2013
181
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 1.25 KB | None | 0 0
  1. /*
  2.  *            DProp functions 1.1
  3.  *       (c) Copyright 2006-2007 by DracoBlue
  4.  *
  5.  * @author    : DracoBlue (http://dracoblue.com)
  6.  * @date      : 17th June 2006
  7.  * @update    : 3rd June 2007
  8.  *
  9.  * This file is provided as is (no warranties).
  10.  *
  11.  */
  12.  
  13. #if defined _dprop_included
  14.   #endinput
  15. #endif
  16.  
  17. #define _dprop_included
  18. #pragma library dprop
  19.  
  20.  
  21. /**
  22.  *  Checks if a property is Exists
  23.  *  @param   name
  24.  */
  25. stock PropertyExists(name[]) {
  26.   if (existproperty(0, "",dprop_PRIVATE_hash(name))) return true;
  27.   return false;
  28. }
  29.  
  30. /**
  31.  *  Returns the value of a property
  32.  *  @param   name
  33.  */
  34. stock PropertyGet(name[]) {
  35.   new value[255];
  36.   getproperty(0, "", dprop_PRIVATE_hash(name), value);
  37.   strunpack(value,value);
  38.   return value;
  39. }
  40.  
  41. /**
  42.  *  Sets the value of a property
  43.  *  @param   name
  44.  */
  45. stock PropertySet(name[],value[]) {
  46.   setproperty(0, "", dprop_PRIVATE_hash(name), value);
  47. }
  48.  
  49. /*
  50.  *  This function is private, and used for internal
  51.  *  calculation of the hashvalue
  52.  */
  53.  
  54. dprop_PRIVATE_hash(buf[]) {
  55.     new length=strlen(buf);
  56.     new s1 = 1;
  57.     new s2 = 0;
  58.     new n;
  59.     for (n=0; n<length; n++)
  60.     {
  61.        s1 = (s1 + buf[n]) % 65521;
  62.        s2 = (s2 + s1)     % 65521;
  63.     }
  64.     return (s2 << 16) + s1;
  65. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement