Author Topic: Sumthing wrong  (Read 1221 times)

0 Members and 3 Guests are viewing this topic.

Offline Centurion

  • Flagrunner
  • ****
  • Posts: 699
Sumthing wrong
« on: November 04, 2008, 11:45:22 am »
Code: [Select]
const
ClMessage = $FFFF0000;

var
Unpause: boolean;
UnpauseCount: integer;
Paused: boolean;

function Split(const Source: string; const Delimiter: string): tstringarray;
var
  i,x,d: integer;
  s: string;
begin
  d := Length(Delimiter);
  x := 0;
  i := 1;
  SetArrayLength(Result,1);
  while i <= Length(source) do begin
    s := Copy(Source,i,d);
    if s = Delimiter then begin
      Inc(i,d);
      Inc(x,1);
      SetArrayLength(result,x + 1);
    end else begin
      Result[x] := Result[x] + Copy(s,1,1);
      Inc(i,1);
    end;
  end;
end;

procedure ActivateServer();
begin
  Unpause := false;
  UnpauseCount := 0;
  Paused := false;
end;

procedure AppOnIdle(Ticks: integer);
begin
  if (Unpause = true) then begin
    if (UnpauseCount = 0) then begin
      WriteConsole(0,'GO!',ClMessage);
      WriteLn('GO!');
      Command('/unpause'); Command('/unpause'); Command('/unpause');
      UnpauseCount := 0;
      Unpause := false;
      Paused := false;
    end
    else if (UnpauseCount > 0) then begin
      WriteConsole(0,InttoStr(UnpauseCount)+'...',ClMessage);
      WriteLn(InttoStr(UnpauseCount)+'...');
      UnpauseCount := UnpauseCount - 1;
    end;
  end;
end;

procedure OnJoinTeam(ID, Team: byte);
begin
  WriteConsole(ID,'Type !help for commands.',ClMessage);
end;

function OnCommand(ID: Byte; Text: string): boolean;
begin
//---/unpause
  if (MaskCheck(lowercase(Text),'/unpause*')) and (Paused = true) and (Unpause = false) then begin
    //Setup all the variables to go! AppOnIdle will do the rest.
    Unpause := true;
    UnpauseCount := 3;
    WriteConsole(0,'Unpausing...',ClMessage);
    WriteLn('Unpausing...');
    Result := true;
  end
//---/pause
  else if (MaskCheck(lowercase(Text),'/pause*')) then begin
    //If it is unpausing, break the countdown and stay paused...
    if (Unpause = true) then begin
      Unpause := false;
      UnpauseCount := 0;
      WriteConsole(0,'>>>Countdown Cancelled<<<',ClMessage);
      WriteLn('>>>Countdown Cancelled<<<');
    end
    //otherwise... just pause.
    else if (Paused = false) then
      Paused := true;
  end;
end;

procedure OnMapChange(NewMap: String);
begin
  Unpause := false;
  UnpauseCount := 0;
  Paused := false;
end;


procedure OnPlayerSpeak(ID: Byte; Text: string);
var
Map: string;
Mapslist: TStringArray;
Password: string;
begin
  if (MaskCheck(lowercase(Text),'!up')) then begin
    OnCommand(255,'/unpause');
  end
  else if (MaskCheck(lowercase(Text),'!p')) then begin
    OnCommand(255,'/pause');
    Command('/pause');
  end
  else if (MaskCheck(lowercase(Text),'!r')) then begin
    Command('/restart');
  end
  else if (MaskCheck(lowercase(Text),'!ub')) then begin
    Command('/unbanlast');
    WriteConsole(0,'Unbanned',ClMessage);
  end
  else if (MaskCheck(lowercase(Text),'!map')) then begin
    Map := GetPiece(Text,' ',1);
    if (FileExists('maps/'+Map+'.PMS')) then
      Command('/map '+Map)
    else
      WriteConsole(0,'Map '+Map+' not found!',ClMessage);
  end
  else if (MaskCheck(lowercase(Text),'!random')) then
    if (FileExists('mapslist.txt')) then begin
      Mapslist := Split(ReadFile('mapslist.txt'),chr(13)+chr(10));
      Map := Mapslist[Random(0,Arrayhigh(Mapslist)+1)];
      Command('/map '+Map);
    end else
      WriteConsole(0,'Unable to choose a random map!',ClMessage)
  else if (MaskCheck(lowercase(Text),'!1')) then
    Command('/setteam1 '+IntToStr(ID))
  else if (MaskCheck(lowercase(Text),'!2')) then
    Command('/setteam2 '+IntToStr(ID))
  else if (MaskCheck(lowercase(Text),'!3')) then
    Command('/setteam5 '+IntToStr(ID))
  else if (MaskCheck(lowercase(Text),'!help')) then begin
    WriteConsole(ID,'Commands:',ClMessage);
    WriteConsole(ID,'!p - Pauses the game.',ClMessage);
    WriteConsole(ID,'!up - Unpauses the game.',ClMessage);
    WriteConsole(ID,'!r - Restarts the game.',ClMessage);
    WriteConsole(ID,'!ub - Unbans the last player banned.',ClMessage);
    WriteConsole(ID,'!map <map> - Changes to the specified map.',ClMessage);
    WriteConsole(ID,'!random - Chooses a random map.',ClMessage);
    WriteConsole(ID,'!1, !2, !5 - Moves you to the specified team.',ClMessage);
  end;
end;

What's wrong with !map <mapname>
It's not working and I'm too dumb to figure it out by myself?

Offline Norbo

  • Camper
  • ***
  • Posts: 338
Re: Sumthing wrong
« Reply #1 on: November 04, 2008, 11:56:47 am »
Post the message that the compiler gives you

Edit: i think i know what it is

Code: [Select]
  else if (MaskCheck(lowercase(Text),'!map')) then begin
    Map := GetPiece(Text,' ',1);
    if (FileExists('maps/'+Map+'.PMS')) then
      Command('/map '+Map)

should be

 
Code: [Select]
else if (MaskCheck(lowercase(Text),'!map*')) then begin
   Map := GetPiece(Text,' ',1);
   if (FileExists('maps/'+Map+'.PMS')) then
     Command('/map '+Map)

(not tested)
« Last Edit: November 04, 2008, 12:06:42 pm by Norbo »

Offline Rampage_Terranius

  • Major
  • *
  • Posts: 69
  • The Strategist
    • Soldat Noob Servers
Re: Sumthing wrong
« Reply #2 on: November 05, 2008, 12:05:27 am »
what is the server type you are using? if your using a linux server im my experience FileExists does not work with them

Offline SpiltCoffee

  • Veteran
  • *****
  • Posts: 1579
  • Spilt, not Split!
    • SpiltCoffee's Site
Re: Sumthing wrong
« Reply #3 on: November 05, 2008, 12:15:47 am »
Be nice if you actually went to the original scripter with your problem (which happens to be me, btw :P).

http://soldatcentral.com/index.php?page=script&f=62 - Just redownload the script. I left a bug in the public version, which has now been fixed.
« Last Edit: November 05, 2008, 02:53:11 am by SpiltCoffee »
When life hands you High Fructose Corn Syrup, Citric Acid, Ascorbic Acid, Maltodextrin, Sodium Acid Pyrophosphate,
Magnesium Oxide, Calcium Fumarate, Yellow 5, Tocopherol and Less Than 2% Natural Flavour... make Lemonade!

Offline Norbo

  • Camper
  • ***
  • Posts: 338
Re: Sumthing wrong
« Reply #4 on: November 05, 2008, 05:01:04 am »
I knew it! I knew that it wass your script SplitCoffie, cause i took the script correction actually from your script :P And the scripts looked the same :p

Offline Centurion

  • Flagrunner
  • ****
  • Posts: 699
Re: Sumthing wrong
« Reply #5 on: November 05, 2008, 09:40:50 am »
Uhh I didn't know it was your script. I got if from my friend who said that !map command isn't working. And he said that his friend wrote it for him. Naliz is the name. Maybe you know?

Offline SpiltCoffee

  • Veteran
  • *****
  • Posts: 1579
  • Spilt, not Split!
    • SpiltCoffee's Site
Re: Sumthing wrong
« Reply #6 on: November 06, 2008, 12:44:07 am »
... SplitCoffie...
I hate you, and I will continue to hate you until you can get this right.

Uhh I didn't know it was your script. I got if from my friend who said that !map command isn't working. And he said that his friend wrote it for him. Naliz is the name. Maybe you know?
If you mean Nails, then, yeah, I know Nails. Good customer of mine.
« Last Edit: November 06, 2008, 02:04:01 am by SpiltCoffee »
When life hands you High Fructose Corn Syrup, Citric Acid, Ascorbic Acid, Maltodextrin, Sodium Acid Pyrophosphate,
Magnesium Oxide, Calcium Fumarate, Yellow 5, Tocopherol and Less Than 2% Natural Flavour... make Lemonade!

Offline Norbo

  • Camper
  • ***
  • Posts: 338
Re: Sumthing wrong
« Reply #7 on: November 06, 2008, 12:20:48 pm »
... SplitCoffie...
I hate you, and I will continue to hate you until you can get this right.

Fuck, i knew i would get it wrong. I even looked at ur nickname to check for mistakes lol, and i found none :P

Sorry, SplitCoffee :(

Offline excruciator

  • Veteran
  • *****
  • Posts: 1216
  • Asshole by Nature
Re: Sumthing wrong
« Reply #8 on: November 06, 2008, 12:29:37 pm »
Sorry, SplitCoffee :(

Nope, he will keep on hatin'
Always remember the succubus...