Author Topic: Help with basic script  (Read 6559 times)

0 Members and 1 Guest are viewing this topic.

Offline frosty

  • Flagrunner
  • ****
  • Posts: 601
  • Uber Desert Eagle ^^
Help with basic script
« on: April 29, 2010, 01:48:13 am »
ok i have a very simple problem

first the code:
Code: (pascal) [Select]
procedure OnPlayerKill(Killer, Victim: byte; Weapon: string);
begin
if Weapon = 'Chainsaw' then begin
for i := 1 to 32 do
begin
x := GetPlayerStat(Victim,'x');
y := GetPlayerStat(Victim,'y');
x2 := GetPlayerStat(i,'x');
y2 := GetPlayerStat(i,'y');
if RayCast(x,y,x2,y2,Dist,300000) then begin
                             if i <> Killer then begin
if GetPlayerStat(i,'Alive') = true then begin
//WriteLn(IDtoName(i)+' is in range of Raycast');
CreateBullet(GetPlayerStat(i,'x'), GetPlayerStat(i,'y') - 0, 0, 0,100, 4, Killer);
                    BioKills:=BioKills+1;
  end;
end;
end;
end;
WriteConsole(Killer,'Bio-Kills: '+Inttostr(BioKills),$EE81FAA1);
                        BioKills:=0;
                        //if Victim <> Killer then if IDtoName(Killer) = 'Mr.Zombie' then if Weapon = 'Chainsaw' then  WriteConsole(0,IDtoName(Victim)+' has just screwed up, Lookout!',$EEFA0002);
end;
end;
now the problem:

on every kill that our zombies make with this, the kill is registering as a chainsaw kill, and not a cluster grenade kill, they should be registering as cluster grenade kills after the 1 Chainsaw kill which starts this, however all kills are somehow being registered as chainsaw kills thus the commented WriteConsole message occurs for each kill made by zombie, Chainsaw or not

what am i missing here?

the message should only trigger if the kill was due to the chainsaw kill only, and not the resulting createbullet kill(s)

in short i only want this message to come up ONCE when one of the team gets too close to one of the zombies and screws everything up for everyone in realistic view (that is, everything that would have been seen from the point where the teammate died without the "sight" going through polygons, for those who dont know what raycast does)
« Last Edit: April 29, 2010, 01:54:58 am by frosty »
check out my server! click here

If at first you don't succeed, Improvise! :D

Offline squiddy

  • Soldat Beta Team
  • Camper
  • ******
  • Posts: 333
  • Flagger assassin
    • SoldatX
Re: Help with basic script
« Reply #1 on: April 29, 2010, 04:20:17 am »
I'm sure you can handle the Messages.

Haven't tested it yet, in theory, it should work.

Code: (pascal) [Select]
//Script Help to Frosty
//By Squiddy ~

Var
 PosX, PosY: Array[1..32] of Single;
BioKills: Array[1..32] of Integer;


Procedure OnPlayerKill(Killer, Victim: Byte; Weapon: String);
 Var F: Byte; Dist: Single;
  Begin
   For F := 1 To 32 Do if GetPlayerStat(F,'Active') = True Then Begin
    if GetPlayerStat(Killer,'Primary') = 15 Then Begin
     PosX[Killer] := GetPlayerStat(Killer,'X');
      PosY[Killer] := GetPlayerStat(Killer,'Y');
       PosX[F] := GetPlayerStat(F,'X');
        PosY[F] := GetPlayerStat(F,'Y');
        if F <> Killer Then Begin
       if RayCast(PosX[Killer],PosY[Killer],PosX[F],PosY[F],Dist,30000) = True Then Begin
      CreateBullet(PosX[F],PosY[F],0,0,150,4,Killer);
     BioKills[Killer] := BioKills[Killer] + 1;
    end;
   end;
  end;
 end;
end;
www.soldatx.com.br - The brazilian Soldat community.

Offline frosty

  • Flagrunner
  • ****
  • Posts: 601
  • Uber Desert Eagle ^^
Re: Help with basic script
« Reply #2 on: April 29, 2010, 08:10:00 pm »
thanks Squiddy, now to finalize if you guys dont mind :D

im getting a Syntax error and unexpected end of file error pointing to this line:
Code: (pascal) [Select]
WriteConsole(Killer,'Bio-Kills: '+Inttostr(BioKills[Killer]),$EE81FAA1);
heres the full code in case the problem is elsewhere:
http://pastebin.com/axQ1p8DW

btw the line above is line 70 in the full code
check out my server! click here

If at first you don't succeed, Improvise! :D

Offline dnmr

  • Camper
  • ***
  • Posts: 315
  • emotionally handicapped
Re: Help with basic script
« Reply #3 on: April 29, 2010, 11:19:49 pm »
how the f**k can you indent it like that? F**king magic everywhere.

Edit: make sure you're saving in ANSI, not unicode. Can't check the syntax because of READ ABOVE^
« Last Edit: April 29, 2010, 11:22:56 pm by dnmr »

Offline frosty

  • Flagrunner
  • ****
  • Posts: 601
  • Uber Desert Eagle ^^
Re: Help with basic script
« Reply #4 on: April 30, 2010, 12:13:12 am »
using tabs instead of spaces, how the hell do u save it as ANSI in pastebin? cuz its saved as ANSI on the server, and it doesnt indent like that until its uploaded then it indents like crazy, but anyway, heres the fixed version using notepad++

http://pastebin.com/X3XwpyfS

and if you still cant read that then i wonder why sometimes you bother because thats how i have Always indented my code since u told me to and u never had any problems with that, and personally i find this easier to read :P
check out my server! click here

If at first you don't succeed, Improvise! :D

Offline dnmr

  • Camper
  • ***
  • Posts: 315
  • emotionally handicapped
Re: Help with basic script
« Reply #5 on: April 30, 2010, 03:37:35 am »
my server says [Error] (90:1): 'BEGIN' expected, which means you have an extra END; right above it.
And your indenting is still inadequate D: (Edit: in some places  ;) )

Offline frosty

  • Flagrunner
  • ****
  • Posts: 601
  • Uber Desert Eagle ^^
Re: Help with basic script
« Reply #6 on: April 30, 2010, 05:27:59 am »
wtf still getting a syntax error and unexpected end of file pointing to line 70 even after the extra end was removed

and it seems that paste-bin is not indenting the code the same as i had put it in (looked at the last link, code is just everywhere) so in future i will be using screenshots of my notepad++ window, i have a nice piece of software which i bought which autoscrolls the window so i can capture code the way I see it, and you will all see the difference, all you need is image reading software such as AABBYY Finereader, i think its free, (well, it was for me, came off a disc from my PC Authority magazine subscription) if not ill just post the pas file alongside the screenshot, first i need to install it, ill post back with the screenshot and pas once im done

From: April 30, 2010, 05:46:19 am
righto, heres the screenshot:


and, as promised heres the pas file

btw i drew the arrow using the scren capture software to point out the exact line that the errors are pointing to

click the image to make it zoomable :D
« Last Edit: April 30, 2010, 05:49:15 am by frosty »
check out my server! click here

If at first you don't succeed, Improvise! :D

Offline Swompie

  • Camper
  • ***
  • Posts: 390
Re: Help with basic script
« Reply #7 on: April 30, 2010, 06:56:36 am »
Seems like something was wrong with the file, I deleted some blank spaces and it worked, don't ask why.
Here's the code:
Code: [Select]
  if GetPlayerStat(Killer,'Primary') = 15 Then Begin
    PosX[Killer] := GetPlayerStat(Killer,'X');
    PosY[Killer] := GetPlayerStat(Killer,'Y');
    PosX[F] := GetPlayerStat(F,'X');
    PosY[F] := GetPlayerStat(F,'Y');
    if F <> Killer Then Begin
      if RayCast(PosX[Killer],PosY[Killer],PosX[F],PosY[F],Dist,30000) = True Then Begin
        CreateBullet(PosX[F],PosY[F],0,0,150,4,Killer);
        BioKills[Killer] := BioKills[Killer] + 1;
        if Victim <> Killer then
          if IDtoName(Killer) = 'Mr.Zombie' then
            if GetPlayerStat(Killer,'Primary') = 15 Then
              WriteConsole(0,IDtoName(Victim)+' has just fucked up, Lookout!',$EEFA0002);
      end;
    end;
  end;

Offline frosty

  • Flagrunner
  • ****
  • Posts: 601
  • Uber Desert Eagle ^^
Re: Help with basic script
« Reply #8 on: April 30, 2010, 07:21:45 am »
still getting same errors

you are looking for Achievement in here i forgot to edit the pic on capture and ran out of time tis getting late

« Last Edit: April 30, 2010, 07:25:35 am by frosty »
check out my server! click here

If at first you don't succeed, Improvise! :D

Offline SpiltCoffee

  • Veteran
  • *****
  • Posts: 1579
  • Spilt, not Split!
    • SpiltCoffee's Site
Re: Help with basic script
« Reply #9 on: April 30, 2010, 08:59:01 am »
Seems like something was wrong with the file, I deleted some blank spaces and it worked, don't ask why.
Yeah, I think there's a space that he uses that the forums don't like or something, because I had a similar problem when attempting to compile some of his code at some point. Like, the compiler will read it as an EOF character or something and just stop reading. Really weird.
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 Swompie

  • Camper
  • ***
  • Posts: 390
Re: Help with basic script
« Reply #10 on: April 30, 2010, 09:06:21 am »
Try to remove spaces in the line where the error appears.

Offline frosty

  • Flagrunner
  • ****
  • Posts: 601
  • Uber Desert Eagle ^^
Re: Help with basic script
« Reply #11 on: April 30, 2010, 07:51:46 pm »
but wheres the blank spaces apart from my indenting? no blank spaces after any of the lines so wtf, and this only started after squiddy gave me the code :S

maybe i shuld just revert to my original code and consider the message i want to put in as impossible to add due to server issues, until i find out what they are

From: April 30, 2010, 07:58:19 pm
ok ive just improvized the code, ive changed line 70 to this:
Code: (pascal) [Select]
WriteConsole(Killer,'Bio-Kills: '+Inttostr(BioKills[Killer]+'!'),$EE81FAA1);
note the added '!'

now im getting a type mismatch error on line 66, which is an end;  so its obviously not pointing to the exact error, ill have to have a look over the code but no time at the moment, maybe someone will see something in the meantime, i have attached the improvised pas file

From: April 30, 2010, 08:17:03 pm
removed a crapload of spaces in the indentation, converting spaces into tabs so its how it shuld be, btw still getting type mismatch error [66:66]

attached the fixed pas file
« Last Edit: April 30, 2010, 08:19:07 pm by frosty »
check out my server! click here

If at first you don't succeed, Improvise! :D

Offline SpiltCoffee

  • Veteran
  • *****
  • Posts: 1579
  • Spilt, not Split!
    • SpiltCoffee's Site
Re: Help with basic script
« Reply #12 on: April 30, 2010, 10:55:56 pm »
What editor are you using? There's a bunch of these weird spaces popping up in your code that the compiler is tripping up on, maybe it has something to do with the editor you're using.

Also, don't put the +'!' where you put it, because that's within the IntToStr procedure, and you've just tried concatenating an Integer to a String, which just doesn't make sense to the compiler.

Try using the file attached.
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 frosty

  • Flagrunner
  • ****
  • Posts: 601
  • Uber Desert Eagle ^^
Re: Help with basic script
« Reply #13 on: May 01, 2010, 12:18:22 am »
thanks spilt, but the message that i want isnt showing up in game, in fact the code for wep 15 isnt even launching
check out my server! click here

If at first you don't succeed, Improvise! :D

Offline frosty

  • Flagrunner
  • ****
  • Posts: 601
  • Uber Desert Eagle ^^
Re: Help with basic script
« Reply #14 on: May 07, 2010, 09:03:12 pm »
ok im not entirely sure if i should use this code or not for a killstreak script i wrote myself, something tells me i should not use the code just yet, something tells me i have used arrays incorrectly

i would just like ppl to verify if the code is usable, havent tested it yet and whenever i get my server set up on the comp, a problem shows up somewhere and i end up losing the server files + takes too long to set up, maybe i shuld just rent a second test server and use that as my testing facility

please disregard the missing ; in the screenshot its all in the pas file




From: May 07, 2010, 11:28:52 pm
getting a syntax error line 3
« Last Edit: May 07, 2010, 11:28:52 pm by frosty »
check out my server! click here

If at first you don't succeed, Improvise! :D

Offline croat1gamer

  • Veteran
  • *****
  • Posts: 1327
  • OMG CHANGING AVATAR!!! ^ω^
Re: Help with basic script
« Reply #15 on: May 08, 2010, 02:14:07 am »
Array[1..32] of Integer;


You placed 3 dots (...).
Last year, I dreamt I was pissing at a restroom, but I missed the urinal and my penis exploded.

Offline Swompie

  • Camper
  • ***
  • Posts: 390
Re: Help with basic script
« Reply #16 on: May 08, 2010, 04:07:23 am »
http://forums.soldat.pl/index.php?topic=29911.0
Part VI: Types

That's all you need for your that what you're trying to do.

Offline frosty

  • Flagrunner
  • ****
  • Posts: 601
  • Uber Desert Eagle ^^
Re: Help with basic script
« Reply #17 on: May 08, 2010, 05:12:43 am »
holy crap is it that simple?? :O


thanks swompie :D

From: May 08, 2010, 05:49:42 am
hmm having some trouble

semicolon expected on line 12


« Last Edit: May 08, 2010, 05:49:43 am by frosty »
check out my server! click here

If at first you don't succeed, Improvise! :D

Offline squiddy

  • Soldat Beta Team
  • Camper
  • ******
  • Posts: 333
  • Flagger assassin
    • SoldatX
Re: Help with basic script
« Reply #18 on: May 08, 2010, 01:01:33 pm »
holy crap is it that simple?? :O


thanks swompie :D

From: May 08, 2010, 05:49:42 am
hmm having some trouble

semicolon expected on line 12

Go this:

Code: (pascal) [Select]

Var
 Kills: Array[1..32] of Integer;

Procedure OnPlayerKill(Killer, Victim: Byte; Weapon: String);
 Begin
 if Killer <> Victim Then Kills[Killer] := Kills[Killer] + 1;   
end;

//Didn't get the rest of the Script..
www.soldatx.com.br - The brazilian Soldat community.

Offline croat1gamer

  • Veteran
  • *****
  • Posts: 1327
  • OMG CHANGING AVATAR!!! ^ω^
Re: Help with basic script
« Reply #19 on: May 08, 2010, 01:45:18 pm »
Code: (pascal) [Select]
procedure OnPlayerKill(Killer, Victim: byte; Weapon: string);
begin
//stuff
if Player[Killer] = Player[Victim] then begin
//stuff
end;
end;

You must place something after then, not just starting it in the next row, also there must be the same amount of begin's and end's in a procedure.
Last year, I dreamt I was pissing at a restroom, but I missed the urinal and my penis exploded.