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

Kick if not in right place

Discussion in 'Development' started by Hipster, May 26, 2017.

  1. Hipster

    Hipster Zombie

    Messages:
    214
    How to check if a player is going out of an area and if out kick him, because there are many hack clients which can enable no clip and they can go outside an area where they are not supposed to go..
     
  2. Thunder33345

    Thunder33345 Moderator Staff Member

    Messages:
    2,137
    GitHub:
    Thunder33345
    just use bounding box, if players are in it kick it or out of it
     
  3. Hipster

    Hipster Zombie

    Messages:
    214
    How? But there are like 2-3 different areas in the same world where they shouldn't get kicked..
     
  4. Thunder33345

    Thunder33345 Moderator Staff Member

    Messages:
    2,137
    GitHub:
    Thunder33345
    since i am feeling generous, here's an example
    this is inside a task under onrun
    Code:
    $areas // @var $areas area[]
    foreach players as player
     foreach areas as area
      if $area->isInside($player) continue 2//skips the kick code and look for next player
     end foreach
     $player->tpToSpawn() //also set them to spawn or they will be kicked forever
     $player->disconnect() //dont let them know i kicked them to emulate some unknow network issue, just because i can
    end foreach
    
    may not be the most ideal lag free but logic certainly works as an example you can improve upon
     
  5. Hipster

    Hipster Zombie

    Messages:
    214
    Laggy since many players and many areas...
     
  6. Thunder33345

    Thunder33345 Moderator Staff Member

    Messages:
    2,137
    GitHub:
    Thunder33345
    it only lags when there's a lot of players online + there's a lot of areas
    if there's 50 players 3 areas it's only about 150 loops at worst since again they have a 33% to be in 1 or 2nd or just put the most popular one on first increasing the odds and reducing the iteration needed
    and players out of areas creates more lagg than players IN the areas
    also you dont need to run this task every tick, save your self some cpu and run it every 60 ticks+
    there's other method like foreaching players and distance them to vector points but it's ultimately same
     
    SOFe likes this.
  7. Hipster

    Hipster Zombie

    Messages:
    214
    Around 80 players and 11 areas...
     
  8. Thunder33345

    Thunder33345 Moderator Staff Member

    Messages:
    2,137
    GitHub:
    Thunder33345
    do you have any other ideas then
    do not expect me to hold you along i dont have infinite ideas
     
  9. Hipster

    Hipster Zombie

    Messages:
    214
    How does lifeboat do it? :O
     
  10. Thunder33345

    Thunder33345 Moderator Staff Member

    Messages:
    2,137
    GitHub:
    Thunder33345
    example?
    afaik they only have one giant area and a VIP zone?
     
  11. Junkdude

    Junkdude Zombie

    Messages:
    346
    GitHub:
    JunkDaCoder
    Incomplete but thats pretty much it, then just kinda schedule a task

    PHP:
        $y $p->getY();
        
    $z $p->getZ();
        
    $xx = [214210];
        
    $yy = [7469];
        
    $zz = [14];
        if(
    $x >= min($xx) and $x <= max($xx) and $y >= min($yy) and $y <= max($yy) and $z >= min($zz) and $z <= max($zz)){
            
    $p->sendmessage("In Region");
        }else{
            
    $p->sendmessage("Not In Region");
        }
     
  12. SOFe

    SOFe Administrator Staff Member PMMP Team Poggit Admin

    Messages:
    1,968
    GitHub:
    sof3
    In a termux command on an Android phone released 3 years ago and bought 2 years ago, executing 6 object field comparisons for 88 players for 11 times takes 0.001234 second, using PHP 7.1.2 (the version where stuff started getting slow).

    On a server supporting 80 players, you definitely have much better hardware than my phone. With PHP 7.0 running, it should take much less than the 2% of a tick as if from my phone.
    Screenshot_2017-05-28-18-40-04.png
     
    HimbeersaftLP and jojoe77777 like this.
  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.