semi auto remover

ggblade

Member
Member
Aug 14, 2014
29
0
6
trying to make a plugin a bit like wiper. the thing im trying to do is make a file each time a player logs in, it would add there uid to that file + the date when he logged in.
when i would type /clean it would remove all buildings not owned by any of the players that are in that file.

(id remove the players from the list that were offline for longer than 5 days)


this is what i have currently but it destroys pretty much everything but also the buildings owned by players in the list

JavaScript:
function NubIni(target)
{
    var ini = Plugin.GetIni("NewPlayers");
    if(!Plugin.IniExists("NewPlayers"))
    {
        Plugin.CreateIni("NewPlayers");
    }
    if(ini.GetSetting("Players", target.SteamID) != null)
    {
        return true;
    }
    else
    {
        return false;
    }
}

function On_PlayerConnected(Player)
{
    var ini = Plugin.GetIni("NewPlayers");
    var day = System.DateTime.Now.ToString("M.dd");
    ini.AddSetting("Players",Player.SteamID,day);
    ini.Save();
}

function On_Command(Player, cmd, args)
{
if(cmd=="bananass" && Player.Admin)
            {
            for (var x in World.Entities){
                if (x.OwnerID != NubIni ){
                x.Destroy();
                }
                }
                break;
                }
}
 
Last edited:

.phase

Member
Member
Jul 29, 2014
58
12
8
Southern California
Your NubIni function is only returning True/False.

So, if(x.OwnerID != True/False) ??

You want to search the World for UIDs that are also in your Ini. I don't think you've accomplished that yet in your code.
 

ggblade

Member
Member
Aug 14, 2014
29
0
6
modified it. thought it would work, however, now when using the command it removes only a certain amount of objects.
(from my server wich had 45k objects it went to 37k first use, then to 30k, then to 22k, then to 14k and ended at 7.5k) but it seemed like everyones buildings were gone, except for deployable objects.
theres some random extra things in to test.


anyone have any tips or ideas why this does not work? or is it because its destroying to many objects (only a few players were in the list of players who's buildings should not be destroyed)

Code:
function getNubIni() {
    if(!Plugin.IniExists("NewPlayers"))
        Plugin.CreateIni("NewPlayers");
    return Plugin.GetIni("NewPlayers");
}
function getPlayerID(player) {
    var ini = getNubIni();
    var playerINI = ini.GetSetting("Players", player);
    return playerINI;
}
function On_PlayerConnected(Player)
{
    var ini = Plugin.GetIni("NewPlayers");
    var day = System.DateTime.Now.ToString("M.dd");
    ini.AddSetting("Players",Player.SteamID,"active");
    ini.AddSetting("PlayersLog",Player.SteamID,Player.Name + " IP:" + Player.IP + day);
    ini.Save();
}

function On_Command(Player, cmd, args)
{
if(cmd=="date")
    {
    var ini = Plugin.GetIni("NewPlayers");
    var day = System.DateTime.Now.ToString("M.dd");
    Player.Message("the date is " + day);
    ini.AddSetting("Players",Player.SteamID,"active");
    ini.AddSetting("PlayersLog",Player.SteamID,Player.Name + " IP:" + Player.IP + day);
    ini.Save();
}
if(cmd=="banana")
    {
    if (getPlayerID(Player.SteamID) == "active")
        {
        Player.Message("yes your a banana");
        }
    else
        {
        Player.Message("no your not a banana");
        }
}
            if(cmd=="bananass" && Player.Admin)
            {
            for (var x in World.Entities){
            if (getPlayerID(x.OwnerID) != "active")
                {
                x.Destroy();
                }
                }
                break;
                }
}
 

Snake

Moderator
Moderator
Jul 13, 2014
288
174
28
modified it. thought it would work, however, now when using the command it removes only a certain amount of objects.
(from my server wich had 45k objects it went to 37k first use, then to 30k, then to 22k, then to 14k and ended at 7.5k) but it seemed like everyones buildings were gone, except for deployable objects.
theres some random extra things in to test.


anyone have any tips or ideas why this does not work? or is it because its destroying to many objects (only a few players were in the list of players who's buildings should not be destroyed)

Code:
function getNubIni() {
    if(!Plugin.IniExists("NewPlayers"))
        Plugin.CreateIni("NewPlayers");
    return Plugin.GetIni("NewPlayers");
}
function getPlayerID(player) {
    var ini = getNubIni();
    var playerINI = ini.GetSetting("Players", player);
    return playerINI;
}
function On_PlayerConnected(Player)
{
    var ini = Plugin.GetIni("NewPlayers");
    var day = System.DateTime.Now.ToString("M.dd");
    ini.AddSetting("Players",Player.SteamID,"active");
    ini.AddSetting("PlayersLog",Player.SteamID,Player.Name + " IP:" + Player.IP + day);
    ini.Save();
}

function On_Command(Player, cmd, args)
{
if(cmd=="date")
    {
    var ini = Plugin.GetIni("NewPlayers");
    var day = System.DateTime.Now.ToString("M.dd");
    Player.Message("the date is " + day);
    ini.AddSetting("Players",Player.SteamID,"active");
    ini.AddSetting("PlayersLog",Player.SteamID,Player.Name + " IP:" + Player.IP + day);
    ini.Save();
}
if(cmd=="banana")
    {
    if (getPlayerID(Player.SteamID) == "active")
        {
        Player.Message("yes your a banana");
        }
    else
        {
        Player.Message("no your not a banana");
        }
}
            if(cmd=="bananass" && Player.Admin)
            {
            for (var x in World.Entities){
            if (getPlayerID(x.OwnerID) != "active")
                {
                x.Destroy();
                }
                }
                break;
                }
}
I would rather use the Date, and when you execute the command, if there's more than x days from the player last login date until today, destroy the buildings of his ID.

Can look complex but it isn't.
 

ggblade

Member
Member
Aug 14, 2014
29
0
6
yeah thatd be the perfect way :p but my brain has not yet enlightened me with that answer or any answer really, seeying as its not working yet :p
i realised though that currently i cant easely remove the ppl that have been offline for longer than 5 days, first idea was making it so it says the date next to the line, so in notepad++ i can mark all lines with that date, then remove all marked, so i could easely everyday go in the file, remove the ones that are on the 6th day, then use the command, and done, woundt even take me 10 mins a day.
but currently ive made it into 2 lines, one with active so it would recognize it and the other with name,uid and ip and last day he logged in.

so that would mean i coundt use the notepad marking to mark it so currently waiting on my brain to eenlighten me with a better option :p

other than that i still need to figure out everything else :p