Author Topic: 2 last script request !  (Read 2705 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
2 last script request !
« on: May 30, 2010, 10:52:43 am »
1-When a player do damage to another that give to him a random number between (1-10) of life
2-bravo team forceweapon SAW

Offline Gizd

  • Flagrunner
  • ****
  • Posts: 586
  • (Re)tired
    • Eat-this! community site
Re: 2 last script request !
« Reply #1 on: May 30, 2010, 12:03:39 pm »
Code: [Select]
function OnPlayerDamage(Victim, Shooter: byte; Damage: integer): integer;
begin
  Result:= Damage;
  DoDamage(Shooter,Random(-10,-1));
end;

procedure OnWeaponChange(ID, PrimaryNum, SecondaryNum: byte);
begin
  if GetPlayerStat(ID,'Team') = 2 then if (PrimaryNum <> 16) and (PrimaryNum <> 255) then ForceWeapon(ID,16,255,0);
end;

Offline mich1103

  • Flagrunner
  • ****
  • Posts: 557
  • Did you say chocolate ? O.o
    • ZoMbIe-DeStRoYeR pk server
Re: 2 last script request !
« Reply #2 on: May 30, 2010, 12:28:49 pm »
 :-\   
Code: [Select]
[Error] (5:35): Invalid number of parameters

DarkCrusade

  • Guest
Re: 2 last script request !
« Reply #3 on: May 30, 2010, 12:30:27 pm »
@mich: Which line is line 5

@gizd:
15 = Chainsaw
16 = LAW

Offline mich1103

  • Flagrunner
  • ****
  • Posts: 557
  • Did you say chocolate ? O.o
    • ZoMbIe-DeStRoYeR pk server
Re: 2 last script request !
« Reply #4 on: May 30, 2010, 12:33:08 pm »
Code: [Select]
function OnPlayerDamage(Victim, Shooter: byte; Damage: integer): integer;
begin
  Result:= Damage;
  DoDamage(Shooter,Random(-10,-1));
end;  //This one ??????????????

procedure OnWeaponChange(ID, PrimaryNum, SecondaryNum: byte);
begin
  if GetPlayerStat(ID,'Team') = 2 then if (PrimaryNum <> 16) and (PrimaryNum <> 255) then ForceWeapon(ID,16,255,0);
end;

« Last Edit: May 30, 2010, 12:36:56 pm by mich1103 »

DarkCrusade

  • Guest
Re: 2 last script request !
« Reply #5 on: May 30, 2010, 12:39:58 pm »
Code: [Select]
function OnPlayerDamage(Victim, Shooter: byte; Damage: integer): integer;
var R:Byte;
begin
  Result:= Damage;
  R := Random(1,11);
  DoDamage(Shooter,-R);
end; 

procedure OnWeaponChange(ID, PrimaryNum, SecondaryNum: byte);
begin
  if GetPlayerStat(ID,'Team') = 2 then if PrimaryNum <> 15
    ForceWeapon(ID,15,255,0);
end;
« Last Edit: May 30, 2010, 12:57:07 pm by DarkCrusade »

Offline mich1103

  • Flagrunner
  • ****
  • Posts: 557
  • Did you say chocolate ? O.o
    • ZoMbIe-DeStRoYeR pk server
Re: 2 last script request !
« Reply #6 on: May 30, 2010, 12:42:49 pm »
[Error] (7:23): Invalid number of parameters
Don't worry be happy  :D  :D

DarkCrusade

  • Guest
Re: 2 last script request !
« Reply #7 on: May 30, 2010, 12:58:18 pm »
Is this little script the only thing you run on the server?

Offline mich1103

  • Flagrunner
  • ****
  • Posts: 557
  • Did you say chocolate ? O.o
    • ZoMbIe-DeStRoYeR pk server
Re: 2 last script request !
« Reply #8 on: May 30, 2010, 01:01:32 pm »
No i use other small script !
My server version is 2.7.0 i dont know if its the problem !

Offline DorkeyDear

  • Veteran
  • *****
  • Posts: 1507
  • I also go by Curt or menturi
Re: 2 last script request !
« Reply #9 on: May 30, 2010, 01:09:18 pm »
I think DoDamageBy replaced the old DoDamage (not 100% certain), so you need a "damage by" parameter in calling the DoDamage function.

EDIT: yup http://enesce.com/help/index.html?Functions/DoDamage.html & @ changelog too it says it.

DarkCrusade

  • Guest
Re: 2 last script request !
« Reply #10 on: May 30, 2010, 01:53:18 pm »
Then use this:

Code: [Select]
Function OnPlayerDamage(Victim, Shooter: byte; Damage: integer): integer;
var R:Byte;
begin
  Result:= Damage;
  R := Random(1,11);
  DoDamage(Shooter,Shooter,-R);
end; 

procedure OnWeaponChange(ID, PrimaryNum, SecondaryNum: byte);
begin
  if GetPlayerStat(ID,'Team') = 2 then if PrimaryNum <> 15
    ForceWeapon(ID,15,255,0);
end;

Also, if you don't want players to get more health than the default amount (150) use this:

Code: [Select]
Function OnPlayerDamage(Victim, Shooter: byte; Damage: integer): integer;
var R:Byte;
begin
  Result:= Damage;
  R := Random(1,11);
  if R + GetPlayerStat(Shooter,'Health') <= 150 then
    DoDamage(Shooter,Shooter,-R);
  else
    DoDamage(Shooter,Shooter,GetPlayerStat(Shooter,'Health') - 150);
end; 

Procedure OnWeaponChange(ID, PrimaryNum, SecondaryNum: byte);
begin
  if GetPlayerStat(ID,'Team') = 2 then if PrimaryNum <> 15
    ForceWeapon(ID,15,255,0);
end;

Offline mich1103

  • Flagrunner
  • ****
  • Posts: 557
  • Did you say chocolate ? O.o
    • ZoMbIe-DeStRoYeR pk server
Re: 2 last script request !
« Reply #11 on: May 30, 2010, 02:44:43 pm »
forceweaponb -> [Error] (13:5): 'THEN' expected

DarkCrusade

  • Guest
Re: 2 last script request !
« Reply #12 on: May 30, 2010, 02:49:11 pm »
Happens if you edit the code of someone else :3

Code: [Select]
Function OnPlayerDamage(Victim, Shooter: byte; Damage: integer): integer;
var R:Byte;
begin
  Result:= Damage;
  R := Random(1,11);
  DoDamage(Shooter,Shooter,-R);
end; 

procedure OnWeaponChange(ID, PrimaryNum, SecondaryNum: byte);
begin
  if GetPlayerStat(ID,'Team') = 2 then if PrimaryNum <> 15 then
    ForceWeapon(ID,15,255,0);
end;

Code: [Select]
Function OnPlayerDamage(Victim, Shooter: byte; Damage: integer): integer;
var R:Byte;
begin
  Result:= Damage;
  R := Random(1,11);
  if R + GetPlayerStat(Shooter,'Health') <= 150 then
    DoDamage(Shooter,Shooter,-R);
  else
    DoDamage(Shooter,Shooter,GetPlayerStat(Shooter,'Health') - 150);
end; 

Procedure OnWeaponChange(ID, PrimaryNum, SecondaryNum: byte);
begin
  if GetPlayerStat(ID,'Team') = 2 then if PrimaryNum <> 15 then
    ForceWeapon(ID,15,255,0);
end;

Offline mich1103

  • Flagrunner
  • ****
  • Posts: 557
  • Did you say chocolate ? O.o
    • ZoMbIe-DeStRoYeR pk server
Re: 2 last script request !
« Reply #13 on: May 30, 2010, 04:57:16 pm »
Code: [Select]
forceweaponb -> [Error] (9:3): Identifier expectedI use this one
Code: [Select]
Function OnPlayerDamage(Victim, Shooter: byte; Damage: integer): integer;
var R:Byte;
begin
  Result:= Damage;
  R := Random(1,11);
  if R + GetPlayerStat(Shooter,'Health') <= 150 then
    DoDamage(Shooter,Shooter,-R);
  else
    DoDamage(Shooter,Shooter,GetPlayerStat(Shooter,'Health') - 150);
end; 

Procedure OnWeaponChange(ID, PrimaryNum, SecondaryNum: byte);
begin
  if GetPlayerStat(ID,'Team') = 2 then if PrimaryNum <> 15 then
    ForceWeapon(ID,15,255,0);
end;

Offline Silnikos

  • Soldier
  • **
  • Posts: 129
Re: 2 last script request !
« Reply #14 on: May 31, 2010, 03:42:29 am »
there you go:
Code: [Select]
Function OnPlayerDamage(Victim, Shooter: byte; Damage: integer): integer;
var R:Byte;
begin
  Result:= Damage;
  R := Random(1,11);
  if R + GetPlayerStat(Shooter,'Health') <= 150 then
    DoDamage(Shooter,Shooter,-R)
  else
    DoDamage(Shooter,Shooter,GetPlayerStat(Shooter,'Health') - 150);
end;

Procedure OnWeaponChange(ID, PrimaryNum, SecondaryNum: byte);
begin
  if GetPlayerStat(ID,'Team') = 2 then if PrimaryNum <> 15 then
    ForceWeapon(ID,15,255,0);
end;

Offline Gizd

  • Flagrunner
  • ****
  • Posts: 586
  • (Re)tired
    • Eat-this! community site
Re: 2 last script request !
« Reply #15 on: May 31, 2010, 12:22:53 pm »
You should've said it's 2.7.0...

Code: [Select]
function OnPlayerDamage(Victim, Shooter: byte; Damage: integer; Weapon: byte): integer;
begin
  Result:= Damage;
  DoDamage(Shooter,Shooter,Random(-10,-1));
end;

procedure OnWeaponChange(ID, PrimaryNum, SecondaryNum: byte);
begin
  if GetPlayerStat(ID,'Team') = 2 then if (PrimaryNum <> 15) and (PrimaryNum <> 255) then ForceWeapon(ID,15,255,0);
end;

Offline mich1103

  • Flagrunner
  • ****
  • Posts: 557
  • Did you say chocolate ? O.o
    • ZoMbIe-DeStRoYeR pk server
Re: 2 last script request !
« Reply #16 on: May 31, 2010, 04:20:22 pm »
when i got hit my server freeze and shutdown and dont right any logs
that happen because i add the Gizd script !

Offline Swompie

  • Camper
  • ***
  • Posts: 390
Re: 2 last script request !
« Reply #17 on: May 31, 2010, 04:44:05 pm »
1. What server version do you use?
2. Do you add bots when the server starts?

Offline mich1103

  • Flagrunner
  • ****
  • Posts: 557
  • Did you say chocolate ? O.o
    • ZoMbIe-DeStRoYeR pk server
Re: 2 last script request !
« Reply #18 on: May 31, 2010, 05:26:39 pm »
yea i add bot on server start and my server version is 2.7.0

Offline Swompie

  • Camper
  • ***
  • Posts: 390
Re: 2 last script request !
« Reply #19 on: June 01, 2010, 04:21:59 am »
There's the problem, adding bots right on ActivateServer will fuck off OnWeaponChange();
If you give a list of the stuff you want to have in your server I can maybe make it for you without that all these little script cause damn crashes...

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