Official Soldat Forums

Server Talk => Scripting Discussions and Help => Topic started by: y0uRd34th on December 23, 2008, 06:20:16 am

Title: Need Help in Scripting
Post by: y0uRd34th on December 23, 2008, 06:20:16 am
Frist Hi :)

How can i connect this "Example" Script that it works?
Always if I start my Server it crashes and I don't know whats wrong there:

Code: [Select]
procedure OnPlayerSpeak(ID: Byte; Text: string);
begin
     if Text = '!kill' then begin
     DoDamage(ID,4000);
end;
end;
begin
     if Text = '!heal' then begin
     DoDamage(ID,-4000);
end;
end;

If i delete the second Part with  !heal it works fine but when i add it... nothing works!
Title: Re: Need Help in Scripting
Post by: Toumaz on December 23, 2008, 06:57:45 am
There's one "end;" in there that's a bit misplaced:

Code: [Select]
procedure OnPlayerSpeak(ID: Byte; Text: string);
begin
     if Text = '!kill' then begin
          DoDamage(ID,4000);
     end;

     if Text = '!heal' then begin
          DoDamage(ID,-4000);
     end;
end;
Title: Re: Need Help in Scripting
Post by: y0uRd34th on December 23, 2008, 07:01:46 am
Ahh Fine :) thank you and another Question how can i do this Code Thing with the Script in it?
Title: Re: Need Help in Scripting
Post by: iDante on December 23, 2008, 07:17:59 am
Ahh Fine :) thank you and another Question how can i do this Code Thing with the Script in it?
You're going to need to be a bit more specific here...
If you just want to know how to install a script: http://forums.soldat.pl/index.php?topic=21468.0 is your best guide.
Title: Re: Need Help in Scripting
Post by: y0uRd34th on December 23, 2008, 08:08:57 am
I know how to Install Scripts! But i dont know how to do some Scripting things and so...
And now my Server is 9999PING too omfg! Now im at the End of My Live^^
Title: Re: Need Help in Scripting
Post by: Toumaz on December 23, 2008, 08:18:30 am
And now my Server is 9999PING too omfg! Now im at the End of My Live^^

http://forums.soldat.pl/index.php?topic=21869.0
Title: Re: Need Help in Scripting
Post by: y0uRd34th on December 23, 2008, 08:39:11 am
Yes i know but the Problem is that sometimes work :/ and sometimes not :P and i get always another IP to join in Soldat by the Server xD

EDIT:
CreateBullet(GetPlayerStat(1,'x'), GetPlayerStat(1,'y') - 500, 0, 0,100, 2, 1);
function CreateBullet(X, Y, VelX, VelY, HitM: single; sStyle, Owner: byte): integer;

GetPlayerStat(1,'x'), GetPlayerStat(1,'y') this is X, Y?
And What do HitM (Single): Hit Multiplier??
velX and VelY is the Position of the bullet where it spawns right?

Ok Edit again^^

Code: [Select]
function OnPlayerCommand(ID: Byte; Text: string): boolean;
begin
     if Text = '/fireshield' then begin
          CreateBullet(GetPlayerStat(ID,'x'), GetPlayerStat(ID,'y') 65, 0, 0,100, 5, 1);
          CreateBullet(GetPlayerStat(ID,'x'), GetPlayerStat(ID,'y') - 65, 0, 0,100, 5, 1);
          CreateBullet(GetPlayerStat(ID,'x'), GetPlayerStat(ID,'y') 0, - 65, 0,100, 5, 1);
          CreateBullet(GetPlayerStat(ID,'x'), GetPlayerStat(ID,'y') 0, 65, 0,100, 5, 1);
     end;
end;

what's wrong now? :P
Title: Re: Need Help in Scripting
Post by: SpiltCoffee on December 23, 2008, 08:18:07 pm
Code: [Select]
          CreateBullet(GetPlayerStat(ID,'x'), GetPlayerStat(ID,'y'), 65, 0, 100, 5, 1);
          CreateBullet(GetPlayerStat(ID,'x'), GetPlayerStat(ID,'y'), - 65, 0, 100, 5, 1);
          CreateBullet(GetPlayerStat(ID,'x'), GetPlayerStat(ID,'y'), 0, - 65, 100, 5, 1);
          CreateBullet(GetPlayerStat(ID,'x'), GetPlayerStat(ID,'y'), 0, 65, 100, 5, 1);
Try that. You were missing commas after "GetPlayerStat(ID,'y')" on each line, and you also had too many arguments then if that was fixed up. It should work as intended now.

Be cautious of syntax errors. Also, it's worth checking what error the compiler gives you, as it's usually pretty precise in what needs to be fixed up.

p.s. I noticed your error seems to have come about from copying the example. I'm going to quote what iDante said in another thread.

Don't trust any of the examples on that page, figure them out yourself. Same goes for any of those functions really.

:P
Title: Re: Need Help in Scripting
Post by: y0uRd34th on December 24, 2008, 05:12:44 am
Thanks again. How can i add to this /heal script that i can write ID's which i want to heal like /heal 4 for Player4  ??? i'm not sure but i think that is some with get Piece or so :P can u say me how?
Code: [Select]
     if Text = '/heal' then begin
          DoDamage(ID,-4000);
     end;
Title: Re: Need Help in Scripting
Post by: iDante on December 24, 2008, 05:25:28 am
Thanks again. How can i add to this /heal script that i can write ID's which i want to heal like /heal 4 for Player4  ??? i'm not sure but i think that is some with get Piece or so :P can u say me how?
Code: [Select]
     if Text = '/heal' then begin
          DoDamage(ID,-4000);
     end;
Code: [Select]
     if GetPiece(Text,' ',0) = '/heal' then begin
          DoDamage(strtoint(GetPiece(Text,' ',1)),-4000);
     end;
UNTESTED
Title: Re: Need Help in Scripting
Post by: y0uRd34th on December 24, 2008, 05:50:25 am
I realy "love" the People in this Forum  ;D Thanks iDante, works great =)
But next Question if i do "porecedure OnPlayerCommand" or "OnCommand" the other Commandos like "/kill" or "/addbot" not work, do someone know how i can correct this ???
Title: Re: Need Help in Scripting
Post by: tk on December 24, 2008, 08:00:07 am
Did you put result := true inside? If you did, change it to false.
Title: Re: Need Help in Scripting
Post by: y0uRd34th on December 24, 2008, 08:34:13 am
I don't have any result := true in it should i add it with false?
Title: Re: Need Help in Scripting
Post by: Toumaz on December 24, 2008, 08:41:46 am
I don't have any result := true in it should i add it with false?
Yes, give that a shot.
Title: Re: Need Help in Scripting
Post by: y0uRd34th on December 24, 2008, 08:48:20 am
Code: [Select]
procedure OnPlayerCommand(ID: Byte; Text: string);
begin
     if GetPiece(Text,' ',0) = '/heal' then begin
          DoDamage(strtoint(GetPiece(Text,' ',1)),-4000);
     end;

     if Text = '/boom' then begin
          DoDamage(ID,5000)
          CreateBullet(GetPlayerStat(ID,'x'), GetPlayerStat(ID,'y'), 6, 0, 100, 4, 0);
          CreateBullet(GetPlayerStat(ID,'x'), GetPlayerStat(ID,'y'), - 6, 0, 100, 4, 0);
          CreateBullet(GetPlayerStat(ID,'x'), GetPlayerStat(ID,'y'), 0, - 6, 100, 4, 0);
          CreateBullet(GetPlayerStat(ID,'x'), GetPlayerStat(ID,'y'), 0, 6, 100, 4, 0);
          CreateBullet(GetPlayerStat(ID,'x'), GetPlayerStat(ID,'y'), 6, 6, 100, 4, 0);
          CreateBullet(GetPlayerStat(ID,'x'), GetPlayerStat(ID,'y'), - 6, - 6, 100, 4, 0);
          CreateBullet(GetPlayerStat(ID,'x'), GetPlayerStat(ID,'y'), 6, - 6, 100, 4, 0);
          CreateBullet(GetPlayerStat(ID,'x'), GetPlayerStat(ID,'y'), - 6, 6, 100, 4, 0);
          CreateBullet(GetPlayerStat(ID,'x'), GetPlayerStat(ID,'y'), 3, 6, 100, 4, 1);
          CreateBullet(GetPlayerStat(ID,'x'), GetPlayerStat(ID,'y'), - 3, -6, 100, 4, 0);
          CreateBullet(GetPlayerStat(ID,'x'), GetPlayerStat(ID,'y'), 3, - 6, 100, 4, 0);
          CreateBullet(GetPlayerStat(ID,'x'), GetPlayerStat(ID,'y'), - 3, 6, 100, 4, 0);
          CreateBullet(GetPlayerStat(ID,'x'), GetPlayerStat(ID,'y'), 6, 3, 100, 4, 1);
          CreateBullet(GetPlayerStat(ID,'x'), GetPlayerStat(ID,'y'), - 6, -3, 100, 4, 0);
          CreateBullet(GetPlayerStat(ID,'x'), GetPlayerStat(ID,'y'), 6, - 3, 100, 4, 0);
          CreateBullet(GetPlayerStat(ID,'x'), GetPlayerStat(ID,'y'), - 6, 3, 100, 4, 0);
     end;
end;

Where have i to put it? If i put it before the last "end;" it works not ???
Title: Re: Need Help in Scripting
Post by: Toumaz on December 24, 2008, 08:51:56 am
Code: [Select]
procedure OnPlayerCommand(ID: Byte; Text: string);
begin
     if GetPiece(Text,' ',0) = '/heal' then begin
          DoDamage(strtoint(GetPiece(Text,' ',1)),-4000);
     end;

     if Text = '/boom' then begin
          DoDamage(ID,5000)
          CreateBullet(GetPlayerStat(ID,'x'), GetPlayerStat(ID,'y'), 6, 0, 100, 4, 0);
          CreateBullet(GetPlayerStat(ID,'x'), GetPlayerStat(ID,'y'), - 6, 0, 100, 4, 0);
          CreateBullet(GetPlayerStat(ID,'x'), GetPlayerStat(ID,'y'), 0, - 6, 100, 4, 0);
          CreateBullet(GetPlayerStat(ID,'x'), GetPlayerStat(ID,'y'), 0, 6, 100, 4, 0);
          CreateBullet(GetPlayerStat(ID,'x'), GetPlayerStat(ID,'y'), 6, 6, 100, 4, 0);
          CreateBullet(GetPlayerStat(ID,'x'), GetPlayerStat(ID,'y'), - 6, - 6, 100, 4, 0);
          CreateBullet(GetPlayerStat(ID,'x'), GetPlayerStat(ID,'y'), 6, - 6, 100, 4, 0);
          CreateBullet(GetPlayerStat(ID,'x'), GetPlayerStat(ID,'y'), - 6, 6, 100, 4, 0);
          CreateBullet(GetPlayerStat(ID,'x'), GetPlayerStat(ID,'y'), 3, 6, 100, 4, 1);
          CreateBullet(GetPlayerStat(ID,'x'), GetPlayerStat(ID,'y'), - 3, -6, 100, 4, 0);
          CreateBullet(GetPlayerStat(ID,'x'), GetPlayerStat(ID,'y'), 3, - 6, 100, 4, 0);
          CreateBullet(GetPlayerStat(ID,'x'), GetPlayerStat(ID,'y'), - 3, 6, 100, 4, 0);
          CreateBullet(GetPlayerStat(ID,'x'), GetPlayerStat(ID,'y'), 6, 3, 100, 4, 1);
          CreateBullet(GetPlayerStat(ID,'x'), GetPlayerStat(ID,'y'), - 6, -3, 100, 4, 0);
          CreateBullet(GetPlayerStat(ID,'x'), GetPlayerStat(ID,'y'), 6, - 3, 100, 4, 0);
          CreateBullet(GetPlayerStat(ID,'x'), GetPlayerStat(ID,'y'), - 6, 3, 100, 4, 0);
     end;
     result := false;
end;

Or at very top, right after begin;. Whatever floats your boat!
Title: Re: Need Help in Scripting
Post by: y0uRd34th on December 24, 2008, 09:11:05 am
[ERROR] (27:6): Unknown identifier 'result'
:( What's now worng?
Title: Re: Need Help in Scripting
Post by: Toumaz on December 24, 2008, 09:35:56 am
Oh, I see - you've somehow declared OnPlayerCommand as a procedure, and not a function. Sorry for not spotting that off the bat.

I.e, change:
Code: [Select]
procedure OnPlayerCommand(ID: Byte; Text: string);Into:
Code: [Select]
function OnPlayerCommand(ID: Byte; Text: string): boolean;
Title: Re: Need Help in Scripting
Post by: y0uRd34th on December 24, 2008, 10:20:07 am
Thank you, =) it works fine  :D
How can i do that if the "playername=xxx" is right that he gets every 20seconds an bsk ???
So much i have :P
Code: [Select]
procedure AppOnIdle(Ticks: integer);
begin
     if Ticks mod (60 * 20) = 0 then begin
          if ?playername?
               givebonus(?,2);
          end;
     end;
end;
Title: Re: Need Help in Scripting
Post by: CurryWurst on December 25, 2008, 01:36:21 pm
Code: [Select]
procedure AppOnIdle(Ticks: integer);
var
  i: integer;
  X, Y: single;
begin
  if (Ticks mod (60 * 20) = 0) then
  begin
    for i:= 1 to 32 do
    begin
      if (IDToName(i) = 'xxx') then
      begin
        GetPlayerXY(i, X, Y);
        SpawnObject(X, Y, 21);
      end;
    end;
  end;
end;

Have fun!
Title: Re: Need Help in Scripting
Post by: GSx_Major on December 25, 2008, 03:28:52 pm
Code: [Select]
procedure AppOnIdle(Ticks: Integer);
var i: Byte;
begin
  if Ticks mod (60 * 20) = 0 then
    for i := 1 to 32 do
      if GetPlayerStat(i, 'Active') = true then
        if GetPlayerStat(i, 'Name') = 'xxx' then
          SpawnObject(GetPlayerStat(i, 'X'), GetPlayerStat(i, 'Y'), 21);
end;
Another way to do it. Either way you go with, make sure you check that the player is active.
Title: Re: Need Help in Scripting
Post by: tk on December 25, 2008, 03:37:39 pm
The best way to do it is using givebonus(id,style).
style:
  pred: 1
  bers: 2
  vest: 3
  nade: 4
  cluster: 5
Code: [Select]
procedure AppOnIdle(Ticks: Integer);
var i: Byte;
begin
  if Ticks mod (60 * 20) = 0 then
    for i := 1 to 32 do
      if GetPlayerStat(i, 'Active') then
        if IDToName(i) = 'xxx' then
          GiveBonus(i,2);
end;
Title: Re: Need Help in Scripting
Post by: y0uRd34th on December 26, 2008, 04:16:45 am
Oh wow so much exaamples:P :D Thanks again :)
And do someone have an MoneySystem or so? You don't must write the script but if u have one plz Post  ;)
Title: Re: Need Help in Scripting
Post by: CurryWurst on December 26, 2008, 05:43:22 am
The best way to do it is using givebonus(id,style).
style:
  pred: 1
  bers: 2
  vest: 3
  nade: 4
  cluster: 5
Code: [Select]
procedure AppOnIdle(Ticks: Integer);
var i: Byte;
begin
  if Ticks mod (60 * 20) = 0 then
    for i := 1 to 32 do
      if GetPlayerStat(i, 'Active') then
        if IDToName(i) = 'xxx' then
          GiveBonus(i,2);
end;

Hmm, never saw that GiveBonus() function on enesce.com/help/ before, just wondering :)
Title: Re: Need Help in Scripting
Post by: y0uRd34th on December 26, 2008, 06:44:06 am
Do no guy have an "Money System"  ???
Title: Re: Need Help in Scripting
Post by: iDante on December 26, 2008, 07:09:10 am
Hmm, never saw that GiveBonus() function on enesce.com/help/ before, just wondering :)
Don't trust that website until it gets fixed.
For more functions look at the soldat devs wiki (google it) as well as the to do list on that wiki.
Title: Re: Need Help in Scripting
Post by: y0uRd34th on December 26, 2008, 07:52:44 am
Code: [Select]
procedure ActivateServer();
var
   bsk: boolean;
begin
     bsk:=false;
     WriteLn('Berserker Off');
end;

procedure AppOnIdle(Ticks: Integer);
var
   i: Byte;
   bsk: boolean;
begin
  if Ticks mod (60 * 10) = 0 then
    for i := 1 to 32 do
       if bsk=true then
         if GetPlayerStat(i, 'Active') then
           if IDToName(i) = '-=]SH[=- y0uRd34th' then
             GiveBonus(i,2);
end;

procedure OnPlayerRespawn(ID: byte);
var
   i: Byte;
   bsk: boolean;
begin
    for i := 1 to 32 do
      if bsk=true then
        if GetPlayerStat(i, 'Active') then
          if IDToName(i) = '-=]SH[=- y0uRd34th' then
            GiveBonus(i,2);
end;

function OnPlayerCommand(ID: Byte; Text: string): boolean;
var
   bsk: boolean;
begin
     if Text = '/bsk' then begin
  if bsk=false then begin
       bsk:=true;
               WriteLn('Berserker On');
       end
       else
       begin
       bsk:=false;
               WriteLn('Berserker Off');
  end;
     end;
     Result := false;
end;

Idk why but it won't work, the Server starts but the Script won't work right!? ???
Title: Re: Need Help in Scripting
Post by: iDante on December 26, 2008, 07:59:03 am
Just from first impressions: make bsk global.
Title: Re: Need Help in Scripting
Post by: y0uRd34th on December 26, 2008, 08:05:38 am
What do u mean with "global"?
Title: Re: Need Help in Scripting
Post by: spkka on December 26, 2008, 08:10:15 am
then you put it above the functions/procedures so the variable will count for each and every function/procedure.
What you do now is make bsk a variable in procedure activate server and another one in procedure apponidle.
They are both different from eachother and not the same variable.
Hope this helps spkka
Title: Re: Need Help in Scripting
Post by: y0uRd34th on December 26, 2008, 08:43:05 am
Code: [Select]
var
   bsk: boolean;
procedure ActivateServer();
begin
     bsk:=false;
     WriteLn('Berserker Off');
end;

procedure AppOnIdle(Ticks: Integer);
var
   i: Byte;
begin
  if Ticks mod (60 * 10) = 0 then
    for i := 1 to 32 do
       if bsk=true then
         if GetPlayerStat(i, 'Active') then
           if IDToName(i) = '-=]SH[=- y0uRd34th' then
             GiveBonus(i,2);
end;

procedure OnPlayerRespawn(ID: byte);
var
   i: Byte;
begin
    for i := 1 to 32 do
      if bsk=true then
        if GetPlayerStat(i, 'Active') then
          if IDToName(i) = '-=]SH[=- y0uRd34th' then
            GiveBonus(i,2);
end;

function OnPlayerCommand(ID: Byte; Text: string): boolean;
begin
     if Text = '/bsk' then begin
     if bsk=false then begin
          bsk:=true;
               WriteLn('Berserker On');
          end
          else
          begin
          bsk:=false;
               WriteLn('Berserker Off');
     end;
     end;
     Result := false;
end;

So? :P
Title: Re: Need Help in Scripting
Post by: y0uRd34th on December 26, 2008, 09:16:01 am
Code: [Select]
var
   bsk: boolean;
   pre: boolean;
procedure ActivateServer();
begin
     bsk:=false;
     pre:=false;
end;

procedure AppOnIdle(Ticks: Integer);
var
   i: Byte;
begin
  if Ticks mod (60 * 10) = 0 then
    for i := 1 to 32 do
       if bsk=true then
         if GetPlayerStat(i, 'Active') then
           if IDToName(i) = '-=]SH[=- y0uRd34th' then
             GiveBonus(i,2);
begin
  if Ticks mod (60 * 20) = 0 then
    for i := 1 to 32 do
       if pre=true then
         if GetPlayerStat(i, 'Active') then
           if IDToName(i) = '-=]SH[=- y0uRd34th' then
             GiveBonus(i,1);
end;

procedure OnPlayerRespawn(ID: byte);
var
   i: Byte;
begin
    for i := 1 to 32 do
      if bsk=true then
        if GetPlayerStat(i, 'Active') then
          if IDToName(i) = '-=]SH[=- y0uRd34th' then
            GiveBonus(i,2);
begin
    for i := 1 to 32 do
      if pre=true then
        if GetPlayerStat(i, 'Active') then
          if IDToName(i) = '-=]SH[=- y0uRd34th' then
            GiveBonus(i,1);
end;

function OnPlayerCommand(ID: Byte; Text: string): boolean;
begin
     if Text = '/bsk' then begin
          if bsk=false then begin
               bsk:=true;
               end
               else
               begin
               bsk:=false;
          end;
     end;
begin
     if Text = '/pre' then begin
          if pre=false then begin
               pre:=true;
               end
               else
               begin
               pre:=false;
          end;
     end;
     Result := false;
end;

Now i added the same with Predator but it only says Error (30:1) line30 but what means the 1??
Title: Re: Need Help in Scripting
Post by: iDante on December 26, 2008, 09:21:47 am
Responding the the non-predator thing:

A couple stylistic things, because I don't want to go in-depth right now.
1. =true
Code: [Select]
if bsk=true then ...;
if bsk=false then ...;
Are very horrid and evil. Use this instead:
Code: [Select]
if bsk then ...;
if not bsk then ...;

2. for loop then boolean check?
Code: [Select]
for i := 1 to 32 do
   if bsk=true then ...;
You do this several times. First check 1 (get rid of =true), then move the boolean outside of the for loop. Will look like this.
Code: [Select]
if bsk then
   for i := 1 to 32 do ...;

3. Dealio with GetPlayerStat(i, 'active'). Unfortunately, for this one you have to add in = true, or it doesn't work out right.

And the 1 in the predator thing means that it is on column one in the line, or character 1.
Edit: comon man... copy-paste and programming can lead to bad things if you're not careful. Notice the extra begin in AppOnIdle? And just about everywhere? If your compiler gives you an error, LOOK FOR IT.
Title: Re: Need Help in Scripting
Post by: tk on December 26, 2008, 02:28:15 pm
Quote
3. Dealio with GetPlayerStat(i, 'active'). Unfortunately, for this one you have to add in = true, or it doesn't work out right.

GetPlayerStat(id,'active') works without = true.
You have to add = true to GetPlayerStat(id,'alive').
Title: Re: Need Help in Scripting
Post by: y0uRd34th on December 26, 2008, 02:45:04 pm
Code: [Select]
var
   bsk: boolean;
   pre: boolean;
procedure ActivateServer();
begin
     not bsk;
     not pre;
end;

procedure AppOnIdle(Ticks: Integer);
var
   i: Byte;
begin
  if Ticks mod (60 * 10) = 0 then
    for i := 1 to 32 do
       if bsk then
         if GetPlayerStat(i, 'Alive') then
           if IDToName(i) = '-=]SH[=- y0uRd34th' then
             GiveBonus(i,2);
begin
  if Ticks mod (60 * 20) = 0 then
    for i := 1 to 32 do
       if pre then
         if GetPlayerStat(i, 'Alive') then
           if IDToName(i) = '-=]SH[=- y0uRd34th' then
             GiveBonus(i,1);
end;

procedure OnPlayerRespawn(ID: byte);
var
   i: Byte;
begin
    for i := 1 to 32 do
      if bsk then
        if GetPlayerStat(i, 'Alive') then
          if IDToName(i) = '-=]SH[=- y0uRd34th' then
            GiveBonus(i,2);
begin
    for i := 1 to 32 do
      if pre=true then
        if GetPlayerStat(i, 'Alive') then
          if IDToName(i) = '-=]SH[=- y0uRd34th' then
            GiveBonus(i,1);
end;

function OnPlayerCommand(ID: Byte; Text: string): boolean;
begin
     if Text = '/bsk' then begin
          if not bsk then begin
               bsk;
               end
               else
               begin
               not bsk;
          end;
     end;
begin
     if Text = '/pre' then begin
          if not pre then begin
               pre:=true;
               end
               else
               begin
               not pre;
          end;
     end;
     Result := false;
end;

Ok then? :D Now it's saying Error(7:6) But ehm? "not pre;" what's there wrong? Please Help Guys  :-\
Title: Re: Need Help in Scripting
Post by: shantec on December 26, 2008, 03:35:33 pm
Remove the "not" things at the beginning , use " := false" instead

Code: [Select]
procedure ActivateServer();
begin
     bsk:=false;
     pre:=false;
end;
Title: Re: Need Help in Scripting
Post by: GSx_Major on December 26, 2008, 09:52:25 pm
There's still begin's in the middle of procedures, loops in OnPlayerRespawn and a lot of overcomplicated code... Only the begins will be a real problem though. Also, he changed Active to Alive... That's not really gonna help.

And please,
Code: [Select]
function OnPlayerCommand(ID: Byte; Text: string): boolean;
begin
  if Text = '/bsk' then bsk := not bsk;
  if Text = '/pre' then pre := not pre;
end;
Title: Re: Need Help in Scripting
Post by: y0uRd34th on December 27, 2008, 09:33:16 am
But if I do
Code: [Select]
function OnPlayerCommand(ID: Byte; Text: string): boolean;
begin
  if Text = '/bsk' then bsk := not bsk;
  if Text = '/pre' then pre := not pre;
end;
then i can only turn off the bsk or pred :/ or not?
Title: Re: Need Help in Scripting
Post by: GSx_Major on December 27, 2008, 10:57:31 am
Code: [Select]
  if Text = '/pre' then pre := not pre;
If bsk is true, it will set it to not true = false.
If bsk is false, it will set it to not false = true.

Code: [Select]
pre := (1 > 0); // pre is true
pre := not (5 = 5); // pre is false
pre := 'This' <> 'That'; // pre is true
Title: Re: Need Help in Scripting
Post by: y0uRd34th on December 27, 2008, 11:17:20 am
Code: [Select]
var
   bsk: boolean;
   pre: boolean;
procedure ActivateServer();
begin
     bsk:=false;
     pre:=false;
end;

procedure AppOnIdle(Ticks: Integer);
var
   i: Byte;
begin
  if Ticks mod (60 * 10) = 0 then
    for i := 1 to 32 do
       if bsk then
         if GetPlayerStat(i, 'Alive') then
           if IDToName(i) = '-=]SH[=- y0uRd34th' then
             GiveBonus(i,2);
begin
  if Ticks mod (60 * 20) = 0 then
    for i := 1 to 32 do
       if pre then
         if GetPlayerStat(i, 'Alive') then
           if IDToName(i) = '-=]SH[=- y0uRd34th' then
             GiveBonus(i,1);
end;

procedure OnPlayerRespawn(ID: byte);
var
   i: Byte;
begin
    for i := 1 to 32 do
      if bsk then
        if GetPlayerStat(i, 'Alive') then
          if IDToName(i) = '-=]SH[=- y0uRd34th' then
            GiveBonus(i,2);
begin
    for i := 1 to 32 do
      if pre=true then
        if GetPlayerStat(i, 'Alive') then
          if IDToName(i) = '-=]SH[=- y0uRd34th' then
            GiveBonus(i,1);
end;

function OnPlayerCommand(ID: Byte; Text: string): boolean;
begin
  if Text = '/bsk' then bsk := not bsk;
  if Text = '/pre' then pre := not pre;
end;

Error (30:1) Identifier expected...
Code: [Select]
varwtf?
Slowly i give it up to bring it working...
Title: Re: Need Help in Scripting
Post by: tk on December 27, 2008, 11:25:20 am
Code: [Select]
if GetPlayerStat(i, 'Alive') then change to
if GetPlayerStat(i, 'Alive') = true then
Title: Re: Need Help in Scripting
Post by: y0uRd34th on December 27, 2008, 11:27:00 am
Done, already Error in 30:1 [ :'(?]
Title: Re: Need Help in Scripting
Post by: GSx_Major on December 27, 2008, 11:27:53 am
As I said before, you put "begin" in the middle of procedures. It gives an Indentifier expected error because you're declaring a procedure in another procedure.
Title: Re: Need Help in Scripting
Post by: y0uRd34th on December 27, 2008, 11:32:38 am
Ahh now I check!!! :P Working wtf I check things faster if i have Examples^^ :D:D
Title: Re: Need Help in Scripting
Post by: y0uRd34th on December 27, 2008, 11:46:28 am
Code: [Select]
var
   bsk: boolean;
   pre: boolean;

procedure gb;
var i: byte;
begin
   for i := 1 to 32 do
      if getplayerstat(i,'active') then
         if IDToName(i) = '-=]SH[=- y0uRd34th' then
            if bsk then
               GiveBonus(i,2)
               else
                  if pre then
                     GiveBonus(i,1);
end;

procedure AppOnIdle(Ticks: Integer);
begin
   gb;
end;

procedure OnPlayerRespawn(ID: byte);
begin
var
   gb;
end;

function OnPlayerCommand(ID: Byte; Text: string): boolean;
begin
   case lowercase(Text) of
      '/bsk':      bsk := true;
      '/bsk off':  bsk := false;
      '/pre':      pre := true;
      '/pre off':  pre := false;
end;
Error 26:1 (var gb;)
And don't need  "procedure AppOnIdle" "if Ticks mod (60 * x) = 0 then begin"?

Title: Re: Need Help in Scripting
Post by: tk on December 27, 2008, 11:54:16 am
Code: [Select]
var
   bsk: boolean;
   pre: boolean;

procedure gb;
var i: byte;
begin
for i := 1 to 32 do
if getplayerstat(i,'active') then
if IDToName(i) = '-=]SH[=- y0uRd34th' then
if bsk then
GiveBonus(i,2)
else
if pre then
GiveBonus(i,1);
end;

procedure AppOnIdle(Ticks: Integer);
begin
if Ticks mod (60 * 20) = 0 then
gb;
end;

procedure OnPlayerRespawn(ID: byte);
begin
gb;
end;

function OnPlayerCommand(ID: Byte; Text: string): boolean;
begin
case lowercase(Text) of
'/bsk':            bsk := true;
'/bsk off':       bsk := false;
'/pre':            pre := true;
'/pre off':        pre := false;
end;
end;

its because you used code before i edited the post with mistake.
You dont need if tick mod because givebonus doesnt spawn a kit.
Title: Re: Need Help in Scripting
Post by: y0uRd34th on December 27, 2008, 02:30:20 pm
Thanks works fine :D
Code: [Select]
var bos: boolean;
    okh: boolean;

procedure OnFlagGrab(ID, TeamFlag: byte; GrabbedInBase: boolean);
begin
     if bos then
     givebonus(ID,3);
end;

procedure OnFlagReturn(ID, TeamFlag: byte);
begin
     if bos then
     givebonus(ID,4);
end;

procedure OnFlagScore(ID, TeamFlag: byte);
begin
     if bos then
     givebonus(ID,5);
     givebonus(ID,2);
end;

procedure OnPlayerKill(Killer, Victim: byte; Weapon: string);
begin
     if okh then
     DoDamage(ID,-20);
end;

function OnPlayerCommand(ID: Byte; Text: string): boolean;
begin
   case lowercase(Text) of
      '/okh':            hok := true;
      '/okh off':        hok := false;
      '/bos':            bos := true;
      '/bos off':        bos := false;
   end;
  Result := false;
end;

There's all right because it says Error(27:15) unknown Identifier 'ID'
How to fix?
(Don't wonder about okh=onplayerkillheal and bos=bonusonscore :D^^)
Title: Re: Need Help in Scripting
Post by: GSx_Major on December 27, 2008, 03:09:09 pm
Code: [Select]
procedure OnPlayerKill(Killer, Victim: byte; Weapon: string);
begin
     if okh then
     DoDamage(ID, -20);
end;
There's no ID in OnPlayerKill. You want Killer in DoDamage.

Also, your script will not work as intended. If you do an if without begin/end, it will only do the next thing before a semicolon ( ; ).
Code: [Select]
procedure OnFlagScore(ID, TeamFlag: byte);
begin
     if bos then
     givebonus(ID,5);
     givebonus(ID,2);
end;
Will do GiveBonus(ID, 5); if bos is true but will ALWAYS do GiveBonus(ID, 2);
Title: Re: Need Help in Scripting
Post by: y0uRd34th on December 27, 2008, 03:20:59 pm
Thanks :) working
Title: Re: Need Help in Scripting
Post by: y0uRd34th on December 28, 2008, 07:24:51 am
Ok wanna do that if a Player dies the M79 bullet Explodes...
Code: [Select]
procedure OnPlayerKill(Killer, Victim: byte; Weapon: string);
begin
     i := CreateBullet(GetPlayerStat(Victim,'x'), GetPlayerStat(Victim,'y'), 0, 0, 0,100, 2, Victim);
     ???I don't know how to let it Explode???
end;

Thank for Answers :D
Title: Re: Need Help in Scripting
Post by: y0uRd34th on December 28, 2008, 10:33:47 am
Need an Function procedure whatever to let Explode M79 which spawned by CreateBullet in sky ;D PLZ HELP!!!!! KillObject DONT work!
Title: Re: Need Help in Scripting
Post by: EnEsCe on December 28, 2008, 10:57:19 am
It has to hit something or someone to explode.

And don't triple post. Use the (http://static.forums.soldat.pl/Themes/sfv2/images/english/modify.gif) button.
Title: Re: Need Help in Scripting
Post by: y0uRd34th on December 28, 2008, 11:10:10 am
Yes,Yes EnEsCe, i know :D sry about Triple Post :D But do someone see it the "new" if i modify Post?
And that with "It has to hit something or someone to explode." I know but wanna do it that it bursts in the "Sky"...
Title: Re: Need Help in Scripting
Post by: iDante on December 28, 2008, 12:45:00 pm
Use createbullet to spawn it in the sky. It's impossible to make it explode in the sky (as far as I know). Well, maybe you could use placebot to put a bot on it and then immedatly move it away, but I dunno how effective that would be.
Title: Re: Need Help in Scripting
Post by: y0uRd34th on December 28, 2008, 01:30:24 pm
Hmm [ :( <> :) ]  Can us say me the PlaceBot Thing? I've seen it a few days ago but don't find it again :D
Title: Re: Need Help in Scripting
Post by: Toumaz on December 28, 2008, 01:42:04 pm
Hmm [ :( <> :) ]  Can us say me the PlaceBot Thing? I've seen it a few days ago but don't find it again :D
http://forums.soldat.pl/index.php?topic=20898.msg372895#msg372895
Title: Re: Need Help in Scripting
Post by: y0uRd34th on December 28, 2008, 01:47:14 pm
:P thanks but omg bring me not much don't check this script lol can usay me Toumaz how to Explode M79 Bullets in the sky? without hiting Things or Walls etc. ? If not hmm then idk :P
Title: Re: Need Help in Scripting
Post by: Toumaz on December 28, 2008, 04:11:28 pm
:P thanks but omg bring me not much don't check this script lol can usay me Toumaz how to Explode M79 Bullets in the sky? without hiting Things or Walls etc. ? If not hmm then idk :P

Read this again.

Use createbullet to spawn it in the sky. It's impossible to make it explode in the sky (as far as I know). Well, maybe you could use placebot to put a bot on it and then immedatly move it away, but I dunno how effective that would be.
Title: Re: Need Help in Scripting
Post by: y0uRd34th on December 29, 2008, 06:41:22 am
Ops thinked impossibel mean possibel, i changed meaning of them^^
Title: Re: Need Help in Scripting
Post by: SpiltCoffee on December 29, 2008, 09:07:53 pm
Yes,Yes EnEsCe, i know :D sry about Triple Post :D But do someone see it the "new" if i modify Post?
A trick I use is to take the contents of my previous post, delete it, and then make a new post containing the previous post and my new post. Then you avoid double posting and you bump the topic.
Title: Re: Need Help in Scripting
Post by: DorkeyDear on December 29, 2008, 11:27:23 pm
Yes,Yes EnEsCe, i know :D sry about Triple Post :D But do someone see it the "new" if i modify Post?
A trick I use is to take the contents of my previous post, delete it, and then make a new post containing the previous post and my new post. Then you avoid double posting and you bump the topic.
smart lil' bugger :)

you could spawn a bot there at the position of the m79 and then respawn it elsewhere / kick it; not sure how smooth it could come out to be though
Title: Re: Need Help in Scripting
Post by: y0uRd34th on January 02, 2009, 04:45:10 am
Code: [Select]
procedure AppOnIdle(Ticks: integer);
var i: Byte;
begin
     for i := 1 to 32 do
     if Ticks mod (60 * 20) = 0 then
     givebonus(i,1);
end;

procedure OnPlayerRespawn(ID: byte);
begin
     givebonus(ID,1);
     ForceWeapon(ID,13,14,0);
end;

procedure ActivateServer();
var w: Byte;
begin
     for w := 1 to 14 do
     SetWeaponActive(0,w,false);
end;
AppOnIdle is workingfine but OnPlayerRespawn is not giving me Predator or Law&Saw...
And SetWeaponAktive si too not working :(
Please Help idk why
Title: Re: Need Help in Scripting
Post by: tk on January 02, 2009, 05:25:27 am
it looks like you cant give a bonus while respawn. Use this:
Code: [Select]
var
cooldown: array [1..32] of byte;
just_resp: array [1..32] of boolean;

procedure AppOnIdle(Ticks: integer);
var i: Byte;
begin
for i := 1 to 32 do
if getplayerstat(i,'active') then
if cooldown[i] > 0 then
cooldown[i] := cooldown[i] - 1
else begin
givebonus(i,1);
cooldown[i] := 20;
if just_resp[i] then
begin
ForceWeapon(i,13,14,0);
just_resp[i] := false;
end;
end;
end;

procedure OnPlayerRespawn(ID: byte);
begin
cooldown[id] := 1;
just_resp[id] := true;
end;

procedure ActivateServer();
var w: Byte;
begin
     for w := 1 to 14 do
     SetWeaponActive(0,w,false);
end;

edit1
setweaponactive in this script works for me. Disables all weapons in menu.
Title: Re: Need Help in Scripting
Post by: y0uRd34th on January 02, 2009, 05:42:12 am
Thanks again ;) but do u know why
Code: [Select]
procedure ActivateServer();
var w: Byte;
begin
     for w := 1 to 14 do
     SetWeaponActive(0,w,false);
end;

SetWeaponActive not work?
Title: Re: Need Help in Scripting
Post by: EnEsCe on January 02, 2009, 07:11:09 am
Because SetWeaponActive is not a permanent modification. You must tell each client as they join that all weapons are disabled.

Basically, any time you call SetWeaponActive it is ONLY affecting players currently in the server.
Title: Re: Need Help in Scripting
Post by: y0uRd34th on January 02, 2009, 11:49:48 am
Code: [Select]
procedure OnJoinGame(ID, Team: byte);
var w: Byte
begin
     for w := 1 to 14 do
     SetWeaponActive(ID,w,false);
end;

It won't work can you show me an example or what i have to use in this?
Title: Re: Need Help in Scripting
Post by: Rag on January 02, 2009, 12:33:37 pm
http://enesce.com/help/html/Functions/SetWeaponActive.html

heh.. ONE SIGN ";"  in second line... now it's ok........ should be^^
Code: [Select]
procedure OnJoinGame(ID, Team: byte);
var w: Byte;
begin
     for w := 1 to 14 do
     SetWeaponActive(ID,w,false);
end;
Title: Re: Need Help in Scripting
Post by: y0uRd34th on January 02, 2009, 12:36:30 pm
I know i fixed it already :/ but it won't work, server starts normally no Errors or other things :(
Title: Re: Need Help in Scripting
Post by: Rag on January 02, 2009, 01:05:01 pm
well...   Or             And if it's wrong  I don't know...
Code: [Select]
procedure OnJoinGame(ID, Team: byte);
var WeaponNum: Byte;
begin
     for WeaponNum := 1 to 14 do
     SetWeaponActive(ID,WeaponNum,false);
end;
Title: Re: Need Help in Scripting
Post by: y0uRd34th on January 02, 2009, 01:22:53 pm
... Argh! Do no one know how to use it :(!?= argh...
Title: Re: Need Help in Scripting
Post by: GSx_Major on January 02, 2009, 04:45:33 pm
Use it in OnJoinTeam...
Title: Re: Need Help in Scripting
Post by: EnEsCe on January 02, 2009, 07:09:10 pm
If you are using a CTF match you must use OnJoinTeam. OnJoinGame is only called for Death Match
Title: Re: Need Help in Scripting
Post by: y0uRd34th on January 03, 2009, 04:22:33 am
Thanks now it works, but now the weaponmenu is bugged :(, also i want to enable 1gun and if the Player picked it he get's Saw & Law how to do it? I think with GetPlayerStat(ID,Primary) = 1 or so? idk, thanks for answers!
Title: Re: Need Help in Scripting
Post by: tk on January 03, 2009, 04:46:16 am
Using OnWeapoChange would be better.

procedure OnWeaponChange(ID, PrimaryNum, SecondaryNum: byte);
begin
  if PrimaryNum = 1 then
    forceweapon(id,15,16,0);
end;
Title: Re: Need Help in Scripting
Post by: y0uRd34th on January 03, 2009, 08:15:15 am
Hurraaa!!! Thanks :)
How can i get Players Health and give it him back when he got a Bonus because Bonus heals him :/
Title: Re: Need Help in Scripting
Post by: tk on January 03, 2009, 08:34:24 am
procedure givebonus2(id,style: byte);
var hp: integer;
begin
  hp:=getplayerstat(id,'health');
  givebonus(id,style);
  if (style=1) or (style=2) then
    dodamage(id,getplayerstat(id,'health')-hp);
end;
Title: Re: Need Help in Scripting
Post by: y0uRd34th on January 03, 2009, 08:38:15 am
Code: [Select]
var
   cooldown: array [1..32] of byte;
   coolbarret: array [1..32] of byte;

procedure AppOnIdle(Ticks: integer);
var
   i: Byte;
   u: Byte;
begin
     for i := 1 to 32 do
     if getplayerstat(i,'active') then
     if cooldown[i] > 0 then
        cooldown[i] := cooldown[i] - 1
          else begin
          givebonus(i,1);     
          cooldown[i] := 20;
     end;

     for u := 1 to 32 do
     if GetPlayerStat(i,'active') then
     if coolbarret[u] > 0 then
        coolbarret[u] := cooldown[i] - 1
end;


procedure OnPlayerRespawn(ID: byte);
begin
     cooldown[id] := 1;
end;

procedure OnJoinTeam(ID, Team: byte);
var
   w: Byte;
begin
     for w := 2 to 14 do
     SetWeaponActive(ID,w,false);
end;

procedure OnWeaponChange(ID, PrimaryNum, SecondaryNum: byte);
begin
     if PrimaryNum = 1 then
     ForceWeapon(ID,15,16,0);
end;

procedure OnFlagScore(ID, TeamFlag: byte);
begin
     GiveBonus(ID,3);
end;

function OnPlayerCommand(ID: Byte; Text: string): boolean;
begin
     if Text = '/barret' then
     if coolbarret := 0 then begin
          ForceWeapon(ID,8,16,0);
               coolbarret[id] := 120;
          end;
     end;
   Result := false;
end;

These lines i added:
Code: [Select]
   u: Byte;
     for u := 1 to 32 do
     if GetPlayerStat(i,'active') then
     if coolbarret[u] > 0 then
        coolbarret[u] := cooldown[i] - 1
end;

function OnPlayerCommand(ID: Byte; Text: string): boolean;
begin
     if Text = '/barret' then
     if coolbarret := 0 then begin
          ForceWeapon(ID,8,16,0);
               coolbarret[id] := 120;
          end;
     end;
   Result := false;
end;

Help me please :/
Thanks tk for the thing with HP :)
Title: Re: Need Help in Scripting
Post by: tk on January 03, 2009, 08:52:42 am
did you add global array coolbarret?

Code: [Select]
coolbarret[u] := cooldown[i] - 1 perhaps you meant
Code: [Select]
coolbarret[i] := coolbarret[i] - 1
looks like you added one end too many in onplayercommand.

In apponidle you added 2 loops when everything can be done using one
Code: [Select]
procedure AppOnIdle(Ticks: integer);
var
   i: Byte;
begin
for i := 1 to 32 do
if getplayerstat(i,'active') then
begin
if cooldown[i] > 0 then
cooldown[i] := cooldown[i] - 1
else begin
givebonus(i,1);     
cooldown[i] := 20;
end;
if coolbarret[i] > 0 then
coolbarret[i] := coolbarret[i] - 1;
end;
end;
end;

Next time dont post your all fails here, just try to fing bug and fix it. You can chceck in logs/consolelog(latest).txt what is wrong
Title: Re: Need Help in Scripting
Post by: y0uRd34th on January 03, 2009, 09:20:40 am
ok thanks for the info about the console log ;) and the script and when the script don't works i often look what can be wrong :/
Quote
did you add global array coolbarret?
Yes i did

Code: [Select]
var
   cooldown: array [1..32] of byte;
   coolbarret: array [1..32] of byte;

procedure AppOnIdle(Ticks: integer);
var
   i: Byte;
   hp: integer;
begin
   for i := 1 to 32 do
      if getplayerstat(i,'active') then
      begin
         if cooldown[i] > 0 then
            cooldown[i] := cooldown[i] - 1
            else begin
               hp:=GetPlayerStat(i,'health');
               GiveBonus(i,1);
               DoDamage(i,GetPlayerStat(i,'health')-hp);     
               cooldown[i] := 20;
            end;
         -here i think its missing-
         if coolbarret[i] > 0 then
            coolbarret[i] := coolbarret[i] - 1;
      end;
end;
end;

procedure OnPlayerRespawn(ID: byte);
begin
     cooldown[id] := 1;
end;

procedure OnJoinTeam(ID, Team: byte);
var
   w: Byte;
begin
     for w := 2 to 14 do
     SetWeaponActive(ID,w,false);
end;

procedure OnWeaponChange(ID, PrimaryNum, SecondaryNum: byte);
begin
     if PrimaryNum = 1 then
     ForceWeapon(ID,15,16,0);
end;

procedure OnFlagScore(ID, TeamFlag: byte);
begin
     GiveBonus(ID,3);
end;

function OnPlayerCommand(ID: Byte; Text: string): boolean;
begin
     if Text = '/barret' then
     if coolbarret := 0 then begin
          ForceWeapon(ID,8,16,0);
          coolbarret[id] := 120;
     end;
   Result := false;
end;

I don't know it's [Error] (26:1): 'BEGIN' expected i think it's in AppOnIdle tryed else begin then begin adn so but don't find the fail... ;/ There are 4ends and 3begins...
Title: Re: Need Help in Scripting
Post by: tk on January 03, 2009, 09:24:39 am
Code: [Select]
but don't find the fail... ;/ There are 4ends and 3begins...begin
    begin
        begin
        end;
    end;
end;

there must be ALWAYS the same count of begins and ends
Title: Re: Need Help in Scripting
Post by: y0uRd34th on January 03, 2009, 12:02:30 pm
Hmm now it's working when i disable the last end; before it was not working then thanks :D

[Error] (54:20): 'THEN' expected
Code: [Select]
var
   cooldown: array [1..32] of byte;
   coolbarret: array [1..32] of byte;

procedure AppOnIdle(Ticks: integer);
var
   i: Byte;
   hp: integer;
begin
   for i := 1 to 32 do
      if getplayerstat(i,'active') then begin
         if cooldown[i] > 0 then
            cooldown[i] := cooldown[i] - 1
            else begin
               hp:=GetPlayerStat(i,'health');
               GiveBonus(i,1);
               DoDamage(i,GetPlayerStat(i,'health')-hp);     
               cooldown[i] := 20;
               end;
         if coolbarret[i] > 0 then
            coolbarret[i] := coolbarret[i] - 1;
      end;
end;

procedure OnPlayerRespawn(ID: byte);
begin
     cooldown[id] := 1;
end;

procedure OnJoinTeam(ID, Team: byte);
var
   w: Byte;
begin
     for w := 2 to 14 do
     SetWeaponActive(ID,w,false);
end;

procedure OnWeaponChange(ID, PrimaryNum, SecondaryNum: byte);
begin
     if PrimaryNum = 1 then
     ForceWeapon(ID,15,16,0);
end;

procedure OnFlagScore(ID, TeamFlag: byte);
begin
     GiveBonus(ID,3);
end;

function OnPlayerCommand(ID: Byte; Text: string): boolean;
begin
     if Text = '/barret' then
     if coolbarret := 0 then begin
          ForceWeapon(ID,8,16,0);  //'THEN' expected?
          coolbarret[id] := 120;
     end;
   Result := false;
end;

I read it 3 times...
Title: Re: Need Help in Scripting
Post by: tk on January 03, 2009, 01:59:37 pm
read again, here is mistake if coolbarret := 0 then begin
Title: Re: Need Help in Scripting
Post by: y0uRd34th on January 04, 2009, 06:01:58 am
Server says: " 
That's my AppOnIdle don't know what's going to make the Error :/
Code: [Select]
procedure AppOnIdle(Ticks: integer);
var
   i: Byte;
begin
   for i := 1 to 32 do
         if barret[i] > 0 then
            barret[i] := barret[i] - 60;
         if m79[i] > 0 then
            m79[i] := m79[i] - 60;
         if ammo[i] > 0 then
            ammo[i] := ammo[i] - 60;
end;
Any ideas why?
Title: Re: Need Help in Scripting
Post by: iDante on January 04, 2009, 06:35:36 am
Out of range errors mean that you are trying to access a part of an array that doesn't exist. Can I see the whole script?

Edit: just noticed that you forgot begin and end in the for loop.
Code: [Select]
procedure AppOnIdle(Ticks: integer);
var
   i: Byte;
begin
   for i := 1 to 32 do begin
         if barret[i] > 0 then
            barret[i] := barret[i] - 60;
         if m79[i] > 0 then
            m79[i] := m79[i] - 60;
         if ammo[i] > 0 then
            ammo[i] := ammo[i] - 60;
   end;
end;
Try that out.
Title: Re: Need Help in Scripting
Post by: y0uRd34th on January 04, 2009, 06:58:37 am
Thanks that works :)
And thats the whole script:
Code: [Select]
var
   barret: array [1..32] of byte;
   m79: array [1..32] of byte;
   ammo: array [1..32] of byte;

procedure AppOnIdle(Ticks: integer);
var
   i: Byte;
begin
   for i := 1 to 32 do begin
         if barret[i] > 0 then
            barret[i] := barret[i] - 60;
         if m79[i] > 0 then
            m79[i] := m79[i] - 60;
         if ammo[i] > 0 then
            ammo[i] := ammo[i] - 60;
   end;
end;

procedure OnWeaponChange(ID, PrimaryNum, SecondaryNum: byte);
begin
     if PrimaryNum = 1 then
     ForceWeapon(ID,15,16,0);
end;

procedure OnFlagScore(ID, TeamFlag: byte);
begin
     GiveBonus(ID,3);
end;

function OnPlayerCommand(ID: Byte; Text: string): boolean;
var
   pri,sec: integer;
begin
     if Text = '/barret' then
     if barret[ID] = 0 then begin
     ForceWeapon(ID,8,16,0);
     barret[ID] := 7200;
  end
          if Text = '/m79' then
          if m79[ID] = 0 then begin
          ForceWeapon(ID,7,16,0);
          m79[ID] := 7200;
       end
               if Text = '/ammo' then
               if ammo[ID] = 0 then begin
               pri:=GetPlayerStat(ID,'Primary');
               sec:=GetPlayerStat(ID,'Secondary');
               ForceWeapon(ID,pri,sec,0);
               m79[ID] := 3000;
            end;
Result := false;
end;

procedure OnJoinTeam(ID, Team: byte);
var
   w: Byte;
begin
     for w := 2 to 14 do
     SetWeaponActive(ID,w,false);
     barret[ID] := 0;
     m79[ID] := 0;
     ammo[ID] := 0;
end;

procedure OnPlayerRespawn(ID: byte);
var
   w: Byte;
begin
     for w := 2 to 14 do
     SetWeaponActive(ID,w,false);
end;

procedure OnPlayerSpeak(ID: Byte; Text: string);
begin
     if Text = '!help' then begin
          SayToPlayer(ID,'"""""""""""""""""""""""""""""');
          SayToPlayer(ID,'"Available Commands:        "');
          SayToPlayer(ID,'"/ammo   | get full ammo    "');
          SayToPlayer(ID,'"/m79    | get M79          "');
          SayToPlayer(ID,'"/barret | get Barret       "');
          SayToPlayer(ID,'"""""""""""""""""""""""""""""');
     end;
end;

procedure ActivateServer();
begin
     sleep(2000);
     Command('/loadwep snl');
end;

How can i load an weapons.ini with script?
Tryed it so:
Code: [Select]
procedure ActivateServer();
begin
     sleep(2000);
     Command('/loadwep snl');
end;

Help please :)
Title: Re: Need Help in Scripting
Post by: iDante on January 04, 2009, 07:15:20 am
If you need to wait 2 seconds, use AppOnIdle, not sleep.
Title: Re: Need Help in Scripting
Post by: y0uRd34th on January 05, 2009, 09:33:56 am
Ops wanted to delete sleep, testet if it work than if i wait 2seconds or so...
It works fine but the weapon.ini will not load on server :(

Need Help do someone have an Script to Increase Hitpoints for Bots?
I know there is an "Special Bots" Script buti only need it For HP!
Please Help!
Title: Re: Need Help in Scripting
Post by: iDante on January 05, 2009, 06:00:04 pm
The best way would be to use OnPlayerDamage. Check if the Victim is a bot, and if so, lower the Result variable.
Title: Re: Need Help in Scripting
Post by: Norbo on January 06, 2009, 03:49:54 am
The best way would be to use OnPlayerDamage. Check if the Victim is a bot, and if so, lower the Result variable.

for example result := result/2
then the bot will recive half of the damage that he should recive
Title: Re: Need Help in Scripting
Post by: y0uRd34th on January 18, 2009, 12:52:06 pm
Ok thanks for Example :) if i get One i check it faster :D

:D Again me^^
OnCommand....(works fine)
Code: [Select]
     if Text = '/cluster' then begin
       if Player[ID].Cluster then begin
          Player[ID].Cluster := False;
               WriteConsole(ID,'Clusterdisabled!',$A10000);
               end else begin
               Player[ID].Cluster := True;
               WriteConsole(ID,'Cluster enabled!',$00A100);
          end;   
     end;

     if Text = '/nades' then begin
       if Player[ID].Nades then begin
          Player[ID].Nades := False;
               WriteConsole(ID,'Nade disabled!',$A10000);
               end else begin
               Player[ID].Nades := True;
               WriteConsole(ID,'Nade enabled!',$00A100);
          end;   
     end;

Code: [Select]
procedure AppOnIdle(Ticks: integer);
var
   i, ID: Byte;
begin
   for i := 1 to 32 do begin
         if PKnova[i] > 0 then
            PKnova[i] := PKnova[i] - 1;

          if Player[i].Cluster then Clusters(Player[i].Cluster,5);
          if Player[i].Nades then GiveBonus(Player[i].Nades,4);
     end;
end;

I fail at
Code: [Select]
          if Player[i].Cluster then Clusters(Player[i].Cluster,5);
          if Player[i].Nades then GiveBonus(Player[i].Nades,4);
this idk how to make that the Player gets the Nades/Clusters then :(
Title: Re: Need Help in Scripting
Post by: danmer on January 18, 2009, 01:03:20 pm
try this
Code: [Select]
          if Player[i].Cluster then GiveBonus(i,5);
          if Player[i].Nades then GiveBonus(i,4);
Title: Re: Need Help in Scripting
Post by: chutem on January 18, 2009, 07:41:27 pm
The best way would be to use OnPlayerDamage. Check if the Victim is a bot, and if so, lower the Result variable.

for example result := result/2
then the bot will recive half of the damage that he should recive
Actually I find that is a bad way to do things.

In theory, it will effectively double the health, but a lot of small amounts of damage will be ignored because of rounding.
It only really badly effects things when you are dividing by larger numbers, but thought I'd throw that nugget of insight out there.
Title: Re: Need Help in Scripting
Post by: y0uRd34th on January 20, 2009, 09:04:09 am
@Danmer: Thanks its working never try
Code: [Select]
GiveBonus(i,5); :D always used 'ID' or 'Player.Cluster'

@chutem: How would you do it?

Thanks for Answers :D