pastebin - collaborative debugging tool
rathena.kpaste.net RSS


Untitled
Posted by Anonymous on Wed 16th Jan 2013 22:11
raw | new post

  1. prontera,165,164,3      script  Boy#465asesDA   962,{
  2.         function get_MAC_variable;
  3.         function set_MAC_variable;
  4.         query_sql "SELECT last_mac FROM login WHERE account_id="+ getcharid(3), @my_MAC$;
  5.        
  6.         if (get_MAC_variable("$#lockout") > 0) {
  7.                 mes "I already gave a prize to someone from your MAC address.";
  8.         } else {
  9.                 if (!checkweight(909,1)) {
  10.                         mes "You are overweight or carrying too many items.";
  11.                 } else {
  12.                         getitem 909,1; // Jellopy
  13.                         set_MAC_variable "$#lockout", 1;
  14.                         mes "Here is your prize!";
  15.                 }
  16.         }
  17.         close;
  18.  
  19.         function get_MAC_variable {
  20.                 // $#variable = MAC variable
  21.                 set .@varname$, strtolower(getarg(0, "null"));
  22.                 set .@is_string, (charat(.@varname$, getstrlen(.@varname$)-1) == "$");
  23.                 if (query_sql("SELECT `value` FROM `mac_reg_value` WHERE `mac`='"+ @my_MAC$ +"' AND `str`='"+ escape_sql(.@varname$) +"'", .@value$)) {
  24.                         return (.@is_string ? .@value$ : atoi(.@value$));
  25.                 } else {
  26.                         return (.@is_string ? "" : 0);
  27.                 }
  28.         }
  29.        
  30.         function set_MAC_variable {
  31.                 set .@varname$, strtolower(getarg(0, "null"));
  32.                 set .@is_string, (charat(.@varname$, getstrlen(.@varname$)-1) == "$");
  33.                 set .@value$, getarg(1, (.@is_string ? "" : 0));
  34.                 // trim the trailing "$" so name validation is easier
  35.                 if (.@is_string) set .@varname$, substr(.@varname$, 0,getstrlen(.@varname$) -1);
  36.                
  37.                 // validate variable name
  38.                 if (.@varname$ == "null") {
  39.                         debugmes "set_MAC_variable - missing variable name";
  40.                         end;
  41.                 } else if (getstrlen(.@varname$) < 3 || substr(.@varname$,0,1) != "$#" ) {
  42.                         debugmes "set_MAC_variable - MAC variables must start with $#";
  43.                         end;
  44.                 }
  45.                 for (set .@i,2; .@i < getstrlen(.@varname$); set .@i,.@i+1) {
  46.                         if (compare("abcdefghijklmnopqrstuvwxyz0123456789_", substr(.@varname$, .@i,.@i)) == 0) {
  47.                                 debugmes "set_MAC_variable - variable names can only contain '_' and alphanumeric characters";
  48.                                 end;
  49.                         }
  50.                 }
  51.                
  52.                 // re-add the trailing "$"
  53.                 if (.@is_string) set .@varname$, .@varname$ + "$";
  54.                
  55.                 // check max lengths
  56.                 if (getstrlen(.@varname$) > 255) {
  57.                         debugmes "set_MAC_variable - variable name longer than 255 characters";
  58.                         end;
  59.                 }
  60.                 if (.@is_string && getstrlen(.@value$) > 255) {
  61.                         debugmes "set_MAC_variable - string value longer than 255 characters";
  62.                         end;
  63.                 } else if (!.@is_string && getstrlen(.@value$) > 9) {
  64.                         query_sql "SELECT ('"+ escape_sql(.@value$) +"' BETWEEN -2147483648 AND 2147483647)", .@valid_int;
  65.                         if (!.@valid_int) {
  66.                                 debugmes "set_MAC_variable - integer overflow detected";
  67.                                 end;
  68.                         }
  69.                 }
  70.                
  71.                 if ((.@is_string && .@value$=="") || (!.@is_string && .@value$=="0")) {
  72.                         // value of "" or 0 --> delete variable
  73.                         query_sql "DELETE FROM `mac_reg_value` WHERE `mac`='"+ @my_MAC$ +"' AND `str`='"+ escape_sql(.@varname$) +"'";
  74.                 } else {
  75.                         // store the variable!!
  76.                         query_sql "REPLACE INTO `mac_reg_value` (`mac`,`str`,`value`) VALUES ('"+@my_MAC$+"', '"+ escape_sql(.@varname$) +"', '"+ (.@is_string ? escape_sql(.@value$) : atoi(.@value$)) +"')";
  77.                 }
  78.                 return;
  79.         }
  80. }

Submit a correction or amendment below (click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.

Syntax highlighting:

To highlight particular lines, prefix each line with {%HIGHLIGHT}




All content is user-submitted.
The administrators of this site (kpaste.net) are not responsible for their content.
Abuse reports should be emailed to us at