Author Topic: Need Help in Scripting  (Read 7049 times)

0 Members and 1 Guest are viewing this topic.

Offline GSx_Major

  • Major
  • *
  • Posts: 97
Re: Need Help in Scripting
« Reply #20 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.
« Last Edit: December 25, 2008, 03:30:34 pm by GSx_Major »
...and headbutt the sucker through your banana suit!

Offline tk

  • Soldier
  • **
  • Posts: 235
Re: Need Help in Scripting
« Reply #21 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;
« Last Edit: December 25, 2008, 03:41:27 pm by tk »

Offline y0uRd34th

  • Camper
  • ***
  • Posts: 325
  • [i]Look Signature![/i]
Re: Need Help in Scripting
« Reply #22 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  ;)

Offline CurryWurst

  • Camper
  • ***
  • Posts: 265
    • Soldat Global Account System
Re: Need Help in Scripting
« Reply #23 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 :)
Soldat Global Account System: #soldat.sgas @ quakenet

Offline y0uRd34th

  • Camper
  • ***
  • Posts: 325
  • [i]Look Signature![/i]
Re: Need Help in Scripting
« Reply #24 on: December 26, 2008, 06:44:06 am »
Do no guy have an "Money System"  ???

Offline iDante

  • Veteran
  • *****
  • Posts: 1967
Re: Need Help in Scripting
« Reply #25 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.

Offline y0uRd34th

  • Camper
  • ***
  • Posts: 325
  • [i]Look Signature![/i]
Re: Need Help in Scripting
« Reply #26 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!? ???

Offline iDante

  • Veteran
  • *****
  • Posts: 1967
Re: Need Help in Scripting
« Reply #27 on: December 26, 2008, 07:59:03 am »
Just from first impressions: make bsk global.

Offline y0uRd34th

  • Camper
  • ***
  • Posts: 325
  • [i]Look Signature![/i]
Re: Need Help in Scripting
« Reply #28 on: December 26, 2008, 08:05:38 am »
What do u mean with "global"?

Offline spkka

  • Camper
  • ***
  • Posts: 469
Re: Need Help in Scripting
« Reply #29 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

Offline y0uRd34th

  • Camper
  • ***
  • Posts: 325
  • [i]Look Signature![/i]
Re: Need Help in Scripting
« Reply #30 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

Offline y0uRd34th

  • Camper
  • ***
  • Posts: 325
  • [i]Look Signature![/i]
Re: Need Help in Scripting
« Reply #31 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??

Offline iDante

  • Veteran
  • *****
  • Posts: 1967
Re: Need Help in Scripting
« Reply #32 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.
« Last Edit: December 26, 2008, 09:24:28 am by iDante »

Offline tk

  • Soldier
  • **
  • Posts: 235
Re: Need Help in Scripting
« Reply #33 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').
« Last Edit: December 26, 2008, 02:30:29 pm by tk »

Offline y0uRd34th

  • Camper
  • ***
  • Posts: 325
  • [i]Look Signature![/i]
Re: Need Help in Scripting
« Reply #34 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  :-\
« Last Edit: December 26, 2008, 02:46:42 pm by y0uRd34th »

Offline shantec

  • Soldier
  • **
  • Posts: 140
  • Get ANGREH!!
Re: Need Help in Scripting
« Reply #35 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;
Also Known As REIMA


Lol Happles (happy apples)

Offline GSx_Major

  • Major
  • *
  • Posts: 97
Re: Need Help in Scripting
« Reply #36 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;
...and headbutt the sucker through your banana suit!

Offline y0uRd34th

  • Camper
  • ***
  • Posts: 325
  • [i]Look Signature![/i]
Re: Need Help in Scripting
« Reply #37 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?
« Last Edit: December 27, 2008, 09:35:54 am by y0uRd34th »

Offline GSx_Major

  • Major
  • *
  • Posts: 97
Re: Need Help in Scripting
« Reply #38 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
...and headbutt the sucker through your banana suit!

Offline y0uRd34th

  • Camper
  • ***
  • Posts: 325
  • [i]Look Signature![/i]
Re: Need Help in Scripting
« Reply #39 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...
« Last Edit: December 27, 2008, 11:20:23 am by y0uRd34th »