Author Topic: 2 last script request !  (Read 2812 times)

0 Members and 1 Guest are viewing this topic.

Offline mich1103

  • Flagrunner
  • ****
  • Posts: 557
  • Did you say chocolate ? O.o
    • ZoMbIe-DeStRoYeR pk server
Re: 2 last script request !
« Reply #20 on: June 01, 2010, 05:53:52 pm »
1-I want that when a player hit a other player that heal it from 10 to 20 (random)
2-Auto add 18 boogie man on activate server
3-forceweapon (SAW) if name is boogie man

Offline Hacktank

  • Camper
  • ***
  • Posts: 462
  • Soldat Scripter
    • HTZRPG
Re: 2 last script request !
« Reply #21 on: June 01, 2010, 06:54:15 pm »
Code: [Select]
procedure AppOnIdle(Ticks: integer);
var i: byte;
begin
for i := 1 to 18 do if (getplayerstat(i,'active')=false) OR (lowercase(getplayerstat(i,'name')) <> 'boogie man') then begin
kickplayer(i);
command('/addbot2 Boogie Man');
end;
end;

function OnPlayerDamage(Victim,Shooter: Byte;Damage: Integer) : integer;
begin
if shooter <> victim then dodamage(shooter,-random(10,21));
end;

procedure OnWeaponChange(ID, PrimaryNum, SecondaryNum: Byte);
begin;
if getplayerstat(ID,'human') = false then if id <= 18 then if primarynum <> 15 then forceweapon(ID,15,secondarynum,0)
end;
Untested, but it should work. Barring possible problems with scriptcore version if your not using the current nonbeta release.

This also keeps people from being able to kick the bots too (well readds them if their kicked).


Offline Swompie

  • Camper
  • ***
  • Posts: 390
Re: 2 last script request !
« Reply #22 on: June 02, 2010, 03:24:03 am »
Blargh.. HT.. no Result in OnPlayerDamage()

Here you go mich, if you want more things added ask here again.

Code: [Select]
const
   num_boogies = 18; // amount of bots that will be added

var
   Saw: Array [1..32] of boolean;
   loadserver: integer;

procedure load;
var i, temp: byte;
begin
  for i := 1 to 32 do
    Saw[i] := false;
  for i := 1 to num_boogies do begin
    Temp := Command('/addbot2 Boogie Man');
    if Temp > 0 then
      Saw[Temp] := true;
  end;
  WriteLn('Bots added!');
end;

procedure ActivateServer;
begin
  loadserver := 1;
end;

procedure AppOnIdle(Ticks: integer);
begin
  if loadserver > 0 then begin
    loadserver := loadserver - 1;
    if loadserver = 0 then
      load;
  end;
end;

function OnPlayerDamage(Victim, Shooter: byte; Damage: integer): integer;
begin
  Result := Damage;

  if Victim <> Shooter then
    DoDamage(Shooter, -Random(10, 21));
end;

procedure OnWeaponChange(ID, PrimaryNum, SecondaryNum: Byte);
begin
  if (Saw[ID]) and (PrimaryNum <> 15) then
    ForceWeapon(ID, 15, 255, 255);
end;

procedure OnLeaveGame(ID, Team: byte; Kicked: boolean);
var Temp: byte;
begin
  if (Saw[ID]) and (Kicked) then begin
    Saw[ID] := false;
    Temp := Command('/addbot2 Boogie Man');
    Saw[Temp] := true;
  end;
end;

Offline mich1103

  • Flagrunner
  • ****
  • Posts: 557
  • Did you say chocolate ? O.o
    • ZoMbIe-DeStRoYeR pk server
Re: 2 last script request !
« Reply #23 on: June 02, 2010, 05:49:32 am »
Code: [Select]
forceweaponb -> [Error] (41:39): Invalid number of parameters :'(  :'(

Offline Swompie

  • Camper
  • ***
  • Posts: 390
Re: 2 last script request !
« Reply #24 on: June 02, 2010, 06:12:17 am »
Meh, my fault, forgot that you use v270.
Code: [Select]
const
   num_boogies = 18; // amount of bots that will be added

var
   Saw: Array [1..32] of boolean;
   loadserver: integer;

procedure load;
var i, temp: byte;
begin
  for i := 1 to 32 do
    Saw[i] := false;
  for i := 1 to num_boogies do begin
    Temp := Command('/addbot2 Boogie Man');
    if Temp > 0 then
      Saw[Temp] := true;
  end;
  WriteLn('Bots added!');
end;

procedure ActivateServer;
begin
  loadserver := 1;
end;

procedure AppOnIdle(Ticks: integer);
begin
  if loadserver > 0 then begin
    loadserver := loadserver - 1;
    if loadserver = 0 then
      load;
  end;
end;

function OnPlayerDamage(Victim, Shooter: byte; Damage: integer): integer;
begin
  Result := Damage;

  if Victim <> Shooter then
    DoDamage(Shooter, Shooter, -Random(10, 21));
end;

procedure OnWeaponChange(ID, PrimaryNum, SecondaryNum: Byte);
begin
  if (Saw[ID]) and (PrimaryNum <> 15) then
    ForceWeapon(ID, 15, 255, 255);
end;

procedure OnLeaveGame(ID, Team: byte; Kicked: boolean);
var Temp: byte;
begin
  if (Saw[ID]) and (Kicked) then begin
    Saw[ID] := false;
    Temp := Command('/addbot2 Boogie Man');
    Saw[Temp] := true;
  end;
end;
Should work now.

Offline mich1103

  • Flagrunner
  • ****
  • Posts: 557
  • Did you say chocolate ? O.o
    • ZoMbIe-DeStRoYeR pk server
Re: 2 last script request !
« Reply #25 on: June 02, 2010, 04:39:54 pm »
Hmmmm work but no healing....
Maybe you can try with SetPlayerStat !

Offline Hacktank

  • Camper
  • ***
  • Posts: 462
  • Soldat Scripter
    • HTZRPG
Re: 2 last script request !
« Reply #26 on: June 02, 2010, 07:08:00 pm »
Code: [Select]
procedure AppOnIdle(Ticks: integer);
var i: byte;
begin
for i := 1 to 18 do if (getplayerstat(i,'active')=false) OR (lowercase(getplayerstat(i,'name')) <> 'boogie man') then begin
kickplayer(i);
command('/addbot2 Boogie Man');
end;
end;

function OnPlayerDamage(Victim,Shooter: Byte;Damage: Integer) : integer;
begin
result := damage;
if shooter <> victim then dodamage(shooter,-random(10,21));
end;

procedure OnWeaponChange(ID, PrimaryNum, SecondaryNum: Byte);
begin;
if getplayerstat(ID,'human') = false then if id <= 18 then if primarynum <> 15 then forceweapon(ID,15,secondarynum,0);
end;

procedure OnPlayerRespawn(ID: Byte);
begin
if id <= 18 then forceweapon(ID,15,15,0);
end;

I dont understand why you want to overcomplicate it with unneeded variables. The 18 bots will always occupy ids 1 - 18, so there is no need for a dedicated saw variable.


Offline Swompie

  • Camper
  • ***
  • Posts: 390
Re: 2 last script request !
« Reply #27 on: June 03, 2010, 05:44:05 am »
@Mich: Do you use other scripts too, that may could cause this problem..



@HT: Well, you're doing very different things that much here wouldn't do, like checking ID, ect.
Also ├Żou check in AppOnIdle all the time if there's a wrong player/bot, which isn't needed since you can just do that in OnLeaveGame(), checking ID's ect in OnWeaponChange is also not needed, that's why I've just decided to use an array of boolean, which is way faster than always using GetPlayerStat's over half the script. This may not be a big problem in small scripts, but in bigger it is.
Oh yeah, I like to tell that people D= (Actually I'm sure you know it already, but yeah, you've got a way different way to script than most people here I noticed)

Offline mich1103

  • Flagrunner
  • ****
  • Posts: 557
  • Did you say chocolate ? O.o
    • ZoMbIe-DeStRoYeR pk server
Re: 2 last script request !
« Reply #28 on: June 03, 2010, 06:16:06 am »
i use Damage Display , Weapon box and your script

Offline Swompie

  • Camper
  • ***
  • Posts: 390
Re: 2 last script request !
« Reply #29 on: June 03, 2010, 08:44:11 am »
Replace that:
Code: [Select]
function OnPlayerDamage(Victim, Shooter: byte; Damage: integer): integer;With that:
Code: [Select]
function OnPlayerDamage(Victim, Shooter: byte; Damage: integer; Weapon: byte): integer;
« Last Edit: June 04, 2010, 03:13:45 am by Swompie »

Offline mich1103

  • Flagrunner
  • ****
  • Posts: 557
  • Did you say chocolate ? O.o
    • ZoMbIe-DeStRoYeR pk server
Re: 2 last script request !
« Reply #30 on: June 03, 2010, 04:31:56 pm »
Thats work !!! thanks  ;D