tpadmin

ggblade

Member
Member
Aug 14, 2014
29
0
6
so there was this old plugin, that has always worked and was really good. but with fougerite it actually crashes your game.... now dretax said somthing about it cant read a null or somthing so that might be it but im not sure,


heres the plugin.

JavaScript:
/*
@title Tp Admin
@author Mastah
@date 14/03/2014
@version: 1.0.1
*/

function On_Command(Player, cmd, args) {
   
    // The target player
    var targetPlayer = null,
   
    // The target name
    targetName = null,
   
    // Distance at which we will teleport from target (stored in cfg file)
    distance = null,
   
    // Vector 3D corresponding to the "inback" position from target
    vector3d = null,
   
    // Y coordinate from ground at TP location
    newYLocation = null;

    switch(cmd) {
   
        case "tpadmin":
       
            // Retrive distance value and set a default value if not exist
            distance = Data.GetConfigValue("TpAdmin", "Settings", "distance") || 20;
   
            // Only if player is admin or in the steam UIDs
            if(Player.Admin ) {
               
                // Set the name
                targetName = ConcatName(args);
               
                // Check for the arg name
                if(!isEmptyString(targetName)) {
               
                    // Retrieve player target
                    targetPlayer = Player.Find(GetProperName(targetName));
                   
                    // Inform that the player couldn't be found in case of not found
                    if (targetPlayer === null) {
                        Player.Message("Player " + targetName + " couldn't be found.");
                    } else {
                   
                        // Logging purpose
                        Player.Message("Teleporting you to " + targetPlayer.Name + ".");
                       
                        // Retrieve the "inback" coordinate from target
                        vector3d = Util.Infront(targetPlayer, distance * -1);
                       
                        // Retrieve the proper Y coordinate to make you land on ground
                        newYLocation = World.GetGround(vector3d.x, vector3d.z);
                       
                        // Teleporting you to destination
                        Player.TeleportTo(vector3d.x, newYLocation, vector3d.z);
                       
                    }
                   
                } else {
                    Player.Message("Player name is empty. The arguments need to be the player name.");
                }
               
            } else {
                Player.Message("You are not allowed.");
            }
            break;
       
    }
   
}




// Tools
function ConcatName(args){
    var name = args[0];
    for(var i=1; i < args.Length; i++)
        name += " " + args[i];
    return name;
}
function GetProperName(name){
    var players = Server.Players, lowerCaseName = null;
    lowerCaseName = Data.ToLower(name);
    for (var i = 0; i < players.Count; i++) {
        if (lowerCaseName == Data.ToLower(players[i].Name)) {
            return players[i].Name;
        }
    }
    return null;
}
function isNull(theValue) {
    return (theValue === null);
}
function isUndefined(theValue) {
    return (typeof theValue === "undefined");
}
function isNullOrUndefined(theValue) {
    return isNull(theValue) || isUndefined(theValue);
}
function isEmptyString(theValue) {
    if (isNullOrUndefined(theValue)) {
        return true;
    } else if (theValue.length === 0) {
        return true;
    } else {
        return false;
    }
}
 

Jakkee

Retired Staff
Retired Staff
Plugin Developer
Jul 28, 2014
1,465
932
113
Australia
so there was this old plugin, that has always worked and was really good. but with fougerite it actually crashes your game.... now dretax said somthing about it cant read a null or somthing so that might be it but im not sure,


heres the plugin.

JavaScript:
/*
@title Tp Admin
@author Mastah
@date 14/03/2014
@version: 1.0.1
*/

function On_Command(Player, cmd, args) {
  
    // The target player
    var targetPlayer = null,
  
    // The target name
    targetName = null,
  
    // Distance at which we will teleport from target (stored in cfg file)
    distance = null,
  
    // Vector 3D corresponding to the "inback" position from target
    vector3d = null,
  
    // Y coordinate from ground at TP location
    newYLocation = null;

    switch(cmd) {
  
        case "tpadmin":
      
            // Retrive distance value and set a default value if not exist
            distance = Data.GetConfigValue("TpAdmin", "Settings", "distance") || 20;
  
            // Only if player is admin or in the steam UIDs
            if(Player.Admin ) {
              
                // Set the name
                targetName = ConcatName(args);
              
                // Check for the arg name
                if(!isEmptyString(targetName)) {
              
                    // Retrieve player target
                    targetPlayer = Player.Find(GetProperName(targetName));
                  
                    // Inform that the player couldn't be found in case of not found
                    if (targetPlayer === null) {
                        Player.Message("Player " + targetName + " couldn't be found.");
                    } else {
                  
                        // Logging purpose
                        Player.Message("Teleporting you to " + targetPlayer.Name + ".");
                      
                        // Retrieve the "inback" coordinate from target
                        vector3d = Util.Infront(targetPlayer, distance * -1);
                      
                        // Retrieve the proper Y coordinate to make you land on ground
                        newYLocation = World.GetGround(vector3d.x, vector3d.z);
                      
                        // Teleporting you to destination
                        Player.TeleportTo(vector3d.x, newYLocation, vector3d.z);
                      
                    }
                  
                } else {
                    Player.Message("Player name is empty. The arguments need to be the player name.");
                }
              
            } else {
                Player.Message("You are not allowed.");
            }
            break;
      
    }
  
}




// Tools
function ConcatName(args){
    var name = args[0];
    for(var i=1; i < args.Length; i++)
        name += " " + args[i];
    return name;
}
function GetProperName(name){
    var players = Server.Players, lowerCaseName = null;
    lowerCaseName = Data.ToLower(name);
    for (var i = 0; i < players.Count; i++) {
        if (lowerCaseName == Data.ToLower(players[i].Name)) {
            return players[i].Name;
        }
    }
    return null;
}
function isNull(theValue) {
    return (theValue === null);
}
function isUndefined(theValue) {
    return (typeof theValue === "undefined");
}
function isNullOrUndefined(theValue) {
    return isNull(theValue) || isUndefined(theValue);
}
function isEmptyString(theValue) {
    if (isNullOrUndefined(theValue)) {
        return true;
    } else if (theValue.length === 0) {
        return true;
    } else {
        return false;
    }
}
Its weird how it crashes the client.
 

DreTaX

Probably knows the answer...
Administrator
Jun 29, 2014
4,093
4,784
113
At your house.
github.com
var targetPlayer =null,

// The target name
targetName =null,

// Distance at which we will teleport from target (stored in cfg file)
distance =null,

// Vector 3D corresponding to the "inback" position from target
vector3d =null,

// Y coordinate from ground at TP location
newYLocation =null;

There are commas ( , ) after lots of lines. Thats not cool. Plus, there is no var before them, which is critical.