Author Topic: nades script  (Read 1037 times)

0 Members and 1 Guest are viewing this topic.

Offline avti

  • Major(1)
  • Posts: 9
nades script
« on: January 22, 2012, 08:49:32 pm »
Im trying to do simple auto regenerating nade script.
it comes through compilator, but it don't add any nades.
any ideas?

Code: [Select]
Procedure AddNades(ID: byte);
begin
for ID := 1 to 32 do begin
if (GetPlayerStat(ID,'Alive')=true) and (GetPlayerStat(ID,'Grenades')<9) then begin
GiveBonus(ID,4);
end;
end;
end;

Offline Falcon`

  • Flagrunner
  • ****
  • Posts: 792
  • A wanted lagger
Re: nades script
« Reply #1 on: January 23, 2012, 09:09:03 am »
is that procedure called anywhere?
If you're not paying for something, you're not the customer; you're the product being sold.
- Andrew Lewis

Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live.

Offline jrgp

  • Administrator
  • Flamebow Warrior
  • *****
  • Posts: 5037
Re: nades script
« Reply #2 on: January 23, 2012, 10:00:37 am »
Why the hell are you defining the ID variable in the procedure argument rather than in the body of it? Look here to see how it's done properly: http://math.uww.edu/~harrisb/courses/cs171/procs_01.htm
There are other worlds than these

Offline TheOne

  • Soldier
  • **
  • Posts: 208
Re: nades script
« Reply #3 on: January 23, 2012, 10:19:23 am »
If you want the regeneration script to be auto-triggered, best call it in AppOnIdle.

About the var, choose one way from these two:

Code: [Select]
procedure AddNades(ID: byte);
begin
if ... then GiveBonus(ID, 4);
end;

procedure AppOnIdle(Ticks: integer);
var i: byte;
begin
for i := 1 to 32 do
AddNades(i);
end;

or the same without the parameter, just one AddNades();-call, and the declaration of ID in the var-section of your AddNades-procedure.

Offline avti

  • Major(1)
  • Posts: 9
Re: nades script
« Reply #4 on: January 23, 2012, 11:28:04 am »
Now it work's. Thanks a lot.  :)