Author Topic: Suicide Bomber  (Read 667 times)

0 Members and 3 Guests are viewing this topic.

Offline BingBong

  • Major(1)
  • Posts: 12
Suicide Bomber
« on: December 24, 2007, 05:36:44 am »
Hey i was just wondering if this was right and if not please help me :D

Code: [Select]
function GetPlayerStat(ID: byte; Stat: string): Variant
function CreateBullet(X,Y,VelX,VelY,HitM: Single; sStyle, Owner: Byte): integer
function OnPlayerDamage(Victim, Shooter: byte; Damage: integer): integer;

If Team = 1 Then

Begin     
        CreateBullet(Shooter.X+10,Shooter.Y+10,0,1,25,4,Shooter);
        CreateBullet(Shooter.X-10,Shooter.Y+10,0,1,25,4,Shooter);
        CreateBullet(Shooter.X+10,Shooter.Y-10,0,1,25,4,Shooter);
        CreateBullet(Shooter.X-10,Shooter.Y-10,0,1,25,4,Shooter);
End

I dont know whether your allowed to have more than one function in the script so please help.

Offline chrisgbk

  • Moderator
  • Veteran
  • *****
  • Posts: 1739
Re: Suicide Bomber
« Reply #1 on: December 24, 2007, 06:59:52 am »
That's way incorrect.

GetPlayerStat and CreateBullet are already defined in the scripting engine, and you are redefining them.

Code: [Select]
function OnPlayerDamage(Victim, Shooter: byte; Damage: integer): integer;
var
  x, y: single;
begin
  if GetPlayerStat( Shooter, 'Team' ) = 1 then begin
    x := GetPlayerStat( Shooter, 'X' );
    y := GetPlayerStat( Shooter, 'Y' );     
    CreateBullet( x + 10, y + 10, 0, 1, 25, 4, Shooter );
    CreateBullet( x - 10, y + 10, 0, 1, 25, 4, Shooter );
    CreateBullet( x + 10, y - 10, 0, 1, 25, 4, Shooter );
    CreateBullet( x - 10, y - 10, 0, 1, 25, 4, Shooter );
  end;
end;

is more or less correct, but I haven't actually tested it.

Also, yes, you can have more than one function in a file. What I wrote above is one entire function; look in the defaults included with the server for an example of having multiple functions.
« Last Edit: December 24, 2007, 07:04:11 am by chrisgbk »