New Script events: onPlayerKill etc.


  • Forum Admin

    There are new events for detecting if a player logins, dies or kills someone. The code needs to appear in scriptclasses/player.js. The event is not fired on the player itself, but on a "control-npc" (if you know Graal you might know the concept) which is automatically joining the player.js class. This can change later though.

    Here are the new events on example code to print them:

    function onPlayerLogin(player) {
        echo("player login: " + player.id + " - " + player.name);
    }
    function onPlayerDeath(player, killer) {
        echo("player death: " + player.name + (killer? " by " + killer.type + (killer.name? " " + killer.name : "") + " with " + killer.weapon : ""));
    }
    function onPlayerKill(player, victim, rejectReason) {
        echo("player kill: " + player.name + (victim? " killed " + victim.name : "") + (rejectReason? ", no score because of: " + rejectReason : ""));
    }
    

    There are also new object attributes: player.type ("player") and player.level, which is a floating point number and by default zero.


  • Corleone Staff Forum Admin

    Looks excellent 🙂 can't wait to hopefully put these to good use!!


Log in to reply