Resource icon

Approved Location 1.1

No permission to download

tarynkelley

Retired Staff
Retired Staff
Trusted Member
Nov 14, 2015
575
178
28
Parts Unknown
On server start I get:

[12/6/2015 9:12:44 PM] [Debug] [IPModule] Loading plugin Location.
[12/6/2015 9:12:44 PM] [Debug] Found function: On_PluginInit
[12/6/2015 9:12:44 PM] [Error] [IronPython] Error in plugin Location:
[12/6/2015 9:12:44 PM] [Error] Traceback (most recent call last):
File "<string>", line 68, in On_PluginInit
UnboundLocalError: Local variable 'd' referenced before assignment.
and on executing

[12/6/2015 9:18:45 PM] [Debug] [CHAT-CMD] "" executed "/location"
[12/6/2015 9:18:45 PM] [Error] [IronPython] Error in plugin Location:
[12/6/2015 9:18:45 PM] [Error] Traceback (most recent call last):
File "<string>", line 84, in On_Command
KeyError: None
V 1.2.8C
 
Last edited:
  • Informative
Reactions: DreTaX

DreTaX

Probably knows the answer...
Administrator
Jun 29, 2014
4,093
4,784
113
At your house.
github.com
On server start I get:



and on executing



V 1.2.8C
It should be working lmao.

Try this though.

Python:
__author__ = 'DreTaX'
__version__ = '1.0'
import clr

clr.AddReferenceByPartialName("Fougerite")
import Fougerite


class Location:
   
    d = {
        "Hacker Valley South": "5907,-1848",
        "Hacker Mountain South": "5268,-1961",
        "Hacker Valley Middle": "5268,-2700",
        "Hacker Mountain North": "4529,-2274",
        "Hacker Valley North": "4416,-2813",
        "Wasteland North": "3208,-4191",
        "Wasteland South": "6433,-2374",
        "Wasteland East": "4942,-2061",
        "Wasteland West": "3827,-5682",
        "Sweden": "3677,-4617",
        "Everust Mountain": "5005,-3226",
        "North Everust Mountain": "4316,-3439",
        "South Everust Mountain": "5907,-2700",
        "Metal Valley": "6825,-3038",
        "Metal Mountain": "7185,-3339",
        "Metal Hill": "5055,-5256",
        "Resource Mountain": "5268,-3665",
        "Resource Valley": "5531,-3552",
        "Resource Hole": "6942,-3502",
        "Resource Road": "6659,-3527",
        "Beach": "5494,-5770",
        "Beach Mountain": "5108,-5875",
        "Coast Valley": "5501,-5286",
        "Coast Mountain": "5750,-4677",
        "Coast Resource": "6120,-4930",
        "Secret Mountain": "6709,-4730",
        "Secret Valley": "7085,-4617",
        "Factory Radtown": "6446,-4667",
        "Small Radtown": "6120,-3452",
        "Big Radtown": "5218,-4800",
        "Hangar": "6809,-4304",
        "Tanks": "6859,-3865",
        "Civilian Forest": "6659,-4028",
        "Civilian Mountain": "6346,-4028",
        "Civilian Road": "6120,-4404",
        "Ballzack Mountain": "4316,-5682",
        "Ballzack Valley": "4720,-5660",
        "Spain Valley": "4742,-5143",
        "Portugal Mountain": "4203,-4570",
        "Portugal": "4579,-4637",
        "Lone Tree Mountain": "4842,-4354",
        "Forest": "5368,-4434",
        "Rad-Town Valley": "5907,-3400",
        "Next Valley": "4955,-3900",
        "Silk Valley": "5674,-4048",
        "French Valley": "5995,-3978",
        "Ecko Valley": "7085,-3815",
        "Ecko Mountain": "7348,-4100",
        "Zombie Hill": "6396,-3428"
    }
   
    Vector2s = {
   
    }


    def On_PluginInit(self):
        for x in self.d.keys():
            v = self.d[x].split(',')
            self.Vector2s[Util.CreateVector2(float(v[0]), float(v[1]))] = x
        self.d.clear()
        del self.d

    def On_Command(self, Player, cmd, args):
        if cmd == "location":
            closest = float(999999999)
            loc = Util.CreateVector2(Player.X, Player.Z)
            v = None
            for x in self.Vector2s.keys():
                dist = Util.GetVector2sDistance(loc, x)
                if dist < closest:
                    v = x
                    closest = dist
            Player.MessageFrom("DetailedLocation", "You are near: " + self.Vector2s[v] + " - " + str(Player.Location))
 

tarynkelley

Retired Staff
Retired Staff
Trusted Member
Nov 14, 2015
575
178
28
Parts Unknown
Thanks a lot. Yes, it works but upon loading the Plugin I still get

Code:
[IronPython] Error in plugin Location:
Traceback (most recent call last):
  File "<string>", line 73, in On_PluginInit
AttributeError: d is not a valid attribute
 

DreTaX

Probably knows the answer...
Administrator
Jun 29, 2014
4,093
4,784
113
At your house.
github.com
Thanks a lot. Yes, it works but upon loading the Plugin I still get

Code:
[IronPython] Error in plugin Location:
Traceback (most recent call last):
  File "<string>", line 73, in On_PluginInit
AttributeError: d is not a valid attribute
Python:
__author__ = 'DreTaX'
__version__ = '1.0'
import clr

clr.AddReferenceByPartialName("Fougerite")
import Fougerite


class Location:

    d = {
        "Hacker Valley South": "5907,-1848",
        "Hacker Mountain South": "5268,-1961",
        "Hacker Valley Middle": "5268,-2700",
        "Hacker Mountain North": "4529,-2274",
        "Hacker Valley North": "4416,-2813",
        "Wasteland North": "3208,-4191",
        "Wasteland South": "6433,-2374",
        "Wasteland East": "4942,-2061",
        "Wasteland West": "3827,-5682",
        "Sweden": "3677,-4617",
        "Everust Mountain": "5005,-3226",
        "North Everust Mountain": "4316,-3439",
        "South Everust Mountain": "5907,-2700",
        "Metal Valley": "6825,-3038",
        "Metal Mountain": "7185,-3339",
        "Metal Hill": "5055,-5256",
        "Resource Mountain": "5268,-3665",
        "Resource Valley": "5531,-3552",
        "Resource Hole": "6942,-3502",
        "Resource Road": "6659,-3527",
        "Beach": "5494,-5770",
        "Beach Mountain": "5108,-5875",
        "Coast Valley": "5501,-5286",
        "Coast Mountain": "5750,-4677",
        "Coast Resource": "6120,-4930",
        "Secret Mountain": "6709,-4730",
        "Secret Valley": "7085,-4617",
        "Factory Radtown": "6446,-4667",
        "Small Radtown": "6120,-3452",
        "Big Radtown": "5218,-4800",
        "Hangar": "6809,-4304",
        "Tanks": "6859,-3865",
        "Civilian Forest": "6659,-4028",
        "Civilian Mountain": "6346,-4028",
        "Civilian Road": "6120,-4404",
        "Ballzack Mountain": "4316,-5682",
        "Ballzack Valley": "4720,-5660",
        "Spain Valley": "4742,-5143",
        "Portugal Mountain": "4203,-4570",
        "Portugal": "4579,-4637",
        "Lone Tree Mountain": "4842,-4354",
        "Forest": "5368,-4434",
        "Rad-Town Valley": "5907,-3400",
        "Next Valley": "4955,-3900",
        "Silk Valley": "5674,-4048",
        "French Valley": "5995,-3978",
        "Ecko Valley": "7085,-3815",
        "Ecko Mountain": "7348,-4100",
        "Zombie Hill": "6396,-3428"
    }

    Vector2s = {

    }


    def On_PluginInit(self):
        for x in self.d.keys():
            v = self.d[x].split(',')
            self.Vector2s[Util.CreateVector2(float(v[0]), float(v[1]))] = x
        self.d.clear()
        # del self.d

    def On_Command(self, Player, cmd, args):
        if cmd == "location":
            closest = float(999999999)
            loc = Util.CreateVector2(Player.X, Player.Z)
            v = None
            for x in self.Vector2s.keys():
                dist = Util.GetVector2sDistance(loc, x)
                if dist < closest:
                    v = x
                    closest = dist
            Player.MessageFrom("DetailedLocation", "You are near: " + self.Vector2s[v] + " - " + str(Player.Location))