Author Topic: /gamemode ctf (dm,rm,pm,inf,htf,tm(or tdm)) command script  (Read 4635 times)

0 Members and 1 Guest are viewing this topic.

Offline Serial K!ller

  • Camper
  • ***
  • Posts: 408
    • Soldat Mods Archive
/gamemode ctf (dm,rm,pm,inf,htf,tm(or tdm)) command script
« on: January 31, 2007, 02:25:30 pm »
Script Name:/gamemode ctf (dm,rm,pm,inf,htf,tm(or tdm)) command script
Script Description:  For people like me who keep forgetting what the number of the gamemode is, just use the abbreviations of the gamemodes (ex: /gametype HTF), also added a warning "say switching to ... gamestyle in 5 seconds" and a countdown.
Original Author(s):Serial K!ller & nub
Core Version:2.5.2
Code(core.pas):
Code: [Select]
const
GMM_CNTDOWNLENGTH = 5; //gamemodeswitch countdownlength

var
//-----/gamemode xxx variables
startgamemodeswitch:integer;
togamemode:integer;
G_TT : integer;
G_CNT : integer;

//-----------------------------------------
procedure ActivateServer();
begin
end;

procedure AppOnIdle(Ticks: integer);
begin
  { gameswitch procedure }
  if (startgamemodeswitch = 1) then begin
    G_CNT := G_CNT-1;
    Command('/say '+inttostr(G_CNT));
    if(G_CNT = 0) then begin Command('/gamemode '+inttostr(togamemode)); startgamemodeswitch := 0;  end;
  end;
end;


procedure OnCommand(ID:integer; Text:string);
var i:byte;
    gamemodeArray: array[0..7] of string;
begin
  Text := lowercase(Text);
  gamemodeArray[0] := 'dm'; gamemodeArray[1] := 'pm'; gamemodeArray[2] := 'tm';
  gamemodeArray[3] := 'ctf'; gamemodeArray[4] := 'rm'; gamemodeArray[5] := 'inf';
  gamemodeArray[6] := 'htf';
  togamemode := 255;
  if(Copy(Text,1,9) = '/gamemode') then begin
    for i:= 0 to ArrayHigh(gamemodeArray) do if(Copy(Text,11,Length(Text)) = gamemodeArray[i]) then begin togamemode := i; break; end;
    if((togamemode <> 255) and (GameStyle <> togamemode)) then begin
      startgamemodeswitch := 1;
      command('/say switching to '+gamemodeArray[togamemode]+' gamestyle in '+IntToStr(GMM_CNTDOWNLENGTH)+' seconds, please rejoin');
      G_CNT := GMM_CNTDOWNLENGTH;
    end;
  end;
end;



here's the script without the warning and countdown
Code: [Select]
procedure OnCommand(ID:integer; Text:string);
var i:byte;
    gamemodeArray: array[0..7] of string;
    togamemode:integer;
begin
  Text := lowercase(Text);
  gamemodeArray[0] := 'dm'; gamemodeArray[1] := 'pm'; gamemodeArray[2] := 'tm';
  gamemodeArray[3] := 'ctf'; gamemodeArray[4] := 'rm'; gamemodeArray[5] := 'inf';
  gamemodeArray[6] := 'htf';
  togamemode := 255;
  if(Copy(Text,1,9) = '/gamemode') then begin
    for i:= 0 to ArrayHigh(gamemodeArray) do if(Copy(Text,11,Length(Text)) = gamemodeArray[i]) then begin togamemode := i; break; end;
    if((togamemode <> 255) and (GameStyle <> togamemode)) then begin
      Command('/gamemode '+inttostr(togamemode))
    end;
  end;
end;


[edit]
updated to the much shorter version of nub
« Last Edit: April 01, 2007, 04:40:04 pm by Serial K!ller »

Offline ultraman

  • Flagrunner
  • ****
  • Posts: 797
Re: /gamemode ctf (dm,rm,pm,inf,htf,tm(or tdm)) command script
« Reply #1 on: February 01, 2007, 05:41:58 am »
Sweet, those gamemode numbers can be quite pesky to remember, thanks man.

Offline KeYDoN

  • Major
  • *
  • Posts: 60
Re: /gamemode ctf (dm,rm,pm,inf,htf,tm(or tdm)) command script
« Reply #2 on: February 19, 2007, 08:12:32 am »
You use Copy wrong.
the correct syntax is
Code: [Select]
function Copy ( Source  : string; StartChar, Count  : Integer ) : string;fore example
Code: [Select]
Text := '/gamemode ctf'
result := Copy(Text, 11,3);
// result = 'ctf'

Offline Serial K!ller

  • Camper
  • ***
  • Posts: 408
    • Soldat Mods Archive
Re: /gamemode ctf (dm,rm,pm,inf,htf,tm(or tdm)) command script
« Reply #3 on: February 19, 2007, 12:31:52 pm »
the compiler accepts it and it works...

Offline KeYDoN

  • Major
  • *
  • Posts: 60
Re: /gamemode ctf (dm,rm,pm,inf,htf,tm(or tdm)) command script
« Reply #4 on: February 19, 2007, 08:48:58 pm »
yes as long no additional letters occur
its not wrong in the way a comiler would not accept it its just wrong ;O
And in this script it maybe doesnt even make problems, but i just noticed that you use it wrong and i just wanted to tell you that :o

Copy(Text,11,12) for example expects 12 other letters after the 11th, but you just want to copy 3, so why copy more?
« Last Edit: February 19, 2007, 08:50:39 pm by KeYDoN »

Offline Serial K!ller

  • Camper
  • ***
  • Posts: 408
    • Soldat Mods Archive
Re: /gamemode ctf (dm,rm,pm,inf,htf,tm(or tdm)) command script
« Reply #5 on: February 20, 2007, 04:05:26 am »
oh lol thought you meant using it directly was wrong; didn't know the 2nd variable was the length thought it was from char 12 to char 13   ::)

[edit] fixed it!
« Last Edit: February 20, 2007, 03:09:53 pm by Serial K!ller »

Offline spkka

  • Camper
  • ***
  • Posts: 469
Re: /gamemode ctf (dm,rm,pm,inf,htf,tm(or tdm)) command script
« Reply #6 on: March 18, 2007, 09:53:05 pm »
is it also possible to make sth in this code that if your playing a ctf map advance will be set to on, and same for survival and realistic. When map changes to trenchwar, advance and survival will be turned off?

Offline nub

  • Major
  • *
  • Posts: 56
Re: /gamemode ctf (dm,rm,pm,inf,htf,tm(or tdm)) command script
« Reply #7 on: March 19, 2007, 08:04:38 am »
You are writing too much.

Code: [Select]
procedure OnCommand(ID:integer; Text:string);
var i:byte;
    gamemodeArray: array[0..7] of string;
begin
  Text := lowercase(Text);
  gamemodeArray[0] := 'dm'; gamemodeArray[1] := 'pm'; gamemodeArray[2] := 'tm';
  gamemodeArray[3] := 'ctf'; gamemodeArray[4] := 'rm'; gamemodeArray[5] := 'inf';
  gamemodeArray[6] := 'htf';
  togamemode := 255;
  if(Copy(Text,1,9) = '/gamemode') then begin
    for i:= 0 to ArrayHigh(gamemodeArray) do if(Copy(Text,11,Length(Text)) = gamemodeArray[i]) then begin togamemode := i; break; end;
    if((togamemode <> 255) and (GameStyle <> togamemode)) then begin
      startgamemodeswitch := 1;
      command('/say switching to '+gamemodeArray[togamemode]+' gamestyle in '+IntToStr(GMM_CNTDOWNLENGTH)+' seconds, please rejoin'); 
      G_CNT := GMM_CNTDOWNLENGTH;
    end;
  end;
end;

procedure AppOnIdle(Ticks: integer);
begin
  { gameswitch procedure }
  if (startgamemodeswitch = 1) then begin
    G_CNT := G_CNT-1;
    Command('/say '+inttostr(G_CNT));
    if(G_CNT = 0) then begin Command('/gamemode '+inttostr(togamemode)); startgamemodeswitch := 0;  end;
  end;
end;
Можно зарезать, украсть и всё-таки быть счастливым...

Offline Freedom

  • Major
  • *
  • Posts: 97
  • Veritas Vincit
Re: /gamemode ctf (dm,rm,pm,inf,htf,tm(or tdm)) command script
« Reply #8 on: November 17, 2007, 04:51:04 am »
It works BUT when i trying to type any command it says "Invalid variant type conversion"

Lol?
Cum pare contendere anceps est, cum superiore furiosum, cum inferiore sordidum.

Offline DorkeyDear

  • Veteran
  • *****
  • Posts: 1507
  • I also go by Curt or menturi
Re: /gamemode ctf (dm,rm,pm,inf,htf,tm(or tdm)) command script
« Reply #9 on: November 17, 2007, 08:21:43 am »
You use Copy wrong.
the correct syntax is
Code: [Select]
function Copy ( Source  : string; StartChar, Count  : Integer ) : string;fore example
Code: [Select]
Text := '/gamemode ctf'
result := Copy(Text, 11,3);
// result = 'ctf'

I learned copy wrong :P I thought it was start + end char # in... (just tested to make sure) hm :)

Offline Kavukamari

  • Camper
  • ***
  • Posts: 435
  • 3.14159265358979, mmm... pi
Re: /gamemode ctf (dm,rm,pm,inf,htf,tm(or tdm)) command script
« Reply #10 on: November 20, 2007, 08:44:13 pm »
err, OnCommand is a function ;) you put it as a procedure

Code: [Select]
function OnCommand(ID:Byte;Text:string):boolean;
"Be mindful of fame, show a mighty courage, watch against foes. Nor shalt thou lack what thou desirest, if with thy life thou hast comest out from that heroic task."