0 Members and 1 Guest are viewing this topic.
procedure ScriptChange(const ScriptName : string; const State : boolean; const ID : byte);var Index, SIndex : string; rec : boolean;begin if not FileExists('scripts/' + ScriptName + '/Includes.txt') then begin WriteConsole(ID,'File not found!',Color); 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,2,length(Index))); WriteConsole(ID,'Script ' + ScriptName + ' enabled.',Color); rec := true; end else if not (State) and (Copy(Index,0,2) <> '//') then begin WriteFile('scripts/' + ScriptName + '/Includes.txt','//' + SIndex); WriteConsole(ID,'Script ' + ScriptName + ' disabled.',Color); rec := true; end else if not (State) and (Copy(Index,0,2) = '//') then begin WriteConsole(ID,'Script ' + ScriptName + ' seems to be disabled already.',Color); rec := false; end else if (State) and (Copy(Index,0,2) <> '//') then begin WriteConsole(ID,'Script ' + ScriptName + ' seems to be enabled already.',Color); rec := false; end; if rec then begin Command('/recompile ' + ScriptName); end else if not rec then exit;end;
Code: [Select]procedure ScriptChange(const ScriptName : string; const State : boolean; const ID : byte);var Index, SIndex : string; rec : boolean;begin if not FileExists('scripts/' + ScriptName + '/Includes.txt') then begin WriteConsole(ID,'File not found!',Color); 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,2,length(Index))); WriteConsole(ID,'Script ' + ScriptName + ' enabled.',Color); rec := true; end else if not (State) and (Copy(Index,0,2) <> '//') then begin WriteFile('scripts/' + ScriptName + '/Includes.txt','//' + SIndex); WriteConsole(ID,'Script ' + ScriptName + ' disabled.',Color); rec := true; end else if not (State) and (Copy(Index,0,2) = '//') then begin WriteConsole(ID,'Script ' + ScriptName + ' seems to be disabled already.',Color); rec := false; end else if (State) and (Copy(Index,0,2) <> '//') then begin WriteConsole(ID,'Script ' + ScriptName + ' seems to be enabled already.',Color); rec := false; end; if rec then begin Command('/recompile ' + ScriptName); end else if not rec then exit;end;Will disable or enable a script. Like in bomskis multi mode (f.e ScriptChange(VolleyBall,true 'or false,ID) will en or disable VolleyBall).
const Color = $E56600; VoteTime = 60; AddTime = 60; VotePerc = 70;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) = 'ZRPG') then begin WriteFile('scripts/' + ScriptName + '/Includes.txt',Copy(Index,3,length(Index))); rec := true; end else if not (State) and (Copy(Index,0,2) <> 'ZRPG') then begin WriteFile('scripts/' + ScriptName + '/Includes.txt','ZRPG' + 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('/loadcon ZRPG.ini'); Command('/loadlist ZRPGMAPS'); Command('/recompile ' + ScriptName); end else if not rec then exit;end;function GetScriptState(const ScriptName : string): boolean;var Index : string; begin if FileExists('scripts/' + ScriptName + '/Includes.txt') then begin Index := ReadFile('Modes/' + ScriptName + '/Includes.txt'); if Copy(Index,0,2) = 'ZRPG' then begin Result := false; end else Result := true 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,'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;
Version I've uploaded in the earlier posts is wrong, I'll attach the correct version. (the one I posted earlier is missing some parts.)The command is !change <script-name>, so if you playing Volley Ball and like to change to ZRPG, you've to type !change ZRPG to start the vote.And, since theres are some people who want to use this script, I'll create a better one later this day, with a config.ini where you can set the scripts you like to use and just vote them with ID's then.