[JS] HomeTeleport

xEnt

Retired Staff
Retired Staff
Sep 6, 2014
48
17
8
You will need to uncomment the part that stops JS plugins from loading then rebuild Pluton. this will be done automatically soon.

Usage:
/sethome - sets the location of your home where you are standing
/tphome - returns to your home


JavaScript:
function On_Command(cmd){
    if(cmd.cmd == "sethome") {
            loc = cmd.User.Location;
            DataStore.Add("Pluton_Home", cmd.User.GameID, loc);
            cmd.User.Message("Your Home location is now Set!");
    } else if(cmd.cmd == "tphome") {
            loc = DataStore.Get("Pluton_Home", cmd.User.GameID);
            if(loc != null) {
                cmd.User.Teleport(loc);
                cmd.User.Message("Welcome Home!");
            } else
                cmd.User.Message("No Home location has been set. use /sethome at desired location");
    }
}
 
Last edited by a moderator:
  • Winner
Reactions: -uK
You will need to uncomment the part that stops JS plugins from loading then rebuild Pluton. this will be done automatically soon.

Usage:
/sethome - sets the location of your home where you are standing
/tphome - returns to your home


C#:
function On_Command(cmd){
    if(cmd.cmd == "sethome") {
            loc = cmd.User.Location;
            DataStore.Add("Pluton_Home", cmd.User.GameID, loc);
            cmd.User.Message("Your Home location is now Set!");
    } else if(cmd.cmd == "tphome") {
            loc = DataStore.Get("Pluton_Home", cmd.User.GameID);
            if(loc != null) {
                cmd.User.Teleport(loc);
                cmd.User.Message("Welcome Home!");
            } else
                cmd.User.Message("No Home location has been set. use /sethome at desired location");
    }
}
pfpfpfppfpfpfpfpfpfppfpfpfpfpfpfpfpfpfp idea stealererrss everywhereeeee. Except the fact that this is js. Also edited the syntax here, cause this isn't C#

Btw you can upload the plugin in the resources.
 
lol, I guess everyone is making those, here is my python version (using ContainKeys() to check if ploc is set or not):
(command = cmd.cmd and Player = cmd.User of course)
Python:
                if command == "sethome":
                ploc = cmd.User.Location
                DataStore.Add("homelocation", Player.SteamID, ploc)
                Player.Message("Home location set to " + str(ploc))
            elif command == "gohome":
                if DataStore.ContainsKey("homelocation", Player.SteamID):
                    location = DataStore.Get("homelocation", Player.SteamID)
                    Player.Message("Teleporting Home")
                    Player.Teleport(location)
                else:
                    Player.Message("No home set, use /sethome to set home location.")

Question: why use the GameID instead of SteamID? is it because SteamID might not be available ?
 
lol, I guess everyone is making those, here is my python version (using ContainKeys() to check if ploc is set or not):
(command = cmd.cmd and Player = cmd.User of course)
Python:
                if command == "sethome":
                ploc = cmd.User.Location
                DataStore.Add("homelocation", Player.SteamID, ploc)
                Player.Message("Home location set to " + str(ploc))
            elif command == "gohome":
                if DataStore.ContainsKey("homelocation", Player.SteamID):
                    location = DataStore.Get("homelocation", Player.SteamID)
                    Player.Message("Teleporting Home")
                    Player.Teleport(location)
                else:
                    Player.Message("No home set, use /sethome to set home location.")

Question: why use the GameID instead of SteamID? is it because SteamID might not be available ?
GameID is ulong, SteamID is GameID.ToString()
 
as balu92 said. GameID is a number, therefore faster to find/lookup or compare, plus its 1 character shorter than using SteamID!
 
  • Funny
Reactions: balu92
xEnt> I am wondering, are you getting an error when there is nothing in the Datastore? I noticed I had to use ContainsKey() to check first or it would stop there and show an error.

I'll be switching to GameID then :D
 
xEnt> I am wondering, are you getting an error when there is nothing in the Datastore? I noticed I had to use ContainsKey() to check first or it would stop there and show an error.

I'll be switching to GameID then :D
if there is nothing in the ds entry, then you get an undefined in js and None in python. You most likely get an error when you want to use those not defined values
 
Is there any documentation for making plugins using javascript?

well, regardless of what language you choose, we don't have a documented API, so take my code and use it just like you would a python plugin, and mess around with it!