0 Members and 1 Guest are viewing this topic.
const Color = $E56600; VoteTime = 60; AddTime = 1; VotePerc = 70; MSGCor = $66FF00; MSGCor2 = $FFFFFF;var Voted : array[1..32] of boolean; VoteRun, EnDis : boolean; Time : integer; Script : string; procedure ScriptChange(const ScriptName : string; const State : boolean);var Index, SIndex : string; rec : boolean;begin if not FileExists('scripts/' + ScriptName + '/Includes.txt') then begin exit; end; Index := ReadFile('scripts/' + ScriptName + '/Includes.txt'); SIndex := Copy(Index,0,length(Index)); rec := false; if (State) and (Copy(Index,0,2) = '//') then begin WriteFile('scripts/' + ScriptName + '/Includes.txt',Copy(Index,3,length(Index))); rec := true; end else if (State) and (Copy(Index,0,2) = '//') then begin WriteFile('scripts/' + ScriptName + '/Includes.txt',Copy(Index,3,length(Index))); end; if (rec) and (ScriptName = '1') then begin WriteFile('scripts/3/Includes.txt','//3.pas'); Command('/recompile'); end else if (rec) and (ScriptName = '3') then begin WriteFile('scripts/1/Includes.txt','//1.pas'); Command('/recompile'); end else if not (rec) and (ScriptName = '1') then begin WriteFile('scripts/3/Includes.txt','//3.pas'); Command('/recompile'); end else if not (rec) and (ScriptName = '3') then begin WriteFile('scripts/1/Includes.txt','//1.pas'); Command('/recompile'); endend;function GetScriptState(const ScriptName : string): boolean;var Index : string; begin if FileExists('scripts/' + ScriptName + '/Includes.txt') then begin Index := ReadFile('scripts/' + ScriptName + '/Includes.txt'); if Copy(Index,0,2) = '//' then begin Result := false; end else Result := false end;end;procedure OnLeaveGame(ID, Team: byte; Kicked: boolean);beginend;procedure OnPlayerSpeak(ID: byte; Text: string);var Total, i : integer;begin if (LowerCase(GetPiece(Text,' ',0)) = '!vote') and not (Voted[ID]) then if (GetPlayerStat(ID,'Active')) then if FileExists('scripts/' + GetPiece(Text,' ',1) + '/Includes.txt') then begin Total := Total + 1; Voted[ID] := true; VoteRun := true; if Time = 0 then Time := VoteTime else Time := Time + AddTime; if GetScriptState(GetPiece(Text,' ',1)) = true then begin EnDis := false; WriteConsole(ID,'O jogador ' + IdToName(ID) + ' Votou no mode ' + GetPiece(Text,' ',1),Color); end else if GetScriptState(GetPiece(Text,' ',1)) = false then begin EnDis := true; WriteConsole(ID,'O jogador ' + IdToName(ID) + ' votou para ativar o mode ID: ' + GetPiece(Text,' ',1),Color); end; Script := GetPiece(Text,' ',1); if (100 * Total / (NumPlayers - NumBots) >= VotePerc) then begin for i := 1 to 32 do Voted[ID] := false; WriteConsole(ID,'Votação para mudar de mode teve sucesso. O Mode ID: "' + Script + '" está ativado',Color); ScriptChange(Script,EnDis); end else WriteConsole(0,FloatToStr(RoundTo(100 * Total / (NumPlayers - NumBots), 2)) + '% / ' + InttoStr(VotePerc) + '% requeridos para muda o mode.', Color); end else WriteConsole(ID,'Error, Mode ID: ' + GetPiece(Text,' ',1) + ' não encontrado.',Color); end;procedure AppOnIdle(Ticks: integer);var i, b : integer;begin if Time > 0 then begin Time := Time - 1; end; if Time = 0 then begin for b := 1 to 32 do Voted[b] := false; end;end;
const Color = $E56600; VoteTime = 60; AddTime = 15; VotePerc = 65;var Voted : array[1..32] of boolean; VoteRun, EnDis, Enable : boolean; Time : integer; Script : string; procedure ScriptChange(const ScriptName : string; const State : boolean);var Index, SIndex : string; rec : boolean;begin if not FileExists('scripts/' + ScriptName + '/Includes.txt') then begin exit; end; Index := ReadFile('scripts/' + ScriptName + '/Includes.txt'); SIndex := Copy(Index,0,length(Index)); rec := false; if (State) and (Copy(Index,0,2) = '//') then begin WriteFile('scripts/' + ScriptName + '/Includes.txt',Copy(Index,3,length(Index))); rec := true; end else if not (State) and (Copy(Index,0,2) <> '//') then begin WriteFile('scripts/' + ScriptName + '/Includes.txt','//' + SIndex); rec := true; end else if not (State) and (Copy(Index,0,2) = '//') then begin rec := false; end else if (State) and (Copy(Index,0,2) <> '//') then begin rec := false; end; if rec then begin Command('/recompile ' + ScriptName); end else if not rec then exit;end;procedure ActivateServer();begin Enable := true;end; function GetScriptState(const ScriptName : string): boolean;var Index : string; begin if FileExists('scripts/' + ScriptName + '/Includes.txt') then begin Index := ReadFile('scripts/' + ScriptName + '/Includes.txt'); if Copy(Index,0,2) = '//' then begin Result := false; end else Result := true end;end;procedure OnJoinGame(ID, Team: byte);begin Voted[ID] := false;end;procedure OnLeaveGame(ID, Team: byte; Kicked: boolean);var i, Total: byte;begin Voted[ID] := false; for i := 1 to 32 do if (GetPlayerStat(i, 'Active') = true) and (Voted[i]) then Total := Total + 1; if (Total > 0) then begin if (100 * Total / (NumPlayers - NumBots) >= VotePerc) then begin for i := 1 to 32 do Voted[ID] := false; Enable := false; WriteConsole(0, 'Scriptvote passed', Color); ScriptChange(Script,EnDis); end else WriteConsole(0,FloattoStr(RoundTo(100 * Total / (NumPlayers - NumBots), 2)) + '% / ' + InttoStr(VotePerc) + '% required for a vote pass', Color); end;end;procedure OnPlayerSpeak(ID: byte; Text: string);var Total, i : integer;begin if (LowerCase(GetPiece(Text,' ',0)) = '!change') and not (Voted[ID]) and (Enable) then if (GetPlayerStat(ID,'Active')) then if FileExists('scripts/' + GetPiece(Text,' ',1) + '/Includes.txt') then begin Total := Total + 1; Voted[ID] := true; VoteRun := true; if Time = 0 then Time := VoteTime else Time := Time + AddTime; if GetScriptState(GetPiece(Text,' ',1)) = true then begin EnDis := false; WriteConsole(ID,'Player ' + IdToName(ID) + ' voted to enable the script ' + GetPiece(Text,' ',1),Color); end else if GetScriptState(GetPiece(Text,' ',1)) = false then begin EnDis := true; WriteConsole(ID,'Player ' + IdToName(ID) + ' voted to disable the script ' + GetPiece(Text,' ',1),Color); end; Script := GetPiece(Text,' ',1); if (100 * Total / (NumPlayers - NumBots) >= VotePerc) then begin for i := 1 to 32 do Voted[ID] := false; WriteConsole(ID,'Script-Change vote passed! Script "' + Script + '" is now ' +iif(EnDis,'en','dis') + 'abled',Color); ScriptChange(Script,EnDis); end else WriteConsole(0,FloatToStr(RoundTo(100 * Total / (NumPlayers - NumBots), 2)) + '% / ' + InttoStr(VotePerc) + '% required for a vote pass', Color); end else WriteConsole(ID,'Error, Script ' + GetPiece(Text,' ',1) + ' not found.',Color);end;procedure AppOnIdle(Ticks: integer);var i, b : integer;begin if Time >= 0 then begin Time := Time - 1; end; if Time = 0 then begin for b := 1 to 32 do Voted[b] := false; WriteConsole(0, 'Script-Vote failed', Color); end;end;