Page 1 of 2 12 LastLast
Results 1 to 10 of 11

Thread: While is so fast than itemcount

  1. #1
    Normal User
    Join Date
    Apr 2012
    Posts
    22
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quoted
    0 Post(s)
    Reputation
    10
    Rep Power
    5

    While is so fast than itemcount

    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.

    Making a dice script.

    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] == 3043then
              local cc 
    tonumber(g[1]) - itemcount(gold[i],field1)    // this decrease the total to move but is slow, if =0 then break
                   
    if(cc<=0then
                       
    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<=0then
                       
    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 
    Last edited by Sajean; 02-11-2014 at 09:48 PM.

  2. #2
    Normal User catok's Avatar
    Join Date
    Jan 2013
    Location
    Sweden
    Posts
    94
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Quoted
    0 Post(s)
    Reputation
    14
    Rep Power
    4
    Quote Originally Posted by Sajean View Post
    //wait(400) if i put this wait this work fine, but my code get an bug, and people can abuse.
    [/php]
    How will they be able to abuse it? It requires a lot of testing to create a dice script. Maybe go somewhere far away like venore east depot and test every possible move you can think of.

    What I would have done is create an action that separates the platinums depending on how much the bettor decided to bet.
    Say if he puts 10k, your bot should already move 8k to another bag (and put his 10k in the same bag), if he wins your bot will give everything from that bag in posx+1 and posy+1.

    Then this problem doesn't have to occur at all and it's probably easier to do it my way
    Hard Working Scripter



    My Free Scripts:

    Knight
    EK - Mutated Mountains 50+ (option to hunt any tower)

  3. #3
    Normal User
    Join Date
    Apr 2012
    Posts
    22
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quoted
    0 Post(s)
    Reputation
    10
    Rep Power
    5
    If i put this wait, the people can steal more golds.
    Like this:
    The player put 10k, and if him win him receveid 1 crystal coin and 80 platinum coins.
    If in my first slot of backpack i have below 80 platinum coins, the bot will move the below amount.
    If the player take this amount, before my function itemcount.
    The itemcount is = 0, and the bot will give more 80 platinum coins, not 50 platinums

  4. #4
    Normal User catok's Avatar
    Join Date
    Jan 2013
    Location
    Sweden
    Posts
    94
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Quoted
    0 Post(s)
    Reputation
    14
    Rep Power
    4
    So in essence your script pays them 2k extra every time they play with 10k?
    I've never tried making or putting my effort in to doing a dice script, but what I said in my previous post is what I would have done.
    PinkPanther is good at doing obscure scripts, maybe if he sees this thread he'll be able to help you.
    Hard Working Scripter



    My Free Scripts:

    Knight
    EK - Mutated Mountains 50+ (option to hunt any tower)

  5. #5
    Normal User
    Join Date
    Apr 2012
    Posts
    22
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quoted
    0 Post(s)
    Reputation
    10
    Rep Power
    5
    If this occur with crystal coins, ins't 2k.
    But thank you for attention.

  6. #6
    iBot User pink_panther's Avatar
    Join Date
    May 2012
    Location
    Australia
    Posts
    4,075
    Mentioned
    49 Post(s)
    Tagged
    1 Thread(s)
    Quoted
    178 Post(s)
    Reputation
    309
    Rep Power
    10
    Quote Originally Posted by catok View Post
    So in essence your script pays them 2k extra every time they play with 10k?
    I've never tried making or putting my effort in to doing a dice script, but what I said in my previous post is what I would have done.
    PinkPanther is good at doing obscure scripts, maybe if he sees this thread he'll be able to help you.

    Oh jesus... I was going to walk away, but then i saw you say my name... :'(

    I hate dicer scripts with a passion, not because of the scripting required, just because I hate how lazy it is.



    Lua 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



    Oooookay, if you want me to help, im going to need to see your setup or the following varisbles at least...

    gold
    field1
    g

    I can assume that platinumbp and crystalbp are contrainers, so thats not a problem.

    Also tell me if you're getting any errors in your debug log.

    I can also see you're using ipairs wrong for a start...
    Last edited by pink_panther; 02-12-2014 at 12:30 AM.

  7. #7
    Normal User catok's Avatar
    Join Date
    Jan 2013
    Location
    Sweden
    Posts
    94
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Quoted
    0 Post(s)
    Reputation
    14
    Rep Power
    4
    Quote Originally Posted by pink_panther View Post
    Oh jesus... I was going to walk away, but then i saw you say my name... :'(
    Haha, I feel good in my stomach now
    Hard Working Scripter



    My Free Scripts:

    Knight
    EK - Mutated Mountains 50+ (option to hunt any tower)

  8. #8
    Normal User
    Join Date
    Apr 2012
    Posts
    22
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quoted
    0 Post(s)
    Reputation
    10
    Rep Power
    5
    @pink_panther
    Yes i know i'm wrong with ipairs, i have changed this, using v for all gold[i].

    gold: is where have the id of the platinum coins, and crystal coins, an array.
    field1: is only the name = 'browse field'
    g:
    I have an calculator of winner, when player put gold on the middle,and him says l or h, i take and put in one backpack, when the gold is in my backpack and if the dice player win, then I take this value inside in my backpack and calcule the payout to return to player, and put in this array.
    g[1] is how much crystal coin i need to give to the player.
    g[2] is how much platinum coins i need to give to the player
    Last edited by Sajean; 02-12-2014 at 07:52 AM.

  9. #9
    Normal User
    Join Date
    Apr 2012
    Posts
    22
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quoted
    0 Post(s)
    Reputation
    10
    Rep Power
    5
    I have fix the problem, Thank you for attention.

  10. #10
    Normal User catok's Avatar
    Join Date
    Jan 2013
    Location
    Sweden
    Posts
    94
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Quoted
    0 Post(s)
    Reputation
    14
    Rep Power
    4
    Good that you solved it yourself my friend
    Hard Working Scripter



    My Free Scripts:

    Knight
    EK - Mutated Mountains 50+ (option to hunt any tower)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •