04-03-2019, 09:37 AM
It manages to open placard, but then i have to press purchase land and it will work until i have to press purchase land again.. how to fix this?
local delay = 5000 --Delay between purchase attempts, 1000 is 1 second
local buytype = 0 --0 is Private Individual, 1 is Free Company, 2 is Relocation...
if BuyHouseVar == nil then
BuyHouseVar = true
BuyHouseStep = 0
BuyHouseLast = 0
BuyHousePushButton = 24
if GetGameRegion() == 1 then BuyHousePushButton = 25 end
else
BuyHouseVar = not BuyHouseVar
end
function BuyHouseFunction()
d("BuyHouseStep: "..tostring(BuyHouseStep))
if BuyHouseVar and TimeSince(BuyHouseLast) > delay then
local PlacardID = 0
local el = EntityList("nearest,contentid=2002736")
if table.valid(el) then
for k,v in pairs(el) do
PlacardID = v.id
end
end
if BuyHouseStep == 0 then
if IsControlOpen("HousingSignBoard") then
BuyHouseStep = 1
else
Player:SetTarget(PlacardID)
Player:Interact(PlacardID)
end
end
if BuyHouseStep == 1 then
UseControlAction("HousingSignBoard","PurchaseLand")
if IsControlOpen("SelectYesno") then
BuyHouseStep = 3
elseif IsControlOpen("SelectString") and not IsControlOpen("HousingSignBoard") then
BuyHouseStep = 2
elseif IsControlOpen("HousingSignBoard") then
local ctrl = GetControl("HousingSignBoard")
if ctrl:GetRawData()[1].value.A == 1 then
ctrl:PushButton(BuyHousePushButton,2)
end
end
end
if BuyHouseStep == 2 then
if IsControlOpen("SelectYesno") then
BuyHouseStep = 3
elseif IsControlOpen("SelectString") then
GetControl("SelectString"):Action("SelectIndex",buytype)
elseif IsControlOpen("HousingSignBoard") then
UseControlAction("SelectYesno","Yes")
BuyHouseStep = 1
end
end
if BuyHouseStep == 3 then
if IsControlOpen("SelectYesno") then
UseControlAction("SelectYesno","Yes")
elseif Player:GetTarget() == nil then
BuyHouseStep = 0
BuyHouseLast = Now()
end
end
end
end
RegisterEventHandler("Gameloop.Update", BuyHouseFunction)(04-25-2019, 04:07 PM)chadit Wrote: [ -> ]anyone been successful yet with the updated code? 10 plots so far and I lose to others. not upset, more or less just want to make sure it works, and or any suggestions for a way to make it faster then other bots :)
(04-25-2019, 07:50 PM)FunkedUp Wrote: [ -> ](04-25-2019, 04:07 PM)chadit Wrote: [ -> ]anyone been successful yet with the updated code? 10 plots so far and I lose to others. not upset, more or less just want to make sure it works, and or any suggestions for a way to make it faster then other bots :)
I was successful with it today, copy the code, change the delay from 5000 to whatever you want. There were so many other people buying houses today I went /busy, set it to 500 and managed to get mine. If I set it to anything lower than 500, the bot would end up crashing.
16:18:58> D = "BuyHouseStep: 0"
16:18:58> D = "BuyHouseStep: 0"
16:18:58> D = "BuyHouseStep: 0"
16:18:58> D = "BuyHouseStep: 0"
16:18:58> D = "BuyHouseStep: 0"
16:18:58> [Lua Error]: [string "local delay = 500..."]:41: attempt to index a nil value
16:18:58> Callstack:
16:18:58> [[string "local delay = 500..."]]:41:
16:18:58> D = "BuyHouseStep: 1"
16:18:58> D = "BuyHouseStep: 2"
16:18:58> D = "BuyHouseStep: 1"
16:18:58> D = "BuyHouseStep: 1"
16:18:58> D = "BuyHouseStep: 2"
16:18:58> D = "BuyHouseStep: 1"(04-30-2019, 04:23 PM)chadit Wrote: [ -> ]still working snagging a house, I was looking a the console output just to see what was happening (can believe I have lost this many times)... is this error because the log is not purchasable or is there an issue with my script
(05-01-2019, 02:56 PM)liouliou Wrote: [ -> ](04-30-2019, 04:23 PM)chadit Wrote: [ -> ]still working snagging a house, I was looking a the console output just to see what was happening (can believe I have lost this many times)... is this error because the log is not purchasable or is there an issue with my script
Same problem here (and same logs), don't know if it's juste because of the loop, or if there is a problem with the script. I've lost the count of the number of house i've lost.
local delay = 500 --Delay between purchase attempts, 1000 is 1 second
local buytype = 0 --0 is Private Individual, 1 is Free Company, 2 is Relocation...
local PlacardID = 0
if BuyHouseVar == nil then
BuyHouseVar = true
BuyHouseStep = 0
BuyHouseLast = 0
BuyHousePushButton = 24
if GetGameRegion() == 1 then BuyHousePushButton = 25 end
else
BuyHouseVar = not BuyHouseVar
end
function BuyHouseFunction()
d("BuyHouseStep: "..tostring(BuyHouseStep))
if BuyHouseVar and TimeSince(BuyHouseLast) > delay then
PlacardID = 0
local el = EntityList("nearest,contentid=2002736")
if table.valid(el) then
for k,v in pairs(el) do
PlacardID = v.id
end
end
if BuyHouseStep == 0 then
if IsControlOpen("HousingSignBoard") then
BuyHouseStep = 1
else
Player:SetTarget(PlacardID)
Player:Interact(PlacardID)
end
end
if BuyHouseStep == 1 then
UseControlAction("HousingSignBoard","PurchaseLand")
if IsControlOpen("SelectYesno") then
BuyHouseStep = 3
elseif IsControlOpen("SelectString") and not IsControlOpen("HousingSignBoard") then
BuyHouseStep = 2
elseif IsControlOpen("HousingSignBoard") then
local ctrl = GetControl("HousingSignBoard")
if ctrl:GetRawData()[1].value.A == 1 then
ctrl:PushButton(BuyHousePushButton,2)
end
end
end
if BuyHouseStep == 2 then
if IsControlOpen("SelectYesno") then
BuyHouseStep = 3
elseif IsControlOpen("SelectString") then
GetControl("SelectString"):Action("SelectIndex",buytype)
elseif IsControlOpen("HousingSignBoard") then
UseControlAction("SelectYesno","Yes")
BuyHouseStep = 1
end
end
if BuyHouseStep == 3 then
if IsControlOpen("SelectYesno") then
UseControlAction("SelectYesno","Yes")
elseif Player:GetTarget() == nil then
BuyHouseStep = 0
BuyHouseLast = Now()
end
end
end
if Player:GetTarget() == nil then
Player:SetTarget(PlacardID)
end
end
RegisterEventHandler("Gameloop.Update", BuyHouseFunction)