Hi Brian, sorry for reviving an old topic; I came across an issue involving this script and I'm not sure where to go from here.
This is the error I get when trying to load it:
script error on npc/custom/glitch/newplayer.txt line 15
parse_callfunc: expected ')' to close argument list
11 : {
12 : function get_MAC_variable;
13 : function set_MAC_variable;
14 :
* 15 : if (get_MAC_variable($'#'lockout)>0) {
16 : mes "I already gave a prize to someone from your MAC address.";
17 : } else {
18 : if (!checkweight(909,1)) {
19 : mes "You are overweight or carrying too many items.";
20 : } else {
I also added two more lines after Line 28:
function get_MAC_variable {
query_sql "select last_mac from login where account_id = " + getcharid(3),.@MAC$;
set @MAC$,.@MAC$[0];
// $#variable = MAC variable
This was to sorta replace getmacaddress() - I'm not sure if that's even a thing lol. I have Harmony and my needs for this NPC's functions are identical to Frost_'s. If you or anyone has a solution for me, it'd help out a lot. Thanks for reading.
Full Script:
prontera,165,164,3 script Boy#465asesDA 962,{
function get_MAC_variable;
function set_MAC_variable;
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 {
query_sql "select last_mac from login where account_id = " + getcharid(3),.@MAC$;
set @MAC$,.@MAC$[0];
// $#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`='"+ @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`='"+ @MAC$ +"' AND `str`='"+ escape_sql(.@varname$) +"'";
} else {
// store the variable!!
query_sql "REPLACE INTO `mac_reg_value` (`mac`,`str`,`value`) VALUES ('"+@MAC$+"', '"+ escape_sql(.@varname$) +"', '"+ (.@is_string ? escape_sql(.@value$) : atoi(.@value$)) +"')";
}
return;
}
}