function init_votekick takes nothing returns nothing
local integer i=0
loop
exitwhen i>11
set votekick_dialog[i]=DialogCreate()
call TriggerRegisterPlayerChatEvent(votekick_votekick,Player(i),"-votekick",true)
call TriggerRegisterDialogEvent(votekick_buttonclick,votekick_dialog[i])
set i=i+1
endloop
endfunction
function VotekickClick takes nothing returns nothing
local player p=GetTriggerPlayer()
local integer id=GetPlayerId(p)
local integer istart=id*12+100
local button b=GetClickedButton()
local integer j=0
local player q
loop
exitwhen j>11
if votekick_buttons[istart+j]==b then
set q=Player(j)
if votekick_votes[istart+j]==1 then
set votekick_votes[istart+j]=0
set votekick_votes[j]=votekick_votes[j]-1
call DisplayTimedTextToPlayer(GetLocalPlayer(),0,0,8.,"A kick vote has been withdrawn for "+GetPlayerName(q))
else
set votekick_votes[j]=votekick_votes[j]+1
set votekick_votes[istart+j]=1
call DisplayTimedTextToPlayer(GetLocalPlayer(),0,0,8.,"A kick vote has been issued for "+GetPlayerName(q))
if votekick_votes[j] >= VOTES_NEEDED_TO_KICK then
call DisplayTimedTextToPlayer(GetLocalPlayer(),0,0,8.,GetPlayerName(q)+" has been kicked by vote")
call RemovePlayer(q,PLAYER_GAME_RESULT_DEFEAT)
if q==GetLocalPlayer()then
call EndGame(false)
endif
endif
endif
endif
set j=j+1
endloop
set q=null
set b=null
set p=null
endfunction
function VotekickShow takes nothing returns nothing
local player p=GetTriggerPlayer()
local integer id=GetPlayerId(p)
local integer istart=id*12+100
local integer j=0
local player q
call DialogClear(votekick_dialog[id])
call DialogSetMessage(votekick_dialog[id],"|cffffcc00Votekick who?")
loop
exitwhen j>11
set votekick_buttons[istart+j]=null
set q=Player(j)
if GetPlayerSlotState(q)==PLAYER_SLOT_STATE_PLAYING and GetPlayerController(q)==MAP_CONTROL_USER and q!=p then
if votekick_votes[istart+j]!=1then
set votekick_buttons[istart+j]=DialogAddButton(votekick_dialog[id],GetPlayerName(q)+" |r[|cffffcc00Vote|r]",0)
else
set votekick_buttons[istart+j]=DialogAddButton(votekick_dialog[id],GetPlayerName(q)+" |r[|cffffcc00Cancel Vote|r]",0)
endif
endif
set j=j+1
endloop
set votekick_buttons[id]=DialogAddButton(votekick_dialog[id],"Cancel |r[|cffff0000ESC|r]",512)
call DialogDisplay(p,votekick_dialog[id],true)
set p=null
set q=null
endfunction
function InitTrig_Votekick takes nothing returns nothing
set votekick_votekick=CreateTrigger()
set votekick_buttonclick=CreateTrigger()
call TriggerAddAction(votekick_votekick,function VotekickShow)
call TriggerAddAction(votekick_buttonclick,function VotekickClick)
call ExecuteFunc("init_votekick")
endfunction
How it works...
A player types "-votekick" and it will open up a dialog for them which contains a list of players who are currently playing and beside their name will be either [Vote] or [Cancel Vote].
At the bottom will be a "Cancel [ESC]" button where pressing ESC will close the dialog.
Three votes or whatever the constant is changed to will be how many votes are required to get booted. You cannot vote or cancel a vote against yourself.
My Favorite Rule: - No excessive BBCode, (colors, flashing text, spoilers, etc.), using; don't use it for every single word you're typing, only use it make a word(s) stand out.
Okay, so, i have gotten into a problem, the thing is, i made 3 triggers and put all 3 parts in 3 triggers. now, when i click save, it gives me error messages and disables all 3 triggers, whats going on?
My Favorite Rule: - No excessive BBCode, (colors, flashing text, spoilers, etc.), using; don't use it for every single word you're typing, only use it make a word(s) stand out.
Its the one you wrote up with the 3 parts, heres a ss of what happens when i try to enable it...
Thanks for the help aero. Appreciate it,
My Favorite Rule: - No excessive BBCode, (colors, flashing text, spoilers, etc.), using; don't use it for every single word you're typing, only use it make a word(s) stand out.