Jump to content

Korasu

Members
  • Posts

    6
  • Joined

  • Last visited

Posts posted by Korasu

  1. This is a bit of a ridiculous request, but I couldn't find an answer anywhere. I want to enable the setting that identifies all equipment dropped by mobs automatically; I simply cannot find where to define it lol. If someone could tell me, it'd be much appreciated. Thanks in advance.

  2. I'm trying to make an NPC that gives players one item per account, and does a MAC address check to see if any other accounts have received an item from the NPC. The MAC address(es) can be found for by checking the last_mac column in the login database, or with some Harmony script command that I'm unaware of; in Brian's post and script, he used getmacaddress() as a filler. I do have Harmony installed.

  3. 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;
    }
    }

  4. Original Post:

    This is essentially just a small modification to the itemizer release that's been floating around for the last few years, and I'm running across a weird problem that I can't seem to fix.

    Script:

    - script item -1,{
    
    OnWhisperGlobal:
    if (getgmlevel() >= 40) {
    rewardOption:
    mes "[^3333FFAthena^000000]";
    mes "More free items? What is it this time?";
    menu "Player Reward",PlayerReward,"Event Consolation",Consolation,"Nevermind",nvm;
    
    nvm:
    next;
    mes "[^3333FFAthena^000000]";
    mes "Good! Stop spoonfeeding these kids!";
    close;
    
    PlayerReward:
    next;
    mes "[^3333FFAthena^000000]";
    mes "Input the player's name EXACTLY as it is spelled.";
    set @charAccNumber,getcharid(3,strcharinfo(0));
    set @when$,callfunc("makeTimestamp");
    set @N_Itemname$,escape_sql(getitemname(@itemID));
    input @playerName$;
    next;
    mes "[^3333FFAthena^000000]";
    mes "Set the Item ID for this reward.";
    input @itemID,501,32767;
    next;
    mes "[^3333FFAthena^000000]";
    mes "How many "+getitemname(@itemID)+"s will you give?";
    input @Amount,0,30000;
    next;
    mes "[^3333FFAthena^000000]";
    mes "Please leave a brief reason for this reward.";
    mes "example: Winner of Zombie Event";
    input @reason$;
    next;
    mes "[^3333FFAthena^000000]";
    mes "Player Name : "+@playerName$+" ";
    mes "Reward : "+getitemname(@itemID)+" ";
    mes "Amount : "+@Amount+" ";
    mes " ";
    mes "Reason:";
    mes ""+@reason$+"";
    mes " ";
    mes "^F00000Please make sure this player is ONLINE.^000000";
    next;
    switch(select("Change Reward","Confirm Reward","Cancel")) {
    case 1:
    goto PlayerReward;
    case 2:
    mes "The item has been given to the selected player.";
    getitem @itemID,@Amount,getcharid(3,@playerName$);
    announce "The Event Manager "+strcharinfo(0)+" has rewarded "+@playerName$+" with "+@Amount+" "+getitemname(@itemID)+".",bc_all;
    set @itemID,query_sql("INSERT INTO `item_reward` VALUES(NULL,'"+ @charAccNumber +"','"+ strcharinfo(0) +"','"+ @itemID +"','"+ @Amount +"','"+ @N_Itemname$ +"','"+ @playerName$ +"','"+ @reason$ +"','"+ @when$ +"')");
    close;
    
    case 3:
    close;
    }
    }
    else {
    dispbottom "Sorry, but you do not have permission to access this feature.";
    }
    
    Consolation:
    next;
    mes "[^3333FFAthena^000000]";
    mes "Set the Item ID for this consolation.";
    set @CcharAccNumber,getcharid(3,strcharinfo(0));
    set @Cwhen$,callfunc("makeTimestamp");
    set @CN_Itemname$,escape_sql(getitemname(@CitemID));
    input @CitemID,501,32767;
    next;
    mes "[^3333FFAthena^000000]";
    mes "How many "+getitemname(@CitemID)+"s will you drop?";
    input @CAmount,0,30000;
    next;
    mes "[^3333FFAthena^000000]";
    mes "Please leave a brief reason for this consolation.";
    mes "example: Consolation for Zombie Event";
    input @Creason$;
    next;
    mes "[^3333FFAthena^000000]";
    mes "Consolation : "+getitemname(@CitemID)+" ";
    mes "Amount : "+@CAmount+" ";
    mes " ";
    mes "Reason:";
    mes ""+@Creason$+"";
    next;
    switch(select("Change Consolation","Confirm Consolation","Cancel")) {
    case 1:
    goto Consolation;
    case 2:
    mes "The item has been given to the selected player.";
    atcommand "@flooritem "+@CitemID+" "+@CAmount+"";
    set @itemID,query_sql("INSERT INTO `item_reward` VALUES(NULL,'"+ @CcharAccNumber +"','"+ strcharinfo(0) +"','"+ @CitemID +"','"+ @CAmount +"','"+ @CN_Itemname$ +"','"+ @Creason$ +"','"+ @Cwhen$ +"')");
    close;
    
    case 3:
    goto nvm;
    }
    }
    else {
    dispbottom "Sorry, but you do not have permission to access this feature.";
    }
    
    }
    
    function script makeTimestamp {
    
    // Get Current Date & Time Variables
    set @curYear,gettime(7);
    set @curMonth,gettime(6);
    set @curDay,gettime(5);
    set @curHour,gettime(3);
    set @curMinute,gettime(2);
    set @curSecond,gettime(1);
    
    // Start A New Timestamp Variable
    set @timestamp$,"";
    
    // MySQL Timestamp Friendly :: Year
    set @timestamp$,@timestamp$+@curYear+"-";
    
    // MySQL Timestamp Friendly :: Month
    if (@curMonth <= 9) {
    set @timestamp$,@timestamp$+"0"+@curMonth+"-";
    }
    else {
    set @timestamp$,@timestamp$+@curMonth+"-";
    }
    
    // MySQL Timestamp Friendly :: Day
    if (@curDay <= 9) {
    set @timestamp$,@timestamp$+"0"+@curDay+" ";
    }
    else {
    set @timestamp$,@timestamp$+@curDay+" ";
    }
    
    // MySQL Timestamp Friendly :: Hour
    if (@curHour <= 9) {
    set @timestamp$,@timestamp$+"0"+@curHour+":";
    }
    else {
    set @timestamp$,@timestamp$+@curHour+":";
    }
    
    // MySQL Timestamp Friendly :: Minute
    if (@curMinute <= 9) {
    set @timestamp$,@timestamp$+"0"+@curMinute+":";
    }
    else {
    set @timestamp$,@timestamp$+@curMinute+":";
    }
    
    // MySQL Timestamp Friendly :: Second
    if (@curSecond <= 9) {
    set @timestamp$,@timestamp$+"0"+@curSecond;
    }
    else {
    set @timestamp$,@timestamp$+@curSecond;
    }
    
    // Return MySQL Friendly Timestamp
    return @timestamp$;
    
    }

    I modified it so GMs can access it via whisper, must give a reason, and restructured the log's table in my database for easy reading. In that regard, the NPC works great and does what it's supposed to.

    What I recently did was add a menu in the beginning, which would distinguish player prizes from @flooritem consolations. For the Consolation section, I basically duplicated the script and tweaked it a bit to correspond with the log table I made for it. Right now, it freezes completely when I get to this part in either switch:

    set @charAccNumber,getcharid(3,strcharinfo(0));
    set @when$,callfunc("makeTimestamp");
    set @N_Itemname$,escape_sql(getitemname(@itemID));
    

    set @CcharAccNumber,getcharid(3,strcharinfo(0));
    set @Cwhen$,callfunc("makeTimestamp");
    set @CN_Itemname$,escape_sql(getitemname(@CitemID));
    

    When I was debugging, I learned that it was likely the callfunc that was screwing things up. I thought maybe the server simply didn't like that there were two callfunc's in the same script, but what do I know - I'm here, aren't I? I tried making a copy of makeTimestamp and naming it makeTimestamp2 (and further defining it in Consolation's callfunc), but that did absolutely nothing.

    If anyone has an answer and would like to share it with me, it'd be really helpful and greatly appreciated. Thanks for reading.

    Edit: Nevermind, I found the problem myself. There were several errors that didn't show up on my console, and just some poor code structure. I know none of you who initially read this replied, but I'd like to share the final product anyways to help combat GM corruption. This final script works and functions fully as intended.

    // --------------------------------------------------------------
    // Original Script by latheesan
    // Modifications by Glitch - Deliverance-Online
    // Item reward system for GMs; logged to MySQL database.
    // @flooritem feature for consolation purposes; logged.
    // - Run this query! --------------------------------------------
    //CREATE TABLE IF NOT EXISTS `item_reward` (
    //  `id` int(11) unsigned NOT NULL auto_increment,
    //  `account` int(11) NOT NULL,
    //  `name` varchar(255) NOT NULL,
    //  `item_id` int(11) NOT NULL,
    //  `item_amount` int(11) NOT NULL,
    //  `item_name` varchar(255) NOT NULL,
    //  `for` varchar(255) NOT NULL,
    //  `reason` varchar(255) NOT NULL,
    //  `when` datetime NOT NULL,
    //  PRIMARY KEY  (`id`)
    //) ENGINE=MyISAM;
    // - And this one: -----------------------------------------------
    //CREATE TABLE IF NOT EXISTS `item_consolation` (
    //  `id` int(11) unsigned NOT NULL auto_increment,
    //  `account` int(11) NOT NULL,
    //  `name` varchar(255) NOT NULL,
    //  `item_id` int(11) NOT NULL,
    //  `item_amount` int(11) NOT NULL,
    //  `item_name` varchar(255) NOT NULL,
    //  `reason` varchar(255) NOT NULL,
    //  `when` datetime NOT NULL,
    //  PRIMARY KEY  (`id`)
    //) ENGINE=MyISAM;
    // --------------------------------------------------------------
    
    -	script	item	-1,{
    
    OnWhisperGlobal:
    if (getgmlevel() >= 40) {
    	// set @when$,callfunc("makeTimestamp");
    	rewardOption:
    		mes "[^3333FFAthena^000000]";
    		mes "More free items? What is it this time?";
    		menu "Player Reward",PlayerReward,"Event Consolation",Consolation,"Nevermind",nvm;
    
    	nvm:
    		next;
    		mes "[^3333FFAthena^000000]";
    		mes "Good! Stop spoonfeeding these kids!";
    		close;
    
    	PlayerReward:
    		next;
    		mes "[^3333FFAthena^000000]";
    		mes "Input the player's name EXACTLY as it is spelled.";
    		input @playerName$;
    		set @charAccNumber,getcharid(3,strcharinfo(0));
    		set @when$,callfunc("makeTimestamp");
    		set @N_Itemname$,escape_sql(getitemname(@itemID));
    		next;
    		mes "[^3333FFAthena^000000]";
    		mes "Set the Item ID for this reward.";
    		input @itemID,501,32767;
    		next;
    		mes "[^3333FFAthena^000000]";
    		mes "How many "+getitemname(@itemID)+"s will you give?";
    		input @Amount,0,30000;
    		next;
    		mes "[^3333FFAthena^000000]";
    		mes "Please leave a brief reason for this reward.";
    		mes "example: Winner of Zombie Event";
    		input @reason$;
    		next;
    		mes "[^3333FFAthena^000000]";
    		mes "Player Name : "+@playerName$+"  ";
    		mes "Reward : "+getitemname(@itemID)+" ";
    		mes "Amount : "+@Amount+" ";
    		mes " ";
    		mes "Reason:";
    		mes ""+@reason$+"";
    		mes " ";
    		mes "^F00000Please make sure this player is ONLINE.^000000";
    		next;
    	switch(select("Change Reward","Confirm Reward","Cancel")) {
    		case 1:
    			goto PlayerReward;
    		case 2:
    			mes "The item has been given to the selected player.";
    			getitem @itemID,@Amount,getcharid(3,@playerName$);
    			announce "The Event Manager "+strcharinfo(0)+" has rewarded "+@playerName$+" with "+@Amount+" "+getitemname(@itemID)+".",bc_all;
    			set @itemID,query_sql("INSERT INTO `item_reward` VALUES(NULL,'"+ @charAccNumber +"','"+ strcharinfo(0) +"','"+ @itemID +"','"+ @Amount +"','"+ @N_Itemname$ +"','"+ @playerName$ +"','"+ @reason$ +"','"+ @when$ +"')");
    			close;
    
    		case 3:
    			close;
    		}
    
    	Consolation:
    		next;
    		mes "[^3333FFAthena^000000]";
    		mes "Set the Item ID for this consolation.";
    		input @itemID,501,32767;
    		set @charAccNumber,getcharid(3,strcharinfo(0));
    		set @when$,callfunc("makeTimestamp");
    		set @N_Itemname$,escape_sql(getitemname(@itemID));
    		next;
    		mes "[^3333FFAthena^000000]";
    		mes "How many "+getitemname(@itemID)+"s will you drop?";
    		input @Amount,0,30000;
    		next;
    		mes "[^3333FFAthena^000000]";
    		mes "Please leave a brief reason for this consolation.";
    		mes "example: Consolation for Zombie Event";
    		input @reason$;
    		next;
    		mes "[^3333FFAthena^000000]";
    		mes "Consolation : "+getitemname(@itemID)+" ";
    		mes "Amount : "+@Amount+" ";
    		mes " ";
    		mes "Reason:";
    		mes ""+@reason$+"";
    		next;
    	switch(select("Change Consolation","Confirm Consolation","Cancel")) {
    		case 1:
    			goto Consolation;
    		case 2:
    			mes ""+@Amount+" "+@itemID+"s have been dropped as consolation.";
    			atcommand "@flooritem "+@itemID+" "+@Amount+"";
    			set @itemID,query_sql("INSERT INTO `item_consolation` VALUES(NULL,'"+ @charAccNumber +"','"+ strcharinfo(0) +"','"+ @itemID +"','"+ @Amount +"','"+ @N_Itemname$ +"','"+ @reason$ +"','"+ @when$ +"')");
    			close;
    
    		case 3:
    			goto nvm;
    		}
    	}
    	else {
    		dispbottom "Sorry, but you do not have permission to access this feature.";
    	    end;
    	}
    }
    
    
    function	script	makeTimestamp	{
    
    // Get Current Date & Time Variables
    set @curYear,gettime(7);
    set @curMonth,gettime(6);
    set @curDay,gettime(5);
    set @curHour,gettime(3);
    set @curMinute,gettime(2);
    set @curSecond,gettime(1);
    
    // Start A New Timestamp Variable
    set @timestamp$,"";
    
    // MySQL Timestamp Friendly :: Year
    set @timestamp$,@timestamp$+@curYear+"-";
    
    // MySQL Timestamp Friendly :: Month
    if (@curMonth <= 9) {
    	set @timestamp$,@timestamp$+"0"+@curMonth+"-";
    }
    else {
    	set @timestamp$,@timestamp$+@curMonth+"-";
    }
    
    // MySQL Timestamp Friendly :: Day
    if (@curDay <= 9) {
    	set @timestamp$,@timestamp$+"0"+@curDay+" ";
    }
    else {
    	set @timestamp$,@timestamp$+@curDay+" ";
    }
    
    // MySQL Timestamp Friendly :: Hour
    if (@curHour <= 9) {
    	set @timestamp$,@timestamp$+"0"+@curHour+":";
    }
    else {
    	set @timestamp$,@timestamp$+@curHour+":";
    }
    
    // MySQL Timestamp Friendly :: Minute
    if (@curMinute <= 9) {
    	set @timestamp$,@timestamp$+"0"+@curMinute+":";
    }
    else {
    	set @timestamp$,@timestamp$+@curMinute+":";
    }
    
    // MySQL Timestamp Friendly :: Second
    if (@curSecond <= 9) {
    	set @timestamp$,@timestamp$+"0"+@curSecond;
    }
    else {
    	set @timestamp$,@timestamp$+@curSecond;
    }
    
    // Return MySQL Friendly Timestamp
    return @timestamp$;
    
    }
    

×
×
  • Create New...