0 Members and 6 Guests are viewing this topic.
function RandomID: integer;vara: array of integer;x, y, z: integer;begin for x := 1 to 32 do begin if GetPlayerStat(x, 'Active') then begin a[y] := x; y := y+1; SetArrayLength(a, y); end; end; z := NumPlayers; case Random(1, z+1) of 1: Result := a[0] 2: Result := a[1] 3: Result := a[2] 4: Result := a[3] 5: Result := a[4] 6: Result := a[5] . . // Tried to do something like that but I don't know what to do here. :) . z: Result := a[z-1] end;end;
http://forums.soldat.pl/index.php?topic=31798.0
Quote from: iDante on June 10, 2011, 04:09:57 pmhttp://forums.soldat.pl/index.php?topic=31798.0soldatcentral is no more
function RandomID: integer;vara: array of integer;x, y: integer;begin for x := 1 to 32 do begin if GetPlayerStat(x, 'Active') then begin a[y] := x; y := y+1; SetArrayLength(a, y); end; end; Result := a[Random(0, y)];end;
function RandomID: integer;vara: array of integer;x, y: integer;begin for x := 1 to 32 do begin if GetPlayerStat(x, 'Active') = true then begin SetArrayLength(a, y + 1); a[y] := x; y := y+1; end; end; Result := a[Random(0, y)];end;
Part IIX: Boolean Statements:Good lord this drives me insane.Would you do this?Code: (Pascal) [Select]if x > y = true then ...;Lets say that x is greater than y. The computer evaluates it as "if true = true then ..." when it makes more sense for it to evaluate it as "if true then ..."A boolean statement goes into the condition part of an if thing.Therefore, DO NOT DO THIS:Code: (Pascal) [Select]var bool: boolean;begin if bool = true then ...;end;THAT IS UGLY AND MEAN TO ME!Code: (Pascal) [Select]if bool then ...;IS MUCH BETTER TY!Same with stuff like this:Code: (Pascal) [Select]var i: integer;begin for i := 1 to 32 do if GetPlayerStat(i, 'active') then ...;end;Note: "if GetPlayerStat(i, 'active') then ...;"I see this written as "if GetPlayerStat(i, 'active) = true then ...;" over and over again and it bugs the living shneidikkies out of me.Please for the love of good god's goldfish, get rid of those = true's.Note: Some of GetPlayerStat's return values are borked, be sure to make sure things are working right.Now lets say you want to test out whether that boolean statement is NOT true.Code: (Pascal) [Select]if not bool then ...;not is the keyword to use here. This basically takes over = false. Its easier to read as well.
if x > y = true then ...;
var bool: boolean;begin if bool = true then ...;end;
if bool then ...;
var i: integer;begin for i := 1 to 32 do if GetPlayerStat(i, 'active') then ...;end;
if not bool then ...;
function RandomID: integer;vara: array of integer;x, y: integer;begin for x := 1 to 32 do begin if GetPlayerStat(x, 'Active') = true then begin SetArrayLength(a, y + 1); [y] := x; y := y+1; end; end; Result := a[Random(0, y)];end;
soldatcentral is no more
But I didn't get the "= true" part.
That's pretty douchy of enesce to just have soldatcentral redirect to his commercial software ad site without even giving a notice.
function RandomID(t: integer): integer;vara: array of integer;x, y: integer;begin if ( t = 0 ) then begin for x := 1 to 32 do begin if ( GetPlayerStat(x, 'Active') = true ) then begin SetArrayLength(a, y+1); a[y] := x; y := y+1; end; end; end else begin for x := 1 to 32 do begin if ( GetPlayerStat(x, 'Active') = true ) and ( GetPlayerStat(x, 'Team') = t ) then begin SetArrayLength(a, y+1); a[y] := x; y := y+1; end; end; end; Result := a[Random(0, y)];end;