System Multi Kick

Status
Not open for further replies.

Darthfett

Aerospace/Cybersecurity Software Engineer
Reaction score
615
Multi Kick!
Created By: Darthfett

Update 8/29/09 v1.21
-The system now requires the use of the Advanced Strings System. The RemoveChar and String2Player (or S2P) function have both been outsourced to this system.
-Renamed String2Player to S2P, for compatibility with Advanced Strings.
-Removed non-vJass version

Update 6/25/09 v1.20:
-The system's player detection has been recoded. (function String2Player)
-It now supports maps with name-changing systems, and maps that allow players to change their color.
-Renamed the abominably long String to player conversion function to "String2Player"

Update 9/29/08 v1.10:
-The system is now a copy and paste system. No more creating the separate starting trigger yourself. :p
-You can no longer kick a player that is not playing.
-Inlined some code a little more, for readability.
-Improved the RemoveChar function very slightly

Update 9/07/08 v1.00:
Since Acehart so gladly helped me with the efficiency of many of my string parsing functions, the speed has been improved, and a lot of useless junk has been removed. A function to do custom actions just before a player is kicked has also been added, since I found it useful in my own map. :)

System created in: vJASS
MUI
MPI
Leakless


This is a Kick function I created because I needed a better one :p

It also ignores capitalization, removes spacing, also allows for host detection, and even supports partial string recognition, which means you can type part of a person's name and it will try to kick them. :)

The host cannot kick the map creator which you can put in your name as the string. The map creator can kick whomever he/she wishes, including the host, and the host may kick whomever he/she wishes except for the map creator.

And now, for the system itself:

Version 1.21:
JASS:
library MultiKick initializer Init uses AdvStrings
//MultiKick!, created by Darthfett v1.21

//Requirements:
//Advanced Strings system

//Features:
//Works with player names, colors, AND numbers!!
//
//It removes spaces
//Ignores capitalization
//has functionality for both spellings of grey/gray
//The map creator cannot be kicked, unless the system itself is edited.
//The host cannot be kicked, except by the map creator.
//It also detects the host for you
//It also supports partial strings, which means you can type -kick Darth, and it would 
//kick the first person with "Darth" in their name.
//Supports color changing players as well as maps with name changing systems in place.

//Only the host/map_creator may kick, votekicking is not supported.

globals
    private constant string creator = "Darthfett"   
    //If you want to make this a bit harder to change, remove this here, 
    //and replace the variable in the functions below.
    private constant string command = "-kick"
    //=============================
    //Don&#039;t mess with the rest <img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="smilie smilie--sprite smilie--sprite2" alt=";)" title="Wink    ;)" loading="lazy" data-shortname=";)" />
    //=============================
    private player host
    private integer temp
endglobals

private function PlayerKicked takes player p returns nothing
    //This function runs just before a player is kicked.
    //Fill this in with whatever you wish.
endfunction

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

function KickPlayer takes player kicker, string target returns boolean //target is the player to be kicked
    local player tar = S2P(target)
    if tar == null then
        call DisplayTextToPlayer(kicker,0,0,&quot;Invalid Player&quot;)
        return false
    endif
    
    if GetPlayerSlotState(tar) != PLAYER_SLOT_STATE_PLAYING then
        call DisplayTextToPlayer(kicker,0,0,&quot;That player is not playing!&quot;)
        return false
    endif
    
    if tar == kicker then
        call DisplayTextToPlayer(kicker,0,0,&quot;You cannot kick yourself!&quot;)
        return false
    endif
    if GetPlayerName(tar) == creator then
        call DisplayTextToPlayer(kicker,0,0,&quot;You cannot kick the creator of the map!&quot;)
        return false
    endif
    if GetPlayerName(kicker) == creator then
        //Creator kicking someone.
        call PlayerKicked(tar)
        call RemovePlayer(tar,PLAYER_GAME_RESULT_DEFEAT)
        call DisplayTextToPlayer(GetLocalPlayer(),0,0,GetPlayerName(tar) + &quot; has been kicked!&quot;)
        call CustomDefeatDialogBJ(tar,&quot;You have been kicked by the map creator.&quot;)
        return true
    endif
    call GetHost()
    if kicker == host then
        //host kicking someone
        call PlayerKicked(tar)
        call RemovePlayer(tar,PLAYER_GAME_RESULT_DEFEAT)
        call DisplayTextToPlayer(GetLocalPlayer(),0,0,GetPlayerName(tar) + &quot; has been kicked!&quot;)
        call CustomDefeatDialogBJ(tar, &quot;You have been kicked.&quot;)
        return true
    endif
    call DisplayTextToPlayer(kicker,0,0,&quot;Only the host may kick another player.&quot;)
    return false
endfunction

private function Conditions takes nothing returns boolean
    if StringCase(SubString(GetEventPlayerChatString(),0,StringLength(command)),false) == StringCase(command,false) then
        call KickPlayer(GetTriggerPlayer(),SubString(GetEventPlayerChatString(),StringLength(command),StringLength(GetEventPlayerChatString())))
    endif
    return false
endfunction

private function Init takes nothing returns nothing
    local trigger t = CreateTrigger()
    
    set temp = 0
    loop
        exitwhen temp &gt;= 12
        call TriggerRegisterPlayerChatEvent(t,Player(temp),&quot;&quot;,false)
        set temp = temp + 1
    endloop
    call TriggerAddCondition(t,Condition(function Conditions))
endfunction

endlibrary

Feedback is more than welcome! :D
 

Romek

Super Moderator
Reaction score
963
Nice! Useful, although we have a few of these already.

One thing I'd suggest is if you could make "-kick" work with only parts of a players name

So if a players name is "Doom_15£&£%£$%_2488" then "-kick Doom" would work.
You'd need to check if its in more than one players name too however :p
 

Darthfett

Aerospace/Cybersecurity Software Engineer
Reaction score
615
Nice! Useful, although we have a few of these already.

One thing I'd suggest is if you could make "-kick" work with only parts of a players name

So if a players name is "Doom_15£&£%£$%_2488" then "-kick Doom" would work.
You'd need to check if its in more than one players name too however :p

I don't think it's possible to put strange characters in your name, but I'll add some functionality for it, thanks for the idea! :)
 

Romek

Super Moderator
Reaction score
963

Darthfett

Aerospace/Cybersecurity Software Engineer
Reaction score
615
Name spoofer.

I didn't know the game triggers worked with game spoofers' names. I thought the game held their actual name, and everything that was displayed to other players was the spoofed name. Does anyone know how spoofers actually work?

Kicking a players' number would work with spoofers fine, though.

I'll see what I can do for partial name strings. :)

EDIT:

Well that was easier than I thought. It now supports partial strings. That means even if it's in the middle of the name, it will work. That also means I wouldn't recommend trying -kick a. It would kick the first person with the letter a in their name, lol. :)
 

cr4xzZz

Also known as azwraith_ftL.
Reaction score
51
Good system, very good indeed. If it gets approved, I may use it in my map. +rep :thup:
 

Prometheus

Everything is mutable; nothing is sacred
Reaction score
589
Make it detect and kick anyone using |r in their name.
Anti-Spoofer! :)
 

UndeadDragon

Super Moderator
Reaction score
447

Darthfett

Aerospace/Cybersecurity Software Engineer
Reaction score
615
Make it detect and kick anyone using |r in their name.
Anti-Spoofer! :)

I'm not quite sure how the game registers spoofed names. I don't exactly have a test subject, either. :p

Not everyone hates spoofers though, so I'll probably put in a boolean that map creators can select to kick spoofers, if this actually works.
 

Darthfett

Aerospace/Cybersecurity Software Engineer
Reaction score
615
UPDATE to the system:

Since Acehart so gladly helped me with the efficiency of many of my string parsing functions, the speed has been improved, and a lot of useless junk has been removed. A function to do custom actions just before a player is kicked has also been added, since I found it useful in my own map. :)
 

Romek

Super Moderator
Reaction score
963
No, I'm pretty sure spoofed colors use |r.

I'm sure they do too.
It explains why you can't use |r in any chats or anything.

---
Also, instead of doing that tiny little trigger:
Code:
Kick
    Events
        Player - Player 1 (Red) types a chat message containing -kick  as A substring
    Conditions
    Actions
        Custom script:   call KickPlayer(GetTriggerPlayer(),SubString(GetEventPlayerChatString(),6,StringLength(GetEventPlayerChatString()))
Why don't you implement that into the system?
So you just paste the system into a new trigger, and bam! It works. :D
 

Darthfett

Aerospace/Cybersecurity Software Engineer
Reaction score
615
I'm sure they do too.
It explains why you can't use |r in any chats or anything.

---
Also, instead of doing that tiny little trigger:
Code:
Kick
    Events
        Player - Player 1 (Red) types a chat message containing -kick  as A substring
    Conditions
    Actions
        Custom script:   call KickPlayer(GetTriggerPlayer(),SubString(GetEventPlayerChatString(),6,StringLength(GetEventPlayerChatString()))
Why don't you implement that into the system?
So you just paste the system into a new trigger, and bam! It works. :D

*shrugs* I was trying to make it so that someone who implements the system can use -ban, -kick, -drop, -remove, etc (whichever they chose).

I'll put that in the system when I can, I've at college right now, so I don't have an editor in front of me. ;)
 

Romek

Super Moderator
Reaction score
963
*shrugs* I was trying to make it so that someone who implements the system can use -ban, -kick, -drop, -remove, etc (whichever they chose).

I'll put that in the system when I can, I've at college right now, so I don't have an editor in front of me. ;)
You could always use constants..
Or even arrays, for multiple choices.

Up to 5.
JASS:
if s<i> == null then
  return
endif</i>

...use 'null' for nothing with the chat messages.
 

Darthfett

Aerospace/Cybersecurity Software Engineer
Reaction score
615
Updated to v1.10.

It will now display an error when trying to kick a player that is not playing.

It also is a copy and paste library now, so you no longer need to create anything that calls the kick function.

You can easily change the command (I'm only going to support one for now, as I don't see much point :p

Read the OP post for all the changes.

To a moderator:
Anything else need changing before this can be approved and moved into the Systems section? Thanks. :)

Anyone have any questions, comments, suggestions?
 

AdamGriffith

You can change this now in User CP.
Reaction score
69
This is going into my map. :)
I would suggest that you stick to the 'naming convention' and make all your global names in block capitals.
 
Status
Not open for further replies.
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top