Lineage 2 Tower Forum

Full Version: Samples
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Foreach Items in Inventory, WH, PetInventory...
    LUA Programming
invList = GetInventory();
for item in invList.list do
  ShowToClient("ITEM", item.Name .. " (ID: " .. item.displayId  .. ")");
end;

How to get your target class:
    LUA Programming
if (GetTarget() ~= nil) then
ShowToClient(">>>>", L2Class2String(GetTarget():GetClass()));
end;



How to get Hp and MaxHP:
    LUA Programming
if (GetTarget() ~= nil) then
ShowToClient(">>>>",  GetTarget():GetName() .. " " .. tostring(GetTarget():GetHp()) .. " / " .. tostring(GetTarget():GetMaxHp()) );
end;



Who have me on target:
    LUA Programming
me = GetMe():GetId();
lol = GetPlayerList(); 
for user in lol.list do 
if (user:GetTarget() == me)  then 
ShowToClient("Want kill u>>>>",user:GetName()); 
end;
end;



How to get mats list (need more ID's):
    LUA Programming
invList = GetInventory();
itemlist= {1864,5549,5550,1893,1885,4044,4042,1890,4043,4041,4040,4039,1888,1894,1873,1872​,1881,1871,1870,1869,1867,1866,1876,1874};
for item in invList.list do
for wtf, test in pairs(itemlist) do
if item.displayId == test  then
  ShowToClient("Mats: ", item.Name .. " (" .. tostring(item.ItemNum)..")");
end;
end;
end;



How to spam PPL ( work in next update )
    LUA Programming
lol = GetPlayerList();
for user in lol.list do
Sleep(50);
SendPM(user:GetName(),"hi");
end;



How to get list of wartags + PVPFlag + Dead:
    LUA Programming
lol = GetPlayerList(); 
for user in lol.list do 
Sleep(50);
if user:IsEnemy() then
ShowToClient(" ",user:GetName() .. " >>> " .. L2Class2String(user:GetClass()) .. " PVPFlag: " ..  tostring(user:IsPvPFlag()) .. " Dead: " .. tostring(user:IsAlikeDeath())); 
end;
end;



Code:
IF U WANT SHOW RESULT IN CHAT CHANGE ShowToClient TO Command and change , to ..
And add some Sleep();, u can get chatban xD

Have fun.

////27.8


    LUA Programming
function getItemCount(name)
invList = GetInventory();
lol=0;
	for item in invList.list do
		if (item.displayId == name or item.objectId==name or item.Name==name) then
			lol=item.ItemNum
		end
	end
return lol;
end;


    LUA Programming
function getItemCount2(name)
invList = GetInventory();
lol=0;
	for item in invList.list do
		if (item.displayId == name or item.objectId==name or item.Name==name) then
			lol=lol+item.ItemNum
		end
	end
return lol;
end;


    LUA Programming
function GetDistanceFromLine(a, b, X, Y)
	return (math.abs(a*X + Y + b)) / (math.sqrt(a*a+b*b));
end;


    LUA Programming
function GetRangeToTarget(User)
-- GetRangeToTarget(GetMe());
	b = User:GetRangeTo(GetTarget());
	return b;
end;


    LUA Programming
function MoveToTarget()
tar = GetTarget();
a = tar:GetLocation();
b = GetMe():GetRangeTo(tar);
MoveTo(a,b);
end;



Say on party your target HP, in %
    LUA Programming
function round(num, idp)
  if idp and idp>0 then
    local mult = 10^idp
    return math.floor(num * mult + 0.5) / mult
  end
  return math.floor(num + 0.5)
end
if (GetTarget() ~= nil) then
Command("# " .. GetTarget():GetName() .. " " .. tostring(round(GetTarget():GetHpPrecent(),2)) .. "% HP");
end;



    LUA Programming
function GetRangeFromPointToPoint(poz,poz1)
y = poz.Y - poz1.Y;
x = poz.X - poz1.X;
z = poz.Z - poz1.Z;
return math.sqrt((x * x)+(y*y)+(z*z));
end;

Script witch will summon Beast Soulshots if number of them get lower than 1k

    LUA Programming
name = "Beast Soulshot";
repeat
invList = GetInventory();
i=0;
for item in invList.list do
	if (item.Name==name) then
		i=item.ItemNum;
		if (i < 1000) then
			UseItem(10515); -- ID of Item - Beast Soulshot Compressed Pack
			Sleep(1000);
		end;
	end;
end;
Sleep(60*1000);
until false



oj petli zapomnialem. Ale juz dziala Big Grin
Working script for beast soulshot since wpp1's doesnt work
    LUA Programming
id = 6645;
repeat
invList = GetInventory();
i=0;
for item in invList.list do
	if (item.displayId==id) then
		i=item.ItemNum;
		if (i < 500) then
			UseItem(10515); -- ID of Item - Beast Soulshot Compressed Pack
			Sleep(1000);
		end;
	end;
end;
Sleep(60*1000);
until false

1000 means 1k millisecond (1s) right?
yes, 60*1000 = 60 sec
(01-02-2012 18:30 PM)Sakaszli Wrote: [ -> ]yes, 60*1000 = 6 sec

60*1000=60000ms=60s

//sakaszli: ahh thx Big Grin
lol = GetPlayerList();
for user in lol.list do
Sleep(50);
SendPM(user:GetName(),"hi");
end;

doesnt work :/

//edit by sakaszli
//try now
Reference URL's