[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

DreTaX

Probably knows the answer...
Administrator
Jun 29, 2014
4,093
4,784
113
At your house.
github.com
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.
 

coersum

Plugin Developer
Plugin Developer
Oct 9, 2014
77
5
8
47
Parts Unknown
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 ?
 

balu92

Retired Staff
Retired Staff
Trusted Member
Jul 11, 2014
338
75
28
34
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()
 

xEnt

Retired Staff
Retired Staff
Sep 6, 2014
48
17
8
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

coersum

Plugin Developer
Plugin Developer
Oct 9, 2014
77
5
8
47
Parts Unknown
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
 

balu92

Retired Staff
Retired Staff
Trusted Member
Jul 11, 2014
338
75
28
34
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
 

xEnt

Retired Staff
Retired Staff
Sep 6, 2014
48
17
8
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!