i look on your script and dont really know what you want. because in code i see 2 thing, gathering energy stones and buying CH SOE.
But if your sleep time dont work like you want, than problem can make waittime
(04-16-2013 08:21 AM)Hebdzik Wrote: i look on your script and dont really know what you want. because in code i see 2 thing, gathering energy stones and buying CH SOE.
But if your sleep time dont work like you want, than problem can make waittime
buy =true;
afk =false;-- will go out clan hall then soe in time if true
LastBuyTimeManually =os.time({year=2012, month=11, day=5, hour=15, min=34, sec=30})
ClanHallNpcName ="Maid";
skip =false;
GiantEnergyQuantityAfterBuy =nil;
GiantEnergyQuantityBeforeBuy =nil;--------------------------------------------------------------------------------------------function LoadLastBuyfromFile(filename)--function that uses filename file to obtain player stock.local file =io.open(GetDir() .. filename, "r")if(file ==nil)then-- then create a file
file =io.open(GetDir() .. filename, "w")elsefor line in file:lines()doif(tonumber(line) ~=nil)thenreturntonumber(line);end;end;end;
file:close();return0;end;--------------------------------------------------------------------------------------------function UpdateLastEnergyBuyFile(thefile)local file =io.open(GetDir() .. thefile, "w+")
file:write(tostring(os.time() + 2) .. "\n");
file:close();end;--------------------------------------------------------------------------------------------
LastBuyOnFile = LoadLastBuyfromFile(GetMe():GetName() .. "LastEnergyBuy.txt");-------------------------------------------------------------------------------------------- if(LastBuyTimeManually > LastBuyOnFile)then
LastBuyTime = LastBuyTimeManually;else
LastBuyTime = LastBuyOnFile;end;--ShowToClient("Buying Energies Script","Next Giant Energy Sale will occur between " .. os.date("%X") .. " and ".. os.date("%X",os.time()+3600) .. " and it need to be done manually.");--------------------------------------------------------------------------------------------if buy thenif(os.time()> LastBuyTime + 7200)then
ShowToClient("Buying Energies Script","No Idea When Spawn Might be.");elseif(os.time()> LastBuyTime + 3610)and(os.time()< LastBuyTime + 7200)then
ShowToClient("Buying Energies Script","Next Giant Energy Sale will occur between " .. os.date("%X") .. " and ".. os.date("%X",os.time()+3600) .. " and it need to be done manually.");while(GiantEnergyQuantityBeforeBuy ==nil)or(GiantEnergyQuantityAfterBuy ==nil)or((GiantEnergyQuantityAfterBuy-GiantEnergyQuantityBeforeBuy)<=0)do
Sleep(2000);
MyTarget = GetTarget();if(MyTarget ~=nil)and(MyTarget:GetName()== ClanHallNpcName)then
GiantEnergy = GetInventory():FindByDisplayId(35563);if(GiantEnergy ==nil)then
GiantEnergyQuantityAfterBuy =0;if(GiantEnergyQuantityBeforeBuy ==nil)then
GiantEnergyQuantityBeforeBuy =0;end;else
GiantEnergyQuantityAfterBuy = GiantEnergy.ItemNum;end;else
GiantEnergy = GetInventory():FindByDisplayId(35563);if(GiantEnergy ==nil)then
GiantEnergyQuantityBeforeBuy =0;if(GiantEnergyQuantityAfterBuy ==nil)then
GiantEnergyQuantityAfterBuy =0;end;else
GiantEnergyQuantityBeforeBuy = GiantEnergy.ItemNum;end;end;end;
ShowToClient("Buying Energies Script","Giant Energy Quantity Change Detected, time set for now");
UpdateLastEnergyBuyFile(GetMe():GetName() .. "LastEnergyBuy.txt");
skip =true;else
ShowToClient("Buying Energies Script","Started, buy will occur in " .. tostring(math.ceil((3600-(os.time()-LastBuyTime))/60)).. " minutes.");while((os.time()-LastBuyTime)<3600)do
Sleep(1000);end;end;
ShowToClient("Buying Energies Script","Attempting to buy for First Time.");---------------------------------------------------------------------------------------------- MAIN LOOP--------------------------------------------------------------------------------------------repeatifnot skip then
GiantEnergy = GetInventory():FindByDisplayId(35563);if(GiantEnergy ==nil)then
GiantEnergyQuantityBeforeBuy =0;else
GiantEnergyQuantityBeforeBuy = GiantEnergy.ItemNum;end;
Command("/target " .. ClanHallNpcName);
Sleep(500);
Command("/target " .. ClanHallNpcName);
GetNormalNPCExchangeManager():Clear();while(not GetNormalNPCExchangeManager():GetStatus())do
Click("menu_select?ask=-201&reply=3", "Create Item");
Sleep(1000);
Click("menu_select?ask=-201&reply=12", "Create Item");
Sleep(1500);end;if(GetNormalNPCExchangeManager():AddBuyByID(35563,2)==true)then
Sleep(1000);
GetNormalNPCExchangeManager():RequestBuyItems();
ShowToClient("Auto Clan Hal buy","Request Buying");
UpdateLastEnergyBuyFile(GetMe():GetName() .. "LastEnergyBuy.txt")end;
Sleep(100);
GetNormalNPCExchangeManager():RequestShopUIClose();
Sleep(4000);
GiantEnergy = GetInventory():FindByDisplayId(35563);if(GiantEnergy ==nil)then
GiantEnergyQuantityAfterBuy =0;else
GiantEnergyQuantityAfterBuy = GiantEnergy.ItemNum;end;
Adena = GetInventory():FindByDisplayId(57);if(Adena ==nil)then
AdenaQuantity =0;else
AdenaQuantity = Adena.ItemNum;end;
ShowToClient("Buying Energies Script","I got extra " .. tostring(GiantEnergyQuantityAfterBuy-GiantEnergyQuantityBeforeBuy) .. " Giant Energy.");end;
skip =false;
ClanHallSoE = GetInventory():FindByDisplayId(1829);if(ClanHallSoE ==nil)then
ClanHallSoEQuantity =0;else
ClanHallSoEQuantity = ClanHallSoE.ItemNum;end;if(ClanHallSoEQuantity >0)and(afk)then
moveDistance =30;
waittime =0;
timeofteleport = GetTime();
MoveTo(144841, 27723, -2269, moveDistance);
waittime = GetTime() - timeofteleport;
Sleep(57*60*1000 -2000);
timeofteleport = GetTime();
UseItem(1829);-- Scroll of Escape: Clan Hall
WaitForTeleport();
MoveTo(144227, 28245, -2242, moveDistance);
Command("/target " .. ClanHallNpcName);
waittime = waittime + GetTime() - timeofteleport;else
waittime =0;
Sleep(57*60*1000 -2000);-- this sleep can be slpit into more for soe scrollsend;
ShowToClient("Buying Energies Script","Clicking in 2 minutes...");--Sleep translation:-- 1000ms = 1s-- 60*1000ms = 1min-- 3*60*1000ms = 3*60s = 3min-- 60*60*1000ms = 3600*1000 = 3600000ms = 1h-- Sleep(1*60*1000) = 60000ms = 60s = 1min
Sleep(60*60*1000 -waittime);-- 1hour - waittime--------------------------------------------------------------------------------------------END MAIN LOOPuntil((GiantEnergyQuantityAfterBuy-GiantEnergyQuantityBeforeBuy)<=0)or(AdenaQuantity <11000000)end;
Thank you for help first.
This script is used to automatically purchase item Giant Energy from Provisional Clan Hall.
Did the way you ordered, changed the time for 3 minutes and even then, after the character buys the item he keeps waiting 60 minutes to buy the next.
I wanted him check item in NPC in 70 minutes, not 60 minutes. Because the item appears to buy again after 1 hour and 1 minute. Thus, if he tries to 60 in 60 minutes this will not work and script stop.
.
Sleep(57*60*1000 -2000); --> 57 min sleep
timeofteleport = GetTime();
UseItem(1829); -- Scroll of Escape: Clan Hall
WaitForTeleport();
MoveTo(144227, 28245, -2242, moveDistance);
Command("/target " .. ClanHallNpcName);
waittime = waittime + GetTime() - timeofteleport;
else
waittime = 0;
Sleep(57*60*1000 -2000);-- this sleep can be slpit into more for soe scrolls --> 57 min sleep
end;
ShowToClient("Buying Energies Script","Clicking in 2 minutes...");
Sleep(3*60*1000 -waittime);
Sleep(57*60*1000 -2000) => it makes 57min sleep and at the end it adds 3 more mins wait time, so if u edit both 57*60*1000 sleep then it will wait more...