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

Solved Need Help :D

Discussion in 'Development' started by brokiem, Jul 14, 2020.

  1. brokiem

    brokiem Silverfish

    Messages:
    18
    GitHub:
    brokiem
    Hi, i have question, For example the damager has been tampered with with the entity Then the damager logs out of the game well then later if the entity dies, he will get the damager's name and the server will error "getName() on null" how to fix it? :D
     
  2. Muqsit

    Muqsit Chicken

    Messages:
    1,548
    GitHub:
    muqsit
    Check if damager isn't null.
    PHP:
    $damager $event->getDamager();
    if(
    $damager !== null){
        
    //...
    }
     
    brokiem and Primus like this.
  3. brokiem

    brokiem Silverfish

    Messages:
    18
    GitHub:
    brokiem
    thank you so much musqit, and 1 more question, how to set damager to null? thanks :D
     
  4. dadodasyra

    dadodasyra Witch

    Messages:
    68
    GitHub:
    dadodasyra
    I advise you to learn the basics of object oriented php. You just need to declare the variable as null, but what would you like to use that for?
    PHP:
    $damager null;
     
    brokiem likes this.
  5. brokiem

    brokiem Silverfish

    Messages:
    18
    GitHub:
    brokiem
    I want the last damager to be null in 10 seconds, because if it is not converted to null the damager will continue to be the last damager to the entity continuously.
    btw thank you!
     
  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.