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

0 Members and 1 Guest are viewing this topic.

Offline y0uRd34th

  • Camper
  • ***
  • Posts: 325
  • [i]Look Signature![/i]
Need Help in Scripting
« 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!
« Last Edit: December 24, 2008, 05:52:07 am by y0uRd34th »

Offline Toumaz

  • Veteran
  • *****
  • Posts: 1906
Re: Need Help in Scripting
« Reply #1 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;

Offline y0uRd34th

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

Offline iDante

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

Offline y0uRd34th

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

Offline Toumaz

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

Offline y0uRd34th

  • Camper
  • ***
  • Posts: 325
  • [i]Look Signature![/i]
Re: Need Help in Scripting
« Reply #6 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
« Last Edit: December 24, 2008, 05:52:30 am by y0uRd34th »

Offline SpiltCoffee

  • Veteran
  • *****
  • Posts: 1579
  • Spilt, not Split!
    • SpiltCoffee's Site
Re: Need Help in Scripting
« Reply #7 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
« Last Edit: December 23, 2008, 08:23:07 pm by SpiltCoffee »
When life hands you High Fructose Corn Syrup, Citric Acid, Ascorbic Acid, Maltodextrin, Sodium Acid Pyrophosphate,
Magnesium Oxide, Calcium Fumarate, Yellow 5, Tocopherol and Less Than 2% Natural Flavour... make Lemonade!

Offline y0uRd34th

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

Offline iDante

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

Offline y0uRd34th

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

Offline tk

  • Soldier
  • **
  • Posts: 235
Re: Need Help in Scripting
« Reply #11 on: December 24, 2008, 08:00:07 am »
Did you put result := true inside? If you did, change it to false.

Offline y0uRd34th

  • Camper
  • ***
  • Posts: 325
  • [i]Look Signature![/i]
Re: Need Help in Scripting
« Reply #12 on: December 24, 2008, 08:34:13 am »
I don't have any result := true in it should i add it with false?

Offline Toumaz

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

Offline y0uRd34th

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

Offline Toumaz

  • Veteran
  • *****
  • Posts: 1906
Re: Need Help in Scripting
« Reply #15 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!

Offline y0uRd34th

  • Camper
  • ***
  • Posts: 325
  • [i]Look Signature![/i]
Re: Need Help in Scripting
« Reply #16 on: December 24, 2008, 09:11:05 am »
[ERROR] (27:6): Unknown identifier 'result'
:( What's now worng?

Offline Toumaz

  • Veteran
  • *****
  • Posts: 1906
Re: Need Help in Scripting
« Reply #17 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;

Offline y0uRd34th

  • Camper
  • ***
  • Posts: 325
  • [i]Look Signature![/i]
Re: Need Help in Scripting
« Reply #18 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;
« Last Edit: December 25, 2008, 05:25:21 am by y0uRd34th »

Offline CurryWurst

  • Camper
  • ***
  • Posts: 265
    • Soldat Global Account System
Re: Need Help in Scripting
« Reply #19 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!
« Last Edit: December 25, 2008, 01:56:31 pm by Markus Quär »
Soldat Global Account System: #soldat.sgas @ quakenet