Helo guys.
I want to make this simple thing.
I have some gps in my depot, platinum coins in one backpack and crystal coins in another.
I try to move an certain quantity of gps to middle of depot.
But when i debbug my code, the while is so fast, and itemcount give me a wrong count.
I make my itemcount to count into 'browse field'
My code is this.
When i debbug without the (wait) i get this.
Example:
Gold to move is 1 crystal coin and 80 platinum coins
when i print, i get this
The total to move is 18k
14:04: 1
14:04: 1
14:04:
14:04:
14:04: 80 // quantity to move
14:04: 80 // while move my item and itemcount can't count my item in 'browse field', then return the same quantity
14:04: 50 // Now itemcount can read my quantity in 'browse field' and return certain
14:04: // Now is nothing to move
if this occur i will move to 'browse field' 23k. and it's wrong.
This occur because i have only 30 platinum coins in my first slot of backpack , and the bot move 30 platinum first and after move the rest.
PHP Code:
for i,v in ipairs(gold) do
while itemcount(gold[i],field1)~= tonumber(g[1]) and itemcount(gold[i],field1)~= tonumber(g[2]) do
if(gold[i] == 3043) then
local cc = tonumber(g[1]) - itemcount(gold[i],field1) // this decrease the total to move but is slow, if =0 then break
if(cc<=0) then
break
else
moveitems(gold[i],crystalbp,ground(posx+1,posy+1,posz),cc)
end
//wait(400) if i put this wait this work fine, but my code get an bug, and people can abuse.
elseif(gold[i]==3035)then
local cp = tonumber(g[2]) - itemcount(gold[i],field1) // this decrease the total to move but is slow , if =0 then break
if(cp<=0) then
break
else
moveitems(gold[i],platinumbp,ground(posx+1,posy+1,posz),cp)
end
//wait(400) if i put this wait this work fine, but my code get an bug, and people can abuse.
end
end
end