Author Topic: Frosty's scripting thread  (Read 21888 times)

0 Members and 1 Guest are viewing this topic.

Offline frosty

  • Flagrunner
  • ****
  • Posts: 601
  • Uber Desert Eagle ^^
Frosty's scripting thread
« on: July 07, 2010, 01:25:53 pm »
ok this is my final scripting thread, i will post ALL of my scripting problems here, if it gets locked ill just make another, but id rather not so keep on topic please guys ;)

ok to start with, this script is being ann annoyance, i havent changed anything on it and neither has my scripter, according to my Panel Log nothig has changed since it was last working

so why the HELL am i getting a comma expected on line 38?

Code: (pascal) [Select]
var
Temp:String;

procedure SetPlayerStat(ID: byte; Stat: string;Value: variant);
begin
end;

function OnCommand(ID: Byte; Text: string): boolean;
begin
Result := false;
if LowerCase(Copy(Text, 1, 5)) = '/big ' then begin
Temp := Copy(Text, 6, length(Text)); // Then I copy anything after the first space into a var
if Temp <> '' then begin
DrawText(0,Temp+'!',330,RGB(255,255,255),0.20,40,240);
end else WriteConsole(0, 'Admin has just failed epicly!', $FF0000); // error messagez
end;

if Text = '/invin' then
begin
SetPlayerStat(ID, 'Health',999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999);
WriteConsole(ID,'temporary invinicibility enabled',$FF0000);
end;
end;

procedure OnPlayerSpeak(ID: Byte; Text: string);
begin
if Text = '!adminlist' then
begin
WriteConsole(0,'Head admin:',$EEFF8000);
WriteConsole(0,'[NMJAS][FSG][Anti]Frost',$EEFF8000);
WriteConsole(0,'',$EEFF8000);
WriteConsole(0,'Scripters/Second Head admin',$EEFFFF00);
WriteConsole(0,'DARK NEO',$EEFFFF00);
WriteConsole(0,'',$EEFFFF00);
WriteConsole(0,'Event Admins:',$EE00FF00);
WriteConsole(0,'<MT> Banan',$EE00FF00);
WriteConsole(0,'-GP- Abumi',$EE00FF00);
WriteConsole(0,'',$EE00FF00);
    WriteConsole(0,'',$EE00FF00);
  WriteConsole(0,'',$EE00FFFF);
end;

if Text = '!rules' then
begin
WriteConsole(0,'->No offensive behavior towards admin!',$EE00FF00);
WriteConsole(0,'',$EE00FF00);
WriteConsole(0,'->Do as the admin tell you!',$EE00FF00);
WriteConsole(0,'',$EE00FF00);
WriteConsole(0,'->NO mass spawning or teleing to flag',$EE00FF00);
WriteConsole(0,'if you need to mass spawn then get admins go ahead first!',$EE00FF00);
WriteConsole(0,'if you are unsure of something then ask',$EE00FF00);
WriteConsole(0,'',$EE00FF00);
WriteConsole(0,'->Cheating is not allowed',$EE00FF00);
WriteConsole(0,'scripts should be more than enough to compensate',$EE00FF00);
WriteConsole(0,'',$EE00FF00);
WriteConsole(0,'',$EE00FF00);
WriteConsole(0,'->No joining Bravo team',$EE00FF00);
WriteConsole(0,'if you are being an annoyance with this',$EE00FF00);
WriteConsole(0,'you WILL be kicked so take it as a warning',$EE00FF00);
WriteConsole(0,'you only get 1 chance with this!',$EE00FF00);
WriteConsole(0,'',$EE00FF00);
WriteConsole(0,'',$EE00FF00);
WriteConsole(0,'if you have any queries concerning rules then contact any admin',$EE00FF00);
WriteConsole(0,'We are happy to help!',$EE00FF00);
end;
end;

char corruption? how do i fix that in notepad? it is saved as ANSI btw
check out my server! click here

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

Offline Swompie

  • Camper
  • ***
  • Posts: 390
Re: Frosty's scripting thread
« Reply #1 on: July 07, 2010, 01:36:54 pm »
I've just tried to compile it, for me it worked fine ;S What server version are you using?

Code: [Select]
SetPlayerStat(ID, 'Health',999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999);Won't do anything else than setting your health to 200 which doesn't make you invincible.

Also why did you add this?
Code: [Select]
procedure SetPlayerStat(ID: byte; Stat: string;Value: variant); 
begin 
end;

And please use normal code tags if your piece of script has more than 20-30 lines, it's very annoying having to scroll down half a minute to read the next message ;<

Offline zyxstand

  • Veteran
  • *****
  • Posts: 1106
  • Mother of all Bombs
Re: Frosty's scripting thread
« Reply #2 on: July 07, 2010, 02:34:17 pm »
OK:

firstly, did you notice that the line number given to you in the error is always 1 more than what it really is (so you're looking at line 37) ((unless it counts include lines as well - then i dunno)

also, the line number is not the line number in the file, but rather an absolute line number from all the files it compiles. this means, if you compiles 2 files, each with (let's say) exactly 40 lines, and it says "error in line 60", it refers to (around) line 20 of the second compiled file.

now, here's a great debugging tip - and tell us what happens when you do it:
DOES THE ERROR PERSIST WHEN YOU TAKE OUT THE ERROR-CAUSING LINE (to be safe, comment out all the WriteToConsole lines from line 29 to line 38.
tell us if it works, or what the error is if it gives one.

ALSO: please show your include file!
Can't think of anything original to put here...

Offline kosik231

  • Major
  • *
  • Posts: 70
  • Where can I find Your soul?
Re: Frosty's scripting thread
« Reply #3 on: July 07, 2010, 04:46:21 pm »
add one more "end;" in the end of procedure OnCommand, i see there 4 begins but 3 ends
For signatures, you are allowed only one image in your signature which may not be wider and taller than 300 and 125 pixels, and may not be over 20kB in file size. No BMPs are allowed.

Offline zyxstand

  • Veteran
  • *****
  • Posts: 1106
  • Mother of all Bombs
Re: Frosty's scripting thread
« Reply #4 on: July 07, 2010, 05:52:56 pm »
add one more "end;" in the end of procedure OnCommand, i see there 4 begins but 3 ends

you are mistaken, i believe: there are 4 begins and 4 ends (one end is in-line with else statement)
Can't think of anything original to put here...

Offline frosty

  • Flagrunner
  • ****
  • Posts: 601
  • Uber Desert Eagle ^^
Re: Frosty's scripting thread
« Reply #5 on: July 07, 2010, 07:01:01 pm »
oops, seems i was reading the wrong error, silly me

ill post if i have more issues ;)

my host tells me that he is using server version 2.6.6 for his clients so thats what i must be using

also, he recently had a hardware upgrade, since then i got this unknown identifier error in a script that i downloaded, it worked for ages and has never been changed, but there was a massive design flaw, one boolean array variable that was "serk" was actually typed as "beserk" everywhere else where that variable was used (explains the script constantly crashing(which had me dumbfounded for quite some time))

just thought id shed some light on something that might help others (maybe newer programmers) should they come accross a similar problem

while i think of it, is there any way to add new scripts without recompiling everything?
« Last Edit: July 07, 2010, 07:56:24 pm by frosty »
check out my server! click here

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

Offline kosik231

  • Major
  • *
  • Posts: 70
  • Where can I find Your soul?
Re: Frosty's scripting thread
« Reply #6 on: July 08, 2010, 06:06:20 am »
Code: [Select]
end else WriteConsole(0, 'Admin has just failed epicly!', $FF0000); // error messagez oh yea... sorry, i thought there was end else BEGIN xD just havent seen it, my mistake
For signatures, you are allowed only one image in your signature which may not be wider and taller than 300 and 125 pixels, and may not be over 20kB in file size. No BMPs are allowed.

Offline frosty

  • Flagrunner
  • ****
  • Posts: 601
  • Uber Desert Eagle ^^
Re: Frosty's scripting thread
« Reply #7 on: July 09, 2010, 08:21:55 pm »
WTF????

[1:1] variable expected

(see attachment, Includes file also there)

was working fine earlier now it wont compile for some reason
check out my server! click here

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

Offline Swompie

  • Camper
  • ***
  • Posts: 390
Re: Frosty's scripting thread
« Reply #8 on: July 10, 2010, 02:29:09 am »
Code: [Select]
procedure inisave(FileName: string; var iniFile: TINIFile);
begin
end;

function iniload(FileName: string): TINIFile;
begin
end;

procedure iniwrite(FileName, section, key, value: string);
begin
end;
Just pasting this into your script doesn't make it work...

Offline frosty

  • Flagrunner
  • ****
  • Posts: 601
  • Uber Desert Eagle ^^
Re: Frosty's scripting thread
« Reply #9 on: July 12, 2010, 01:28:24 pm »
OMFG!!!!!

just got the same error again, see attachments

wtf is going on?

Code: [Select]
[*] Shop -> [Error] (1:1): Variable Expected
[*] Compiling Shop -> Done in 0.03 secs
Shutting down server...
check out my server! click here

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

Offline zyxstand

  • Veteran
  • *****
  • Posts: 1106
  • Mother of all Bombs
Re: Frosty's scripting thread
« Reply #10 on: July 12, 2010, 01:58:31 pm »
OMG i thought i answered this already!

Code: [Select]
procedure iniSave(FileName: string; var iniFile: TINIFile);
why does it say VAR in there?
Can't think of anything original to put here...

Offline frosty

  • Flagrunner
  • ****
  • Posts: 601
  • Uber Desert Eagle ^^
Re: Frosty's scripting thread
« Reply #11 on: July 12, 2010, 07:52:15 pm »
i dont know, ask PerroAZUL

Quote from: PerroAZUL
procedure iniSave(FileName: string; var iniFile: TINIFile);

quoted from here:
http://forums.soldat.pl/index.php?topic=22338.0

anyways if i remove the word var from function iniload, i get type mismatch on line 580, i cant see any type mismatche in the scriot, and the error must be where im using the inifunctions on about line 580, because if i comment the ini things out on lines 579 to 580 (all 3 lines commented out) it works fine

have a look at the attachment, see what you guys think of it, maybe im missing something, forgive me (coding straight after a hard days work is hard as hell cuz im so tired)

edit: done some debugging, if i have only the iniwrite and iniload lines uncommented it works fine, just inisave thats not working, but why would that be erroring when the syntax for the ini file to load is string?

ive just tried this where all the ini things are:
iniFile:='Players/'+GetPlayerStat(ID,'Name')+'.ini'
      ini:=iniLoad(iniFile);
      IniWrite(IniFile,'stats','reg', '1');
      inisave(iniFile,ini);

but the resulting ini file is 0 bytes and completely empty

reuploaded pas file, it has these lines in it, look at line 580, line 580 is one of those lines (for quick browsing of file)
« Last Edit: July 12, 2010, 09:03:52 pm by frosty »
check out my server! click here

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

Offline zyxstand

  • Veteran
  • *****
  • Posts: 1106
  • Mother of all Bombs
Re: Frosty's scripting thread
« Reply #12 on: July 12, 2010, 08:43:28 pm »
yes, that is what it says, but it causes the error.
if you take out "var " then you won't get that error. you'll get a different error on line 581 (it says 582)
the line that starts with "inisave" seems to have weird arguments. (you also get an unimportant warning)
without studying the code a lot i can't do much, but try changing the line to such:
ORIGINAL: 
Code: [Select]
inisave('Players/'+GetPlayerStat(ID,'Name')+'.ini',iniLoad('Players/'+GetPlayerStat(ID,'Name')+'.ini'));
change to:
Code: [Select]
inisave('Players/'+GetPlayerStat(ID,'Name')+'.ini',iniLoad('Players/'+GetPlayerStat(ID,'Name')+'.ini'));
that compiles fine, but i dunno how that whole script is supposed to work, so this is my best guess as to what it should be.
no guarantees or warranties as to if this will work.

also, DEBUG YOURSELF GODDAMNIT!  don't quote other people saying that's what they said it's supposed to be like. take some initiative and do something. if you take out the "var ", it works (as i've said) - if you leave it how they said it, it doesn't work. so maybe they have something wrong!
Can't think of anything original to put here...

Offline frosty

  • Flagrunner
  • ****
  • Posts: 601
  • Uber Desert Eagle ^^
Re: Frosty's scripting thread
« Reply #13 on: July 12, 2010, 08:48:44 pm »
read the edit

it compiles fine but the resulting ini file is 0 bytes, what its supposed to do at the moment is create an ini file with <playername> as name
and create a section called stats and a key called reg and write 1 to it, just until i get it working then im gonna add more

btw: where did you get this part from the original script? u say ORIGINAL but its not, the (what you called Original) and what you posted are no different

inisave('Players/'+GetPlayerStat(ID,'Name')+'.ini',iniLoad('Players/'+GetPlayerStat(ID,'Name')+'.ini'));

where the hell did you get that from my script ????

in my script its:

inisave('Players/'+GetPlayerStat(ID,'Name')+'.ini','Players/'+GetPlayerStat(ID,'Name')+'.ini');

see? completely different


edit: btw2: you didnt have to be such a dick and /rage on me im only askin for help

anyways, that line fixed the problem, tx :)
« Last Edit: July 12, 2010, 09:08:07 pm by frosty »
check out my server! click here

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

Offline frosty

  • Flagrunner
  • ****
  • Posts: 601
  • Uber Desert Eagle ^^
Re: Frosty's scripting thread
« Reply #14 on: July 17, 2010, 06:15:37 am »
is there any way to check to see if a particular player is in predator mode, or has just picked up a predator or flame god bonus? i realize i can check flame god with Getplayerstat, but how do i check for predator?

this is what i mean, (behold, ma shop plan):
see in achievements, "assassins son", etc, thats what i need pred check for
also is it feasable to change player names, ie: add rank inits to the start? (also in plan)

btw, still having trouble with ma Nuke Turret, everything else is fine, rank system is in place and everything else is on plan ready to be coded in, wont have any issue with the rest, just need to know if it possible to add rank inits to playernames, and how to check if someones in pred
« Last Edit: July 17, 2010, 06:27:45 am by frosty »
check out my server! click here

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

DarkCrusade

  • Guest
Re: Frosty's scripting thread
« Reply #15 on: July 17, 2010, 06:40:17 am »
You can only check whether a player picked up a predator box by idling through all objects in AppOnIdle and plain guess who picked up a box by his coordinates compared to the coordinates of the box. Then you can start a timer for this player, though this method would be very inaccurate.

Just give the player the predator box manually by GiveBonus() it's easier.

Offline frosty

  • Flagrunner
  • ****
  • Posts: 601
  • Uber Desert Eagle ^^
Re: Frosty's scripting thread
« Reply #16 on: July 17, 2010, 06:42:28 am »
i know but i want to trigger an event when a player does pick one up, for example, if a player is in pred and makes a kill, a certain variable would be raised

maybe if i grabbed the players coordinates continously after GiveBonus was used (thats the only way players are getting bonuses atm, bonuses are turned off), hmm, then, umm,  Raycast between the last grabbed coords and the victim, and guess the killer-in-pred's ID that way

hmm...
« Last Edit: July 17, 2010, 06:46:34 am by frosty »
check out my server! click here

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

DarkCrusade

  • Guest
Re: Frosty's scripting thread
« Reply #17 on: July 17, 2010, 06:43:28 am »
Yeah, that's what you need the timer for. If the timer is not -1 you can trigger any event.

Offline frosty

  • Flagrunner
  • ****
  • Posts: 601
  • Uber Desert Eagle ^^
Re: Frosty's scripting thread
« Reply #18 on: July 17, 2010, 06:47:02 am »
hold up, what timer???

edit:oooh i get ya, set a timer, when Givebonus(pred) is used and when the timer is above 0 and a kill is made i can do it that way, since the ID of the receiver is already defined by the Givebonus, thanks Dark :)
« Last Edit: July 17, 2010, 06:50:29 am by frosty »
check out my server! click here

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

DarkCrusade

  • Guest
Re: Frosty's scripting thread
« Reply #19 on: July 17, 2010, 06:48:31 am »
The timer that you must start when you recognized a predator box has vanished.