1. The forums will be archived and moved to a read only mode in about 2 weeks (mid march).

Giving an item in a specific event

Discussion in 'Development' started by MSG100PM, Aug 18, 2018.

  1. MSG100PM

    MSG100PM Slime

    Messages:
    95
    GitHub:
    MSG100TC
  2. xXNiceAssassinlo YT

    xXNiceAssassinlo YT Zombie Pigman

    Messages:
    499
    GitHub:
    xXNiceYT
    MSG100PM likes this.
  3. MSG100PM

    MSG100PM Slime

    Messages:
    95
    GitHub:
    MSG100TC
    Thanks but how can I make the cooldown to 5 seconds?
     
  4. MalakasPlayzMCPE

    MalakasPlayzMCPE Zombie Pigman

    Messages:
    667
    Add the player in an array and schedule a repeating task. In the task file use public $time = 0 and onRun you $this->time++;
    Check if the time is 1 and unset from the array
    On the interact function you check if the player's name is in_array so you do not leap and return false. 20 ticks = 1 second so 100 ticks = 5 seconds.

    Hope you undertand.
     
  5. HimbeersaftLP

    HimbeersaftLP Fish

    Messages:
    2,402
    GitHub:
    HimbeersaftLP
    Whenever that code gets called, save the playername (key) and a timestamp (value, using time()) into an array. And before that, check whether the player is already in that array and if their timestamp is old enough (at least 5 seconds old), if it is, remove it from that array. If the player isn't in the array or the timestamp was old enough, give them the item, then save their name and new timestamp into the array.
     
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.