Author Topic: Mines  (Read 1295 times)

0 Members and 1 Guest are viewing this topic.

Offline Kuba134

  • Major(1)
  • Posts: 6
Mines
« on: June 22, 2009, 02:59:17 am »
   
hey gays.
I am writing a script mine. Everything is ok as long as anybody do not touch mines, then the server turn off  and console server writes
Code: [Select]
Access violation at address 00405037 in module 'soldatserver.exe'. Read of addr
ss C15E7544
script you can see here

http://www.wklej.eu/index.php?id=4e5e2584ea

P.S. Sorry for the mistakes in the text but I am not Englishman
« Last Edit: June 22, 2009, 05:12:10 am by Kuba134 »

Offline Gizd

  • Flagrunner
  • ****
  • Posts: 586
  • (Re)tired
    • Eat-this! community site
Re: Mines
« Reply #1 on: June 22, 2009, 03:15:31 am »
Comment (add // before) 2 of those nova() and see if it works. This function needs many calculations and calling it few times at once may result in access.
Code: [Select]
...
      WriteConsole(0,'Bum!!!!!!!!!',Color);
//      nova(MinesX[j], MinesY[j], 0, 90, 100, 100, 4, 15);
      WriteConsole(0,'Bum!!!!!!!!!',Color)
//    nova(MinesX[j], MinesY[j], 0, 60, 100, 100, 4, 10);
      nova(Minesx[j], MinesY[j], 0, 30, 100, 100, 4, 5);
      end;
...


And I'm not gay...
« Last Edit: June 22, 2009, 03:19:29 am by Gizd »

Offline Kuba134

  • Major(1)
  • Posts: 6
Re: Mines
« Reply #2 on: June 22, 2009, 03:49:59 am »
the same error

Offline Gizd

  • Flagrunner
  • ****
  • Posts: 586
  • (Re)tired
    • Eat-this! community site
Re: Mines
« Reply #3 on: June 22, 2009, 04:57:52 am »
Try to comment some parts of script until error stops appearing.

That part should be somewhere in AppOnIdle or nova.

Offline Kuba134

  • Major(1)
  • Posts: 6
Re: Mines
« Reply #4 on: June 22, 2009, 05:09:49 am »
I commet

   WriteConsole(0,'Bum!!!!!!!!!',Color);
// nova(MinesX[j], MinesY[j], 0, 90, 100, 100, 4, 15);
   WriteConsole(0,'Bum!!!!!!!!!',Color)
// nova(MinesX[j], MinesY[j], 0, 60, 100, 100, 4, 10);
// nova(Minesx[j], MinesY[j], 0, 30, 100, 100, 4, 5);

and is ok

but what I must do to it explosion
« Last Edit: June 22, 2009, 05:16:46 am by Kuba134 »

Offline spkka

  • Camper
  • ***
  • Posts: 469
Re: Mines
« Reply #5 on: June 22, 2009, 05:29:38 am »
Lots of ways, just create explosions near the position of the player? Try using createBullet for that

Offline shantec

  • Soldier
  • **
  • Posts: 140
  • Get ANGREH!!
Re: Mines
« Reply #6 on: June 22, 2009, 05:59:52 am »
I looked at u'r script...
Why do you use "\" in almost every place?

I think those little slash-lines are causing the errors. Remove 'em?
Also Known As REIMA


Lol Happles (happy apples)

Offline JFK

  • Camper
  • ***
  • Posts: 255
    • My TraxInSpace Account
Re: Mines
« Reply #7 on: June 22, 2009, 06:30:13 am »
Don't know if this is the problem, but I'm pretty sure it's wrong:
Code: [Select]
for j:=1 to Mines+1 do
Suppose you have 1 mine, so Mines will be one, then the script will check mine 1 and 2, but 2 doesn't exist yet. As far a I can see this shouldn't matter, as MinesX, MinesY and MinesT on index 2 will just return 0 and not an error, but who knows.
Also it can never hurt to put a 'if getplayerstat(i, 'Active')' before trying to get a player's XY and other stuff (script might just crash on getPlayerXY, if the player doesn't exist).
Also^2 I wonder what you'll do after using 100 mines, I hope you understand the script as it is now will crash then.
Come join: EliteCTF
Listen to: My Music

Offline Kuba134

  • Major(1)
  • Posts: 6
Re: Mines
« Reply #8 on: June 22, 2009, 06:43:09 am »
I found a bug

but now appeared on a different

Code: [Select]
[*] [Error] mines -> (AppOnIdle): Out Of Range

Now the code looks like this

Code: [Select]
const
 Color= $FF0033FF;
 MaxDist=14;
var
 MinesX, MinesY: array[1..100] of single;
 MinesT: array[1..100] of byte;
 Mines: byte;
 MinesP: array[1..100] of byte;
 MinesO: array[1..100] of boolean;

procedure new (ID:byte);
 var
  x1, y1: single;
  begin

 if GetPlayerStat(ID,'kills')>=5 then
  begin
  GetPlayerXY(ID,x1,y1);
  Mines:=Mines+1;
  MinesX[Mines]:=x1;
  MinesY[Mines]:=y1;
  MinesT[Mines]:=GetPlayerStat(ID,'Team');
  MinesP[Mines]:=ID;
  MinesO[Mines]:=True;
  SetScore(ID,GetPlayerStat(ID,'Kills')-5);
  WriteConsole(0,GetPlayerStat(ID,'Name')+' put mine',Color);
 end;
 end;
 procedure nova(const x, y, speed, radius, power: single; id, style: byte; n: integer);
  var i: byte;
      angle: single;
  begin
    angle := 2 * pi / n;
    for i := 0 to n do
      createbullet(x + cos(angle * i) * radius, y + sin(angle * i) * radius, cos(angle * i) * speed, sin(angle * i) * speed, power, style, id);
 end;
function OnPlayerCommand(ID: Byte; Text: string): Boolean;
begin
 if Text='/mine' then
 SetScore(ID,5)
   new(ID);
 end;
procedure AppOnIdle(Ticks: integer);
 var
  i,j: byte;
  dist: Single;

 begin
 
    if Mines<>0 then
    for i:=1 to 16 do begin
    for j:=0 to Mines do begin
if MinesO[j] then
if MinesT[j]<>GetPlayerStat(i,'Team')then
begin
Dist:=Distance(MinesX[j],MinesY[j],GetPlayerStat(i,'X'),GetPlayerStat(i,'Y'));
if Dist <= MaxDist then
begin
nova(MinesX[j], MinesY[j], 0, 90, 100, MinesP[j], 4, 15);
WriteConsole(0,'Bum!!!!!!!!!',Color)
    nova(MinesX[j], MinesY[j], 0, 60, 100, MinesP[j], 4, 10);
    nova(Minesx[j], MinesY[j], 0, 30, 100, MinesP[j], 4, 5);
MinesO[j]:=False;
end;
end;
end;
end;
end;
   
   

Offline JFK

  • Camper
  • ***
  • Posts: 255
    • My TraxInSpace Account
Re: Mines
« Reply #9 on: June 22, 2009, 07:33:50 am »
Code: [Select]
for j:=0 to Mines do begin
Mines*[0] doesn't exist, start with 1 (for i:=1 to 1 do... <- will run once)

Pro tip: ;D
You could create your own variable type for mines:
Code: [Select]
type
T_Mine = record
   X : single;
   Y : single;
   T : byte;
   O : boolean;
end;

//this array is dynamic, use setArrayLength(Mines, x) to change it's size:
Mines : array of T_Mine;

//call like this:
Mines[i].T := 2;
Come join: EliteCTF
Listen to: My Music

Offline Kuba134

  • Major(1)
  • Posts: 6
Re: Mines
« Reply #10 on: June 22, 2009, 07:39:40 am »
thanks

but

setArrayLength
or
getArrayLength
« Last Edit: June 22, 2009, 07:42:53 am by Kuba134 »

Offline JFK

  • Camper
  • ***
  • Posts: 255
    • My TraxInSpace Account
Re: Mines
« Reply #11 on: June 22, 2009, 07:54:07 am »
setArrayLength(arrayname, size) -  will CHANGE the size of an array.
getArrayLength(arrayname) - will RETURN the size of an array.
Code: [Select]
setArrayLength(MyArray, 2); //changes size of MyArray to 2, that means MyArray[0] and MyArray[1] exist now. (NOT MyArray[2]!!)
MySize := getArrayLength(MyArray); //MySize will now be 2 aswell.
Come join: EliteCTF
Listen to: My Music

Offline Kuba134

  • Major(1)
  • Posts: 6
Re: Mines
« Reply #12 on: June 22, 2009, 08:32:33 am »
all is ok this script works  ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D

   
thank you