Author Topic: Command.  (Read 1097 times)

0 Members and 1 Guest are viewing this topic.

Offline Gnintendo

  • Major
  • *
  • Posts: 61
Command.
« on: February 09, 2008, 06:06:41 pm »
I had a command on my server where you checked some stats of all the players, so I decided to mod it so that it first does the stats of all the Alpha players in red, then the stats of all the Bravo players in blue, it won't work right...please help:
  Case Text of
    '/players','/plrs','/allchars': begin
      if GetPlayerStat(AlphaPlayers,'active') then WriteConsole(ID,GetPlayerStat(AlphaPlayers,'name')+': '+inttostr(Player[AlphaPlayers].Level),$FFFF0000);
      if GetPlayerStat(BravoPlayers,'active') then WriteConsole(ID,GetPlayerStat(BravoPlayers,'name')+': '+inttostr(Player[BravoPlayers].Level),$FF0000FF);
    end;

that's the part that applies, help please, it compiles, but it doesn't work right, please help.

Offline chrisgbk

  • Moderator
  • Veteran
  • *****
  • Posts: 1739
Re: Command.
« Reply #1 on: February 09, 2008, 06:32:52 pm »
First off you'll need some sort of FOR loop to loop through players. You'll also need to check the players team.

AlphaPlayers and BravoPlayers only return the number of players currently on that team, you can't use that to access the array directly.

Offline Gnintendo

  • Major
  • *
  • Posts: 61
Re: Command.
« Reply #2 on: February 09, 2008, 06:36:29 pm »
Can you show me, I have no idea how to do that.

I'm still learning, I spent two hours trying everything I know how to do.

NVM figured it out
« Last Edit: February 09, 2008, 09:59:51 pm by Gnintendo »

Offline Boblekonvolutt

  • Soldier
  • **
  • Posts: 222
  • "YOU are a CAR."
Re: Command.
« Reply #3 on: February 09, 2008, 11:54:51 pm »
You should put the thingy in code tags

Code: [Select]
Like this! Oh, the joys of readable code. *sniff* Makes a grown man cry. (if you ask then yes. if you ask the other one, then no. stupid.)

Oh yeah, not for you - since you figured it out - but to show others (if they wonder). Err, maybe I'm just doing it to promote the use of procedures and functions... Keep OnCommand clean, or be damned! Mwahahaha! *bangs head into desk* HEAVY METAL BABY (*listens to Kelly Clarkson*) ZOMG IM SO ALTERNATIVE, YOU ALL ARE MAINSTREAM MTV ZOMBIES (*votes for the underdog in Idol*). Damnit, I'd better stop this now or no amount of code in the world could stop this from being a spam post!

Code: [Select]
procedure ListThemLittlePlayerThingys(ID: Byte);
var
  i: Integer;

begin

  // alpha
  if AlphaPlayers > 0 then
    WriteConsole(ID, 'Alpha Players...', $FFFF0000);

  for i := 1 to 32 do
    if GetPlayerStat(i, 'Active') = true then
      if GetPlayerStat(i, 'Team') = 1 then
        WriteConsole(ID, GetPlayerStat(i, 'Name') + ': ' + inttostr(Player[i].Level), $FFFF0000);

  // bravo
  if BravoPlayers > 0 then
    WriteConsole(ID, 'Bravo Players...', $FF0000FF);

  for i := 1 to 32 do
    if GetPlayerStat(i, 'Active') = true then
      if GetPlayerStat(i, 'Team') = 2 then
        WriteConsole(ID, GetPlayerStat(i, 'Name') + ': ' + inttostr(Player[i].Level), $FF0000FF);

end;

function OnCommand(ID: Byte; Text: String): Boolean;
begin
  if Text = '/players' then
    ListThemLittlePlayerThingys(ID);
end;

I didn't try it, so there might be some errors (if you run just this code, there will be for sure, since I didnt define Player) but it's pretty much how you'd do it. Unless there's a better way (then you should post that and let the rest of us bask in the everlasting glory of your soldat scripting skills).

Offline Gnintendo

  • Major
  • *
  • Posts: 61
Re: Command.
« Reply #4 on: February 10, 2008, 08:22:35 am »
You should put the thingy in code tags

Code: [Select]
Like this! Oh, the joys of readable code. *sniff* Makes a grown man cry. (if you ask then yes. if you ask the other one, then no. stupid.)

Oh yeah, not for you - since you figured it out - but to show others (if they wonder). Err, maybe I'm just doing it to promote the use of procedures and functions... Keep OnCommand clean, or be damned! Mwahahaha! *bangs head into desk* HEAVY METAL BABY (*listens to Kelly Clarkson*) ZOMG IM SO ALTERNATIVE, YOU ALL ARE MAINSTREAM MTV ZOMBIES (*votes for the underdog in Idol*). Damnit, I'd better stop this now or no amount of code in the world could stop this from being a spam post!

Code: [Select]
procedure ListThemLittlePlayerThingys(ID: Byte);
var
 i: Integer;

begin

 // alpha
 if AlphaPlayers > 0 then
 WriteConsole(ID, 'Alpha Players...', $FFFF0000);

 for i := 1 to 32 do
 if GetPlayerStat(i, 'Active') = true then
 if GetPlayerStat(i, 'Team') = 1 then
 WriteConsole(ID, GetPlayerStat(i, 'Name') + ': ' + inttostr(Player[i].Level), $FFFF0000);

 // bravo
 if BravoPlayers > 0 then
 WriteConsole(ID, 'Bravo Players...', $FF0000FF);

 for i := 1 to 32 do
 if GetPlayerStat(i, 'Active') = true then
 if GetPlayerStat(i, 'Team') = 2 then
 WriteConsole(ID, GetPlayerStat(i, 'Name') + ': ' + inttostr(Player[i].Level), $FF0000FF);

end;

function OnCommand(ID: Byte; Text: String): Boolean;
begin
 if Text = '/players' then
 ListThemLittlePlayerThingys(ID);
end;

I didn't try it, so there might be some errors (if you run just this code, there will be for sure, since I didnt define Player) but it's pretty much how you'd do it. Unless there's a better way (then you should post that and let the rest of us bask in the everlasting glory of your soldat scripting skills).
Read my post next time...here let me quote it for you.

"NVM figured it out"

Also, that is a ton more work than you need to do, why the hell wouldn't you just do if getplayerstat thing team = 1 or 2 and then do the rest with an i instead of alpha players and bravo players.

yeah...


Offline DorkeyDear

  • Veteran
  • *****
  • Posts: 1507
  • I also go by Curt or menturi
Re: Command.
« Reply #5 on: February 10, 2008, 10:02:00 am »
You should put the thingy in code tags

Code: [Select]
Like this! Oh, the joys of readable code. *sniff* Makes a grown man cry. (if you ask then yes. if you ask the other one, then no. stupid.)

Oh yeah, not for you - since you figured it out - but to show others (if they wonder). Err, maybe I'm just doing it to promote the use of procedures and functions... Keep OnCommand clean, or be damned! Mwahahaha! *bangs head into desk* HEAVY METAL BABY (*listens to Kelly Clarkson*) ZOMG IM SO ALTERNATIVE, YOU ALL ARE MAINSTREAM MTV ZOMBIES (*votes for the underdog in Idol*). Damnit, I'd better stop this now or no amount of code in the world could stop this from being a spam post!

Code: [Select]
procedure ListThemLittlePlayerThingys(ID: Byte);
var
 i: Integer;

begin

 // alpha
 if AlphaPlayers > 0 then
 WriteConsole(ID, 'Alpha Players...', $FFFF0000);

 for i := 1 to 32 do
 if GetPlayerStat(i, 'Active') = true then
 if GetPlayerStat(i, 'Team') = 1 then
 WriteConsole(ID, GetPlayerStat(i, 'Name') + ': ' + inttostr(Player[i].Level), $FFFF0000);

 // bravo
 if BravoPlayers > 0 then
 WriteConsole(ID, 'Bravo Players...', $FF0000FF);

 for i := 1 to 32 do
 if GetPlayerStat(i, 'Active') = true then
 if GetPlayerStat(i, 'Team') = 2 then
 WriteConsole(ID, GetPlayerStat(i, 'Name') + ': ' + inttostr(Player[i].Level), $FF0000FF);

end;

function OnCommand(ID: Byte; Text: String): Boolean;
begin
 if Text = '/players' then
 ListThemLittlePlayerThingys(ID);
end;

I didn't try it, so there might be some errors (if you run just this code, there will be for sure, since I didnt define Player) but it's pretty much how you'd do it. Unless there's a better way (then you should post that and let the rest of us bask in the everlasting glory of your soldat scripting skills).
Read my post next time...here let me quote it for you.

"NVM figured it out"

Also, that is a ton more work than you need to do, why the hell wouldn't you just do if getplayerstat thing team = 1 or 2 and then do the rest with an i instead of alpha players and bravo players.

yeah...


lol you should read, he said "Oh yeah, not for you - since you figured it out - but to show others (if they wonder)."

Offline Boblekonvolutt

  • Soldier
  • **
  • Posts: 222
  • "YOU are a CAR."
Re: Command.
« Reply #6 on: February 11, 2008, 12:55:17 am »
Right under the first code thingy...

As for why not to just do a single loop, I just wanted it to be sorted into alpha and bravo players instead of just all at once (it looks much cleaner).