System cmdKick

Darthfett

Aerospace/Cybersecurity Software Engineer
Reaction score
615
cmdKick
Created by Darthfett

Description:
A command that gives kicking functionality. The host can kick any playing player except his/her self and the map creator. The map creator can kick any player, regardless of whether he/she is the host, except his/her self. The host can kick a player using this system, using the in-game command "-kick " along with any reference to the desired player (such as their name, color, or number).

Requirements:
stringPlayer
stringFind
Event

The rest of the documentation can be found in the system code, below:

JASS:
library cmdKick initializer Init uses stringPlayer,Event,stringFilter,stringFind,stringColor
/*
__________________________________________________________________________________

        cmdKick library, created by Darthfett - version 1.0
        http://www.thehelper.net/forums/showthread.php?t=144461
        
                                Requirements
                                
-vJass compiler (such as JASSHelper, this version compiled for version 0.A.2.7)
                     
+stringPlayer library - http://www.thehelper.net/forums/showthread.php?t=143590        
    +stringFilter library - http://www.thehelper.net/forums/showthread.php?t=143589
    
+stringFind library - http://www.thehelper.net/forums/showthread.php?t=143591

+Event library (this version compiled for version 1.04) - http://www.thehelper.net/forums/showthread.php?t=126846 

                                Documentation

-Credit for this library is not necessary.  Feel free to use it in your map.
If you feel obligated to credit me, I won't object.  I only ask that you do 
not simply copy and paste the library as your own.

                                    API

<CONFIG>
    
private constant string cmd
    Set this string to the command to be used to kick a player.
    Using a space at the end will require a space in-between the command
    and the name of the player.
    
private constant string creator
    Set this string to your in-game name, to prevent the system from kicking you.
    
public boolean ENABLED <cmdKick_ENABLED>
    Set this to true/false to enable/disable the in-game command.
    
private constant string ATTEMPT_KICK_INVALID_PLAYER
    This message is displayed to the kicking player when he types in an invalid string.
    
private constant string ATTEMPT_KICK_PLAYER_NOT_PLAYING
    This message is displayed to the kicking player when he chooses a player that is not playing.
    
private constant string ATTEMPT_KICK_SELF
    This message is displayed to the kicking player when he attempts to kick himself.
    
private constant string ATTEMPT_KICK_CREATOR
    This message is displayed to the kicking player when he attempts to kick the map creator.
    
private constant string ATTEMPT_KICKER_NOT_HOST
    This message is displayed to the kicking player when he attempts to kick and is not the host (or creator).

private function KICK_MESSAGE_ALL_PLAYERS takes player p returns string
    This message is displayed to all players when player p is kicked.

private function KICK_MESSAGE_KICKED_PLAYER takes player p returns string
    This message is displayed to player p when he is kicked.
    
<END CONFIG>
    
string In-Game Command "-kick "
    This command (by default) allows you to kick a player by typing "-kick " followed
    by a reference to a player.  This reference can be anything from:
        -Player Name
        -Player Color
        -Player Number ("1" refers to Player(0))
        -Any SubString of a player's name

Event EVENT_PLAYER_IS_KICKED
    This Event is fired just before a player is kicked from the game.
    Invalid kick commands will not trigger this Event.
        
global player KickedPlayer
    OR
function GetKickedPlayer takes nothing returns player
    When a player is kicked, just before he is booted from the game, the
    EVENT_PLAYER_IS_KICKED Event is fired.  You can refer to the Kicked player
    with this function.
    
global player KickingPlayer
    OR
function GetKickingPlayer takes nothing returns player
    When a player is kicked, just before he is booted from the game, the
    EVENT_PLAYER_IS_KICKED Event is fired.  You can refer to the Kicking player
    with this function.
__________________________________________________________________________________
*/

//CONFIG
globals
    private constant string cmd = "-kick "
    private constant string creator = "Darthfett"
    
    public boolean ENABLED = true
    
    private constant string ATTEMPT_KICK_INVALID_PLAYER = CLR_RED + "Invalid Player" + CLR_END
    private constant string ATTEMPT_KICK_PLAYER_NOT_PLAYING = CLR_RED + "That player is not playing!" + CLR_END
    private constant string ATTEMPT_KICK_SELF = CLR_RED + "You cannot kick yourself!" + CLR_END
    private constant string ATTEMPT_KICK_CREATOR = CLR_RED + "You cannot kick the creator of the map!" + CLR_END
    private constant string ATTEMPT_KICKER_NOT_HOST = CLR_RED + "Only the host may kick another player." + CLR_END
endglobals

private function KICK_MESSAGE_ALL_PLAYERS takes player p returns string
    return P2CN(p) + CLR_RED + " has been kicked!" + CLR_END
endfunction

private function KICK_MESSAGE_KICKED_PLAYER takes player p returns string
    return CLR_RED + "You have been kicked." + CLR_END
endfunction
//END CONFIG

globals
    Event EVENT_PLAYER_IS_KICKED
    player KickedPlayer
    player KickingPlayer
    
    private player host
    private string tempStr
    
    private integer temp
endglobals
    

function GetKickedPlayer takes nothing returns player
    return KickedPlayer
endfunction

function GetKickingPlayer takes nothing returns player
    return KickingPlayer
endfunction

private function GetHost takes nothing returns nothing
    local gamecache g = InitGameCache("Map.w3v")
    call StoreInteger ( g, "Map", "Host", GetPlayerId(GetLocalPlayer ())+1)
    call TriggerSyncStart ()
    call SyncStoredInteger ( g, "Map", "Host" )
    call TriggerSyncReady ()
    set host = Player( GetStoredInteger ( g, "Map", "Host" )-1)
    call FlushGameCache( g )
    set g = null
endfunction

private function Conditions takes nothing returns boolean
    local string s = GetEventPlayerChatString()
    local player kicker = GetTriggerPlayer()
    local player tar
    if StartsWith(s,cmd,false) and ENABLED then
        set tar = S2P(Strip(SubString(s,StringLength(cmd),StringLength(s))))
        if tar == null or (DEBUG_MODE and tar == Player(12)) then
            call DisplayTextToPlayer(kicker,0,0,ATTEMPT_KICK_INVALID_PLAYER)
            return false
        endif
        if GetPlayerSlotState(tar) != PLAYER_SLOT_STATE_PLAYING then
            call DisplayTextToPlayer(kicker,0,0,ATTEMPT_KICK_PLAYER_NOT_PLAYING)
            return false
        endif
        if tar == kicker then
            call DisplayTextToPlayer(kicker,0,0,ATTEMPT_KICK_SELF)
            return false
        endif
        if StringCase(GetPlayerName(tar),false) == StringCase(creator,false) then
            call DisplayTextToPlayer(kicker,0,0,ATTEMPT_KICK_CREATOR)
            return false
        endif
        if StringCase(GetPlayerName(kicker),false) == StringCase(creator,false) then
            set KickedPlayer = tar
            set KickingPlayer = kicker
            return true
        endif
        call GetHost()
        if kicker == host then
            set KickedPlayer = tar
            set KickingPlayer = kicker
            return true
        endif
        call DisplayTextToPlayer(kicker,0,0,ATTEMPT_KICKER_NOT_HOST)
    endif
    return false
endfunction

private function Actions takes nothing returns nothing
    call EVENT_PLAYER_IS_KICKED.fire()
    call RemovePlayer(KickedPlayer,PLAYER_GAME_RESULT_DEFEAT)
    call DisplayTextToPlayer(GetLocalPlayer(),0,0,KICK_MESSAGE_ALL_PLAYERS(KickedPlayer))
    call CustomDefeatDialogBJ(KickedPlayer,KICK_MESSAGE_KICKED_PLAYER(KickedPlayer))
endfunction

private function Init takes nothing returns nothing
    local trigger t = CreateTrigger()
    
    set temp = 0
    loop
        exitwhen temp >= 12
        call TriggerRegisterPlayerChatEvent(t,Player(temp),"",false)
        set temp = temp + 1
    endloop
    call TriggerAddCondition(t,Condition(function Conditions))
    call TriggerAddAction(t,function Actions)
    set EVENT_PLAYER_IS_KICKED = Event.create()
endfunction

endlibrary

library_once stringColor

globals
    constant string CLR_RED =         "|cffff0000"
    constant string CLR_END =        "|r"
endglobals

endlibrary
 

jig7c

Stop reading me...-statement
Reaction score
123
nice!!
i'm sure people will use this a lot!

is there a vote kick in this too?
doesn't look like it!

-kick ass system :)
 

tooltiperror

Super Moderator
Reaction score
231
I would recommend molding this with the stringPlayer library.
 

Darthfett

Aerospace/Cybersecurity Software Engineer
Reaction score
615
So many tiny things, I wish you could bunch a few together. :/

They're mainly tiny because all of the work has been delegated to the libraries they require. They don't exactly fit together, so I don't think it's a good idea to merge libraries. It wouldn't make sense to combine all the commands together, because not everyone wants to include a name-changing and color changing system/command in their map. It would be excess and bloat.

I would recommend molding this with the stringPlayer library.

The two are unrelated. This system uses the stringPlayer library to convert from string to a player, and then kicks the player. It uses a smart priority system to prevent any player from kicking his/her self, regular players from kicking, and the host from kicking the map creator.

For anyone who is wondering, no this is not a vote-kick system. Vote-kick systems usually suffer from having a terrible interface (such as "type yes or no to vote to kick this player", or an annoying dialog box that gets in the way). I also think it is fair for the host and map creator both to have kick privileges.
 

Azlier

Old World Ghost
Reaction score
461
>and the host from kicking the map creator.

Why?

I detest maps that have these mystical "safelists" of players that can't be kicked.
 

Darthfett

Aerospace/Cybersecurity Software Engineer
Reaction score
615
>and the host from kicking the map creator.

Why?

I detest maps that have these mystical "safelists" of players that can't be kicked.

It has room for one player, not a list of them. Why should I allow myself to be kicked from a game I created?
 

gameman

It's been a long, long time.
Reaction score
95
at least a add a constant allowing the kicking of the creator or not.

constant boolean Allowhostkick = false

otherwise, great system. Many times kicking by name has failed the map host.
 

Darthfett

Aerospace/Cybersecurity Software Engineer
Reaction score
615
at least a add a constant allowing the kicking of the creator or not.

constant boolean Allowhostkick = false

Why?

If you want to disable the creator thing entirely, set it to "". However, I see no point in giving the host priority over the map creator.

otherwise, great system. Many times kicking by name has failed the map host.

Thanks, but I don't think I understand what you mean. Are you saying it's good because it supports numbers and colors as well? :eek:

Is it possible to be set to two owners ??? I dont really understand JASS

Currently, it is not set up to support multiple map creators, no. I want to discourage people from using this as an 'admin' list or 'unkickable' list, and so I specifically limited the creator to one possible player.

You don't need to know JASS in order to know how to use this. The documentation in the code is relatively simple, just look in the <CONFIG> section. That will explain the config.
 

bLu3_eYeS

New Member
Reaction score
31
if possible , Please :( tell me how can i use it with two admins , i am making a map with a friend and we need immunity...so they cannot kick the map maker...
 

Darthfett

Aerospace/Cybersecurity Software Engineer
Reaction score
615
Just to let any mods who are reviewing resources know, this was previously known as Multi Kick, and was approved. I simply renamed the system and standardized it to make it fit in with my 'cmd' libraries.

Anything I can work on to get this approved?
 

Darthfett

Aerospace/Cybersecurity Software Engineer
Reaction score
615
Darth, I think this could be [del]very[/del] much [del]more[/del] simpl[del]i[/del]er. [del]I think.[/del]

It probably could if you left out the customization/constant stuff, and the event system. However, it would not be a whole lot shorter, and it's not currently doing a whole lot. Most of the string parsing work is done by the two required string libs, which can't really get much simpler without losing a lot of functionality for the user.

Overall, this is one the systems I'm most happy with, as far as how lightweight it is.
 

tooltiperror

Super Moderator
Reaction score
231
JASS:
library cmdKick initializer Init uses stringPlayer,Event,stringFilter,stringFind,stringColor


Doesn't say it needs stringColor in the thread.
 

Crazy_Dead

New Member
Reaction score
24
It probably could if you left out the customization/constant stuff, and the event system. However, it would not be a whole lot shorter, and it's not currently doing a whole lot. Most of the string parsing work is done by the two required string libs, which can't really get much simpler without losing a lot of functionality for the user.

Overall, this is one the systems I'm most happy with, as far as how lightweight it is.

Yes. You are true.
But i was thinking like this:

Register when someone enters it. Check if the "typer" is player(0) and if his name is the Mapmakers. Done?
 

Darthfett

Aerospace/Cybersecurity Software Engineer
Reaction score
615
Yes. You are true.
But i was thinking like this:

Register when someone enters it. Check if the "typer" is player(0) and if his name is the Mapmakers. Done?

The systems detect whether the entered string is a name, part of a name (in case the persons name is long and/or hard to read), a player's color (which works with player-color switching systems), or a player's number (e.g. '1' is Player(0) or Player 1).

They also allow the "host" to be in any slot, rather than forcing him to be in slot 1, and allow there to be a host AND a map maker in the same game, correctly giving the map maker priority over the host.

If used with my cmdName system, it also prevents players from changing their name TO the map maker's name, thus avoiding any problems with name spoofing (though the hack-spoofing can still be a problem).

It's quite a bit more useful than it seems on the surface. :)

JASS:
library cmdKick initializer Init uses stringPlayer,Event,stringFilter,stringFind,stringColor


Doesn't say it needs stringColor in the thread.

Whoops, I forgot to include the [ljass]library_once[/ljass]:

JASS:
library_once stringColor

globals
    constant string CLR_RED =         &quot;|cffff0000&quot;
    constant string CLR_END =        &quot;|r&quot;
endglobals

endlibrary

It has been added at the very end. It should now work without the stringColor library, and have no problems if you happen to have it imported.
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • The Helper The Helper:
    that sucks i bet they are expensive
  • Varine Varine:
    Not really
  • Varine Varine:
    The entire hot end is like 20 dollars, I just can't get anymore until next week
  • Varine Varine:
    I ordered like five blocks for 15 dollars. They're just little aluminum blocks with holes drilled into them
  • Varine Varine:
    They are pretty much disposable. I have shitty nozzles though, and I don't think these were designed for how hot I've run them
  • Varine Varine:
    I tried to extract it but the thing is pretty stuck. Idk what else I can use this for
  • Varine Varine:
    I'll throw it into my scrap stuff box, I'm sure can be used for something
  • Varine Varine:
    I have spare parts for like, everything BUT that block lol. Oh well, I'll print this shit next week I guess. Hopefully it fits
  • Varine Varine:
    I see that, despite your insistence to the contrary, we are becoming a recipe website
  • Varine Varine:
    Which is unique I guess.
  • The Helper The Helper:
    Actually I was just playing with having some kind of mention of the food forum and recipes on the main page to test and see if it would engage some of those people to post something. It is just weird to get so much traffic and no engagement
  • The Helper The Helper:
    So what it really is me trying to implement some kind of better site navigation not change the whole theme of the site
  • Varine Varine:
    How can you tell the difference between real traffic and indexing or AI generation bots?
  • The Helper The Helper:
    The bots will show up as users online in the forum software but they do not show up in my stats tracking. I am sure there are bots in the stats but the way alot of the bots treat the site do not show up on the stats
  • Varine Varine:
    I want to build a filtration system for my 3d printer, and that shit is so much more complicated than I thought it would be
  • Varine Varine:
    Apparently ABS emits styrene particulates which can be like .2 micrometers, which idk if the VOC detectors I have can even catch that
  • Varine Varine:
    Anyway I need to get some of those sensors and two air pressure sensors installed before an after the filters, which I need to figure out how to calculate the necessary pressure for and I have yet to find anything that tells me how to actually do that, just the cfm ratings
  • Varine Varine:
    And then I have to set up an arduino board to read those sensors, which I also don't know very much about but I have a whole bunch of crash course things for that
  • Varine Varine:
    These sensors are also a lot more than I thought they would be. Like 5 to 10 each, idk why but I assumed they would be like 2 dollars
  • Varine Varine:
    Another issue I'm learning is that a lot of the air quality sensors don't work at very high ambient temperatures. I'm planning on heating this enclosure to like 60C or so, and that's the upper limit of their functionality
  • Varine Varine:
    Although I don't know if I need to actually actively heat it or just let the plate and hotend bring the ambient temp to whatever it will, but even then I need to figure out an exfiltration for hot air. I think I kind of know what to do but it's still fucking confusing
  • The Helper The Helper:
    Maybe you could find some of that information from AC tech - like how they detect freon and such

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top