0 Members and 1 Guest are viewing this topic.
//First part of a Player Count script. Used for a lobby of some description.//The Values where comments have the * can be changed to suit the needs of the AdminConstFull = 6; //*Needed Players to begin* varGram1, Gram2, Gram3 : string; //There are/There is/player/playersRP, CP, OL, NP : byte; //Remaining Players, Current Players, One player left to join, Needed PlayersbeginNP := 6; //*Needed Players to begin*OL := NP - 1; //One less than fullCP := NumPlayers; //This is the bit I'm confused about...if (CP = 1) then begin //Grammar rules for below procedure Gram1 := 'is '; Gram2 := ''; Gram3 := 's ';end;else if (CP> 1 < OL or CP = NP) then begin Gram1 := 'are '; Gram2 := 's'; Gram3 := 's';end;else if (CP = OL) then begin Gram1 := 'are '; Gram2 := 's'; Gram3 := '';end;end.procedure OnJoinGame(ID, Team: byte);begin WriteConsole(ID, 'This server requires ' + NP + 'players to begin', $FFFFFF00); if (CP<> NP) then begin RP := NP - CP; WriteConsole(0, 'There ' Gram1 + CP + 'player' + Gram2 + ' in the server. Waiting for ' + RP + ' player' + Gram3 + ' to join', $FFFFFF00); Full := False; end; else Full := True; WriteConsole(0, 'The server is full', $FFFFFF00);end;
const FULL = 6;procedure OnJoinGame(ID, Team: byte); var diff: smallint; str: string;begin WriteConsole(ID, 'This server requires ' + IntToStr(FULL)+ ' players to begin', $FFFFFF00); diff := FULL - NumPlayers; if diff > 0 then begin if NumPlayers = 1 then begin str := 'There is 1 player'; end else str := 'There are '+IntToStr(NumPlayers)+' players'; str := str + ' in the server, waiting for ' + IntToStr(diff) + ' player' + iif(diff > 1, 's', '') + ' to join'; WriteConsole(0, str, $FFFFFF00); end else WriteConsole(0, 'The server is full', $FFFFFF00); end;
B := 1; // A = ? (0 default), B = 1A := B; // A = 1, B = 1B := 2; // A = 1, B = 2
In regards to if statements:if condition then line else line;if condition then begin block end else begin block end;if condition then begin block end else line;if condition then line else begin block end;
procedure OnPlayerSpeak(ID: Byte; Text: string);begin if(Text = '/test') then begin if (GetPlayerStat(ID, Team) = 1) then WriteConsole(ID, 'You are in the Alpha Team', $FFFF0000); else if (GetPlayerStat(ID, Team) = 2) then WriteConsole(ID, 'You are in the Bravo Team', $FFFF0000); else WriteConsole(ID, 'You are in neither in Alpha or Bravo Team', $FFFF0000); end;end;
The compiler reckons there should be a ";" instead of "ELSE" on line 6?