Author Topic: ugh! what am i doing wrong here? (shop.pas)  (Read 991 times)

0 Members and 1 Guest are viewing this topic.

Offline frosty

  • Flagrunner
  • ****
  • Posts: 601
  • Uber Desert Eagle ^^
ugh! what am i doing wrong here? (shop.pas)
« on: July 03, 2010, 11:11:13 pm »
see attached file

for some reason this section of code doesnt want to fire, and nuke turret is arming far too quick

Code: (pascal) [Select]
for PlayerID := 1 to 32 do
begin
for i:=1 to 32 do
  begin
    if NTB[PlayerID] = True then begin
      if ntTimer[PlayerID] > 0 then ntTimer[PlayerID]:=ntTimer[PlayerID]-1;
      WriteConsole(PlayerID,''+inttostr(ntTimer[PlayerID])+'...',$EE00FFFF);
      if ntTimer[PlayerID] = 0 then begin
        WriteConsole(PlayerID,'Armed! keep your distance',$EE00FFFF);
        NTB[PlayerID]:=False;
      end;
      if ntTimer[PlayerID] = 0 then if ntfTimer[PlayerID] > 0 then ntfTimer[PlayerID]:=ntfTimer[PlayerID]-1;
      if ntfTimer[PlayerID] = 0 then if GetPlayerStat(i,'Name') = 'Mr.Zombie' then if RayCast(GetPlayerStat(i,'x'),GetPlayerStat(i,'Y'),ntPosX[PlayerID],ntPosY[PlayerID],Dist,50) then begin
        Nova(ntPosX[PlayerID],ntPosY[PlayerID],0,DED*I,25, i,10,EBNNTT*I);
        Nova(ntPosX[PlayerID],ntPosY[PlayerID],0,(DED*I)/2,25, i,10,EBNND);
        Nova(ntPosX[PlayerID],ntPosY[PlayerID],0,(DED*I)/3,25, i,10,EBNNT);
        ntfTimer[PlayerID]:=30;
        end;
      end;
    end;
  end;

and this code is in OnAppIdle, timer was working fine up until i tried to add a section of code to fire the nuke on the turret when the zombies are in range of turret, then auto rearm after 30 seconds

probably something stupid, remember, code is in Attached file

it compiles just fine by the way ;), specifically the Novas wont fire, i mean nothing hapens when zombies are in range
« Last Edit: July 03, 2010, 11:13:45 pm by frosty »
check out my server! click here

If at first you don't succeed, Improvise! :D

Offline EnEsCe

  • Retired Soldat Developer
  • Flamebow Warrior
  • ******
  • Posts: 3101
  • http://enesce.com/
    • [eC] Official Website
Re: ugh! what am i doing wrong here? (shop.pas)
« Reply #1 on: July 03, 2010, 11:24:32 pm »
You really really should not loop that many times in AppOnIdle... no wonder your server has massive CPU usage issues >_>

Also code won't work because your i for loop is in the wrong spot.

Offline squiddy

  • Soldat Beta Team
  • Camper
  • ******
  • Posts: 333
  • Flagger assassin
    • SoldatX
Re: ugh! what am i doing wrong here? (shop.pas)
« Reply #2 on: July 03, 2010, 11:48:14 pm »
I suggest you to use WriteLn() to find errors.

By any chance, do you update ntPosX and ntPosY each second?

Correct these:

For PlayerID := 1 To 32 Do if GetPlayerStat(PlayerID,'Active') = True Then For i := 1 To 32 Do if GetPlayerStat(i,'Active') = True Then if GetPlayerStat(i,'Human') = False Then Begin
www.soldatx.com.br - The brazilian Soldat community.

Offline frosty

  • Flagrunner
  • ****
  • Posts: 601
  • Uber Desert Eagle ^^
Re: ugh! what am i doing wrong here? (shop.pas)
« Reply #3 on: July 04, 2010, 01:01:48 am »
I suggest you to use WriteLn() to find errors.

By any chance, do you update ntPosX and ntPosY each second?

Correct these:

For PlayerID := 1 To 32 Do if GetPlayerStat(PlayerID,'Active') = True Then For i := 1 To 32 Do if GetPlayerStat(i,'Active') = True Then if GetPlayerStat(i,'Human') = False Then Begin

no the ntPosX and ntPosY is only set when the player buys the turret

someone help plz, what would be the correct code using squiddys code, and where exactly should i put the for i := statement to check if the zombies are in range of the bought turret? and what would be the correct code to Store Player XY vals then reget them without regetting the current players XY stats at the time?
 
i am a bit confused

also writeln wont work as my firewall is blocking me from downloading ARSSE dev version and there is NO way to allow it, and the normal arrse version doesnt work propoerly, all lines come up as blank
« Last Edit: July 04, 2010, 01:03:43 am by frosty »
check out my server! click here

If at first you don't succeed, Improvise! :D

Offline Hacktank

  • Camper
  • ***
  • Posts: 462
  • Soldat Scripter
    • HTZRPG
Re: ugh! what am i doing wrong here? (shop.pas)
« Reply #4 on: July 04, 2010, 03:11:23 am »
Wrightline stuff is saved to the log files aswell. Use FTP to get them if your testing on your ec server, otherwise just the log file. Also why don't you just turn your firewall off, they are useless.


Offline frosty

  • Flagrunner
  • ****
  • Posts: 601
  • Uber Desert Eagle ^^
Re: ugh! what am i doing wrong here? (shop.pas)
« Reply #5 on: July 04, 2010, 11:58:23 pm »
OK! new problem, novas are firing fine but are firing way too early, it either fires when ntTimer[PlayerID] = 4 or i go out of detection range, wtf?? and the nuke turret wont rearm */me wonders why the ntfTimer[PlayerID]:=30; is doing nothing, nuke fires /me waits for 2 mins wit no refire with plenty of zombies in range*

also i was using the wrong code section, the novas wouldnt fire because the number of bullets to spawn hadnt of been bought yet(oops), so i fixed it with the set one i had for selfkills

ive just done some more testing, for some reason it will ONLY fire if im in range, but it still only fires once, with no rearm

see attachment

From: July 05, 2010, 01:18:03 pm
bump!

From: July 05, 2010, 10:35:51 pm
Bump! i dont know how to fix this...
« Last Edit: July 05, 2010, 10:35:51 pm by frosty »
check out my server! click here

If at first you don't succeed, Improvise! :D