Help installing a "Kick System"
How do i install this system in my map?
I copy paste it into my Map Header and it gives me 2450 errors...
How do i install this system in my map?
JASS:
library MultiKick initializer Init
//MultiKick!, created by Darthfett v1.10
//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, unless the system itself is edited.
//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.
//Only the host 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 string array PlayerNames //EX: White text of the exact name of the player at map initialization
private string array PlayerColors //EX: "Red", "Blue"
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 RemoveChar takes string str, string char returns string
//Removes all instances of one character from an entire string.
//Thanks to AceHart for reducing amount of SubString calls.
local integer i = 0
local string s = ""
local string c
loop
set c = SubString(str, i, i + 1)
exitwhen c == null or c == ""
if c != char then
set s = s + c
endif
set i = i + 1
endloop
set str = s
return str
endfunction
private function StringContainsString takes string str, string partial returns boolean
//Returns true if the full string is contained inside. Capitalization matters!
local integer i = 0
local integer l = StringLength(partial)
local integer l2 = StringLength(str)
loop
exitwhen i > l2
if SubString(str,i,i+l) == partial then
return true
endif
set i = i + 1
endloop
return false
endfunction
private function GetPlayerFromFormattedString takes string argstr returns player
local string str = StringCase(RemoveChar(argstr," "),false) //this is getting rid of capitalization and spaces
local integer i = 0
//First determine whether it is a player name, color, or number
loop //Loop to see if it is a number, the simplest loop
exitwhen i >= 12
if i == S2I(str) - 1 then
return Player(i)
endif
set i = i + 1
endloop
set i = 0
loop //Loop to see if it is a player's name.
exitwhen i >= 12
if StringCase(PlayerNames<i>,false) == str then
return Player(i)
endif
set i = i + 1
endloop
set i = 0
if str == "grey" then
//Some countries have different ways of spelling gray/grey,
//so if it is not a name or number, it will check for this spelling.
return Player(8) //8 is Grey/Gray's player number.
endif
loop //Loop to see if it is a player's color.
exitwhen i >= 12
if StringCase(RemoveChar(PlayerColors<i>," "),false) == str then
return Player(i)
endif
set i = i + 1
endloop
set i = 0
loop
exitwhen i >= 12
if StringContainsString(StringCase(PlayerNames<i>,false),str) then
return Player(i)
endif
set i = i + 1
endloop
debug call BJDebugMsg("INVALID")
return null //If it cannot recognize either a player's name or color from the string given, it will give an invalid player number.
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, lol
local player tar = GetPlayerFromFormattedString(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. Pay attention next time.")
call GetHost()
return true
endif
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.")
call GetHost()
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 integer i = 0
local trigger t = CreateTrigger()
loop
exitwhen i >= 12
call TriggerRegisterPlayerChatEvent(t,Player(i),"",false)
set i = i + 1
endloop
call TriggerAddCondition(t,Condition(function Conditions))
set i = 0
loop
exitwhen i >= 12
set PlayerNames<i> = GetPlayerName(Player(i))
set i = i + 1
endloop
set i = 0
set PlayerColors[0] = "Red"
set PlayerColors[1] = "Blue"
set PlayerColors[2] = "Teal"
set PlayerColors[3] = "Purple"
set PlayerColors[4] = "Yellow"
set PlayerColors[5] = "Orange"
set PlayerColors[6] = "Green"
set PlayerColors[7] = "Pink"
set PlayerColors[8] = "Gray"
//capitalization is ignored
//There is functionality in the trigger for the "grey" spelling of the word.
//Spaces are also ignored, so lightblue works just the same as light blue.
set PlayerColors[9] = "Light Blue"
set PlayerColors[10] = "Dark Green"
set PlayerColors[11] = "Brown"
endfunction
endlibrary</i></i></i></i>
I copy paste it into my Map Header and it gives me 2450 errors...