ChangeOwner

Approved ChangeOwner 1.0

No permission to download

DreTaX

Probably knows the answer...
Administrator
Jun 29, 2014
4,093
4,785
113
At your house.
github.com
DreTaX submitted a new resource:

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

Description:

This plugin is able to change ownership of a building structure or all objects on the server.

Commands:

/changeowner NewPlayerOwnerName STEAMIDOfOldOwner - Changes all objects to the new owner

/changeowner2 NewPlayerOwnerName - You will be prompted to hit an object to change the ownership
Read more about this resource...
 

Arxara

New Member
Member
Mar 27, 2016
14
0
1
28
Canada
what is the error
[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
 

DreTaX

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

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)
 

Arxara

New Member
Member
Mar 27, 2016
14
0
1
28
Canada
Try this-

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)
[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.
 

DreTaX

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

tarynkelley

Retired Staff
Retired Staff
Trusted Member
Nov 14, 2015
575
178
28
Parts Unknown
[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
 

Arxara

New Member
Member
Mar 27, 2016
14
0
1
28
Canada
[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
the desired string in the 88 line
 

DreTaX

Probably knows the answer...
Administrator
Jun 29, 2014
4,093
4,785
113
At your house.
github.com
  • Like
Reactions: tarynkelley