Author Topic: Error with simple script  (Read 715 times)

0 Members and 1 Guest are viewing this topic.

Offline cynicle

  • Major(1)
  • Posts: 37
Error with simple script
« on: January 25, 2009, 03:29:31 am »
Hey I just added some code on to my script and now it wont load. The error is apparenly on the line
Code: [Select]
else if (Text = '/trained') AND (Rape = 1) then begin and it says in the log
Code: [Select]
[Error] (30:5): Identifier expected
I know it's probally something really simple but I've looked over and over it and can't seem to find it. The var Rape has been defined at the top of the code (not included).


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

begin
  Result := false;
    if (Text = '/m79') then begin
     Result := true;
     Admin := GetPlayerStat(ID,'Name');   
     AdminID := ID
     DrawText(0,Admin + ' has initiated m79 training',330,RGB(255,255,255),0.1,40,240);   
     SayToPlayer(ID,'Go Postal!');
     Rape := 1;
     ForceWeapon(ID, 7, 11, 0)
    else if (Text = '/trained') AND (Rape = 1) then begin
     Result := true;
     Admin := GetPlayerStat(ID,'Name');   
     AdminID := ID
     DrawText(0,Admin + ' is now scoring!',330,RGB(255,255,255),0.1,40,240);   
     SayToPlayer(ID,'Now start getting points!');
     Rape := 0;
     ForceWeapon(ID, 8, 11, 0);
   end;
  end;
 end;
Join the Army. Visit strange and exotic places. Meet fascinating people. And kill them.

Aus Soldat League 203.208.70.216:23073

Offline iDante

  • Veteran
  • *****
  • Posts: 1967
Re: Error with simple script
« Reply #1 on: January 25, 2009, 04:53:01 am »
ah, yes it is pretty simple. You have if (...) then begin but no end before else.
How is this treating you:
Code: [Select]
function OnCommand(ID: Byte; Text: string): boolean;

begin
  Result := false;
    if (Text = '/m79') then begin
     Result := true;
     Admin := GetPlayerStat(ID,'Name');   
     AdminID := ID
     DrawText(0,Admin + ' has initiated m79 training',330,RGB(255,255,255),0.1,40,240);   
     SayToPlayer(ID,'Go Postal!');
     Rape := 1;
     ForceWeapon(ID, 7, 11, 0);
    end else if (Text = '/trained') AND (Rape = 1) then begin
     Result := true;
     Admin := GetPlayerStat(ID,'Name');   
     AdminID := ID
     DrawText(0,Admin + ' is now scoring!',330,RGB(255,255,255),0.1,40,240);   
     SayToPlayer(ID,'Now start getting points!');
     Rape := 0;
     ForceWeapon(ID, 8, 11, 0);
   end;
 end;

Offline cynicle

  • Major(1)
  • Posts: 37
Re: Error with simple script
« Reply #2 on: January 25, 2009, 07:10:48 pm »
Thanks heaps didn't realise the end had to be placed there. Now i'll continue with my script. (It's like a variation on ramobo mod).
Join the Army. Visit strange and exotic places. Meet fascinating people. And kill them.

Aus Soldat League 203.208.70.216:23073