AdminCommands

Jakkee

Plugin Developer
Plugin Developer
Contributor
Jul 28, 2014
1,465
925
113
Australia
This should work
Python:
elif cmd.cmd == "god":
            if not Player.Admin:
                Player.Message("You aren't an admin!")
                return
            if DataStore.Get("godmode", Player.SteamID) == "on":
                DataStore.Remove("godmode", Player.SteamID)
                Player.Message("God mode: off")
            else:
                DataStore.Add("godmode", Player.SteamID, "on")
                Player.Message("God mode: on")
Python:
def On_PlayerAttacked(self, PlayerHurtEvent):
         if PlayerHurtEvent.Attacker.ToPlayer() is not None:
                if DataStore.Get("godmode", PlayerHurtEvent.Victim.SteamID) == "on":
                    PlayerHurtEvent.info.damageAmount  = 0
 

DreTaX

Probably knows the answer...
Administrator
Jun 29, 2014
4,065
4,486
113
At your house.
github.com
This should work
Python:
elif cmd.cmd == "god":
            if not Player.Admin:
                Player.Message("You aren't an admin!")
                return
            if DataStore.Get("godmode", Player.SteamID) == "on":
                DataStore.Remove("godmode", Player.SteamID)
                Player.Message("God mode: off")
            else:
                DataStore.Add("godmode", Player.SteamID, "on")
                Player.Message("God mode: on")
Python:
def On_PlayerAttacked(self, PlayerHurtEvent):
         if PlayerHurtEvent.Attacker.ToPlayer() is not None:
                if DataStore.Get("godmode", PlayerHurtEvent.Victim.SteamID) == "on":
                    PlayerHurtEvent.info.damageAmount  = 0
Wuts wrong with my solution? O_O
 

Robert Pearson29

New Member
Member
Sep 7, 2014
11
1
1
tp commands are working awsome god mode will stay on now after new code but still god mode does not work atm i got someone to kill me and i tested it in water
 

Jakkee

Plugin Developer
Plugin Developer
Contributor
Jul 28, 2014
1,465
925
113
Australia
tp commands are working awsome god mode will stay on now after new code but still god mode does not work atm i got someone to kill me and i tested it in water
From what I see is that God mode only protects you from other players only.
 

DreTaX

Probably knows the answer...
Administrator
Jun 29, 2014
4,065
4,486
113
At your house.
github.com
/god still doesn't work.
Python:
__author__ = 'DreTaX'
__version__ = '1.1'

import clr

clr.AddReferenceByPartialName("Pluton")
import Pluton
import System
from System import *
import math

"""
    Class
"""


class AdminCommands:

    def AdminCmdConfig(self):
        if not Plugin.IniExists("AdminCmdConfig"):
            loc = Plugin.CreateIni("AdminCmdConfig")
            loc.Save()
        return Plugin.GetIni("AdminCmdConfig")

    # method by Illuminati
    def CheckV(self, Player, args):
        systemname = "Admin Commands"
        p = Server.FindPlayer(String.Join(" ", args))
        if p is not None:
            return p

        count = 0
        for pl in Server.ActivePlayers:
            for namePart in args:
                if namePart in pl.Name:
                    p = pl
                    count += 1
                    continue
        if count == 0:
            Player.MessageFrom(systemname, String.Format("Couldn't find {0}!", String.Join(" ", args)))
            return None
        elif count == 1 and p is not None:
            return p
        else:
            Player.MessageFrom(systemname, String.Format("Found {0} player with similar name. Use more correct name!"))
            return None

    def On_Command(self, cmd):
        Player = cmd.User
        args = cmd.args
        if cmd.cmd == "tpto":
            if not Player.Admin:
                Player.Message("You aren't an admin!")
                return
            pl = self.CheckV(Player, args)
            if pl is not None:
                Player.GroundTeleport(pl.Location)
                Player.Teleport(pl.Location)
        elif cmd.cmd == "tphere":
            if not Player.Admin:
                Player.Message("You aren't an admin!")
                return
            pl = self.CheckV(Player, args)
            if pl is not None:
                pl.GroundTeleport(Player.Location)
                pl.Teleport(Player.Location)
        elif cmd.cmd == "god":
            if not Player.Admin:
                Player.Message("You aren't an admin!")
                return
            if DataStore.Get("godmode", Player.SteamID) == 1:
                DataStore.Remove("godmode", Player.SteamID)
                Player.Message("God mode off.")
            else:
                DataStore.Add("godmode", Player.SteamID, 1)
                Player.Message("God mode on.")


    def On_PlayerAttacked(self, PlayerHurtEvent):
        get = int(DataStore.Get("godmode", PlayerHurtEvent.Victim.SteamID))
        if get is not None and get == 1:
             PlayerHurtEvent.info.damageAmount = 0
Try this one. Seems like I'm not really on the stage tonight..
 

Louis

Member
Member
Oct 11, 2014
33
3
8
36
Parts Unknown
Python:
__author__ = 'DreTaX'
__version__ = '1.1'

import clr

clr.AddReferenceByPartialName("Pluton")
import Pluton
import System
from System import *
import math

"""
    Class
"""


class AdminCommands:

    def AdminCmdConfig(self):
        if not Plugin.IniExists("AdminCmdConfig"):
            loc = Plugin.CreateIni("AdminCmdConfig")
            loc.Save()
        return Plugin.GetIni("AdminCmdConfig")

    # method by Illuminati
    def CheckV(self, Player, args):
        systemname = "Admin Commands"
        p = Server.FindPlayer(String.Join(" ", args))
        if p is not None:
            return p

        count = 0
        for pl in Server.ActivePlayers:
            for namePart in args:
                if namePart in pl.Name:
                    p = pl
                    count += 1
                    continue
        if count == 0:
            Player.MessageFrom(systemname, String.Format("Couldn't find {0}!", String.Join(" ", args)))
            return None
        elif count == 1 and p is not None:
            return p
        else:
            Player.MessageFrom(systemname, String.Format("Found {0} player with similar name. Use more correct name!"))
            return None

    def On_Command(self, cmd):
        Player = cmd.User
        args = cmd.args
        if cmd.cmd == "tpto":
            if not Player.Admin:
                Player.Message("You aren't an admin!")
                return
            pl = self.CheckV(Player, args)
            if pl is not None:
                Player.GroundTeleport(pl.Location)
                Player.Teleport(pl.Location)
        elif cmd.cmd == "tphere":
            if not Player.Admin:
                Player.Message("You aren't an admin!")
                return
            pl = self.CheckV(Player, args)
            if pl is not None:
                pl.GroundTeleport(Player.Location)
                pl.Teleport(Player.Location)
        elif cmd.cmd == "god":
            if not Player.Admin:
                Player.Message("You aren't an admin!")
                return
            if DataStore.Get("godmode", Player.SteamID) == 1:
                DataStore.Remove("godmode", Player.SteamID)
                Player.Message("God mode off.")
            else:
                DataStore.Add("godmode", Player.SteamID, 1)
                Player.Message("God mode on.")


    def On_PlayerAttacked(self, PlayerHurtEvent):
        get = int(DataStore.Get("godmode", PlayerHurtEvent.Victim.SteamID))
        if get is not None and get == 1:
             PlayerHurtEvent.info.damageAmount = 0
Try this one. Seems like I'm not really on the stage tonight..
Still doesn't work :(
 

Jakkee

Plugin Developer
Plugin Developer
Contributor
Jul 28, 2014
1,465
925
113
Australia
What doesn't work? A little detail would help him pin point the problem
 

Jakkee

Plugin Developer
Plugin Developer
Contributor
Jul 28, 2014
1,465
925
113
Australia
I think its DamageAmount not damageAmount.
(Haven't looked through dotpeek yet)