Discussion in 'Releases' started by DreTaX, Mar 26, 2016.

Approved ChangeOwner 1.0

This is able to change ownership of a structure or all objects

  1. DreTaX
    Offline

    DreTaX Probably knows the answer... Administrator

    Joined:
    Jun 29, 2014
    Messages:
    3,850
    Likes Received:
    638
    DreTaX submitted a new resource:

    ChangeOwner - This is able to change ownership of a structure or all objects

    Read more about this resource...
     
    #1
  2. Arxara
    Offline

    Arxara New Member Member

    Joined:
    Mar 27, 2016
    Messages:
    14
    Likes Received:
    0
    #2
  3. DreTaX
    Offline

    DreTaX Probably knows the answer... Administrator

    Joined:
    Jun 29, 2014
    Messages:
    3,850
    Likes Received:
    638
    error?
     
    #3
  4. Arxara
    Offline

    Arxara New Member Member

    Joined:
    Mar 27, 2016
    Messages:
    14
    Likes Received:
    0
    yes when asked to inflict damage on the house


    and please tell me how to make a plug-in to find out who put the object - say a command to register / who writes in chat who set the thing
     
    #4
  5. DreTaX
    Offline

    DreTaX Probably knows the answer... Administrator

    Joined:
    Jun 29, 2014
    Messages:
    3,850
    Likes Received:
    638
    what is the error
     
    #5
  6. Arxara
    Offline

    Arxara New Member Member

    Joined:
    Mar 27, 2016
    Messages:
    14
    Likes Received:
    0
    [3/28/2016 6:11:23 PM] [Debug] [CHAT-CMD] "Arxara" executed "/changeowner Arxara 76561198216684111"
    [3/28/2016 6:11:24 PM] [Error] [IronPython] Error in plugin ChangeOwner:
    [3/28/2016 6:11:24 PM] [Error] Traceback (most recent call last):
    File "<string>", line 88, in On_Command
    TypeError: Cannot cast from source type to destination type.
    [3/28/2016 6:11:26 PM] [Error] [IronPython] Error in plugin ChangeOwner:
    [3/28/2016 6:11:26 PM] [Error] Traceback (most recent call last):
    File "<string>", line 108, in On_EntityHurt
    TypeError: expected str, got UInt64
    [3/28/2016 6:11:28 PM] [Error] [IronPython] Error in plugin ChangeOwner:
    [3/28/2016 6:11:28 PM] [Error] Traceback (most recent call last):
    File "<string>", line 108, in On_EntityHurt
    TypeError: expected str, got UInt64
     
    #6
  7. DreTaX
    Offline

    DreTaX Probably knows the answer... Administrator

    Joined:
    Jun 29, 2014
    Messages:
    3,850
    Likes Received:
    638
    Try this-

    Code (Python):
    __author__ = 'DreTaX'
    __version__ = '1.0'

    import clr

    clr.AddReferenceByPartialName("Fougerite")
    import Fougerite

    """
        Class
    """

    green = "[color #009900]"
    sysname = "ChangeOwner"


    class ChangeOwner:
        """
            Methods
        """


        def On_PluginInit(self):
            Util.ConsoleLog("BannedPeople by " + __author__ + " Version: " + __version__ + " loaded.", False)

        """
            CheckV method based on Spock's method.
            Upgraded by DreTaX
            Can Handle Single argument and Array args.
            V4.1
        """


        def GetPlayerName(self, namee):
            try:
                name = namee.lower()
                for pl in Server.Players:
                    if pl.Name.lower() == name:
                        return pl
                return None
            except:
                return None

        def CheckV(self, Player, args):
            count = 0
            if hasattr(args, '__len__') and (not isinstance(args, str)):
                p = self.GetPlayerName(str.join(" ", args))
                if p is not None:
                    return p
                for pl in Server.Players:
                    for namePart in args:
                        if namePart.lower() in pl.Name.lower():
                            p = pl
                            count += 1
                            continue
            else:
                nargs = str(args).lower()
                p = self.GetPlayerName(nargs)
                if p is not None:
                    return p
                for pl in Server.Players:
                    if nargs in pl.Name.lower():
                        p = pl
                        count += 1
                        continue
            if count == 0:
                if Player is not None:
                    Player.MessageFrom(sysname, "Couldn't find [color#00FF00]" + str.join(" ", args) + "[/color]!")
                return None
            elif count == 1 and p is not None:
                return p
            else:
                if Player is not None:
                    Player.MessageFrom(sysname, "Found [color#FF0000]" + str(count) +
                                       "[/color] player with similar name. [color#FF0000] Use more correct name!")
                return None


        def On_Command(self, Player, cmd, args):
            if cmd == "changeowner":
                if Player.Admin:
                    if len(args) == 2:
                        player = self.CheckV(Player, args[0])
                        if player is not None:
                            if not args[1].isdigit():
                                Player.MessageFrom(sysname, "The id is only made of numbers")
                                return
                            c = 0
                            for x in World.Entities:
                                if x.OwnerID == args[1]:
                                    x.ChangeOwner(player)
                                    c += 1
                            Player.MessageFrom(sysname, "Successfully changed " + str(c) + " objects of " + player.Name)
                            player.MessageFrom(sysname, "You became an owner of " + str(c) + " objects")
                    else:
                        Player.MessageFrom(sysname, "Usage: /changeowner TheNewOwnerPlayerName STEAMIDOfOldOwner")
            elif cmd == "changeowner2":
                if Player.Admin:
                    if len(args) == 1:
                        player = self.CheckV(Player, args[0])
                        if player is not None:
                            DataStore.Add("ChangeOwner", Player.SteamID, player.SteamID)
                            Player.MessageFrom(sysname, "Hit the house to change ownership")

        def On_EntityHurt(self, HurtEvent):
            if not HurtEvent.AttackerIsPlayer:
                return
            if HurtEvent.Entity is not None and HurtEvent.Attacker is not None:
                if HurtEvent.Attacker.Admin and DataStore.ContainsKey("ChangeOwner", HurtEvent.Attacker.SteamID):
                    entity = HurtEvent.Entity
                    player = Server.FindPlayer(DataStore.Get("ChangeOwner", HurtEvent.Attacker.SteamID))
                    if player is not None:
                        c = 1
                        entity.ChangeOwner(player)
                        structs = entity.GetLinkedStructs()
                        for ent in structs:
                            ent.ChangeOwner(player)
                            c += 1
                        HurtEvent.Attacker.MessageFrom(sysname, "Successfully changed " + str(c) + " objects of "
                                                       + player.Name)
                        player.MessageFrom(sysname, "You became an owner of " + str(c) + " objects")
                        DataStore.Remove("ChangeOwner", HurtEvent.Attacker.SteamID)
                    else:
                        HurtEvent.Attacker.MessageFrom(sysname, "Selected Player is Offline.")
                        DataStore.Remove("ChangeOwner", HurtEvent.Attacker.SteamID)
     
     
    #7
  8. Arxara
    Offline

    Arxara New Member Member

    Joined:
    Mar 27, 2016
    Messages:
    14
    Likes Received:
    0
    [3/28/2016 6:55:31 PM] [Error] [IronPython] Error in plugin ChangeOwner:
    [3/28/2016 6:55:31 PM] [Error] Traceback (most recent call last):
    File "<string>", line 111, in On_EntityHurt
    TypeError: Cannot cast from source type to destination type.
     
    #8
  9. DreTaX
    Offline

    DreTaX Probably knows the answer... Administrator

    Joined:
    Jun 29, 2014
    Messages:
    3,850
    Likes Received:
    638
    Wot de fok.
     
    #9
  10. Arxara
    Offline

    Arxara New Member Member

    Joined:
    Mar 27, 2016
    Messages:
    14
    Likes Received:
    0
    in general, to solve the problem if you want
     
    #10
  11. DreTaX
    Offline

    DreTaX Probably knows the answer... Administrator

    Joined:
    Jun 29, 2014
    Messages:
    3,850
    Likes Received:
    638
    I'm checking whats the problem
     
    #11
  12. tarynkelley
    Offline

    tarynkelley Moderator Moderator

    Joined:
    Nov 14, 2015
    Messages:
    559
    Likes Received:
    36
    [IronPython] Error in plugin ChangeOwner:
    Traceback (most recent call last):
    File "<string>", line 88, in On_Command
    TypeError: Cannot cast from source type to destination type.

    Same for me when I use /changeowner
     
    #12
  13. Arxara
    Offline

    Arxara New Member Member

    Joined:
    Mar 27, 2016
    Messages:
    14
    Likes Received:
    0
    the desired string in the 88 line
     
    #13
  14. tarynkelley
    Offline

    tarynkelley Moderator Moderator

    Joined:
    Nov 14, 2015
    Messages:
    559
    Likes Received:
    36
    #14
  15. DreTaX
    Offline

    DreTaX Probably knows the answer... Administrator

    Joined:
    Jun 29, 2014
    Messages:
    3,850
    Likes Received:
    638
    Last time i used it there wasnt. I think the casting is wrong.
     
    #15
  16. DreTaX
    Offline

    DreTaX Probably knows the answer... Administrator

    Joined:
    Jun 29, 2014
    Messages:
    3,850
    Likes Received:
    638
    #16
    • Like Like x 1
  17. Mehran
    Offline

    Mehran Member Member

    Joined:
    Jun 23, 2015
    Messages:
    39
    Likes Received:
    2
    Have problems with new fougerite :
     

    Attached Files:

    #17
  18. DreTaX
    Offline

    DreTaX Probably knows the answer... Administrator

    Joined:
    Jun 29, 2014
    Messages:
    3,850
    Likes Received:
    638
    1. Doesn't have anything to do with ChangeOwner
    2. You are using /instakoall on a deployable object. That can only be used for structures. This will be fixed in 1.5.6
     
    #18
    Last edited: Mar 28, 2017

Share This Page