Darthfett
Aerospace/Cybersecurity Software Engineer
- Reaction score
- 615
Multi Kick!
Created By: Darthfett
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
-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"
-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.
-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
-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
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'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("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
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,"Invalid Player")
return false
endif
if GetPlayerSlotState(tar) != PLAYER_SLOT_STATE_PLAYING then
call DisplayTextToPlayer(kicker,0,0,"That player is not playing!")
return false
endif
if tar == kicker then
call DisplayTextToPlayer(kicker,0,0,"You cannot kick yourself!")
return false
endif
if GetPlayerName(tar) == creator then
call DisplayTextToPlayer(kicker,0,0,"You cannot kick the creator of the map!")
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) + " has been kicked!")
call CustomDefeatDialogBJ(tar,"You have been kicked by the map creator.")
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) + " has been kicked!")
call CustomDefeatDialogBJ(tar, "You have been kicked.")
return true
endif
call DisplayTextToPlayer(kicker,0,0,"Only the host may kick another player.")
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 >= 12
call TriggerRegisterPlayerChatEvent(t,Player(temp),"",false)
set temp = temp + 1
endloop
call TriggerAddCondition(t,Condition(function Conditions))
endfunction
endlibrary
Feedback is more than welcome!