L2Tower Discord Let's keep the community alive with discord. Discussions about plugins and scripts L2Tower Discord

Post Reply 
 
Thread Rating:
  • 82 Vote(s) - 2.8 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Samples
Author Message
ClockMan Offline
All Mighty
*******

Posts: 2,886
Joined: Jan 2011
Reputation: 499
Version: 1.4.3.143
Post: #1
Samples

Foreach Items in Inventory, WH, PetInventory...
    LUA Programming
invList = GetInventory();
for item in invList.list do
  ShowToClient("ITEM", item.Name .. " (ID: " .. item.displayId  .. ")");
end;


[Image: owner.gif]
(This post was last modified: 12-05-2014 01:36 AM by Fox.)
04-01-2011 18:54 PM
Visit this user's website Find all posts by this user Quote this message in a reply
Sakaszli Offline
I'm too pro to be pro.
*******

Posts: 1,189
Joined: Jan 2011
Reputation: 484
Version: 1.4.2.134.5b
Post: #2
RE: Samples

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;

(This post was last modified: 08-28-2011 12:51 PM by Sakaszli.)
08-27-2011 12:38 PM
Visit this user's website Find all posts by this user Quote this message in a reply
Hebdzik Offline
Tester

Posts: 1,235
Joined: Aug 2011
Reputation: 265
Version: 1.4.3.143
Post: #3
RE: Samples

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
(This post was last modified: 09-07-2011 15:03 PM by Hebdzik.)
08-31-2011 20:16 PM
Find all posts by this user Quote this message in a reply
Daczu Offline
Zaken's Royal Guard
*

Posts: 51
Joined: Aug 2011
Reputation: 3
Version: 1.4.1.118
Post: #4
RE: Samples

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

09-07-2011 09:57 AM
Find all posts by this user Quote this message in a reply
davidavyd Offline
Rebmem

Posts: 13
Joined: Dec 2011
Reputation: 0
Version: 1.4.1.76
Post: #5
RE: Samples

1000 means 1k millisecond (1s) right?
(This post was last modified: 01-02-2012 18:22 PM by davidavyd.)
01-02-2012 18:22 PM
Find all posts by this user Quote this message in a reply
Sakaszli Offline
I'm too pro to be pro.
*******

Posts: 1,189
Joined: Jan 2011
Reputation: 484
Version: 1.4.2.134.5b
Post: #6
RE: Samples

yes, 60*1000 = 60 sec
(This post was last modified: 01-19-2012 00:58 AM by Sakaszli.)
01-02-2012 18:30 PM
Visit this user's website Find all posts by this user Quote this message in a reply
pwnage Offline
Ratman Chieftain
*

Posts: 25
Joined: Apr 2011
Reputation: 0
Version: 1.4.1.92
Post: #7
RE: Samples

(01-02-2012 18:30 PM)Sakaszli Wrote:  yes, 60*1000 = 6 sec

60*1000=60000ms=60s

//sakaszli: ahh thx Big Grin
(This post was last modified: 01-19-2012 00:58 AM by Sakaszli.)
01-19-2012 00:54 AM
Find all posts by this user Quote this message in a reply
Pretendent Offline
Expired VIP Member
**

Posts: 5
Joined: Mar 2012
Reputation: 0
Version: 1.4.3.143
Post: #8
RE: Samples

lol = GetPlayerList();
for user in lol.list do
Sleep(50);
SendPM(user:GetName(),"hi");
end;

doesnt work :/

//edit by sakaszli
//try now
(This post was last modified: 03-30-2012 14:16 PM by Sakaszli.)
03-30-2012 13:55 PM
Find all posts by this user Quote this message in a reply
Post Reply 




User(s) browsing this thread: 1 Guest(s)