Random plugins

ggblade

Member
Member
Aug 14, 2014
29
0
6
so im trying to just randomly make some plugins, and see if im able to make it or if i end up not being able to.
the only things i know of javascript is the random things i figure out while looking at other plugins.

so i tried to make a /ping command, but i ended up seeying this Player.Ping:int, and using var ping = Player.Ping , clearly just gives me a undefined...
how could one make it so it would give a number?

also, a /pm command. function On_Command(Player, cmd, args), you have your command, then the args is the name of the player youd try to pm. so i have no idea what to do when i want to add their text to it...

also the wiper plugin isent working for me so id like some on Entity.UpdateHealth(), havent tried anything yet, but id like to just have a command to heal barricades and large/small spike walls...
 

DreTaX

Probably knows the answer...
Administrator
Jun 29, 2014
4,098
4,863
113
At your house.
github.com
so im trying to just randomly make some plugins, and see if im able to make it or if i end up not being able to.
the only things i know of javascript is the random things i figure out while looking at other plugins.

so i tried to make a /ping command, but i ended up seeying this Player.Ping:int, and using var ping = Player.Ping , clearly just gives me a undefined...
how could one make it so it would give a number?

also, a /pm command. function On_Command(Player, cmd, args), you have your command, then the args is the name of the player youd try to pm. so i have no idea what to do when i want to add their text to it...

also the wiper plugin isent working for me so id like some on Entity.UpdateHealth(), havent tried anything yet, but id like to just have a command to heal barricades and large/small spike walls...
Rust++ has most of these features, but:

JavaScript:
function On_Command(Player, cmd, args) {
    if(cmd == "ping") {
        var ping = Player.Ping;
        Player.Message("Your ping: " + ping);
    }
    else if(cmd == "pm") {
        var playername = Player.Name;
        var text = argsToText(args);
        if (args.Length > 0) {
            if (args.Length == 1) {
                Player.Message("Usage: /pm playername text here");
                return;
            }
            else {
                var pmto = CheckV(Player, args);
                if (pmto != null) {
                    var name = pmto.Name;
                    text.replace(name, "");
                    pmto.MessageFrom("PM FROM: " + playername, text);
                }
                else {
                    Player.Message("Couldn't find the player!");
                    return;
                }
            }
        }
        else {
            Player.Message("Usage: /pm playername text here");
            return;
        }
    }
}

/*
*    Provided by SPooCK
*
*/

function CheckV(Player, args) {
    var target;
    var systemname = Data.GetConfigValue("TpFriend", "Settings", "sysname");
    var Nickname = "";
    for(var i=0; i < args.Length; i++)
    Nickname += args[i] + " ";
    Nickname = Data.Substring(Nickname, 0, Data.StrLen(Nickname) - 1)
    target = Fougerite.Player.FindByName(Nickname);
    if (target != null) {
        return (target);
    }
    else {
        var cc = 0;
        for (var all in Server.Players) {
            var name = all.Name.ToLower();
            var check = args[0].ToLower();
            if (name.Contains(check)) {
                var found = all.Name;
                cc++;
            }
        }
        if (cc == 1) {
            target = Fougerite.Player.FindByName(found);
            return (target);
        } else if (cc > 1) {
            Player.MessageFrom(systemname, "Found [color#FF0000]" + cc + " players[/color] with similar names. [color#FF0000]Use more correct name !");
            return null;
        } else if (cc == 0) {
            Player.MessageFrom(systemname, "Player [color#00FF00]" + Nickname + "[/color] not found");
            return null;
        }
    }
}
//Combines the array into one text (idk from who)
function argsToText(args){
    var text = "";
    if (args.Length == 1 ){
        text = args[0];
    }else{
        for (var l = 0; l < args.Length; l++){
            if (l == args.Length - 1){
                text += args[l];
            }else {
                text += args[l] + " ";
            }
        }
    }
    return text;
}
I was to lazy to write anything special or pro, but i hope it works.
 
Last edited: