Jump to content
  • 0

Requesting @item (bindatcmd) w/ Password system


Question

Posted

hi folks! i just want to request a bindcmd script that if a GM use @item for the first time, the script will show a menu Setup password, Change password, cancel

 

then after i set a password, when i use @item again. i will input the password i made, then after that i will put the item_id, amount.

 

thanks!

6 answers to this question

Recommended Posts

Posted

-	script	item_cmd	-1,{
OnInit:
	bindatcmd "item",strnpcinfo(3)+"::OnAtcommand",60,60;// your min gmlevel
	end;
OnAtcommand:
	.@amount = atoi( .@atcmd_parameters$[1] );
	.@amount = .@amount < 1 ? 1 : .@amount;
	.@myname$ = strcharinfo(0);
	if ( .@atcmd_numparameters == 0 ) {
		message .@myname$, "Please enter an item name or ID (usage: @item <item name/ID> <quantity>).";
		message .@myname$, "@item failed.";
		end;
	}
	if ( countstr( .@atcmd_parameters$[0], ":" ) ) {
		explode( .@dummy$, .@atcmd_parameters$[0], ":" );
		.@size = getarraysize( .@dummy$ );
		while( .@i < .@size ) {
			.@item_id[.@i] = atoi( .@dummy$[.@i] );
			if ( .@item_id[.@i] == 0 && getstrlen( .@dummy$[.@i] ) > 2 )
				.@count = !searchitem( .@item_id[.@i],.@dummy$[.@i] );
			if ( .@count || getiteminfo( .@item_id[.@i],0 ) == -1 ) {
				message .@myname$, "Invalid item ID or name.";
				message .@myname$, "@item failed.";
				end;
			}
			.@count = 0;
			.@i++;
		}
	}
	else {
		.@item_id = atoi( .@atcmd_parameters$[0] );
		if ( .@item_id == 0 && getstrlen( .@atcmd_parameters$[0] ) > 2 )
			.@count = !searchitem( .@item_id,.@atcmd_parameters$[0] );
		if ( .@count || getiteminfo( .@item_id,0 ) == -1 ) {
			message .@myname$, "Invalid item ID or name.";
			message .@myname$, "@item failed.";
			end;
		}
		.@size = 1;
	}
	if ( #item_cmd_password$ == "" ) {
	L_password:
		message .@myname$, "Please set your @item password (length must be between 4-10).";
		if ( input( .@tmp$, 4,10 ) != 0 ) {
			message .@myname$, "The length must be between 4-10.";// => cancel
			end;
		}
		message .@myname$, "Your @item password is now : "+ .@tmp$;
		#item_cmd_password$ = .@tmp$;
	}
	else {
		message .@myname$, "Your @item password ?";
		input .@tmp$;
		if ( .@tmp$ != #item_cmd_password$ ) {
			message .@myname$, "Wrong password.";
			end;
		}
		if ( select( "Continue", "Change password" ) == 2 )
			goto L_password;
	}
	while( .@j < .@size ) {
		getitem .@item_id[.@j], .@amount;
		.@j++;
	}
	message .@myname$, "Item created.";
	end;
}

it supports item name/ID and multi item name/ID

@item <item name/ID>{:<item name/ID>:...} {<amount>}

/item <item name>

  • Upvote 1
Posted

the script can be done with atcommand too

-	script	item_cmd	-1,{
OnInit:
	bindatcmd "item",strnpcinfo(3)+"::OnAtcommand",60,60;// your min gmlevel
	end;
OnAtcommand:
	.@myname$ = strcharinfo(0);
	if ( #item_cmd_password$ == "" ) {
	L_password:
		message .@myname$, "Please set your @item password (length must be between 4-10).";
		if ( input( .@tmp$, 4,10 ) != 0 ) {
			message .@myname$, "The length must be between 4-10.";// => cancel
			end;
		}
		message .@myname$, "Your @item password is now : "+ .@tmp$;
		#item_cmd_password$ = .@tmp$;
	}
	else {
		message .@myname$, "Your @item password ?";
		input .@tmp$;
		if ( .@tmp$ != #item_cmd_password$ ) {
			message .@myname$, "Wrong password.";
			end;
		}
		if ( select( "Continue", "Change password" ) == 2 )
			goto L_password;
	}
	atcommand "@item "+ .@atcmd_parameters$[0] +" "+ .@atcmd_parameters$[1];
	end;
}

but it was fun to make the script without it

both working

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...