Lineage 2 Tower Forum

Full Version: WTB craft script code
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3 4
(05-30-2015 13:42 PM)schubbel2208 Wrote: [ -> ]hrhr my fault it should be

    LUA Programming
if (GetItemAmountByName(crystals) > 2) then
 if (GetItemAmountByName(stone) > 80) then


you should edit your previous post and make the change in the main script !
change to this, its better for your CPU if you don't have enough MP:

Code:
repeat
Sleep(1000);
if (me:GetMp() > 258) then
if (GetItemAmountByName(crystals) > 2) then
if (GetItemAmountByName(stone) > 80) then
CraftItem(1125);

end;
end;
end;
until false
    LUA Programming
-- credits to original author W4rGo
 
CraftStatus = false;
weigthLimit=95;
 
function OnCreate()
	this:RegisterCommand("craft", CommandChatType.CHAT_ALLY, CommandAccessLevel.ACCESS_ME);
end;
 
function OnCommand_craft(vCommandChatType, vNick, vCommandParam)
if (vCommandParam:GetCount() == 1) and (CraftStatus == false) then
	ShotType = string.lower(vCommandParam:GetParam(0):GetStr(true));
	if (ShotType == "ssa") then
 craftId=23;
 mpCost=120;
 mat1="Crystal (A-grade)";
 mat1num=1;
 mat2="Spirit Ore";
 mat2num=36; 
 CraftStatus = true;
	elseif (ShotType == "ssb") then
 craftId=22;
 mpCost=100;
 mat1="Crystal (B-Grade)";
 mat1num=1;
 mat2="Soul Ore";
 mat2num=54; 
 CraftStatus = true;
	elseif (ShotType == "ssc") then
 craftId=21;
 mpCost=84;
 mat1="Crystal (C-Grade)";
 mat1num=2;
 mat2="Soul Ore";
 mat2num=30; 
 CraftStatus = true;
	elseif (ShotType == "ssd") then
 craftId=20;
 mpCost=150;
 mat1="Crystal (D-Grade)";
 mat1num=3;
 mat2="Soul Ore";
 mat2num=9; 
 CraftStatus = true;
	elseif (ShotType == "sss") then
 craftId=24;
 mpCost=150;
 mat1="Crystal (S-Grade)";
 mat1num=1;
 mat2="Soul Ore";
 mat2num=40;
 CraftStatus = true;
	elseif (ShotType == "bssc") then
 craftId=324;
 mpCost=150;
 mat1="Crystal (C-Grade)";
 mat1num=2;
 mat2="Spirit Ore";
 mat2num=30; 
 CraftStatus = true; 
	elseif (ShotType == "bssd") then 
 craftId=323;
 mpCost=150;
 mat1="Crystal (D-Grade)";
 mat1num=2;
 mat2="Spirit Ore";
 mat2num=8; 
 CraftStatus = true;	
	elseif (ShotType == "bssa") then 
 craftId=326;
 mpCost=240;
 mat1="Crystal (A-grade)";
 mat1num=2;
 mat2="Spirit Ore";
 mat2num=70; 
 CraftStatus = true;	
	elseif (ShotType == "bssb") then 
 craftId=325;
 mpCost=180;
 mat1="Crystal (B-Grade)";
 mat1num=2;
 mat2="Spirit Ore";
 mat2num=16; 
 CraftStatus = true;	
	elseif (ShotType == "ssr") then 
 craftId=1125;
 mpCost=258;
 mat1="Crystal (R-grade)";
 mat1num=2;
 mat2="Soulstone";
 mat2num=80; 
 CraftStatus = true;	
	elseif (ShotType == "bssr") then 
 craftId=1127;
 mpCost=258;
 mat1="Crystal (R-grade)";
 mat1num=2;
 mat2="Spirit Ore";
 mat2num=750; 
 CraftStatus = true; 
	else
 ShowToClient("Craft Plugin","Item Is not Supported.");
	end;
else
	if (CraftStatus == true) then
 CraftStatus = false;
 ShowToClient("Craft Plugin","Craft Is Deactivated.");
	else
 ShowToClient("Craft Plugin","You must choose the item you want to craft for example: /craft_ssa");
	end;	
end; 
end;
 
function getItemByName(name)
local invList = GetInventory();
	for item in invList.list do
 if (item.Name == name) then
 return item;
 end;
	end;
	return nil;
end;
 
function hasItem(name)
local invList = GetInventory();
	for item in invList.list do
 if (item.Name == name) then
 return true;
 end;
	end;
	return false;
end;
 
function Craft(RecipeId)
 if (type(RecipeId) == "number" and RecipeId > 0) then
 local packet = PacketBuilder();
 packet:AppendInt(0xB8, 1);
 packet:AppendInt(RecipeId, 4);
 SendPacket(packet);
 end;
end;
 
function OnLTick1s()
 
if (CraftStatus == true) then
	if(GetMe():GetWeightPercent() < weigthLimit) then
 if (hasItem(mat1) == true) then 
 if(getItemByName(mat1).ItemNum >= mat1num) then
 if(hasItem(mat2) == true) then 
 if(getItemByName(mat2).ItemNum >= mat2num) then
 if (GetMe():GetMp() > mpCost) then
 Craft(craftId);
 end;
 else
 CraftStatus = false;
 ShowToClient("Craft Plugin","Not enough " .. mat2);
 end;
 else
 CraftStatus = false;
 ShowToClient("Craft Plugin","Missing " .. mat2);
 end;
 else
 CraftStatus = false;
 ShowToClient("Craft Plugin","Not enough " .. mat1);
 end;	
 else
 CraftStatus = false;
 ShowToClient("Craft Plugin","Missing " .. mat1);
 end;
	else
 CraftStatus = false;
 ShowToClient("Craft Plugin","Weigth limit approaching, Craft Plugin Deactivated.");	
 end;	
end;
 
end;



save as plugin
Thx for sharing Schubbel... i'll test it in a few minutes

Just tested it and found some problems...

1- Description of Crystals is: Crystal (S-grade) and not (S-Grade) the "G" should be lowercase, if not, it doesn't work.

2- Description of Soul Stones to make Soulshots should be: Soulstone and NOT Soul ore

3- You didn't add BSSS... any reason why or simply forgot?

I made the changes for the 2 description above and I managed to craft SSS.

So thx for the updated plugin!


(05-31-2015 22:33 PM)schubbel2208 Wrote: [ -> ]
    LUA Programming
-- credits to original author W4rGo
 
CraftStatus = false;
weigthLimit=95;
 
function OnCreate()
	this:RegisterCommand("craft", CommandChatType.CHAT_ALLY, CommandAccessLevel.ACCESS_ME);
end;
 
function OnCommand_craft(vCommandChatType, vNick, vCommandParam)
if (vCommandParam:GetCount() == 1) and (CraftStatus == false) then
	ShotType = string.lower(vCommandParam:GetParam(0):GetStr(true));
	if (ShotType == "ssa") then
 craftId=23;
 mpCost=120;
 mat1="Crystal (A-grade)";
 mat1num=1;
 mat2="Spirit Ore";
 mat2num=36; 
 CraftStatus = true;
	elseif (ShotType == "ssb") then
 craftId=22;
 mpCost=100;
 mat1="Crystal (B-Grade)";
 mat1num=1;
 mat2="Soul Ore";
 mat2num=54; 
 CraftStatus = true;
	elseif (ShotType == "ssc") then
 craftId=21;
 mpCost=84;
 mat1="Crystal (C-Grade)";
 mat1num=2;
 mat2="Soul Ore";
 mat2num=30; 
 CraftStatus = true;
	elseif (ShotType == "ssd") then
 craftId=20;
 mpCost=150;
 mat1="Crystal (D-Grade)";
 mat1num=3;
 mat2="Soul Ore";
 mat2num=9; 
 CraftStatus = true;
	elseif (ShotType == "sss") then
 craftId=24;
 mpCost=150;
 mat1="Crystal (S-Grade)";
 mat1num=1;
 mat2="Soul Ore";
 mat2num=40;
 CraftStatus = true;
	elseif (ShotType == "bssc") then
 craftId=324;
 mpCost=150;
 mat1="Crystal (C-Grade)";
 mat1num=2;
 mat2="Spirit Ore";
 mat2num=30; 
 CraftStatus = true; 
	elseif (ShotType == "bssd") then 
 craftId=323;
 mpCost=150;
 mat1="Crystal (D-Grade)";
 mat1num=2;
 mat2="Spirit Ore";
 mat2num=8; 
 CraftStatus = true;	
	elseif (ShotType == "bssa") then 
 craftId=326;
 mpCost=240;
 mat1="Crystal (A-grade)";
 mat1num=2;
 mat2="Spirit Ore";
 mat2num=70; 
 CraftStatus = true;	
	elseif (ShotType == "bssb") then 
 craftId=325;
 mpCost=180;
 mat1="Crystal (B-Grade)";
 mat1num=2;
 mat2="Spirit Ore";
 mat2num=16; 
 CraftStatus = true;	
	elseif (ShotType == "ssr") then 
 craftId=1125;
 mpCost=258;
 mat1="Crystal (R-grade)";
 mat1num=2;
 mat2="Soulstone";
 mat2num=80; 
 CraftStatus = true;	
	elseif (ShotType == "bssr") then 
 craftId=1127;
 mpCost=258;
 mat1="Crystal (R-grade)";
 mat1num=2;
 mat2="Spirit Ore";
 mat2num=750; 
 CraftStatus = true; 
	else
 ShowToClient("Craft Plugin","Item Is not Supported.");
	end;
else
	if (CraftStatus == true) then
 CraftStatus = false;
 ShowToClient("Craft Plugin","Craft Is Deactivated.");
	else
 ShowToClient("Craft Plugin","You must choose the item you want to craft for example: /craft_ssa");
	end;	
end; 
end;
 
function getItemByName(name)
local invList = GetInventory();
	for item in invList.list do
 if (item.Name == name) then
 return item;
 end;
	end;
	return nil;
end;
 
function hasItem(name)
local invList = GetInventory();
	for item in invList.list do
 if (item.Name == name) then
 return true;
 end;
	end;
	return false;
end;
 
function Craft(RecipeId)
 if (type(RecipeId) == "number" and RecipeId > 0) then
 local packet = PacketBuilder();
 packet:AppendInt(0xB8, 1);
 packet:AppendInt(RecipeId, 4);
 SendPacket(packet);
 end;
end;
 
function OnLTick1s()
 
if (CraftStatus == true) then
	if(GetMe():GetWeightPercent() < weigthLimit) then
 if (hasItem(mat1) == true) then 
 if(getItemByName(mat1).ItemNum >= mat1num) then
 if(hasItem(mat2) == true) then 
 if(getItemByName(mat2).ItemNum >= mat2num) then
 if (GetMe():GetMp() > mpCost) then
 Craft(craftId);
 end;
 else
 CraftStatus = false;
 ShowToClient("Craft Plugin","Not enough " .. mat2);
 end;
 else
 CraftStatus = false;
 ShowToClient("Craft Plugin","Missing " .. mat2);
 end;
 else
 CraftStatus = false;
 ShowToClient("Craft Plugin","Not enough " .. mat1);
 end;	
 else
 CraftStatus = false;
 ShowToClient("Craft Plugin","Missing " .. mat1);
 end;
	else
 CraftStatus = false;
 ShowToClient("Craft Plugin","Weigth limit approaching, Craft Plugin Deactivated.");	
 end;	
end;
 
end;



save as plugin
how can make work if char is not in alliance?
(06-02-2015 02:28 AM)plixplox Wrote: [ -> ]how can make work if char is not in alliance?

What alliance are u talking about??? im confused...Huh
function OnCreate()
this:RegisterCommand("craft", CommandChatType.CHAT_ALLY, CommandAccessLevel.ACCESS_ME);

looking at script to me anyways, to activate script says type in allychat, ssa, ssb, etc..
don't see any stop command tho.. like stop .. to change craft type, or stop to do something else a bit, etc...

Just realized, I don't even know hot to start this plugin, let alone stop it Sad
/craft_ssr
ok, how turn off?
(06-02-2015 15:00 PM)plixplox Wrote: [ -> ]ok, how turn off?

to start, u simply type in GENERAL chat (white chat) like all plugin commands...

so to craft BSSR: /craft_bssr

SSB: /craft_ssb

and to stop: /craft
Pages: 1 2 3 4
Reference URL's