TpFriend Conversion

coersum

Plugin Developer
Plugin Developer
Oct 9, 2014
77
5
8
47
Parts Unknown
I spent the day making my own before finding your plugin...(/tpask, /tpaccept, /tpdeny but not as bug free as yours I am sure (never thought of the names with spaces in them or that player find function worked on partial names so would have been bad!).

I tested it a bit but noticed, on /tpa playername , I get some errors on:
Python:
playertor = self.CheckV(Player, args)
after some debugging, I noticed it's because in CheckV() you use:
Python:
systemname = ini.GetSetting("Main", "Name")
but your config file is setup for:
Python:
systemname = ini.GetSetting("Settings", "sysname")
(you have Settings/sysname in all other loading of your config file).

*****************************************************************
Now farther down, you use Time which you get from DataStore, but if it has not been set yet, you get an error when you use it in:

Python:
calc = System.Environment.TickCount - time
so maybe (again new guy suggestion):

replace:
Python:
                time = DataStore.Get("tpfriendcooldown", Player.SteamID)
                usedtp = DataStore.Get("tpfriendusedtp", Player.SteamID)
                # if time is not set in DataStore, you get an error on the next line
                calc = System.Environment.TickCount - time
                if time == None or calc < 0 or math.isnan(calc):
                    time = DataStore.Add("tpfriendcooldown", Player.SteamID, System.Environment.TickCount)
with:
Python:
                usedtp = DataStore.Get("tpfriendusedtp", Player.SteamID)
                if DataStore.ContainsKey("tpfriendcooldown", Player.SteamID):
                    time = DataStore.Get("tpfriendcooldown", Player.SteamID)
                else:
                    time = DataStore.Add("tpfriendcooldown", Player.SteamID, System.Environment.TickCount)
                calc = System.Environment.TickCount - time
Hope that helps. I'm wondering if it's not my setup that is wrong somehow and giving me those errors, let me know.
 
Last edited:

coersum

Plugin Developer
Plugin Developer
Oct 9, 2014
77
5
8
47
Parts Unknown
And finally:

Python:
playerfromm = Server.Find(pending)
to
Python:
playerfromm = Server.FindPlayer(pending)
x2

Python:
playerfromm.SafeTeleportTo(Player.Location)
to
Python:
playerfromm.GroundTeleport(Player.Location)
or
Python:
playerfromm.Teleport(Player.Location)
Also, and I have no clue why, just test and error, changing:
Python:
from System import *
to
Python:
import System
removed some errors.. with all those modification (and from my limited tests), it works great. I haven't tested names with spaces or special character etc.
 

DreTaX

Probably knows the answer...
Administrator
Jun 29, 2014
4,065
4,486
113
At your house.
github.com
And finally:

Python:
playerfromm = Server.Find(pending)
to
Python:
playerfromm = Server.FindPlayer(pending)
x2

Python:
playerfromm.SafeTeleportTo(Player.Location)
to
Python:
playerfromm.GroundTeleport(Player.Location)
or
Python:
playerfromm.Teleport(Player.Location)
Also, and I have no clue why, just test and error, changing:
Python:
from System import *
to
Python:
import System
removed some errors.. with all those modification (and from my limited tests), it works great. I haven't tested names with spaces or special character etc.
Thanks for the list thox atleast I dont have to find them myself xD

Sent from my Samsung Galaxy S4
 

DreTaX

Probably knows the answer...
Administrator
Jun 29, 2014
4,065
4,486
113
At your house.
github.com
And finally:

Python:
playerfromm = Server.Find(pending)
to
Python:
playerfromm = Server.FindPlayer(pending)
x2

Python:
playerfromm.SafeTeleportTo(Player.Location)
to
Python:
playerfromm.GroundTeleport(Player.Location)
or
Python:
playerfromm.Teleport(Player.Location)
Also, and I have no clue why, just test and error, changing:
Python:
from System import *
to
Python:
import System
removed some errors.. with all those modification (and from my limited tests), it works great. I haven't tested names with spaces or special character etc.
Safe Teleport remained in from the conversion.

And nah. Replacing the nan check to this:

Python:
usedtp = DataStore.Get("tpfriendusedtp", Player.SteamID)
                if DataStore.ContainsKey("tpfriendcooldown", Player.SteamID):
                    time = DataStore.Get("tpfriendcooldown", Player.SteamID)
can break the plugin. Any value can be contained in the ds if you give that, even NAN. But you cannot calculate with nan. That solution is wrong.


This can be a solution:

Python:
systick = System.Environment.TickCount
                usedtp = DataStore.Get("tpfriendusedtp", Player.SteamID)
                if time is None or (systick - time) < 0 or math.isnan(systick - time):
                    time = DataStore.Add("tpfriendcooldown", Player.SteamID, systick)

                calc = systick - time
 
Last edited:

Mr.Moody

New Member
Member
Oct 14, 2014
1
0
1
55
plus.google.com
I was wondering how I could make the plugin so that if Player.Admin, /tpaccept is no longer required. I really want to learn more about making plugins so that when I understand it all I can contribute to Pluton.