Is this can be done?

meruem

New member
Messages
52
Points
0
A new @item command for players but they cant @item a certain item that i will not allowed. 

For example: Player have @item command but they cant @item 5377 (gpipe). But me as an admin can get it via @item. Hope you understand my explanation. Lol. 

Do I need to create new command or disable something or any trick you will advice. Thank you in advance. 

 
Code:
//Created by Racaae (https://herc.ws/board/topic/20119-is-this-can-be-done/)
-	script	restricted_item_command	HIDDEN_WARP_NPC,{
OnInit:

//== CONF ===========
	.command$ = "item3";
	.max_qty = 10;

	//0 = Whitelist (can only create items in the list below) or
	//1 = Blacklist (cannot create items in the list below)
	.mode = 1;

	//Item list
	.items$ = "607,608,1530,2020,2021,2181,2182,2383,2410," +
	          "2541,2629,2630,5377,";

//===================

	bindatcmd .command$,strnpcinfo(3)+"::OnAtcommand";
	end;

OnAtcommand:
	if (atoi(.@atcmd_parameters$[0]) < 501) {
		dispbottom "Please enter an item ID (usage: @" + .command$ + " <item ID> <quantity>).";
		end;
	}
	.@id = atoi(.@atcmd_parameters$[0]);
	.@qty = atoi(.@atcmd_parameters$[1]);
	if (.@qty < 1)
		.@qty = 1;
	if (getitemname(.@id) == "null") {
		dispbottom "Invalid item ID.";
		end;
	}
	if (.@qty > .max_qty) {
		dispbottom "You can create only " + .max_qty + " at a time.";
		end;
	}
	if (compare(","+.items$+"," , ","+.@id+","))
		.@listed = 1;
	if ((.mode == 1 && .@listed) || (!.mode && !.@listed)) {
		dispbottom "You cannot create " + getitemname(.@id) + ".";
		end;
	}
	getitem .@id, .@qty;
	dispbottom "Item created.";
	end;
}
 
Last edited by a moderator:
//Created by Racaae (https://herc.ws/board/topic/20119-is-this-can-be-done/)
- script restricted_item_command HIDDEN_WARP_NPC,{
OnInit:

//== CONF ===========
.command$ = "item3";
.max_qty = 10;

//0 = Whitelist (can only create items in the list below) or
//1 = Blacklist (cannot create items in the list below)
.mode = 1;

//Item list
.items$ = "607,608,1530,2020,2021,2181,2182,2383,2410," +
"2541,2629,2630,5377,";

//===================

bindatcmd .command$,strnpcinfo(3)+"::OnAtcommand";
end;

OnAtcommand:
if (atoi(.@atcmd_parameters$[0]) < 501) {
dispbottom "Please enter an item ID (usage: @" + .command$ + " <item ID> <quantity>).";
end;
}
.@id = atoi(.@atcmd_parameters$[0]);
.@qty = atoi(.@atcmd_parameters$[1]);
if (.@qty < 1)
.@qty = 1;
if (getitemname(.@id) == "null") {
dispbottom "Invalid item ID.";
end;
}
if (.@qty > .max_qty) {
dispbottom "You can create only " + .max_qty + " at a time.";
end;
}
if (compare(","+.items$+"," , ","+.@id+","))
.@listed = 1;
if ((.mode == 1 && .@listed) || (!.mode && !.@listed)) {
dispbottom "You cannot create " + getitemname(.@id) + ".";
end;
}
getitem .@id, .@qty;
dispbottom "Item created.";
end;
}

//Created by Racaae (https://herc.ws/board/topic/20119-is-this-can-be-done/)
- script restricted_item_command HIDDEN_WARP_NPC,{
OnInit:

//== CONF ===========
.command$ = "item3";
.max_qty = 10;

//0 = Whitelist (can only create items in the list below) or
//1 = Blacklist (cannot create items in the list below)
.mode = 1;

//Item list
.items$ = "607,608,1530,2020,2021,2181,2182,2383,2410," +
"2541,2629,2630,5377,";

//===================

bindatcmd .command$,strnpcinfo(3)+"::OnAtcommand";
end;

OnAtcommand:
if (atoi(.@atcmd_parameters$[0]) < 501) {
dispbottom "Please enter an item ID (usage: @" + .command$ + " <item ID> <quantity>).";
end;
}
.@id = atoi(.@atcmd_parameters$[0]);
.@qty = atoi(.@atcmd_parameters$[1]);
if (.@qty < 1)
.@qty = 1;
if (getitemname(.@id) == "null") {
dispbottom "Invalid item ID.";
end;
}
if (.@qty > .max_qty) {
dispbottom "You can create only " + .max_qty + " at a time.";
end;
}
if (compare(","+.items$+"," , ","+.@id+","))
.@listed = 1;
if ((.mode == 1 && .@listed) || (!.mode && !.@listed)) {
dispbottom "You cannot create " + getitemname(.@id) + ".";
end;
}
getitem .@id, .@qty;
dispbottom "Item created.";
end;
}

Thank you so much for this script sir. 

Can you further explain how can I makr this work? 

Example i want to give every player "@item3" meaning i need to input all item id from the item_db?

 
Example i want to give every player "@item3" meaning i need to input all item id from the item_db?
No, insert only the ID of the items you don't want them to create.

//Item list
.items$ = "607,608,1530,2020,2021,2181,2182,2383,2410," +
"2541,2629,2630,5377,";


Using the example above: player can't create Yggdrasil Berry (ID 607), nor Yggdrasil Seed (ID 608), nor Brynhild (ID 2383), nor Gentleman's Pipe (ID 5377).

They will be able to create, let's say... Combat Knife (ID 1228), and any other items, since it's not in the list.

 
No, insert only the ID of the items you don't want them to create.

//Item list
.items$ = "607,608,1530,2020,2021,2181,2182,2383,2410," +
"2541,2629,2630,5377,";

//Item list
.items$ = "607,608,1530,2020,2021,2181,2182,2383,2410," +
"2541,2629,2630,5377,";


Using the example above: player can't create Yggdrasil Berry (ID 607), nor Yggdrasil Seed (ID 608), nor Brynhild (ID 2383), nor Gentleman's Pipe (ID 5377).

They will be able to create, let's say... Combat Knife (ID 1228), and any other items, since it's not in the list.
Do I add this as an npc? 
Or add this like adding a new command? 
Im quite confuse. 

 
It would be a npc script. Once it's enabled you can use the atcommand. Looks like it's bound for @item3

 
Back
Top