Author Topic: Random Commands, Help!  (Read 777 times)

0 Members and 1 Guest are viewing this topic.

Offline Netherdrake

  • Major(1)
  • Posts: 12
  • Climber of Heaven
Random Commands, Help!
« on: May 11, 2008, 08:17:51 am »
There is a script called "Random_commands" there is two things: text color and weapon spawning. I have problems on weapons because USER can spawn weapons and i don't want that, i want just admin do everything on this, Sorry my english  :-\
-
There is the code of script, it's a little bit huge  :o
Code: [Select]
function OnCommand(ID: Byte; Text: string): boolean;
var
  pname: string;




//==================================
//==========RANDOM COMMANDS=========
//==========BY: TYLER WIGHT=========
//==========   AKA CORL45  =========
//==================================





//-----------------------------
//---------COLOR---------------
//-----------------------------

begin
  if ID = 255 then pname := 'Server' else pname := GetPlayerStat(ID,'Name');

  if GetPiece(LowerCase(Text), ' ', 0) = '/black' then
    begin
      WriteConsole(0, '[' + pname + '] ' + Copy(Text, 8, Length(Text)), RGB(0, 0, 0));
    end;

  if GetPiece(LowerCase(Text), ' ', 0) = '/red' then
    begin
      WriteConsole(0, '[' + pname + '] ' + Copy(Text, 6, Length(Text)), RGB(255, 0, 0));
    end;

  if GetPiece(LowerCase(Text), ' ', 0) = '/blue' then
    begin
      WriteConsole(0, '[' + pname + '] ' + Copy(Text, 7, Length(Text)), RGB(0, 0, 255));
    end;

  if GetPiece(LowerCase(Text), ' ', 0) = '/pink' then
    begin
      WriteConsole(0, '[' + pname + '] ' + Copy(Text, 7, Length(Text)), RGB(255, 20, 147));
    end;

  if GetPiece(LowerCase(Text), ' ', 0) = '/green' then
    begin
      WriteConsole(0, '[' + pname + '] ' + Copy(Text, 8, Length(Text)), RGB(0,255,0));
    end;

  if GetPiece(LowerCase(Text), ' ', 0) = '/purple' then
    begin
      WriteConsole(0, '[' + pname + '] ' + Copy(Text, 9, Length(Text)), RGB(155,48,255));
    end;

  if GetPiece(LowerCase(Text), ' ', 0) = '/aqua' then
    begin
      WriteConsole(0, '[' + pname + '] ' + Copy(Text, 7, Length(Text)), RGB(127,255,212));
    end;


  if regExpMatch('^/(color|text|commands)$', Text) then
    begin
      writeConsole(ID, 'Tylers color script all avalable to ADMINS:', RGB(0, 0, 255));
      writeConsole(ID, 'type /black /red /blue /pink /green /purple or /aqua', RGB(0, 0, 255));
      writeConsole(ID, 'use like regular /say command', RGB(0, 0, 255));
      writeConsole(ID, 'but it is in the color defined by the function', RGB(0, 0, 255));
      writeConsole(ID, 'type /spawns for a list of spawns', RGB(0, 0, 255));
    end;




  if regExpMatch('^/(preditor|inv|invisible)$', Text) then
    begin
      SpawnObject(GetPlayerStat(ID,'x')+20,GetPlayerStat(ID,'y')-20,20);
    end;

  if regExpMatch('^/(flame god|flame|flamegodmode|flame god mode)$', Text) then
    begin
      SpawnObject(GetPlayerStat(ID,'x')+20,GetPlayerStat(ID,'y')-20,18);
    end;

  if regExpMatch('^/(berseker|serk)$', Text) then
    begin
      SpawnObject(GetPlayerStat(ID,'x')+20,GetPlayerStat(ID,'y')-20,21);
    end;

  if regExpMatch('^/(boxes|power|box)$', Text) then
    begin
      SpawnObject(GetPlayerStat(ID,'x')+20,GetPlayerStat(ID,'y')-20,16);
      SpawnObject(GetPlayerStat(ID,'x')+30,GetPlayerStat(ID,'y')-20,17);
      SpawnObject(GetPlayerStat(ID,'x')+40,GetPlayerStat(ID,'y')-20,18);
      SpawnObject(GetPlayerStat(ID,'x')+50,GetPlayerStat(ID,'y')-20,19);
      SpawnObject(GetPlayerStat(ID,'x')+60,GetPlayerStat(ID,'y')-20,20);
      SpawnObject(GetPlayerStat(ID,'x')+70,GetPlayerStat(ID,'y')-20,21);
      SpawnObject(GetPlayerStat(ID,'x')+80,GetPlayerStat(ID,'y')-20,22);
    end;




if regExpMatch('^/(stationary|stat|turrent)$', Text) then
  begin
    SpawnObject(GetPlayerStat(ID,'x'),GetPlayerStat(ID,'y'),15);
  end;



if regExpMatch('^/(gunz|guns|weapons|weaps|weps)$', Text) then
    begin
      SpawnObject(GetPlayerStat(ID,'x')+20,GetPlayerStat(ID,'y')-20,1);
      SpawnObject(GetPlayerStat(ID,'x')+30,GetPlayerStat(ID,'y')-20,2);
      SpawnObject(GetPlayerStat(ID,'x')+40,GetPlayerStat(ID,'y')-20,3);
      SpawnObject(GetPlayerStat(ID,'x')+50,GetPlayerStat(ID,'y')-20,4);
      SpawnObject(GetPlayerStat(ID,'x')+60,GetPlayerStat(ID,'y')-20,5);
      SpawnObject(GetPlayerStat(ID,'x')+70,GetPlayerStat(ID,'y')-20,6);
      SpawnObject(GetPlayerStat(ID,'x')+80,GetPlayerStat(ID,'y')-20,7);
      SpawnObject(GetPlayerStat(ID,'x')-20,GetPlayerStat(ID,'y')-20,8);
      SpawnObject(GetPlayerStat(ID,'x')-30,GetPlayerStat(ID,'y')-20,9);
      SpawnObject(GetPlayerStat(ID,'x')-40,GetPlayerStat(ID,'y')-20,10);
      SpawnObject(GetPlayerStat(ID,'x')-50,GetPlayerStat(ID,'y')-20,11);
      SpawnObject(GetPlayerStat(ID,'x')-60,GetPlayerStat(ID,'y')-20,12);
      SpawnObject(GetPlayerStat(ID,'x')-70,GetPlayerStat(ID,'y')-20,13);
      SpawnObject(GetPlayerStat(ID,'x')-80,GetPlayerStat(ID,'y')-20,14);

    end;

//-------------------------
//-------Everything--------
//-------------------------

if regExpMatch('^/(big|boom|lots)$', Text) then
    begin
      SpawnObject(GetPlayerStat(ID,'x')+20,GetPlayerStat(ID,'y')-20,1);
      SpawnObject(GetPlayerStat(ID,'x')+30,GetPlayerStat(ID,'y')-20,2);
      SpawnObject(GetPlayerStat(ID,'x')+40,GetPlayerStat(ID,'y')-20,3);
      SpawnObject(GetPlayerStat(ID,'x')+50,GetPlayerStat(ID,'y')-20,4);
      SpawnObject(GetPlayerStat(ID,'x')+60,GetPlayerStat(ID,'y')-20,5);
      SpawnObject(GetPlayerStat(ID,'x')+70,GetPlayerStat(ID,'y')-20,6);
      SpawnObject(GetPlayerStat(ID,'x')+80,GetPlayerStat(ID,'y')-20,7);
      SpawnObject(GetPlayerStat(ID,'x')-20,GetPlayerStat(ID,'y')-20,8);
      SpawnObject(GetPlayerStat(ID,'x')-30,GetPlayerStat(ID,'y')-20,9);
      SpawnObject(GetPlayerStat(ID,'x')-40,GetPlayerStat(ID,'y')-20,10);
      SpawnObject(GetPlayerStat(ID,'x')-50,GetPlayerStat(ID,'y')-20,11);
      SpawnObject(GetPlayerStat(ID,'x')-60,GetPlayerStat(ID,'y')-20,12);
      SpawnObject(GetPlayerStat(ID,'x')-70,GetPlayerStat(ID,'y')-20,13);
      SpawnObject(GetPlayerStat(ID,'x')-80,GetPlayerStat(ID,'y')-20,14);
      SpawnObject(GetPlayerStat(ID,'x')-90,GetPlayerStat(ID,'y')-20,16);
      SpawnObject(GetPlayerStat(ID,'x')+90,GetPlayerStat(ID,'y')-20,17);
      SpawnObject(GetPlayerStat(ID,'x')-100,GetPlayerStat(ID,'y')-20,18);
      SpawnObject(GetPlayerStat(ID,'x')+100,GetPlayerStat(ID,'y')-20,19);
      SpawnObject(GetPlayerStat(ID,'x')-110,GetPlayerStat(ID,'y')-20,20);
      SpawnObject(GetPlayerStat(ID,'x')+110,GetPlayerStat(ID,'y')-20,21);
      SpawnObject(GetPlayerStat(ID,'x')-120,GetPlayerStat(ID,'y')-20,22);
    end;

   Result := false;
end;

function OnPlayerCommand(ID: Byte; Text: string): boolean;
  begin
    if regExpMatch('^/(commands|spawns|spawn|help)$', Text) then
      begin
        writeConsole(ID, '-----Tylers spawn script------', $0099CC00);
        writeConsole(ID, 'commands:', $0099CC00);
        writeConsole(ID, '/inv  spawns preditor box--ADMIN', RGB(255,0,0));
        writeConsole(ID, '/med  spawns med-kit--USER', RGB(255,0,0));
        writeConsole(ID, '/nade  spawns normal nade box--USER', RGB(255,0,0));
        writeConsole(ID, '/flame   spawns flame box--ADMIN', RGB(255,0,0));
        writeConsole(ID, '/vest   spawns armor vest--USER', RGB(255,0,0));
        writeConsole(ID, '/serk   spawns beserker box--ADMIN', RGB(255,0,0));
        writeConsole(ID, '/clust   spawns cluster nades--USER', RGB(255,0,0));
        writeConsole(ID, '/power   spawns all power-ups--ADMIN', RGB(255,0,0));
        writeConsole(ID, '/stat   spawns turrent--ADMIN', RGB(255,0,0));
        writeConsole(ID, '/eagle   spawns eagles--USER', RGB(255,0,0));
        writeConsole(ID, '/mp5   spawns the HK MP5--USER', RGB(255,0,0));
        writeConsole(ID, '/ak47   spawns an ak47--USER', RGB(255,0,0));
        writeConsole(ID, '/aug   spawns streyr AUG--USER', RGB(255,0,0));
        writeConsole(ID, '/spas  spawns spas 12--USER', RGB(255,0,0));
        writeConsole(ID, '/ruge  spawns ruger77--USER', RGB(255,0,0));
        writeConsole(ID, '/m79  spwans m79--USER', RGB(255,0,0));
        writeConsole(ID, '/barr  spawns barreta--USER', RGB(255,0,0));
        writeConsole(ID, '/minim  spawns minimi--USER', RGB(255,0,0));
        writeConsole(ID, '/minig  spawns minigun--USER', RGB(255,0,0));
        writeConsole(ID, '/usso  spawns USSOCOM--USER', RGB(255,0,0));
        writeConsole(ID, '/knife  spawns knife--USER', RGB(255,0,0));
        writeConsole(ID, '/chain  spawns chainsaw--USER', RGB(255,0,0));
        writeConsole(ID, '/law spawns LAW--USER', RGB(255,0,0));
        writeConsole(ID, '/guns  spawns all guns(no stat gun)--ADMIN', RGB(255,0,0));
        writeConsole(ID, '/boom  spawns everything(no stat gun)--ADMIN', RGB(255,0,0));
        writeConsole(ID, 'PRESS  /  TO SEE EVERYTHING', $0099CC00);
        writeConsole(ID, '-------------END----------------', RGB(255,0,0));
      end;



  if regExpMatch('^/(desert eagles|eagle|deagles|deserteagles)$', Text) then
    begin
      forceWeapon(ID,1,GetPlayerStat(ID,'Secondary'),0);
    end;

  if regExpMatch('^/(hkmp5|mp5|hk)$', Text) then
    begin
      forceWeapon(ID,2,GetPlayerStat(ID,'Secondary'),0);
    end;

  if regExpMatch('^/(ak47)$', Text) then
    begin
      forceWeapon(ID,3,GetPlayerStat(ID,'Secondary'),0);
    end;

  if regExpMatch('^/(steyr|aug)$', Text) then
    begin
      forceWeapon(ID,4,GetPlayerStat(ID,'Secondary'),0);
    end;

  if regExpMatch('^/(spas 12|spas|spas12)$', Text) then
    begin
      forceWeapon(ID,5,GetPlayerStat(ID,'Secondary'),0);
    end;

  if regExpMatch('^/(ruger|ruge|ruger77)$', Text) then
    begin
      forceWeapon(ID,6,GetPlayerStat(ID,'Secondary'),0);
    end;

  if regExpMatch('^/(m79)$', Text) then
    begin
      forceWeapon(ID,7,GetPlayerStat(ID,'Secondary'),0);
    end;

  if regExpMatch('^/(barreta|barr|barrett m82a1|barrett|barret m)$', Text) then
    begin
      forceWeapon(ID,8,GetPlayerStat(ID,'Secondary'),0);
    end;

  if regExpMatch('^/(fn minimi|minim|fn)$', Text) then
    begin
      forceWeapon(ID,9,GetPlayerStat(ID,'Secondary'),0);
    end;

  if regExpMatch('^/(minigun|minig)$', Text) then
    begin
      forceWeapon(ID,10,GetPlayerStat(ID,'Secondary'),0);
    end;

  if regExpMatch('^/(ussocom|usso)$', Text) then
    begin
      ForceWeapon(ID,GetPlayerStat(ID,'Primary'),0,0);
    end;

  if regExpMatch('^/(combat|knife|combat knife|combatknife)$', Text) then
    begin
      ForceWeapon(ID,GetPlayerStat(ID,'Primary'),14,0);
    end;

  if regExpMatch('^/(chainsaw|chain)$', Text) then
    begin
      ForceWeapon(ID,GetPlayerStat(ID,'Primary'),15,0);
    end;

  if regExpMatch('^/(LAW|law|m72 law|m72law)$', Text) then
    begin
      ForceWeapon(ID,GetPlayerStat(ID,'Primary'),16,0);
    end;

  if regExpMatch('^/(medic|med|health|med pack)$', Text) then
    begin
      SpawnObject(GetPlayerStat(ID,'x')+20,GetPlayerStat(ID,'y')-20,16);
    end;

  if regExpMatch('^/(grenade|nade)$', Text) then
    begin
      SpawnObject(GetPlayerStat(ID,'x')+20,GetPlayerStat(ID,'y')-20,17);
    end;

  if regExpMatch('^/(cluster|clust|clustergrandes|clusternades|clustnades)$', Text) then
    begin
      SpawnObject(GetPlayerStat(ID,'x')+20,GetPlayerStat(ID,'y')-20,22);
    end;

  if regExpMatch('^/(armor|vest|bulletproofvest)$', Text) then
    begin
      SpawnObject(GetPlayerStat(ID,'x')+20,GetPlayerStat(ID,'y')-20,19);
    end;

   Result := false;
end;



Netherdrake .CoH

Offline JFK

  • Camper
  • ***
  • Posts: 255
    • My TraxInSpace Account
Re: Random Commands, Help!
« Reply #1 on: May 11, 2008, 08:46:19 am »
very easy..

change:
Code: [Select]
function OnPlayerCommand(ID: Byte; Text: string): boolean;

to:
Code: [Select]
function OnCommand(ID: Byte; Text: string): boolean;

makes sense? heh? :p
Come join: EliteCTF
Listen to: My Music

Offline Boblekonvolutt

  • Soldier
  • **
  • Posts: 222
  • "YOU are a CAR."
Re: Random Commands, Help!
« Reply #2 on: May 11, 2008, 08:57:01 am »
Well, duplicate identifier error (2x OnCommand) might not be what he's after... Just put all the stuff in one.  [pigtail]

Offline JFK

  • Camper
  • ***
  • Posts: 255
    • My TraxInSpace Account
Re: Random Commands, Help!
« Reply #3 on: May 11, 2008, 09:08:38 am »
lol.. missed that.. i that case remove the following:

Code: [Select]
   Result := false;
end;

function OnPlayerCommand(ID: Byte; Text: string): boolean;
  begin

I *think* that should work, maybe some commands do double things now, didn't check that..
Come join: EliteCTF
Listen to: My Music

Offline Netherdrake

  • Major(1)
  • Posts: 12
  • Climber of Heaven
Re: Random Commands, Help!
« Reply #4 on: May 12, 2008, 05:39:47 am »
Thanks, now it works :D
Netherdrake .CoH