NoSuicide

tarynkelley

Retired Staff
Retired Staff
Trusted Member
Nov 14, 2015
575
178
28
Parts Unknown
Name: NoSuicide

Description: Prevents that user can kill themselves with F1 + suicide command.

Commands: /suicide on , /suicide off (Disabling and activating suicide)
 

Jakkee

Retired Staff
Retired Staff
Plugin Developer
Jul 28, 2014
1,465
932
113
Australia
Name: NoSuicide

Description: Prevents that user can kill themselves with F1 + suicide command.

Commands: /suicide on , /suicide off (Disabling and activating suicide)
Python:
__title__ = 'AntiSuicide'
__author__ = 'Jakkee'
__version__ = '1.0'

import clr
clr.AddReferenceByPartialName("Fougerite")
import Fougerite


class AntiSuicide:
    def On_PluginInit(self):
        Util.ConsoleLog(__title__ + " by " + __author__ + " Version: " + __version__ + " loaded.", False)
        if not DataStore.ContainsKey("AntiSuicide", "Enabled"):
            DataStore.Add("AntiSuicide", "Enabled", False)

    def On_Command(self, Player, cmd, args):
        if cmd == "suicide":
            if Player.Admin or Player.Moderator:
                if len(args) == 1:
                    if args[0] == "on":
                        if DataStore.Get("AntiSuicide", "Enabled"):
                            Player.MessageFrom("AntiSuicide", "is already enabled!")
                        else:
                            DataStore.Add("AntiSuicide", "Enabled", True)
                            Player.MessageFrom("AntiSuicide", "is now enabled!")
                    elif args[0] == "off":
                        if DataStore.Get("AntiSuicide", "Enabled"):
                            DataStore.Add("AntiSuicide", "Enabled", False)
                            Player.MessageFrom("AntiSuicide", "is now disabled!")
                        else:
                            Player.MessageFrom("AntiSuicide", "is already disabled!")                       
                    else:
                        Player.MessageFrom("AntiSuicide", "Usage: /suicide <on/off>")
                else:
                    Player.MessageFrom("AntiSuicide", "Usage: /suicide <on/off>")
            else:
                Player.Message("You are not allowed to use that command!")

    def On_ClientConsole(self, Player, cmd, args):
#Hook probably doesn't exist
        if cmd == "suicide":
            if not Player.Admin:
                if not Player.Moderator:
                    if DataStore.Get("AntiSuicide", "Enabled"):
                        Player.MessageFrom("AntiSuicide", "Suicide is blocked!")
                        return False
            return True
Not even sure if On_ClientConsole is even a hook, Or even if one exists for players client console.
@DreTaX
 

DreTaX

Probably knows the answer...
Administrator
Jun 29, 2014
4,093
4,784
113
At your house.
github.com
Python:
__title__ = 'AntiSuicide'
__author__ = 'Jakkee'
__version__ = '1.0'

import clr
clr.AddReferenceByPartialName("Fougerite")
import Fougerite


class AntiSuicide:
    def On_PluginInit(self):
        Util.ConsoleLog(__title__ + " by " + __author__ + " Version: " + __version__ + " loaded.", False)
        if not DataStore.ContainsKey("AntiSuicide", "Enabled"):
            DataStore.Add("AntiSuicide", "Enabled", False)

    def On_Command(self, Player, cmd, args):
        if cmd == "suicide":
            if Player.Admin or Player.Moderator:
                if len(args) == 1:
                    if args[0] == "on":
                        if DataStore.Get("AntiSuicide", "Enabled"):
                            Player.MessageFrom("AntiSuicide", "is already enabled!")
                        else:
                            DataStore.Add("AntiSuicide", "Enabled", True)
                            Player.MessageFrom("AntiSuicide", "is now enabled!")
                    elif args[0] == "off":
                        if DataStore.Get("AntiSuicide", "Enabled"):
                            DataStore.Add("AntiSuicide", "Enabled", False)
                            Player.MessageFrom("AntiSuicide", "is now disabled!")
                        else:
                            Player.MessageFrom("AntiSuicide", "is already disabled!")                      
                    else:
                        Player.MessageFrom("AntiSuicide", "Usage: /suicide <on/off>")
                else:
                    Player.MessageFrom("AntiSuicide", "Usage: /suicide <on/off>")
            else:
                Player.Message("You are not allowed to use that command!")

    def On_ClientConsole(self, Player, cmd, args):
#Hook probably doesn't exist
        if cmd == "suicide":
            if not Player.Admin:
                if not Player.Moderator:
                    if DataStore.Get("AntiSuicide", "Enabled"):
                        Player.MessageFrom("AntiSuicide", "Suicide is blocked!")
                        return False
            return True
Not even sure if On_ClientConsole is even a hook, Or even if one exists for players client console.
@DreTaX
I think It's a hook
 

tarynkelley

Retired Staff
Retired Staff
Trusted Member
Nov 14, 2015
575
178
28
Parts Unknown
Any ideas?

I tried it with OnConsole and OnConsoleReceived C# but it does not work for the global.suicide and suicide command. I also cannot create a new command like suicide2 or global.suicide2, but fougerite.suicide2 for example is working.

Oxides uses this Hook as an object it seems.

private object OnRunCommand(ConsoleSystem.Arg arg, bool wantreply)

{


}

Their Command Block Plugin simply ends the command with a return false in order to block it.
 
Last edited: