So here is !vote map , !vote kick command .
AddChatCommand(\"vote\",function(self,player,msg,tpe,tgt,sp)
local allowMapVote=true;
if not tpe then
Chat:SendToTarget(nil,player,\"Enter valid action - !vote kick\");
end
if tpe~=\"kick\" then
if allowMapVote then
if tpe~=\"map\" then
Chat:SendToTarget(nil,player,\"Enter valid action - !vote kick or !vote map\");
return;
end
else
Chat:SendToTarget(nil,player,\"Enter valid action - !vote kick\");
return;
end
end
local gd=SafeWriting.GlobalData;
if(gd.__VoteInProgress)then
Chat:SendToTarget(nil,player,\"[[Prebieha hlasovanie]]\");
return;
end
if(not tgt)then
if tpe==\"kick\" then
Chat:SendToTarget(nil,player,\"Enter valid player!\");
else
Chat:SendToTarget(nil,player,\"Enter valid map name!\");
end
return;
end
local validmaps={};
local rules=g_gameRules.class==\"PowerStruggle\" and \"ps\" or \"ia\";
if sp and tpe==\"map\" then
rules=tgt;
tgt=sp;
end
rules=rules or (g_gameRules.class==\"PowerStruggle\" and \"ps\" or \"ia\");
if rules==\"ps\" then
validmaps={
\"mesa\",\"shore\",\"beach\",\"refinery\",\"plantation\"
};
elseif rules==\"ia\" then
validmaps={
\"poolday_v2\",\"aimmapv2\",\"dsg_1_aim\",
\"steelmill\",\"quarry\",\"outpost\",\"armada\",
};
end
if tpe==\"kick\" then
local pl=GetPlayerByName(tgt);
if not pl then
Chat:SendToTarget(nil,player,\"Enter valid player!\");
return;
end
Chat:SendToAll(nil,\"Player %s has started a kick vote for player %s, use !yes or !no to vote.\",player:GetName(),pl:GetName());
for i=1,12 do
Script.SetTimer(i*5000,function()
Msg:SendToAll(\"%s kick vote in progress - vote !yes, !no\",\"center\",pl:GetName());
end);
end
KICKVOTETGT=pl;
MakeSimpleVote(60,nil,nil,function(y,n)
local total=g_gameRules.game:GetPlayers();
if not total then total=0; else total=#total; end
if (y+n)>=total*0.6 then
if y>n then
Chat:SendToAll(nil,\"Kick vote was successful, %s was kicked\",KICKVOTETGT:GetName());
if KICKVOTETGT then KickPlayer(KICKVOTETGT,\"kick vote\"); end
else
Chat:SendToAll(nil,\"Kick vote failed, voted %.2f %% of players, yes: %d, no: %d\",((y+n)*100)/total,y,n);
end
else
Chat:SendToAll(nil,\"Kick vote failed, only %.2f %% of players voted (minimum: 60%%).\",((y+n)*100)/total);
end
end);
else
local valid=false;
grules=rules==\"ia\" and \"InstantAction\" or \"PowerStruggle\";
tgt=tgt:lower();
for i,v in pairs(validmaps) do if v==tgt then valid=true; break; end end
if not valid then
Chat:SendToTarget(nil,player,\"Enter valid map name!\");
return;
end
Chat:SendToAll(nil,\"Player %s has started a map vote for map %s.\",player:GetName(),tgt);
MAPVOTETGT=tgt;
local gs=SafeWriting.GlobalStorage;
MakeSimpleVote(60,nil,nil,function(y,n)
local total=g_gameRules.game:GetPlayers();
if not total then total=0; else total=#total; end
--if total==1 then total=2; end
local yp=y/(math.max(1,y+n));
local np=n/(math.max(1,y+n));
local tp=(y+n)/(math.max(1,total));
if (y+n)>=total*0.6 then
if y>n then
System.ExecuteCommand(\"sv_gamerules \"..grules);
Chat:SendToAll(nil,\"Map vote was successful, next map: %s\",MAPVOTETGT);
--gs.ForceNextMap=true;
--gs.NextMap=nextmap;
Script.SetTimer(5000,function()
System.ExecuteCommand(\"map \"..MAPVOTETGT)
end);
else
Chat:SendToAll(nil,\"Map vote failed, yes: %.1f %%, no: %.1f %%, percent of all: %.1f %%\",100*yp,100*np,100*tp);
end
else
Chat:SendToAll(nil,\"Map vote failed, yes: %.1f %%, no: %.1f %%, percent of all: %.1f %% < 60%%\",100*yp,100*np,100*tp);
end
end);
end
end,{WORD,WORD,WORD},nil,\"Starts kick voting, usage !vote kick playername or !vote map mapname or !vote map ia/ps mapname\");
❤️ 0