Official Soldat Forums

Server Talk => Scripting Discussions and Help => Topic started by: frosty on April 29, 2010, 01:48:13 am

Title: Help with basic script
Post by: frosty 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)
Title: Re: Help with basic script
Post by: squiddy 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;
Title: Re: Help with basic script
Post by: frosty 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 (http://pastebin.com/axQ1p8DW)

btw the line above is line 70 in the full code
Title: Re: Help with basic script
Post by: dnmr 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^
Title: Re: Help with basic script
Post by: frosty 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 (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
Title: Re: Help with basic script
Post by: dnmr 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  ;) )
Title: Re: Help with basic script
Post by: frosty 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:
(http://i583.photobucket.com/albums/ss278/fro16_photo/Soldat%20Scripting%20Code/BioModCode.jpg) (http://i583.photobucket.com/albums/ss278/fro16_photo/Soldat%20Scripting%20Code/BioModCode.jpg)

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
Title: Re: Help with basic script
Post by: Swompie 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;
Title: Re: Help with basic script
Post by: frosty 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

(http://i583.photobucket.com/albums/ss278/fro16_photo/Soldat%20Scripting%20Code/Snap_20100430222241_001.jpg) (http://i583.photobucket.com/albums/ss278/fro16_photo/Soldat%20Scripting%20Code/Snap_20100430222241_001.jpg)
Title: Re: Help with basic script
Post by: SpiltCoffee 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.
Title: Re: Help with basic script
Post by: Swompie on April 30, 2010, 09:06:21 am
Try to remove spaces in the line where the error appears.
Title: Re: Help with basic script
Post by: frosty 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
Title: Re: Help with basic script
Post by: SpiltCoffee 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.
Title: Re: Help with basic script
Post by: frosty 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
Title: Re: Help with basic script
Post by: frosty 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

(http://i583.photobucket.com/albums/ss278/fro16_photo/Soldat%20Scripting%20Code/Snap_20100508115717_001.jpg)


From: May 07, 2010, 11:28:52 pm
getting a syntax error line 3
Title: Re: Help with basic script
Post by: croat1gamer on May 08, 2010, 02:14:07 am
Array[1..32] of Integer;


You placed 3 dots (...).
Title: Re: Help with basic script
Post by: Swompie on May 08, 2010, 04:07:23 am
http://forums.soldat.pl/index.php?topic=29911.0 (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.
Title: Re: Help with basic script
Post by: frosty 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

(http://i583.photobucket.com/albums/ss278/fro16_photo/Soldat%20Scripting%20Code/Snap_20100508202155_001.jpg)
Title: Re: Help with basic script
Post by: squiddy 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..
Title: Re: Help with basic script
Post by: croat1gamer 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.
Title: Re: Help with basic script
Post by: frosty on May 08, 2010, 07:29:57 pm
but then how would i show it in a writeconsole message when they die considering Kills is array in your code

would it be.....?
Code: (pascal) [Select]
if Player[Killer] = Player[Victim] then writeconsole(Victim,'your kill streak: '+inttostr(Kills[Victim]),$FFEO2OFE)
also, kills would be alot more than 32, or is that just storing the values for all 32 ppl? i am still a tiny bit confused about the arrays

From: May 08, 2010, 07:40:18 pm
also im getting a type mismatch with the writeconsole part of the code posted above, if i get rid of inttostr it still says type mismatch so how would i show it in a writeconsole message?
Title: Re: Help with basic script
Post by: squiddy on May 08, 2010, 07:42:20 pm
also, kills would be alot more than 32, or is that just storing the values for all 32 ppl? i am still a tiny bit confused about the arrays

Array[1..32] Stores 32 datas for 32 different, in the case, players.

Go:

Code: (pascal) [Select]
Var
 Kills: Array[1..32] of Integer;

Procedure OnPlayerKill();
 Begin
  if Killer <> Victim Then Begin //Checks if killer is different from victim
   Kills[Killer] := Kills[Killer] + 1; //Increasing by one Killer's Kills.
  WriteConsole(Killer,'Your Kill Streak: '+IntToStr(Kills[Killer]),$FFFFFF);
 end else WriteConsole(ID,'You cant get kills by killing yourself!',$FFFFFF);
end;

//That should do it.

//Arrays store data for [Min..Max] values you put in.

//Like, go:

Procedure OnPlayerSpeak();
 Begin
  if Text = '!mykills' Then WriteConsole(ID,'Your kills: '+IntToStr(Kills[ID]),$FFFFFF);
end;

//See?

//This \/

{
Var
 Kills: Integer;
}

//That /\ is a global var. It's unique for every player in the server.

//If, for instance, you go "Kills := 0;", then every player's kills streak will be reseted.

//Doing "Kills[ID] := 0;" would only reset one player's kills streak

//Hope you've learned :)

//Any more questions, feel free to ask :D
Title: Re: Help with basic script
Post by: frosty on May 08, 2010, 07:52:51 pm
nevermind, inttostr works perfect, its just the color value was incorrect, now its working on my test server perfectly, heres the working code:


From: May 08, 2010, 07:56:42 pm
and thanks squiddy :D that makes life alot easier :D
Title: Re: Help with basic script
Post by: dnmr on May 09, 2010, 01:01:13 am
frosty.. try using the "code=pascal" tag for syntax highlighting if you're not going to use nopaste services (with square braces instead of quotes ofc, and a /code in the end).
Looking at your screenshots kills people from inside bit by bit
Title: Re: Help with basic script
Post by: frosty on May 09, 2010, 01:38:20 am
dnmr why did i start doing this in the first place???

u obviously havent read why

posting code in the code highlighing (code)(/code)  does not indent it properly, and then you complain because you cant read the indents, same with pastebin it does not indent it properly, then you complain because you cant read the code because it hasnt indented properly, so dont complain cuz this is what you get, and im not changing it >:( and im sick of complaints so build a f**king bridge and get the f**k over it

i mean how f**king hard is ot to click the screenshot and read it? not f**king hard so whats the big f**king deal?

so:
-i use code=pascal, it doesnt indent properly= you complain
-i use pastebin, it doesnt indent properly=you complain
-i post easy to read screenshots AND include the code=you complain
-i post it as plain code i know your going to complain

this is very annoying especially when i have taken the best option which IS indented properly so you can actually READ IT

and this getting beyond a joke so in future why dont i just post it as normal text just to annoy you? just to show just how annoyed i am at this bullshit?

From: May 09, 2010, 01:50:26 am
i ahve no other option except to post screenshots as thats the only thing that WILL BE INDENTED PROPERLY SO STFU
Title: Re: Help with basic script
Post by: Swompie on May 09, 2010, 01:52:38 am
We're just giving tips away, we know what's good and what not.
Btw. I never had problems with the indenting here..

Anyway, here's an example with types.
Code: (pascal) [Select]
type // start type
   TPlayer = Record // name of the type
     Kills: integer;
     Anoter_Variable: byte;
   end; // declares the end of the TPlayer type.

var
   Player: Array [1..32] of TPlayer; // next you need to declare it as an variable.

//Looks like that when you use it: Player[ID].Variable

procedure OnPlayerKill(Killer, Victim: byte; Weapon: string);
begin
   if Killer <> Victim then begin
     Player[Killer].Kills := Player[Killer] + 1;
     WriteConsole(ID, 'Kill streak: ' + inttostr(Player[Killer].Kills), $FFFFFF);
   end;
   Player[Victim].Kills := 0;
end;
Now you should check it  ::)
Title: Re: Help with basic script
Post by: frosty on May 09, 2010, 01:56:04 am
thanks swompie, see dnmr? no one else has any problem, if you post anything like that again ima just ignore it
Title: Re: Help with basic script
Post by: Swompie on May 09, 2010, 01:59:36 am
thanks swompie, see dnmr? no one else has any problem, if you post anything like that again ima just ignore it
Tbh idc how you post it, but it's not the forum fucking up the indent, srsly it depends on how you do it,
do you use a mix of tabs and spaces? I never noticed anyone having trouble with it >_>
Title: Re: Help with basic script
Post by: frosty on May 09, 2010, 02:10:06 am
i always use just tabs cuz its easer, but somehow the size of a tab gets doubled and you get lines everywhere if i use pastebin so is started posting screenshots

and all id o i copy and paste and it screws up so yeh

also most browsers put half of most of the lines to the next line cuz it wont fit all on page so u still get lines everywhere so yeh
Dnmr tends to complain about my postings, pastebin or otherwise
Title: Re: Help with basic script
Post by: SpiltCoffee on May 09, 2010, 10:17:42 am
Looking at the latest screenshot you attached, frosty, I can't help but notice that you're indentation is poor. You should be using two spaces for every indent, and make sure that you indent your block statements and conditional statements correctly. :)
Title: Re: Help with basic script
Post by: frosty on May 09, 2010, 01:18:40 pm
so using a single tab for each indent is bad? if i use spaces then notepad++ doesnt show me the indent guide(the lines going from the begins to the ends) and using spaces somehow corrupts the script i had to use tabs as indent just to fix up one of my scripts so idk what to do
Title: Re: Help with basic script
Post by: Gizd on May 09, 2010, 02:12:42 pm
so using a single tab for each indent is bad? if i use spaces then notepad++ doesnt show me the indent guide(the lines going from the begins to the ends) and using spaces somehow corrupts the script i had to use tabs as indent just to fix up one of my scripts so idk what to do
How can using 2 spaces corrupt script? After every operator creating a list like begin/case/var/const you should move to next column and you're not doing that.
Title: Re: Help with basic script
Post by: Swompie on May 09, 2010, 02:48:28 pm
Just because it doesn't show the indent guide doesn't mean it corrupts the script in any way, I never had problems with spaces, you just saved the file in the wrong format or w/e.
Also you don't need that indent guide, works fine without it imo if you can script abit..
Tbh I think that you can that? Also I'm pretty sure that you may can change when the indent guide pops up somewhere, google is your friend if you're going to change your style indenting scripts.
Title: Re: Help with basic script
Post by: dnmr on May 09, 2010, 03:20:34 pm
dear frosty. Nobody's complaining about how the forum or pastebin treat tabs. The thing is, when you post text in any form, anyone here can copy it and paste it in his editor of choice. If he's not comfortable with tabs, they can be replaced by any number or spaces in no time in most text editors. When you post a graphical representation of the text, it is not that easy to copy the code and work with it from there. Nobody's going to use a text recognition program, it's just ridiculous.

The key problem is not in how different applications treat tabs/spaces, the problem is in your indenting. It's as good as no indenting at all, because it is not consistent and at some places you don't tab your code at all or tab it too much, thus breaking the code structure and provoking the loss of some begins and ends.
Title: Re: Help with basic script
Post by: SpiltCoffee on May 09, 2010, 06:14:19 pm
If you want Notepad++ to use two spaces instead of a real tab whenever you press the tab button, do the following:

1. In Notepad++, go to Settings > Preferences.
2. In this new window, click on the Language Menu/Tab Settings tab.
3. On the right side, scroll down the language list and select Pascal.
4. Check the box that says "Replace by space".
5. Click on the blue underlined number so that a little box appears, and type in the number 2, and then press enter.
6. Click close and enjoy using two spaces whenever you use tab, and seeing Notepad++ offer the indent guide. :)
Title: Re: Help with basic script
Post by: squiddy on May 09, 2010, 09:13:47 pm
If you want Notepad++ to use two spaces instead of a real tab whenever you press the tab button, do the following:
[...]

I know this doesn't concern me, but thanks! :P
Title: Re: Help with basic script
Post by: frosty on May 09, 2010, 10:42:36 pm
@dnmr: well considering i am adding the pas file, dnmr i dont see what the problem is, noone needs to use image recognition software because the physical pas file with the code is there in my posts, you are confusing me dnmr.... unless you are implying that maybe i shuld also post a pastebin URL with my code snapshot instead of attaching the pas file to the post with the snapshot?

@Spilt: Thankyou spilt that will help alot :)

From: May 10, 2010, 01:22:02 am
oh god i have got to be missing something here

Code: (pascal) [Select]
procedure OnMapChange(NewMap: string);
begin
For i := 1 to 32 do
begin
GiveBonus(i, BonusID);
    if GetPlayerStat(i,'Team') = 1 then begin
      Cash:=Cash+GetPlayerStat(i,'Kills');
      WriteConsole(i,'Match Bonus, congrats you have earned your team: '+GetPlayerStat(i,'Kills')+' bonus cash for kills this match',$EE81FAA1);
    end;
end;
end;

i want the Cash to be updated with all the kills last map from each person on alpha team as a bonus but this doesnt launch until the map has actually changed

how do i get it to update the cash just before the time is up and can i set the update to launch when /nextmap is used without causing any conflicts?

wtf once again it hasnt indented correctly and i used your thing to update tabs to 2 spaces spilt
Title: Re: Help with basic script
Post by: SpiltCoffee on May 10, 2010, 03:53:44 am
Well, in 2.6.5, you'd have to use the AppOnIdle event and check to see if there is a certain amount of time left, and if so, you do your code. Otherwise, if you're using 2.7.0, you can use the OnGameEnd event.
Title: Re: Help with basic script
Post by: dnmr on May 10, 2010, 08:54:21 am
oh god.. you're actually attaching the code as well... That makes the screenshots totally pointless. Nvm.
Title: Re: Help with basic script
Post by: frosty on May 10, 2010, 01:27:01 pm
@dnmr: :P lol
Title: Re: Help with basic script
Post by: frosty on June 02, 2010, 01:49:07 am
very simple problem , probably a solution thats staring me in da face

ok i have added an item to my shop which when the person buys the item and captures the Blue flag, this then Teleports them to where the red flag is, problem is, the player warps without the flag, is there any way i can warp the player with the captured flag?

da code:
Code: (pascal) [Select]
var HBFT:Array[1..32] of Boolean;

function OnPlayerCommand(ID: Byte; Text: string): boolean;
begin
  if Text = '/buy FTP' then begin
    if Cash < 10000 then begin
      WriteConsole(0,IdtoName(ID)+' just tried to purchase a Flag Teleport, not enough funds!',$EE81FAA1);
    end;
    if Cash >= 10000 then begin
      Cash :=Cash-10000;
      WriteConsole(0,IdtoName(ID)+' has just bought a Flag Teleport for 10000 Cash',$EE81FAA1);
      HBFT[ID]:=True;
    end;
  end;
end;

procedure OnFlagGrab(ID, TeamFlag: byte; GrabbedInBase: boolean);
begin
  if HBFT[ID] = True then begin
    MovePlayer(ID,GetObjectStat(1,'X'), GetObjectStat(1, 'Y'));
    WriteConsole(ID,'Grab detected, moving you now...',$EE81FAA1);
    HBFT[ID]:=False;
  end;
end;
Title: Re: Help with basic script
Post by: Hacktank on June 02, 2010, 02:00:38 am
No, it is a hacker preventitive measure that warping returns the flag. But you may be able to spawnobject a new flag onto him where he warps? :)
Title: Re: Help with basic script
Post by: frosty on June 02, 2010, 02:06:44 am
thanks Hacktank now i got something to work off

From: June 02, 2010, 02:30:03 am
hmm, the flags arent on the Object list, i guess its definitely not possible to do

From: June 02, 2010, 02:58:36 am
hmm lol sometimes it works sometimes it doesnt, its quite unpredictable where you land if you have the flag after grabbing and it warps you With the flag, lol
Title: Re: Help with basic script
Post by: Swompie on June 02, 2010, 03:03:39 am
MovePlayer() is broken...
Title: Re: Help with basic script
Post by: frosty on June 02, 2010, 03:23:16 am
aww what? so what else can i use to move players with? have a few new scrips in mind, need something that works with soldatserver 263

From: June 02, 2010, 01:21:14 pm
hmm was it 263 or 253? cant remember
Title: Re: Help with basic script
Post by: Swompie on June 03, 2010, 05:50:58 am
Blurr, I failed..
Well, actually it sometimes cause people to drop their weapons, I read that the server causes you to drop the flag because of some "anti cheat" stuff or so, jbut not sure if that's true. (But it should move to correct XY, atleast it does in eC's servers)
The object styles of alpha/bravo flags should be 1 and 2 iirc.
Title: Re: Help with basic script
Post by: frosty on June 04, 2010, 01:39:34 am
The object styles of alpha/bravo flags should be 1 and 2 iirc.
nope, im going to have to find out how the devs on ECs servers did it

list is exactly as follows:
ObjType List:
 1        Desert Eagle
 2        HK MP5
 3        AK 74
 4        Steyr AUG
 5        Spas 12
 6        Ruger77
 7        M79
 8        Barrett M82A1
 9        Minimi
 10       Minigun
 11       USSOCOM
 12       Combat Knife
 13       Chainsaw
 14       LAW
 15       Stationary Gun
 16       Medical Kit
 17       Grenade Kit
 18       Flamer Kit
 19       Vest Kit
 20       Predator Kit
 21       Berserk Kit
 22       Cluster Kit
Title: Re: Help with basic script
Post by: Swompie on June 04, 2010, 03:13:17 am
You've just failed.. You don't wanna tell me that eC doesn't know what the list is? >_>
Title: Re: Help with basic script
Post by: frosty on June 04, 2010, 05:17:16 am
no i wanna ask Ec what the exact list is, because id number 1 does actually spawn DE and id 2 actually does spawn a mp5 so if thats the case then what are the numbers for the flags?   why am i asking? because i tried all the numbers
Title: Re: Help with basic script
Post by: Swompie on June 04, 2010, 05:21:46 am
Becuase thats SpawnObject() and not GetObjectStat()..?

Oh now I get what you want, you wanna spawn a flag with SpawnObject?
Title: Re: Help with basic script
Post by: frosty on June 04, 2010, 05:34:17 am
yes, and if its not Spawnobject that works, then how did Ec get the flags to correct XY pos when ppl use aether?
Title: Re: Help with basic script
Post by: Swompie on June 04, 2010, 06:58:40 am
oh god, you really need to learn alot..
it's a bug/glitch w/e you wanna call it which causes the flag to respawn at the flag spawns
Title: Re: Help with basic script
Post by: dnmr on June 04, 2010, 07:55:48 am
and you cant spawn flags directly. Try moving the flag spawn point and killing the actual flag - the server should respawn it where you moved the spawnpoint
Title: Re: Help with basic script
Post by: DorkeyDear on June 04, 2010, 09:00:55 am
SpawnObject does not work with flags. You must KillObject a flag (if it already exists), and then spawn in with SetObjetStat (that is, if I recall correctly; its been a while since I did anything like this). Refer to the wiki objects article (http://devs.soldat.pl/wiki/index.php?title=Objects).
Title: Re: Help with basic script
Post by: frosty on June 04, 2010, 08:02:09 pm
i have a problem with that, how do i get the objectid for the existing flag?

im getting a type mismatch error somewhere in this section of code, im thinking its the KillObject line because its not working from a spawnobject variable, but since the flags have already been spawned, how do i get the id for the already spawned flags, Killobject only works with Spawnobect, but since i never used spawnobject to spawn the flag and it was done by server.....
Code: (pascal) [Select]
i:=KillObject(2);
SetSpawnStat(i,'x',GetPlayerStat(ID,'x'));
SetSpawnStat(i,'y',GetPlayerStat(ID,'y'));
Title: Re: Help with basic script
Post by: DorkeyDear on June 04, 2010, 08:07:59 pm
you must loop through all the objects, check using GetObjectStat if style == a flag; if so, that is the id of the flag. You can then KillObject(that id) and do whatever else you wish (im not sure why KillObject returns anything, as it shouldn't; it might be a typo in the manual, since it says "procedure" but also ": integer" :P)
Title: Re: Help with basic script
Post by: absoulut1234 on June 05, 2010, 07:49:43 am
frosty??
Are you [NMJAS]Frosty?
if you are,i am DD! yahaha~ ::)  8)
Title: Re: Help with basic script
Post by: frosty on June 05, 2010, 06:17:28 pm
yeah!!! :cool: thats me DD :D
Title: Re: Help with basic script
Post by: frosty on June 10, 2010, 01:25:32 am
got another problem, trying to make a counter which counts up seconds and minutes until the player dies, problem is the values arent updating
Code: (pascal) [Select]
var
TSec,Tmin,BTSec,BTMin:Array[1..32] of Integer;
TA:Array[1..32] of Boolean;

procedure AppOnIdle(Ticks: integer);
begin
  for i:= 1 to 32 do begin
    if GetPlayerStat(i,'human') = true then if GetPlayerStat(i,'Alive') = true then TA[i]:= True;
    if TA[i] = True then begin
      TSec[i]:=TSec[i]+1;
      if TSec[i] = 60 then begin
        TMin[i]:= TMin[i]+1;
        TSec[i]:= 0;
      end;
    end;
    if GetPlayerStat(i,'human') = true then if GetPlayerStat(i,'Alive') = False then TA[i]:= False;
    If TA[i] = False then begin
      BTSec[i]:=TSec[i];
      TSec[i]:=0;
      if TMin[i]>BTMin[i] then BTMin[i]:=TMin[i];
      TMin[i]:=0;
    end;
  end;
end;

i want to show the time in this message when certain events happen:
Code: (pascal) [Select]
WriteConsole(i,'Longest Time Survived: '+inttostr(BTMin[i])+':'+inttostr(BTSec[i])+' (M:S)!',$EE81FAA1);
when the message does trigger it shows 0:0 where the vars are, which means that the values arent being assigned properly in the initial "for" loop or they are being assigned and something is causing them to be set to 0 every second

what am i missing here?

Referance:
TA sees if the player is alive and human
TSec and TMin : current time alive
BTSec and BTMin : Best time alive
Title: Re: Help with basic script
Post by: DarkCrusade on June 10, 2010, 01:47:22 am
Code: (pascal) [Select]
const
  ClBad = $FFFF44;

Type
  Stats = Record
  LongTime: Boolean;
  TSec,Tmin,BTSec,BTMin: Integer;
end;

var
  Player: Array[1..32] of Stats;
LongestTime: Array[1..2] of Integer;

Procedure ResetStats(ID:Byte);
  begin
  Player[ID].LongTime := false;
end;

Procedure CheckTime(ID:Byte); 
begin
    if Player[ID].BTMin > LongestTime[1] then begin
  LongestTime[1] := Player[ID].BTMin;
LongestTime[2] := Player[ID].BTSec;
Player[ID].LongTime := true;
end else begin
      if Player[ID].BTMin = LongestTime[1] then
  if Player[ID].BTSec > LongestTime[2] then begin
  LongestTime[1] := Player[ID].BTMin;
    LongestTime[2] := Player[ID].BTSec;
    Player[ID].LongTime := true;
end;
    end;
  end;

Procedure OnJoinGame(ID,Team:Byte);
  begin
  ResetStats(ID);
end;

Procedure AppOnIdle(Ticks: integer);
var
  i:Byte;
begin
 for i:= 1 to 32 do if (GetPlayerStat(i,'Active') = true) AND (GetPlayerStat(i,'Alive') = true) then begin
if GetPlayerStat(i,'Human') = true then begin
   TSec[i]:= TSec[i]+1;
   if TSec[i] = 60 then begin
     TMin[i]:= TMin[i]+1;
     TSec[i]:= 0;
end;
   end else begin
     BTSec[i]:=TSec[i];
     TSec[i]:=0;
     if TMin[i] <> 0 then BTMin[i]:=TMin[i];
     TMin[i]:=0;
CheckTime(i);
   end;
end;
end;
Title: Re: Help with basic script
Post by: frosty on June 10, 2010, 03:02:28 am
wth im getting a crapload of errors with that code

im geting a syntax error and Begin expected error on line [2:2] to start with
Title: Re: Help with basic script
Post by: DarkCrusade on June 10, 2010, 06:38:19 am
I just acknowledged that there are random invisible chars that mess everything up. I'll post the corrected code in some minutes :3

EDIT: This should be working now..

Code: (pascal) [Select]
const
  ClBad  = $FFFF44;
  ClGood = $EE00FF;

Type
  Stats = Record
  LongTime: Boolean;
  TSec,Tmin,BTSec,BTMin: Integer;
end;

var
  Player: Array[1..32] of Stats;
LongestTime: Array[1..2] of Integer;

Procedure ResetStats(ID:Byte);
  begin
 Player[ID].LongTime := false;
end;

Procedure CheckTime(ID:Byte);  
begin
    if Player[ID].BTMin > LongestTime[1] then begin
  LongestTime[1] := Player[ID].BTMin;
    LongestTime[2] := Player[ID].BTSec;
    Player[ID].LongTime := true;
WriteConsole(0,IDToName(ID) + ' beats the record! His surviving time is ' + inttostr(Player[ID].BTMin) + ' minutes and ' + inttostr(Player[ID].BTSec) + ' seconds!', ClGood);
end else begin
      if Player[ID].BTMin = LongestTime[1] then
  if Player[ID].BTSec > LongestTime[2] then begin
      LongestTime[1] := Player[ID].BTMin;
    LongestTime[2] := Player[ID].BTSec;
    Player[ID].LongTime := true;
WriteConsole(0,IDToName(ID) + ' beats the record! His surviving time is ' + inttostr(Player[ID].BTMin) + ' minutes and ' + inttostr(Player[ID].BTSec) + ' seconds!', ClGood);
end;
      end;
  end;

Procedure OnJoinGame(ID,Team:Byte);
  begin
  ResetStats(ID);
end;

Procedure AppOnIdle(Ticks: integer);
var
  i:Byte;
begin
 for i:= 1 to 32 do if (GetPlayerStat(i,'Active') = true) AND (GetPlayerStat(i,'Alive') = true) then begin
if GetPlayerStat(i,'Human') = true then begin
    TSec[i]:= TSec[i] + 1;
    if TSec[i] = 60 then begin
      TMin[i]:= TMin[i] + 1;
      TSec[i]:= 0;
end;
    end else begin
      if TSec[i] > 0 then BTSec[i] := TSec[i];
      TSec[i] := 0;
      if TMin[i] > 0 then BTMin[i]:= TMin[i];
      TMin[i] := 0;
CheckTime(i);
      end;
end;
end;
Title: Re: Help with basic script
Post by: frosty on June 11, 2010, 12:46:40 am
(49:13): Unknown identifier 'TSec'

wtf?
i have had a look at the code but i dont get why its unknown since its defined in the Type
Title: Re: Help with basic script
Post by: Hacktank on June 11, 2010, 01:31:31 am
There is no array called TSec tho. Dark, didnt declare it.
Title: Re: Help with basic script
Post by: DarkCrusade on June 11, 2010, 02:01:28 am
I didn't test the code, I kind of rushed through it due to school stuff waiting for me and I actually thought you were able to debug a script yourself, Frosty :3
Title: Re: Help with basic script
Post by: frosty on June 11, 2010, 02:01:58 am
i can :3 but im still having same issue

still showing 0:0

i declared them in vars hacktank now it compiles

hers the full code: (see attachment)

From: June 12, 2010, 11:24:39 pm
Bump! still not working, someone help plz, this is irritating