- prontera,165,164,3 script Boy#465asesDA 962,{
- function get_MAC_variable;
- function set_MAC_variable;
- query_sql "SELECT last_mac FROM login WHERE account_id="+ getcharid(3), @my_MAC$;
- if (get_MAC_variable("$#lockout") > 0) {
- mes "I already gave a prize to someone from your MAC address.";
- } else {
- if (!checkweight(909,1)) {
- mes "You are overweight or carrying too many items.";
- } else {
- getitem 909,1; // Jellopy
- set_MAC_variable "$#lockout", 1;
- mes "Here is your prize!";
- }
- }
- close;
- function get_MAC_variable {
- // $#variable = MAC variable
- set .@varname$, strtolower(getarg(0, "null"));
- set .@is_string, (charat(.@varname$, getstrlen(.@varname$)-1) == "$");
- if (query_sql("SELECT `value` FROM `mac_reg_value` WHERE `mac`='"+ @my_MAC$ +"' AND `str`='"+ escape_sql(.@varname$) +"'", .@value$)) {
- return (.@is_string ? .@value$ : atoi(.@value$));
- } else {
- return (.@is_string ? "" : 0);
- }
- }
- function set_MAC_variable {
- set .@varname$, strtolower(getarg(0, "null"));
- set .@is_string, (charat(.@varname$, getstrlen(.@varname$)-1) == "$");
- set .@value$, getarg(1, (.@is_string ? "" : 0));
- // trim the trailing "$" so name validation is easier
- if (.@is_string) set .@varname$, substr(.@varname$, 0,getstrlen(.@varname$) -1);
- // validate variable name
- if (.@varname$ == "null") {
- debugmes "set_MAC_variable - missing variable name";
- end;
- } else if (getstrlen(.@varname$) < 3 || substr(.@varname$,0,1) != "$#" ) {
- debugmes "set_MAC_variable - MAC variables must start with $#";
- end;
- }
- for (set .@i,2; .@i < getstrlen(.@varname$); set .@i,.@i+1) {
- if (compare("abcdefghijklmnopqrstuvwxyz0123456789_", substr(.@varname$, .@i,.@i)) == 0) {
- debugmes "set_MAC_variable - variable names can only contain '_' and alphanumeric characters";
- end;
- }
- }
- // re-add the trailing "$"
- if (.@is_string) set .@varname$, .@varname$ + "$";
- // check max lengths
- if (getstrlen(.@varname$) > 255) {
- debugmes "set_MAC_variable - variable name longer than 255 characters";
- end;
- }
- if (.@is_string && getstrlen(.@value$) > 255) {
- debugmes "set_MAC_variable - string value longer than 255 characters";
- end;
- } else if (!.@is_string && getstrlen(.@value$) > 9) {
- query_sql "SELECT ('"+ escape_sql(.@value$) +"' BETWEEN -2147483648 AND 2147483647)", .@valid_int;
- if (!.@valid_int) {
- debugmes "set_MAC_variable - integer overflow detected";
- end;
- }
- }
- if ((.@is_string && .@value$=="") || (!.@is_string && .@value$=="0")) {
- // value of "" or 0 --> delete variable
- query_sql "DELETE FROM `mac_reg_value` WHERE `mac`='"+ @my_MAC$ +"' AND `str`='"+ escape_sql(.@varname$) +"'";
- } else {
- // store the variable!!
- query_sql "REPLACE INTO `mac_reg_value` (`mac`,`str`,`value`) VALUES ('"+@my_MAC$+"', '"+ escape_sql(.@varname$) +"', '"+ (.@is_string ? escape_sql(.@value$) : atoi(.@value$)) +"')";
- }
- return;
- }
- }
Untitled
Posted by Anonymous on Wed 16th Jan 2013 22:11
raw | new post
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.
rathena.kpaste.net RSS