Author Topic: Need Help in Scripting  (Read 7412 times)

0 Members and 1 Guest are viewing this topic.

Offline y0uRd34th

  • Camper
  • ***
  • Posts: 325
  • [i]Look Signature![/i]
Re: Need Help in Scripting
« Reply #80 on: January 03, 2009, 12:02:30 pm »
Hmm now it's working when i disable the last end; before it was not working then thanks :D

[Error] (54:20): 'THEN' expected
Code: [Select]
var
   cooldown: array [1..32] of byte;
   coolbarret: array [1..32] of byte;

procedure AppOnIdle(Ticks: integer);
var
   i: Byte;
   hp: integer;
begin
   for i := 1 to 32 do
      if getplayerstat(i,'active') then begin
         if cooldown[i] > 0 then
            cooldown[i] := cooldown[i] - 1
            else begin
               hp:=GetPlayerStat(i,'health');
               GiveBonus(i,1);
               DoDamage(i,GetPlayerStat(i,'health')-hp);     
               cooldown[i] := 20;
               end;
         if coolbarret[i] > 0 then
            coolbarret[i] := coolbarret[i] - 1;
      end;
end;

procedure OnPlayerRespawn(ID: byte);
begin
     cooldown[id] := 1;
end;

procedure OnJoinTeam(ID, Team: byte);
var
   w: Byte;
begin
     for w := 2 to 14 do
     SetWeaponActive(ID,w,false);
end;

procedure OnWeaponChange(ID, PrimaryNum, SecondaryNum: byte);
begin
     if PrimaryNum = 1 then
     ForceWeapon(ID,15,16,0);
end;

procedure OnFlagScore(ID, TeamFlag: byte);
begin
     GiveBonus(ID,3);
end;

function OnPlayerCommand(ID: Byte; Text: string): boolean;
begin
     if Text = '/barret' then
     if coolbarret := 0 then begin
          ForceWeapon(ID,8,16,0);  //'THEN' expected?
          coolbarret[id] := 120;
     end;
   Result := false;
end;

I read it 3 times...
« Last Edit: January 03, 2009, 12:09:55 pm by y0uRd34th »

Offline tk

  • Soldier
  • **
  • Posts: 235
Re: Need Help in Scripting
« Reply #81 on: January 03, 2009, 01:59:37 pm »
read again, here is mistake if coolbarret := 0 then begin

Offline y0uRd34th

  • Camper
  • ***
  • Posts: 325
  • [i]Look Signature![/i]
Re: Need Help in Scripting
« Reply #82 on: January 04, 2009, 06:01:58 am »
Server says: " 
  • [Error] Saw'n'Law -> (AppOnIdle): Out Of Range"

That's my AppOnIdle don't know what's going to make the Error :/
Code: [Select]
procedure AppOnIdle(Ticks: integer);
var
   i: Byte;
begin
   for i := 1 to 32 do
         if barret[i] > 0 then
            barret[i] := barret[i] - 60;
         if m79[i] > 0 then
            m79[i] := m79[i] - 60;
         if ammo[i] > 0 then
            ammo[i] := ammo[i] - 60;
end;
Any ideas why?

Offline iDante

  • Veteran
  • *****
  • Posts: 1967
Re: Need Help in Scripting
« Reply #83 on: January 04, 2009, 06:35:36 am »
Out of range errors mean that you are trying to access a part of an array that doesn't exist. Can I see the whole script?

Edit: just noticed that you forgot begin and end in the for loop.
Code: [Select]
procedure AppOnIdle(Ticks: integer);
var
   i: Byte;
begin
   for i := 1 to 32 do begin
         if barret[i] > 0 then
            barret[i] := barret[i] - 60;
         if m79[i] > 0 then
            m79[i] := m79[i] - 60;
         if ammo[i] > 0 then
            ammo[i] := ammo[i] - 60;
   end;
end;
Try that out.
« Last Edit: January 04, 2009, 06:42:42 am by iDante »

Offline y0uRd34th

  • Camper
  • ***
  • Posts: 325
  • [i]Look Signature![/i]
Re: Need Help in Scripting
« Reply #84 on: January 04, 2009, 06:58:37 am »
Thanks that works :)
And thats the whole script:
Code: [Select]
var
   barret: array [1..32] of byte;
   m79: array [1..32] of byte;
   ammo: array [1..32] of byte;

procedure AppOnIdle(Ticks: integer);
var
   i: Byte;
begin
   for i := 1 to 32 do begin
         if barret[i] > 0 then
            barret[i] := barret[i] - 60;
         if m79[i] > 0 then
            m79[i] := m79[i] - 60;
         if ammo[i] > 0 then
            ammo[i] := ammo[i] - 60;
   end;
end;

procedure OnWeaponChange(ID, PrimaryNum, SecondaryNum: byte);
begin
     if PrimaryNum = 1 then
     ForceWeapon(ID,15,16,0);
end;

procedure OnFlagScore(ID, TeamFlag: byte);
begin
     GiveBonus(ID,3);
end;

function OnPlayerCommand(ID: Byte; Text: string): boolean;
var
   pri,sec: integer;
begin
     if Text = '/barret' then
     if barret[ID] = 0 then begin
     ForceWeapon(ID,8,16,0);
     barret[ID] := 7200;
  end
          if Text = '/m79' then
          if m79[ID] = 0 then begin
          ForceWeapon(ID,7,16,0);
          m79[ID] := 7200;
       end
               if Text = '/ammo' then
               if ammo[ID] = 0 then begin
               pri:=GetPlayerStat(ID,'Primary');
               sec:=GetPlayerStat(ID,'Secondary');
               ForceWeapon(ID,pri,sec,0);
               m79[ID] := 3000;
            end;
Result := false;
end;

procedure OnJoinTeam(ID, Team: byte);
var
   w: Byte;
begin
     for w := 2 to 14 do
     SetWeaponActive(ID,w,false);
     barret[ID] := 0;
     m79[ID] := 0;
     ammo[ID] := 0;
end;

procedure OnPlayerRespawn(ID: byte);
var
   w: Byte;
begin
     for w := 2 to 14 do
     SetWeaponActive(ID,w,false);
end;

procedure OnPlayerSpeak(ID: Byte; Text: string);
begin
     if Text = '!help' then begin
          SayToPlayer(ID,'"""""""""""""""""""""""""""""');
          SayToPlayer(ID,'"Available Commands:        "');
          SayToPlayer(ID,'"/ammo   | get full ammo    "');
          SayToPlayer(ID,'"/m79    | get M79          "');
          SayToPlayer(ID,'"/barret | get Barret       "');
          SayToPlayer(ID,'"""""""""""""""""""""""""""""');
     end;
end;

procedure ActivateServer();
begin
     sleep(2000);
     Command('/loadwep snl');
end;

How can i load an weapons.ini with script?
Tryed it so:
Code: [Select]
procedure ActivateServer();
begin
     sleep(2000);
     Command('/loadwep snl');
end;

Help please :)
« Last Edit: January 04, 2009, 07:10:11 am by y0uRd34th »

Offline iDante

  • Veteran
  • *****
  • Posts: 1967
Re: Need Help in Scripting
« Reply #85 on: January 04, 2009, 07:15:20 am »
If you need to wait 2 seconds, use AppOnIdle, not sleep.

Offline y0uRd34th

  • Camper
  • ***
  • Posts: 325
  • [i]Look Signature![/i]
Re: Need Help in Scripting
« Reply #86 on: January 05, 2009, 09:33:56 am »
Ops wanted to delete sleep, testet if it work than if i wait 2seconds or so...
It works fine but the weapon.ini will not load on server :(

Need Help do someone have an Script to Increase Hitpoints for Bots?
I know there is an "Special Bots" Script buti only need it For HP!
Please Help!

Offline iDante

  • Veteran
  • *****
  • Posts: 1967
Re: Need Help in Scripting
« Reply #87 on: January 05, 2009, 06:00:04 pm »
The best way would be to use OnPlayerDamage. Check if the Victim is a bot, and if so, lower the Result variable.

Offline Norbo

  • Camper
  • ***
  • Posts: 338
Re: Need Help in Scripting
« Reply #88 on: January 06, 2009, 03:49:54 am »
The best way would be to use OnPlayerDamage. Check if the Victim is a bot, and if so, lower the Result variable.

for example result := result/2
then the bot will recive half of the damage that he should recive

Offline y0uRd34th

  • Camper
  • ***
  • Posts: 325
  • [i]Look Signature![/i]
Re: Need Help in Scripting
« Reply #89 on: January 18, 2009, 12:52:06 pm »
Ok thanks for Example :) if i get One i check it faster :D

:D Again me^^
OnCommand....(works fine)
Code: [Select]
     if Text = '/cluster' then begin
       if Player[ID].Cluster then begin
          Player[ID].Cluster := False;
               WriteConsole(ID,'Clusterdisabled!',$A10000);
               end else begin
               Player[ID].Cluster := True;
               WriteConsole(ID,'Cluster enabled!',$00A100);
          end;   
     end;

     if Text = '/nades' then begin
       if Player[ID].Nades then begin
          Player[ID].Nades := False;
               WriteConsole(ID,'Nade disabled!',$A10000);
               end else begin
               Player[ID].Nades := True;
               WriteConsole(ID,'Nade enabled!',$00A100);
          end;   
     end;

Code: [Select]
procedure AppOnIdle(Ticks: integer);
var
   i, ID: Byte;
begin
   for i := 1 to 32 do begin
         if PKnova[i] > 0 then
            PKnova[i] := PKnova[i] - 1;

          if Player[i].Cluster then Clusters(Player[i].Cluster,5);
          if Player[i].Nades then GiveBonus(Player[i].Nades,4);
     end;
end;

I fail at
Code: [Select]
          if Player[i].Cluster then Clusters(Player[i].Cluster,5);
          if Player[i].Nades then GiveBonus(Player[i].Nades,4);
this idk how to make that the Player gets the Nades/Clusters then :(

Offline danmer

  • Camper
  • ***
  • Posts: 466
  • crabhead
Re: Need Help in Scripting
« Reply #90 on: January 18, 2009, 01:03:20 pm »
try this
Code: [Select]
          if Player[i].Cluster then GiveBonus(i,5);
          if Player[i].Nades then GiveBonus(i,4);

Offline chutem

  • Veteran
  • *****
  • Posts: 1119
Re: Need Help in Scripting
« Reply #91 on: January 18, 2009, 07:41:27 pm »
The best way would be to use OnPlayerDamage. Check if the Victim is a bot, and if so, lower the Result variable.

for example result := result/2
then the bot will recive half of the damage that he should recive
Actually I find that is a bad way to do things.

In theory, it will effectively double the health, but a lot of small amounts of damage will be ignored because of rounding.
It only really badly effects things when you are dividing by larger numbers, but thought I'd throw that nugget of insight out there.
1NK3FbdNtH6jNH4dc1fzuvd4ruVdMQABvs

Offline y0uRd34th

  • Camper
  • ***
  • Posts: 325
  • [i]Look Signature![/i]
Re: Need Help in Scripting
« Reply #92 on: January 20, 2009, 09:04:09 am »
@Danmer: Thanks its working never try
Code: [Select]
GiveBonus(i,5); :D always used 'ID' or 'Player.Cluster'

@chutem: How would you do it?

Thanks for Answers :D