Official Soldat Forums

Server Talk => Scripting Discussions and Help => Topic started by: frosty on July 07, 2010, 01:25:53 pm

Title: Frosty's scripting thread
Post by: frosty 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
Title: Re: Frosty's scripting thread
Post by: Swompie 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 ;<
Title: Re: Frosty's scripting thread
Post by: zyxstand 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!
Title: Re: Frosty's scripting thread
Post by: kosik231 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
Title: Re: Frosty's scripting thread
Post by: zyxstand 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)
Title: Re: Frosty's scripting thread
Post by: frosty 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?
Title: Re: Frosty's scripting thread
Post by: kosik231 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
Title: Re: Frosty's scripting thread
Post by: frosty 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
Title: Re: Frosty's scripting thread
Post by: Swompie 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...
Title: Re: Frosty's scripting thread
Post by: frosty 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...
Title: Re: Frosty's scripting thread
Post by: zyxstand 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?
Title: Re: Frosty's scripting thread
Post by: frosty 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 (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)
Title: Re: Frosty's scripting thread
Post by: zyxstand 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!
Title: Re: Frosty's scripting thread
Post by: frosty 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 :)
Title: Re: Frosty's scripting thread
Post by: frosty 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
Title: Re: Frosty's scripting thread
Post by: DarkCrusade 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.
Title: Re: Frosty's scripting thread
Post by: frosty 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...
Title: Re: Frosty's scripting thread
Post by: DarkCrusade 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.
Title: Re: Frosty's scripting thread
Post by: frosty 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 :)
Title: Re: Frosty's scripting thread
Post by: DarkCrusade on July 17, 2010, 06:48:31 am
The timer that you must start when you recognized a predator box has vanished.
Title: Re: Frosty's scripting thread
Post by: frosty on July 17, 2010, 06:48:50 am
srry, see edit :)

thanks for da help dark :)

edit: is there any way to change player names to add rank inits? like "pvt.<playername>"
Title: Re: Frosty's scripting thread
Post by: DarkCrusade on July 17, 2010, 07:07:03 am
No, because it is not only unnecessary but abusable. Like /setname ID ToothyVagina
Title: Re: Frosty's scripting thread
Post by: zyxstand on July 17, 2010, 06:28:31 pm
I had a question myself, but I didn't wanna start a brand new thread *cough*
what is the best (and most accurate name) to keep track of in-game time (ie: starting at the beginning of map) to be used, for example, in OnPlayerKill.  does something like GetTicks() exist?
Title: Re: Frosty's scripting thread
Post by: DorkeyDear on July 17, 2010, 08:29:59 pm
@tyxstand:
Code: [Select]
function GetTickCount(): cardinal;It is the same "tick unit" used by AppOnIdle. Return type is cardinal, or integer; not certain, but if I recall correctly I saw it first posted with type cardinal, which does not match AppOnIdle :/ not sure why but whatever, they are still interchangeable usually.
Title: Re: Frosty's scripting thread
Post by: zyxstand on July 17, 2010, 08:51:49 pm
@tyxstand:
Code: [Select]
function GetTickCount(): cardinal;It is the same "tick unit" used by AppOnIdle. Return type is cardinal, or integer; not certain, but if I recall correctly I saw it first posted with type cardinal, which does not match AppOnIdle :/ not sure why but whatever, they are still interchangeable usually.

uhhhm, GetTickCount is a real function? i've never heard of that anywhere. or are you suggesting that it should be implemented?
Title: Re: Frosty's scripting thread
Post by: DorkeyDear on July 17, 2010, 10:24:19 pm
@tyxstand:
Code: [Select]
function GetTickCount(): cardinal;It is the same "tick unit" used by AppOnIdle. Return type is cardinal, or integer; not certain, but if I recall correctly I saw it first posted with type cardinal, which does not match AppOnIdle :/ not sure why but whatever, they are still interchangeable usually.

uhhhm, GetTickCount is a real function? i've never heard of that anywhere. or are you suggesting that it should be implemented?
It is real. Test it out yourself if you do not believe me.
Title: Re: Frosty's scripting thread
Post by: frosty on July 18, 2010, 12:23:26 am
ok this is annoying me, for some reason its not reading the ini file correctly and keeps returning the set error when i use /char

Code: (pascal) [Select]
Procedure OnPlayerCommand()
if Text = '/char' then begin
    WriteConsole(ID,'Your stats',$EE81FAA1);
    WriteConsole(ID,'Total Kills: '+inttostr(trKills[ID])+'!',$EE81FAA1);
    WriteConsole(ID,'Rank: '+ReadINI('Players/'+GetPlayerStat(ID,'Name')+'.ini','stats','rank','*ERROR while loading rank*')+'!',$EE81FAA1);
    WriteConsole(ID,'Class: '+ReadINI('Players/'+GetPlayerStat(ID,'Name')+'.ini','stats','class','*ERROR while loading kills*')+'!',$EE81FAA1);
    WriteConsole(ID,'Total number of Predators used: '+ReadINI('Players/'+GetPlayerStat(i,'Name')+'.ini','stats','tupred','*ERROR while loading pred num*')+'!',$EE81FAA1);
    WriteConsole(ID,'Total number of Achievements: '+ReadINI('Players/'+GetPlayerStat(i,'Name')+'.ini','stats','kills','*ERROR while loading achievements*')+'!',$EE81FAA1);
  end;
end;

why is it erroring, thats the only line that is erroring, every other line is fine

the var should be updating when someone uses "/buy pred" or "/buy tpred' but its not updating for some reason

and heres the contents of the ini file that its reading from
Code: [Select]
[stats]
IP=
reg=1
kills=0
rank=1
class=1
tupred=0
tna=1

[achievements]
TP=1

Total Number of Preds used should be "0" not "*error while loading pred num*"

in fact that line isnt even being written to and i dont see why, should be when i type /save, but EVERYTHING else is writing so i dont see how debugging will do anything as the rest of the section thats its in is working perfect, including the line below thats is giving me the error

edit: also Total number of achievements is returning its error which is 0, atm it should be saying 1 ingame cuz thats what it says in the char file, tna=1, yet ingame tna=0 so something isnt right

full code is attached
Title: Re: Frosty's scripting thread
Post by: zyxstand on July 18, 2010, 01:06:31 am
first rule of debugging:
you can ALWAYS debug. if you honestly thing you cannot debug, you probably are: a) not debugging correctly, or b) not using your debug information correctly.

anyway, what is this "i" variable. maybe you mean "ID"?
Code: [Select]
GetPlayerStat(i,'Name')
yet another question:
which is programming-wise smarter:

a -> boolean
if (a) then a := false;

or sipmly:

a := false;

also, i'm about 70% of time a will be false when getting to this point.
Title: Re: Frosty's scripting thread
Post by: frosty on July 18, 2010, 03:27:46 am
uhh which line u reading from?

nvm another silly error
Title: Re: Frosty's scripting thread
Post by: DarkCrusade on July 18, 2010, 04:37:55 am
OnPlayerCommand is a function, not a procedure:

Code: (pascal) [Select]
Function OnPlayerCommand(ID:Byte; Text:String):Boolean;
begin

  Result := false // set to true to disallow commands
end;

Title: Re: Frosty's scripting thread
Post by: frosty on July 18, 2010, 01:28:23 pm
lol oops, u get the point tho, thanks dark

From: July 18, 2010, 11:53:10 pm
omg how the feck do i debug this?

for some reason lines are disappearing from the ini file, and some are being changed randomly

but there is nothing used in the code to remove keys from the ini file, only think that is is the code for the iniremovekey or whatever they were, but those functions arent being used, as for the randomly changing keys...., maybe theres somehing else thats causing this, but i got a headache and cant think at the moment, this is aggrivating


From: July 18, 2010, 11:57:05 pm
seems to be caused on lag spike
Title: Re: Frosty's scripting thread
Post by: zyxstand on July 19, 2010, 12:00:34 pm
lol oops, u get the point tho, thanks dark

From: July 18, 2010, 11:53:10 pm
omg how the feck do i debug this?

for some reason lines are disappearing from the ini file, and some are being changed randomly

but there is nothing used in the code to remove keys from the ini file, only think that is is the code for the iniremovekey or whatever they were, but those functions arent being used, as for the randomly changing keys...., maybe theres somehing else thats causing this, but i got a headache and cant think at the moment, this is aggrivating


From: July 18, 2010, 11:57:05 pm
seems to be caused on lag spike

are you quoting yourself or something?
are you saying you've figured it out?

if not, DEBUG!
is the error consistent?
  YES: your code is wrong.
  NO: does the error occur consistently with something happening in the game (ie, player joins, leaves, and joins again later, and THEN the error happens)
    YES: check your code (now you have better idea where to look for errors)
    NO: keep trying to figure out what causes it. at worst, it's something your code is vulnerable to (ie: lag spike?) - in which case you need to try another approach that would circumvent this issue.

this is example of basic debugging (at least so from the limited information we have from what you explained)
Title: Re: Frosty's scripting thread
Post by: frosty on July 19, 2010, 01:32:31 pm
yes but im only using iniwrite in the lag spike which i have removed and replaced with "saving all accounts"

which is causing all players files who are online to remove most of the lines, and leave only the lines that were written to and reset the lines that arent kills, but the lines that are being reset arent being written to on save in that section
theres only iniwrite and inisave so it shouldnt be doing it, i have also tried removing sleep(), same thing happens

so how would i save the accs every 5 mins when this happens, right now i have to /save manually, and when this does happen i have to delete the player file and get them to start over i have even tried getting the /save command to be triggered every 5 mins but that didnt work

i know where the problem is , but the problem with the problem is that the problem shouldnt be happening, look:

Code: (pascal) [Select]
procedure apponidle
if Timer = 0 then begin
//Writeconsole(0,'saving all accounts',$0000FFFF);
//Command('/save');
for i:= 1 to 32 do if Getplayerstat(i,'Ping') > 0 then begin
iniWrite('Players/'+GetPlayerStat(i,'Name')+'.ini','stats','kills',inttostr(trKills[i]));
iniWrite('Players/'+GetPlayerStat(i,'Name')+'.ini','stats','tupred',inttostr(TUPred[i]));
iniWrite('Players/'+GetPlayerStat(i,'Name')+'.ini','stats','barkills',inttostr(barKills[i]));
inisave('Players/'+GetPlayerStat(i,'Name')+'.ini',iniLoad('Players/'+GetPlayerStat(ID,'Name')+'.ini'));
end;
iniWrite('scripts/Shop/profit.ini','profit','cash',inttostr(Cash));
//Sleep(2000);
//Timer:=300;
end;
end;

what is wrong with this section, in the ini file, class and rank are changed and tna and the achieveemnts section are removed, but why is class and rank being changed and tna ancd achievements section being removed when this is triggered? theres no class or rank, or tna or achieveemnts here, so WTF, only thing i can think of is that using apponidle to save accs isnt a good way to do it, so how then without using timers would i save accs every 5 mins as i need apponidle to do it so idk what else to do. having that section in its own function being triggered by apponidle also does the same thing :(

From: July 19, 2010, 01:33:42 pm
edit: omg!!!!! i thin i just saw the problem, srry guys and thanks
Title: Re: Frosty's scripting thread
Post by: zyxstand on July 19, 2010, 02:37:30 pm
few questions:
apponidle is called every second.  it seems your function is also then called every second (I don't see anything modifying variable "Timer").
also: in line 9 of what you've shown, what is the variable "ID" in "GetPlayerStat(ID,'Name')" ?

READ THIS:  If i understand correctly, this chunk of code is supposed to update the 3 keys for all players (namely kills, tupred, and barkills).  If this is so, then all you need to have is the iniWrite lines. i don't understand what the inisave line is supposed to do.  iniwrite loads the ini, modifies the desired line, and saves the ini - all you need to effectively update any section.
so explain to me what inisave is!

if i'm correct, and you don't need inisave, then take this lesson:
part of programming is understanding what the computer goes through, line-by-line!  look at where you call iniwrite, look at what iniwrite does, and then look at how the whole thing continues from there.  it's very important to know what steps the computer will go through (or, in this case, at least what the code will go through)!

also:
lagspikes may be caused if you're overloading the engine at one point and not allowing it to deal with non-scripting soldat-related tasks (including processing and sending out packets) - so if you make your engine do a lott of computations, and only after one whole second will it continue to do soldat stuff, then everyone in the server will get a lagspike (on their end, it looks like the server hasn't responded for a whole second, just like when there's very slow connection).
Title: Re: Frosty's scripting thread
Post by: DarkCrusade on July 19, 2010, 02:44:59 pm
ID is an identifier for the player who called a procedure. To clarify who is who in some procedures ID is replaced by something more specific like "Victim" or "Shooter" (example: Procedure OnPlayerKill(Killer,Victim:Byte; Weapon:String);.

Title: Re: Frosty's scripting thread
Post by: zyxstand on July 19, 2010, 02:52:06 pm
but this section of code is contained in apponidle. i don't see parameters or argument calls that determine ID.
to me, it looks like the point is to update all ini files of all the players in the game once every 10 seconds or so (although as it stands, it seems to do so every second)
Title: Re: Frosty's scripting thread
Post by: DarkCrusade on July 19, 2010, 03:03:13 pm
What ... ID as a global var? :|
Title: Re: Frosty's scripting thread
Post by: zyxstand on July 19, 2010, 03:10:17 pm
well forgive me if i'm wrong, but then wouldn't line 09 overwrite what's been updated by the previous iniwrite lines??

Code: [Select]
08:  iniWrite('Players/'+GetPlayerStat(i,'Name')+'.ini','stats','barkills',inttostr(barKills[i]));
09:  inisave('Players/'+GetPlayerStat(i,'Name')+'.ini',iniLoad('Players/'+GetPlayerStat(ID,'Name')+'.ini'));
Title: Re: Frosty's scripting thread
Post by: DarkCrusade on July 19, 2010, 03:16:16 pm
Right ;)
Title: Re: Frosty's scripting thread
Post by: zyxstand on July 19, 2010, 03:19:37 pm
so... is something wrong with his code? or is that its correct function???  also, i dunno if it was just for demonstration purposes, but why isn't there any code limiting how often this gets called. i don't think it can be too good for any server to rewrite files every second!
Title: Re: Frosty's scripting thread
Post by: DarkCrusade on July 19, 2010, 03:22:36 pm
Right again! ;)
Title: Re: Frosty's scripting thread
Post by: frosty on July 19, 2010, 06:46:36 pm
it doesnt get rewritten every second


i havent posted whats modifying the Timer, but it is called every 5 minutes, not every second

if u uncomment line 13 on what i posted on the last page, thats the modifier, before posting this however, i had commented out that entire section until i figured out whats going on, realised that
Code: (pascal) [Select]
inisave('Players/'+GetPlayerStat(i,'Name')+'.ini',iniLoad('Players/'+GetPlayerStat(ID,'Name')+'.ini')); 
was actually supposed to be:
inisave('Players/'+GetPlayerStat(i,'Name')+'.ini',iniLoad('Players/'+GetPlayerStat(i,'Name')+'.ini')); 

as there is no ID var in apponidle, like it is for Oncommand, etc, so the script was getting confused

if i was using it as the section was posted then it would have been saving every second, however that was not the case

thanks again for your help guys

From: July 19, 2010, 06:58:33 pm
as a result, the following code works flawlessly

Code: (pascal) [Select]
procedure AppOnIdle(Ticks: integer);
begin
Timer:=Timer - 1;
if Timer = 0 then begin
Writeconsole(0,'Saving all accounts...',$0000FFFF);
//Command('/save');
for i:= 1 to 32 do if Getplayerstat(i,'Ping') > 0 then begin
iniWrite('Players/'+GetPlayerStat(i,'Name')+'.ini','stats','kills',inttostr(trKills[i]));
iniWrite('Players/'+GetPlayerStat(i,'Name')+'.ini','stats','tupred',inttostr(TUPred[i]));
iniWrite('Players/'+GetPlayerStat(i,'Name')+'.ini','stats','barkills',inttostr(barKills[i]));
inisave('Players/'+GetPlayerStat(i,'Name')+'.ini',iniLoad('Players/'+GetPlayerStat(i,'Name')+'.ini'));
end;
iniWrite('scripts/Shop/profit.ini','profit','cash',inttostr(Cash));
Sleep(2000);
Timer:=300;
Writeconsole(0,'Done!',$0000FFFF);
end;
end;

my debugging info was telling me that the files were being writen to fine, but were not saving correctly, thus, that brought my attention to the inisave line
Title: Re: Frosty's scripting thread
Post by: zyxstand on July 19, 2010, 07:33:06 pm
good.
now frosty, do me one more little favor:
it seems to me that line 11 is useless as it stands.  the "iniWrite" already saves the file!  if you go to the iniWrite function, you will see that it contains a line "iniSave" which already saves what you update. so just delete the inisave file and you'll make your code less wasteful...
Title: Re: Frosty's scripting thread
Post by: frosty on July 19, 2010, 07:47:09 pm
onto the next problem: grr DoDamageBy still isnt working, if i have 1 as the damage it doesnt hang, why is it still hanging the server? at the moment its not causing it to crash unless i hit more than one zombie with a barret shot (using shotgun shells), if its just 1 that it hits it still hangs for about 10 seconds then it goes back to normal, after all the targets were killed

this is so frustrating

(file attached)
Title: Re: Frosty's scripting thread
Post by: DarkCrusade on July 20, 2010, 02:04:43 am
Learn from your failures or die!

Link (http://darkcrusade.pastebin.com/W1yNiXcx)
Title: Re: Frosty's scripting thread
Post by: zyxstand on July 20, 2010, 03:41:52 am
I'm not sure, but I really think that an admin should lock this.  There may not be an explicit rule about this, but you need to learn programming on your own.  ESPECIALLY when we tell you exactly what to do (ie: give links to tutorials!) and he still doesn't try to read them.
frosty, you're a little boy, and you don't understand things in this world.  You need to do research on your own.  You can't expect to write soldat scripts without having any previous (real) programming experience.  Read what we told you to learn (as posted previously), go through tutorials, and come back when you're done.  It should take you at least a month to grasps SOME basics.

can admin lock this now?  his questions are getting ridiculous...
Title: Re: Frosty's scripting thread
Post by: frosty on July 20, 2010, 01:08:39 pm
thanks guys, better not ill just make another topic so locking will be a waste of time
Title: Re: Frosty's scripting thread
Post by: DarkCrusade on July 20, 2010, 01:09:30 pm
If you don't want to help him, ignore him.
Title: Re: Frosty's scripting thread
Post by: frosty on July 20, 2010, 01:11:02 pm
umm hold up, for startas, each time i posted, the code was different, so how is it i did not even try to read what you posted? links and such? :P

btw Dark, that code is giving me a syntax error, says line 26, but i dont see where the error is on any of those lines
Title: Re: Frosty's scripting thread
Post by: zyxstand on July 20, 2010, 01:36:59 pm
umm hold up, for startas, each time i posted, the code was different, so how is it i did not even try to read what you posted? links and such? :P

btw Dark, that code is giving me a syntax error, says line 26, but i dont see where the error is on any of those lines

there are no syntax error in his code on line 26 (or 25). make sure you copy pasted it correctly... make sure you've changed your Includes file... make sure you learn programming first...
Title: Re: Frosty's scripting thread
Post by: DarkCrusade on July 20, 2010, 01:40:09 pm
Start by stopping the use of global variables like i,Dist and ID. Those should be initialized in the procedures/functions themselves.

I cannot see any possible error source right now, too..
Title: Re: Frosty's scripting thread
Post by: Swompie on July 20, 2010, 03:38:43 pm
It doesn't matter if you have i as a global variable, the ones in the procedures will overwrite it, atleast that's what I think  :P
But having ID or similar words also used as params or sth. similar may cause problems I think.

Besides all of that I really have to agree with zyxstand, you are asking lots of basic questions, just take a look at when you just pasted the procedure names of the ini functions with a begin-end; into your script and thought it would work and then ask here >_>
That's just, sorry, but that's the reality, freakin' dumb.

What I just saw:
Code: [Select]
if Getplayerstat(i,'Ping') > 0 then beginIt makes me whine, use GetPlayerStat(i, 'Active') = true because it's the only safe way to check wether a player ID is used or not.

Do what I told you several times, look at simple, not-complex scripts and learn from them step-by-step. (For example get used to LowerCase(), GetPiece(), case .. of in use with OnPlayerCommand() or similar things)
The if Text = '/foobar' method is old, for example it only works with the lowercase cmd /foobar, but not /fOoBaR.
A simple use of LowerCase() would clear that up.
There are tons of other stuff I could tell you in use with OnPlayerCommad(), but they would just irritate you in the moment.

Now go and repeat the basics step-by-step (Like if Text = '!noob' then WriteConsole(ID, 'You are a noob!', $FF0000), ignore the stuff I told you before, add it afterwards when you managed to do the very basics.) or you won't learn proper scripting ever imo.

Hope you guys like lots of text, ;f
Title: Re: Frosty's scripting thread
Post by: frosty on July 20, 2010, 07:10:52 pm
odd, i copied and pasted the whole script and overwrote my code and is still saying syntax error on line 26, like wtf?

and u say change the Inludes file, change to what? its fine as it is

anyways heres the files (attached)

edit: ill fix up the code once we figure out why the hell im getting a syntax error, i have reassigned the i var in onplayerkill and removed i and killer from vars so its now saying syntax error on line 25

heres the full error if it helps
Code: [Select]
Achievement -> [Error] (25:166): Syntax error
edit2: and thanks so much for the help and patience guys, i appreciate it, but its errors like these where my compiler is being a douche and noone can see what the hell is wrong is where i really need help, ive had too many of these stupid errors
Title: Re: Frosty's scripting thread
Post by: zyxstand on July 20, 2010, 10:18:32 pm
wtf is wrong with you?
i opened the attached file you sent and the error says its syntax error on line 28 (so line 27 in the .pas file).
it's the line that says:
Code: [Select]
if (RayCast(x,y,x2,y2,Dist,200)) AND (if i <> Killer) AND (GetPlayerStat(i,'Alive') = true) AND (GetPlayerStat(i,'Team') <> GetPlayerStat(Killer,'Team')) then beginand now i just wanna know why you didn't see the extra "if" word in there.  ppl wont' always give u perfect code, but u just have to be a bit less of an idiot to deal with that.
TAKE OUT THE "IF", DO IT AGAIN IN THE OTHER SECTION (same code essentially), AND FIX THE ACTIVATE SERVER INITIALIZATION -> FIGURE OUT THE LAST ONE ON YOUR OWN - IF YOU CAN'T DO IT DON'T BOTHER WITH SCRIPTING.

bye forever, frosty
Title: Re: Frosty's scripting thread
Post by: DarkCrusade on July 20, 2010, 10:19:53 pm
No need for yelling.. he's just asking for help.
Title: Re: Frosty's scripting thread
Post by: frosty on July 20, 2010, 10:39:13 pm
FFS u idiot!!

my host said error on line 26, not me u idiot, i even copied and pasted the error from the website which tells me if my server has crashed and lets me stop and start it, Where the f**k did u get line 28 from? or is your compiler "different" to mine? and why the f**k do u think i even bothered with using the {code] tags? read before u post ffs, can't you tell i copied and pasted the code? shows how good u are, not!!! so far all u have done is insult me without even TRYING to help, which proves to me and everyone else that you are naive and not even worth communicating with, so fine, i dont need your help anyways "xystand"

anyways, new problem

i have come accross a wierd bug, i made this script: (attached) which logs everything to a single log file, (Text, Commands, Team Joins and Exceptions)

only problem is, with the OnCommand Section there, instead of the command going through, it just logs the command and then does nothing, how do i get around this? (not released yet due to this bug so dont go searching)

edit2: server is still hanging when i use barret, wtf????????????????? FFS THIS f**kING STUPID SERVER, see attached achievement.pas
Title: Re: Frosty's scripting thread
Post by: tk on July 21, 2010, 03:30:20 am
Quote
edit2: server is still hanging when i use barret, wtf?? FFS THIS f**kING STUPID SERVER, see attached achievement.pas
It's not because of the "f**kING STUPID SERVER" but your horrible code. No surprise it hangs on it.

replace the barret part with
Code: [Select]
var x, y, x2, y2: single; team: byte;

// ...

  if Weapon = 'Barrett M82A1' then begin
    team := GetPlayerStat(Killer,'Team');
    GetPlayerXy(Victim, x, y);
    for i := 1 to 32 do
      if i <> Killer then
        if GetPlayerStat(i,'Alive') = true then
          if GetPlayerStat(i,'Team') <> team then begin
            GetPlayerXY(i, x2, y2);
            if RayCast(x,y,x2,y2,Dist,400) then begin
              DoDamageBy(i,Killer,200);
              BioKills[Killer]:=BioKills[Killer]+1;
            end;
          end;
    WriteConsole(Killer,'Bio-Kills: '+Inttostr(BioKills[Killer]),$EE81FAA1);
    BioKills[Killer]:=0;
  end;
Title: Re: Frosty's scripting thread
Post by: frosty on July 21, 2010, 01:16:33 pm
Quote
edit2: server is still hanging when i use barret, wtf?? FFS THIS f**kING STUPID SERVER, see attached achievement.pas
It's not because of the "f**kING STUPID SERVER" but your horrible code. No surprise it hangs on it.

replace the barret part with
Code: [Select]
var x, y, x2, y2: single; team: byte;

// ...

  if Weapon = 'Barrett M82A1' then begin
    team := GetPlayerStat(Killer,'Team');
    GetPlayerXy(Victim, x, y);
    for i := 1 to 32 do
      if i <> Killer then
        if GetPlayerStat(i,'Alive') = true then
          if GetPlayerStat(i,'Team') <> team then begin
            GetPlayerXY(i, x2, y2);
            if RayCast(x,y,x2,y2,Dist,400) then begin
              DoDamageBy(i,Killer,200);
              BioKills[Killer]:=BioKills[Killer]+1;
            end;
          end;
    WriteConsole(Killer,'Bio-Kills: '+Inttostr(BioKills[Killer]),$EE81FAA1);
    BioKills[Killer]:=0;
  end;


still hanging, even with JUST this script compiled on its own it still crashes the server, but im not getting any exception messages
Title: Re: Frosty's scripting thread
Post by: DarkCrusade on July 21, 2010, 01:33:29 pm
You didn't check whether 'i' is active.. when I told you already thrice that you need to!
Title: Re: Frosty's scripting thread
Post by: dnmr on July 21, 2010, 10:27:53 pm
frosty, you stubborn fuck, we told you countless times to put the "active" check before everything else in the loop and you still haven't done it? For fucks sake, if you want to get some help here - do what people suggest. If you don't, GTFO
Title: Re: Frosty's scripting thread
Post by: frosty on July 21, 2010, 11:51:18 pm
ok, ive added in if get player stat active  but its still hanging
Title: Re: Frosty's scripting thread
Post by: DarkCrusade on July 22, 2010, 02:33:43 am
Grrr Grrrr Grrrr


RAWR



/ragequit
Title: Re: Frosty's scripting thread
Post by: Swompie on July 22, 2010, 09:42:04 am
Sleep(5);
Sleep(5);
Sleep(5);
Sleep(5);
Sleep(5);
Sleep(5);
Sleep(5);
FFS DON'T USE SLEEP.
And as the whole fucking code showed you didn't even try to fix your code.
Do it or gtfo here.
Title: Re: Frosty's scripting thread
Post by: frosty on July 22, 2010, 12:58:46 pm
/rage

READ BEFORE YOU POST FFS!!!!! YOU PEOPLE DONT f**kING READ THEN WONDER WHY WHY PEOPLE GET f**kING UPSET!!!

Quote
i will fix up the code when this bug is fixed

but fine i have removed sleep from the full code and its still hanging, any other suggestions?

and like i said before, its the fixed parts that are causing the server to hang, the rest of the weapons DONT hang the server, i could mass spawn with the rest of the weapons and i only get a tiny bit of lag
Title: Re: Frosty's scripting thread
Post by: DarkCrusade on July 22, 2010, 01:13:24 pm
READ BEFORE YOU POST FFS!!!!! YOU PEOPLE DONT f**kING READ THEN WONDER WHY WHY PEOPLE GET f**kING UPSET!!!

Oh, the irony. Oh...

So I told you 3 times that whenever you access an ID in a loop you must check whether the ID is active. Now you get angry over this? Okay. My work is done.
Title: Re: Frosty's scripting thread
Post by: tk on July 22, 2010, 01:17:39 pm
Btw, why is the 'active' check needed since we check 'alive' too? 'Alive' will not return true if 'active' is false anyway.
Title: Re: Frosty's scripting thread
Post by: frosty on July 22, 2010, 01:18:32 pm
Dark when u said that the first time you failed to read what i posted, you then posted that another 2 times and then wonder why im getting angry...

2 words: blame yourself

Quote
do it or gtfo
let me hurt you a bit here, Swompie, only an idiot would say that unless ur a naive -12 who cant even get a single peice of homework done without any help, or unless you a school dropout, since u failed to read what i posted DIRECTLY after Dark said to check if an ID is active and to fix my code, i see that as an epic fail considering how much coding you have "apparently" done, and, didnt your mother teach you any manners?

as for you: Dark, you should know better than that as you ALSO failed to read what i had posted resulting in you having to post it 3 times, bad, bad, bad :(
Title: Re: Frosty's scripting thread
Post by: DarkCrusade on July 22, 2010, 01:54:34 pm
I don't know whether to laugh or to cry. Get the facts straight, frosty. You want us to help you, yet you are raging against us. It's not very admirable that you put it the way that your errors are ours instead of taking critique like a man.

The only person that is blaming itself is you. As you fail to understand the basics of Soldat's most usual syntax (and the most common English grammar) I am quit bothered about your mental abilities, that - not to sound rude - needs attention of a good doctor.

I don't attempt to troll or insult you, but you didn't leave it open to me as you apparently decided that it'd be the best to piss me off as much as you can (and you did), so I don't see any reason why I should be gentle.

To be frank: As you lack basic programming skills and enough maturity to take critique I will not respond  in this thread anymore and ignore personal requests, too. Learn from your failures and hopefully grow up soon.   

Once and for all: Learn to take critique.
Title: Re: Frosty's scripting thread
Post by: kosik231 on July 22, 2010, 04:24:48 pm
Btw, why is the 'active' check needed since we check 'alive' too? 'Alive' will not return true if 'active' is false anyway.
i think that "Active" checks that player is IN GAME, but "Alive"... i think you understand it, checks that you are dead or not... so what is different? ask yourself

btw, this topic is funny...  ^^
Title: Re: Frosty's scripting thread
Post by: frosty on July 22, 2010, 07:57:31 pm
ok. fine, was just pointing out a fact, i didnt mean to piss you off but i was quite irritated at the time, and i apologize for pissing you off
end of argument

but could you plz help me with one last thing
Quote
i have come accross a wierd bug, i made this script: (attached) which logs everything to a single log file, (Text, Commands, Team Joins and Exceptions)

only problem is, with the OnCommand Section there, instead of the command going through, it just logs the command and then does nothing, how do i get around this? (not released yet due to this bug so dont go searching)

For your info the section i am having trouble with is commented out

edit: just so you know, ive fixed the code and its still hanging, but if i replace dodamgeby with createBullet then it doesnt hang but most of the time it misses, so why dodamageby isnt working...idk and i dont care cuz all its done is caused an argument, i knew, i KNEW that fixing the code wouldnt have made any difference, cuz if the ONE section that im triggering that is "fixed" isnt working, then why would any other section with the same code work when, my code doesnt make the server hang, idfk and i dont care, like i said earlier, i give up on dodamgeby

ive done everything everyone has suggested and its still not working, so then you all blame me, its not my fault that dodamageby isnt working, idfk why it isnt working. all i know is when i dont use it, my server doesnt hang

Title: Re: Frosty's scripting thread
Post by: tk on July 23, 2010, 01:43:13 am
Btw, why is the 'active' check needed since we check 'alive' too? 'Alive' will not return true if 'active' is false anyway.
i think that "Active" checks that player is IN GAME, but "Alive"... i think you understand it, checks that you are dead or not... so what is different? ask yourself

btw, this topic is funny...  ^^

If you can't understand the question, don't answer or read it a few times more please.
Title: Re: Frosty's scripting thread
Post by: chutem on July 23, 2010, 02:36:36 am
Quote
i have come accross a wierd bug, i made this script: (attached) which logs everything to a single log file, (Text, Commands, Team Joins and Exceptions)

only problem is, with the OnCommand Section there, instead of the command going through, it just logs the command and then does nothing, how do i get around this? (not released yet due to this bug so dont go searching)

You can disable commands from going through by setting result to true, therefore make sure it is set to false right before the end of the onCommand function.
Title: Re: Frosty's scripting thread
Post by: dnmr on July 23, 2010, 02:40:14 pm
Btw, why is the 'active' check needed since we check 'alive' too? 'Alive' will not return true if 'active' is false anyway.
apparently getplayerstat likes to touch the memory in inappropriate places if you request any info about an inactive player (and that includes 'Alive' as far as im concerned)

Edit: forgot to add - "your results may vary" (ofc it's more intense on some systems than on others)
Title: Re: Frosty's scripting thread
Post by: frosty on July 23, 2010, 07:09:01 pm
thanks :D


Great, looks like File Uploading is down on my host, cant upload anything at all so now i gotta wait, sent the host a message, still waiting for a reply, Great now im screwed for the day, always the way, i go to test something and it doesnt work due to host issues, or when im not in the mood its working perfectly, whenever i want to do some coding theres a problem with the host so i cant do much, and i cant start a server on my comp cuz it doesnt like the soldatserver for some bizzarre reason, whenever i try it i get a blue screen, obviously my comp cant handle the epicness that is soldatserver, grrr....

From: July 24, 2010, 03:23:12 am
question, how do i set result? "unknown identifier "result""

Code: (pascal) [Select]
procedure OnPlayerCommand(ID: Byte; Text: string);
begin
WriteLnFile('PlayerSpeech/PlayerSpeechLog-'+FormatDate('dd')+'-'+FormatDate('mm')+'-'+FormatDate('yyyy')+'.txt',FormatDate('hh:mm am/pm')+'::'+IDtoname(ID)+'::'+Text);
Result:=False;
end;
Title: Re: Frosty's scripting thread
Post by: dnmr on July 24, 2010, 04:32:42 am
http://pascalprogramming.byethost15.com/lesson7.php

http://enesce.com/help/html/Events/OnPlayerCommand.html

You made nine (9) spelling errors in the word "function" and forgot to declare the result var
Title: Re: Frosty's scripting thread
Post by: frosty on July 24, 2010, 08:56:30 pm
thanks dnmr :D

From: July 25, 2010, 01:40:05 am
wow that has also solved the lagging issue ive been having, now createbullet hits no matter what, just from setting the main part of code into its own procedure instead of constantly repeating, thanks dnmr :D

i will test this with DoDamageBy a bit later and post my results, but for now my procedure is this, its so much more effective than my old code :)

Code: (pascal) [Select]
procedure RangeKill(Owner, Victim, Range, VelX ,VelY, HitMult, BulletType:Integer);
var i:Byte;
begin
     x := GetPlayerStat(Victim,'x');
     y := GetPlayerStat(Victim,'y');
      for i := 1 to 32 do begin
       x2 := GetPlayerStat(i,'x');
       y2 := GetPlayerStat(i,'y');
       if (RayCast(x,y,x2,y2,Dist,Range)) AND (i <> Owner) AND (GetPlayerStat(i,'Active') = true) AND (GetPlayerStat(i,'Team') <> GetPlayerStat(Owner,'Team')) then begin
         CreateBullet(GetPlayerStat(i,'x'), GetPlayerStat(i,'y') - 0, VelX,VelY,HitMult, BulletType, Owner);
BioKills[Owner]:=BioKills[Owner]+1;
       end;
     end;
     WriteConsole(Owner,'Bio-Kills: '+Inttostr(BioKills[Owner]),$EE81FAA1);
     BioKills[Owner] := 0;
end;

From: July 25, 2010, 01:56:45 am
ok i have tried with DoDamageBy, but its still not quite working, first off it kills me even it says not o if i isnt owner of kill, bit odd, its not hanging as much, or causing the script to crash as much, now it only crashes once per use, and its only causing lag, maybe im getting somewhere here

procedure seems to work better than function, but, should it be function?

anyways, full code attached

From: July 25, 2010, 02:03:40 am
edit, lol i just changed procedure to function and swapped i for Owner in DoDamageBy now it works perfect :D, reuploaded working file :D



From: July 25, 2010, 02:06:51 am
nvm its still lagging like a dumbshit, i give up, does teh code work alrite for everyone else? if yes then the problem lies in one of my other scripts, need to refine them if thats the case
Title: Re: Frosty's scripting thread
Post by: Swompie on July 25, 2010, 04:37:18 am
Code: [Select]
(GetPlayerStat(i,'Team') <> GetPlayerStat(Owner,'Team'))Hold the team of owner in a variable since it won't change in that loop.
Code: [Select]
Team := GetPlayerStat(Owner, 'Team');
for i := 1 to 32 do
if (..) and (Team <> GetPlayerStat(i, 'Team') then

Also why -0 here?
Code: [Select]
GetPlayerStat(i,'y') - 0
Quote
other scripts
Just disable them to see if they cause the errors.
Title: Re: Frosty's scripting thread
Post by: frosty on July 25, 2010, 09:32:58 pm
thanks swompie, im getting an access violation error after testing this script on its own which caused the server to crash, here it is:

Code: [Select]
(12:30:34)  [*] [Error] Achievement -> OnPlayerKill: Access violation at address 0808AD0E, accessing address 0160000C
and once again i got spammed with script crashes, first the server hung, then the script crashed 5 times in a row before i got a CP and CT

i also got spammed with kills (got to 100 in just a few seconds) just before the server hung, very, very interesting, wth is causing such a loop?

so whats wrong with the OnplayerKill section?

Title: Re: Frosty's scripting thread
Post by: frosty on July 28, 2010, 01:22:29 am
i really dont get this, its doing nearly 10 createbullets, if not more for every kill, if theres 6 kills theres 6 createbullets done on each victim, give or take, some of these createbullets are being done when the victim is dead, wtf?? look at the attachment, Function RangeKill

would someone mind shedding some light on the problem as the only loop im seeing is to check if the zombies are in range, or is it becuase im using Shotgun Shells on the barret? o.0, maybe its my wep mod? (also attached, named Onehit.ini)

also does anyone have the original weapons.ini unchanged? i want to revert back to original wep settings without reinstalling soldat in order to get the file

edit: found a mistake, fixed the mistake but its still doing the same thing, reuploaded
Title: Re: Frosty's scripting thread
Post by: frosty on August 06, 2010, 08:32:26 pm
hi guys, i want to do something a little advanced here using code thats repeated quite a bit and i was wondering if its possible or how to get around this

Code: (pascal) [Select]
procedure ForceAchUpdate(ID:Byte; Ach:String); //will update current accounts with new achievements to get as the players join (going to use in OnJoinTeam)
begin
if ReadINI('Players/'+IDtoname(ID)+'.ini','achievements',Ach,'*ERROR*') = '*ERROR*' then iniWrite('Players/'+IDtoname(ID)+'.ini','achievements',Ach,'0');
      if ReadINI('Players/'+IDtoname(ID)+'.ini','achievements',Ach,'*ERROR while loading achievement*') = '1' then Ach:=True; //Replaces Ach with the string in the sytax so say if i use ForceAchUpdate(ID, 'yeahyeah')'; it should make Ach[ID] into yeahyeah[ID] where i want to use the code, but i get a type mismatch error here as Ach isnt an array
      if ReadINI('Players/'+IDtoname(ID)+'.ini','achievements',Ach,'*ERROR while loading achievement*') = '0' then Ach[ID]:=False;
end;

will defining Ach as an array of string work here? or will it give me other results? just curious

edit: nvm, maybe i should just experiment more before asking stuff, worked it out, this works perfect

Code: (pascal) [Select]
procedure ForceAchUpdate(ID:Byte; Ach:String; Boolvar:array [1..32] of Boolean);
begin
if ReadINI('Players/'+IDtoname(ID)+'.ini','achievements',Ach,'*ERROR*') = '*ERROR*' then iniWrite('Players/'+IDtoname(ID)+'.ini','achievements',Ach[ID],'0');
      if ReadINI('Players/'+IDtoname(ID)+'.ini','achievements',Ach,'*ERROR while loading achievement*') = '1' then Boolvar[ID]:=True;
      if ReadINI('Players/'+IDtoname(ID)+'.ini','achievements',Ach,'*ERROR while loading achievement*') = '0' then Boolvar[ID]:=False;
end;

edit2: no its not, need some help here, its not setting the Boolvar correctly so should i try something else?
Title: Re: Frosty's scripting thread
Post by: dnmr on August 07, 2010, 01:36:03 am
you dont have to send Boolvar[] as an argument since you already send ID. Just declare it as a global array and use as is in the procedure
Title: Re: Frosty's scripting thread
Post by: frosty on August 07, 2010, 02:02:08 am
ok, tx :), but then if i dont send it as an arg, how would i change the boolval [id]? if i use:

Code: (pascal) [Select]
ForceAchUpdate(ID, 'TP', TP);
the Boolval[ID] should change to TP[ID], as Boolval[ID] isnt what i want to change, i only want to update the val thats replacing Boolval, if that makes sense

if i dont send it as an argument, Boolval will stay as Boolval and not turn into the val i want? maybe im doing it wrong? impossible? do i need to recode the procedure?

maybe i need to change it to a function then use result to store the val in a variable then set the var i want to change off that result
Title: Re: Frosty's scripting thread
Post by: dnmr on August 07, 2010, 02:27:30 am
or maybe you should read what i wrote again. Make boolvar a global array so you can interact with it anywhere throughout the script
Title: Re: Frosty's scripting thread
Post by: frosty on August 07, 2010, 03:18:21 am
is this what you mean?:
Code: (pascal) [Select]
var Boolval:Array [1..32] of Boolean;

procedure ForceAchUpdate(ID:Byte; Ach:String); //will update current accounts with new achievements to get as the players join (going to use in OnJoinTeam) 
begin 
if ReadINI('Players/'+IDtoname(ID)+'.ini','achievements',Ach,'*ERROR*') = '*ERROR*' then iniWrite('Players/'+IDtoname(ID)+'.ini','achievements',Ach,'0'); 
     if ReadINI('Players/'+IDtoname(ID)+'.ini','achievements',Ach,'*ERROR while loading achievement*') = '1' then Boolval[ID]:=True;
     if ReadINI('Players/'+IDtoname(ID)+'.ini','achievements',Ach,'*ERROR while loading achievement*') = '0' then Boolval[ID]:=False; 
end; 

procedure OnJoinTeam(ID, Team: byte);
begin
  if (Team = 1) AND (FileExists('Players/'+IDtoname(ID)+'.ini')) then begin
ForceAchUpdate(ID, 'TP');
TP[ID] := Boolval[ID];
end;
end;
Title: Re: Frosty's scripting thread
Post by: dnmr on August 07, 2010, 03:55:05 am
yes, although i cant see what TP is supposed to be, but i guess you're getting the idea
Title: Re: Frosty's scripting thread
Post by: tk on August 07, 2010, 04:08:20 am
Quote
if ReadINI('Players/'+IDtoname(ID)+'.ini','achievements',Ach,'*ERROR while loading achievement*') = '1' then Boolval[ID]:=True; 
if ReadINI('Players/'+IDtoname(ID)+'.ini','achievements',Ach,'*ERROR while loading achievement*') = '0' then Boolval[ID]:=False;

Boolval[ID] := ReadINI('Players/'+IDtoname(ID)+'.ini','achievements',Ach,'') = '1';

Also you should get a rid of illegal chars from nicknames before naming files with them.
Title: Re: Frosty's scripting thread
Post by: frosty on August 07, 2010, 04:35:51 am
how do i do that? specially since people wont change their names and it works all off the playername, its not like i can change the players nickname

ive given up on asking ppl to get rid of bad chars, they never do it

and so ive told them:

if your account has bad characters, then your acc will not save, if you like my server, then change your name so it doesnt have the illegal characters

but i guess those ppl dont want accounts being saved, their loss
Title: Re: Frosty's scripting thread
Post by: dnmr on August 07, 2010, 05:14:54 am
http://forums.soldat.pl/index.php?topic=34934.0
Title: Re: Frosty's scripting thread
Post by: frosty on August 12, 2010, 01:38:28 am
tx dnmr :)

trying something with constants, to make it easier to update item prices

in onplayercommand:
Code: (pascal) [Select]
if Lowercase(Text) = '/buy pred' then begin
if Cash < (pred) then begin
WriteConsole(0,IdtoName(ID)+' just tried to purchase predator, not enough funds!',$EE81FAA1);
end;
if Cash >= (pred) then begin
Cash :=Cash-(pred);
WriteConsole(0,IdtoName(ID)+' has just bought predator for '+(pred)+' Cash',$EE81FAA1);
GiveBonus(ID, 1);
SpawnObject(GetPlayerStat(ID,'x'),GetPlayerStat(ID,'y'),20);
      TUPred[ID]:=TUPred[ID]+1;
end;
  end;

pred is defined as a const, how do i use the const in this example?

arsse is giving me the following error
Code: [Select]
open round ('(')expected
to attempt a debug i tried putting ()s on each side of pred in the code, but the same error remains, i know its definitely the "pred" const causing the error, as the error only occured when i (tried to) put the const in there

Code: (pascal) [Select]
const
pred = 200;

having inttostr in writeconsole for pred does nothing for the error, what do i need to show the consts value in writeconsole if i can get the code to work?
Title: Re: Frosty's scripting thread
Post by: tk on August 12, 2010, 02:46:57 am
Since you declare the const as int, you have to convert it into a string before doing anything with it in writeconsole
WriteConsole(0,IdtoName(ID)+' has just bought predator for '+IntToStr(pred)+' Cash',$EE81FAA1);
Title: Re: Frosty's scripting thread
Post by: frosty on August 12, 2010, 04:19:31 am
yes but whats causing the error?

even if i do have inttostr there the error is still there

Code: (pascal) [Select]
if Lowercase(Text) = '/buy pred' then begin 
    if Cash < (pred) then begin 
        WriteConsole(0,IdtoName(ID)+' just tried to purchase predator, not enough funds!',$EE81FAA1); 
    end;   
    if Cash >= (pred) then begin 
        Cash :=Cash-(pred); 
        WriteConsole(0,IdtoName(ID)+' has just bought predator for '+IntToStr(pred)+' Cash',$EE81FAA1);
        GiveBonus(ID, 1); 
        SpawnObject(GetPlayerStat(ID,'x'),GetPlayerStat(ID,'y'),20); 
     TUPred[ID]:=TUPred[ID]+1; 
    end; 
 end; 
Title: Re: Frosty's scripting thread
Post by: chutem on August 12, 2010, 04:33:59 am
is the scriptcore giving you an error, or just arsse?
Error doesn't seem like something the scriptcore would chuck out, but then again, I don't know much about arsse.
Title: Re: Frosty's scripting thread
Post by: frosty on August 12, 2010, 01:12:02 pm
scriptcore is giving me the exact same error

Code: (pascal) [Select]
if Lowercase(Text) = '/buy pred' then begin   
   if Cash < (pred) then begin //actuall error is on this line, why isnt pred being parsed correctly? error doesnt point directly to this line, points above it, however after counting commented out lines (section it was pointing to was not changed, neither was anything above it, except for consts, and there were 15 commented out lines before that line) and adding the result number to the supposed error line (387+15=line 402)
       WriteConsole(0,IdtoName(ID)+' just tried to purchase predator, not enough funds!',$EE81FAA1);   
   end;     
   if Cash >= (pred) then begin   
       Cash :=Cash-(pred);   
       WriteConsole(0,IdtoName(ID)+' has just bought predator for '+IntToStr(pred)+' Cash',$EE81FAA1); 
       GiveBonus(ID, 1);   
       SpawnObject(GetPlayerStat(ID,'x'),GetPlayerStat(ID,'y'),20);   
    TUPred[ID]:=TUPred[ID]+1;   
   end;   
end;


full code is attached

i have also included the original shop.pas (named Shop_original.pas)

so you can see what changes ive made

btw, just to clear this up, when you /recompile with arsse, it isnt actually arsse thats compiling the scripts, its the servers scriptore that its connected to that is, arsse doesnt have or use a compiler, all it does is relay commands to the server and output server messages, thats it :D
Title: Re: Frosty's scripting thread
Post by: Falcon` on August 12, 2010, 07:45:44 pm
remove parenthesis
Title: Re: Frosty's scripting thread
Post by: frosty on August 13, 2010, 12:31:49 am
got rid of the ( ) s but the error is still the same

see pastebin link

http://pastebin.com/bG6dckm0 (http://pastebin.com/bG6dckm0)

edit: how do i create a bullet going from mone player to another again?, i know one of you guys posted it somewhere but i cant find, could u plz post it again? :D, i know it was something about the sin, cos and tan things..
Title: Re: Frosty's scripting thread
Post by: kosik231 on August 13, 2010, 06:57:49 am
i found mistake :D change const name "pred" to another one like "predat", i think that script used your "/buy pred" as variable O.o btw it works for me
Title: Re: Frosty's scripting thread
Post by: frosty on August 13, 2010, 07:11:37 am
LOL, its an emote, most people use that instead of "Doh!"

and thanks :D, it worked :D, changing pred to predat fixed the problem, many thanks
Title: Re: Frosty's scripting thread
Post by: dnmr on August 13, 2010, 07:25:23 am
go through the mmod script, it should have the shooting function you need, as well as a bunch of other stuff
Title: Re: Frosty's scripting thread
Post by: tk on August 13, 2010, 09:21:16 am
Quote
edit: how do i create a bullet going from mone player to another again?, i know one of you guys posted it somewhere but i cant find, could u plz post it again? , i know it was something about the sin, cos and tan things..
You don't have to use neither of them

procedure Shoot(x, y, x2, y2, speed, dmg: single; style, owner: byte);
var dist: single;
begin
 dist := Distance(x, y, x2, y2) / speed;
 x2 := (x2 - x) / dist;
 y2 := (y2 - y) / dist;
 createbullet(x, y, x2, y2, dmg, style, owner);
end;
 
(untested)
 
Title: Re: Frosty's scripting thread
Post by: frosty on August 13, 2010, 08:20:55 pm
@tk, that gives me a type mismatch error on line 6 of that code, cant see why tho, ill have a look at mmod, tx dnmr ;)

From: August 13, 2010, 08:22:03 pm
Title: Re: Frosty's scripting thread
Post by: tk on August 14, 2010, 02:22:36 am
fixed the code in the bost above (accidentally declared style as single)
Title: Re: Frosty's scripting thread
Post by: frosty on August 14, 2010, 08:20:58 pm
tx tk

From: August 14, 2010, 08:37:38 pm
how do i boost bot HP? i want to make Boss Bots which are much harder to kill than normal bots (popular request)

From: August 14, 2010, 09:07:29 pm
btw, setplayerstat doesnt work on my server

Code: [Select]
unknown identifier 'SetPlayerStat'
Title: Re: Frosty's scripting thread
Post by: dnmr on August 15, 2010, 02:30:55 am
setplayerstat is for 1.5.1 only OMG
Title: Re: Frosty's scripting thread
Post by: frosty on August 15, 2010, 03:32:33 am
thats the question, What do i use? how did hexer do it? etc

and if its for 1.5.1 then why does this compile, in a seperate script?
Code: (pascal) [Select]
SetPlayerStat(ID, 'Health',999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999);
i dont get it, Shop.pas wont compile due to unknown identifier "setPlayerstat", yet adminstuff will compile perfectly with the same setplayerstat code

like, huh ???

i know that this wont do anything when its triggered but the fact that the exact same line will compile in one script but wont compile elsewhere is a mystery
Title: Re: Frosty's scripting thread
Post by: Boblekonvolutt on August 15, 2010, 04:23:39 am
i dont get it, Shop.pas wont compile due to unknown identifier "setPlayerstat", yet adminstuff will compile perfectly with the same setplayerstat code
In Adminstuff.pas you have declared your own (empty) SetPlayerStat.

I really have no idea why. The reasoning behind the script doesn't make sense anywhere.


Either way, there is a max value for how much health you can have, so no matter how many 9's you put in there it's not really gonna make a difference. If you want to make a bot harder to kill, you would have to edit the damage thats being done in the OnPlayerDamage event.


Not that ten people haven't said that already, but I figure eventually he'll get it.
Title: Re: Frosty's scripting thread
Post by: kosik231 on August 15, 2010, 04:34:28 am
why you dont use SpecialBots script? you can make bosses with this :) just use "search" option and download it, configure what you want and start server ^^
Title: Re: Frosty's scripting thread
Post by: Falcon` on August 15, 2010, 06:09:19 am
idea of more hp is simple: reduce damage in OnPlayerDamage.
Title: Re: Frosty's scripting thread
Post by: VinceBros on August 15, 2010, 03:13:29 pm
Do something like:

If it's the boss, do 25% of the normal damage..
Title: Re: Frosty's scripting thread
Post by: frosty on August 15, 2010, 06:39:07 pm
tx guys :D

From: August 17, 2010, 01:31:44 pm
i have a new problem,tyrying to use some sytax that only loops through players names until it comes accross a zombie, it then stops looping and does the code

Code: (pascal) [Select]
   if Lowercase(Text) = '/bossbot' then begin;
     for i := 1 to 32 do until (Idtoname(i) = 'Mr.Zombie') do if Idtoname(i) = 'Mr.Zombie' then begin
       Command('/kick '+inttostr(i)+'');
       Command('/addbot2 MRZOMBIEW');
       WriteConsole(0,'You Hear the distant roar of a warlord zombie, that cant be good...', $00FFEE22);
     end
   end;

i cant figure out how to get it to work, right now it wont compile, but the code below will, only problem is, nothing happens when the command is typed

Code: (pascal) [Select]
   if Lowercase(Text) = '/bossbot' then begin;
     for i := 1 to Idtoname(i) = 'Mr.Zombie' do if Idtoname(i) = 'Mr.Zombie' then begin
       Command('/kick '+inttostr(i)+'');
       Command('/addbot2 MRZOMBIEW');
       WriteConsole(0,'You Hear the distant roar of a warlord zombie, that cant be good...', $00FFEE22);
     end
   end;
Title: Re: Frosty's scripting thread
Post by: Falcon` on August 18, 2010, 06:19:53 am
Tell you what? Your codes are more like an art, not working programs. When i watch them i think: "Beautiful, why that instruction isn't allowed? They'd own." I love especially the first one lol.

Working code:
Code: (pascal) [Select]
   if Lowercase(Text) = '/bossbot' then begin;
     for i := 1 to 32 do
       if IDToName(i) = 'Mr.Zombie' then begin
           Command('/kick '+inttostr(i)+'');
           Command('/addbot2 MRZOMBIEW');
           WriteConsole(0,'You Hear the distant roar of a warlord zombie, that cant be good...', $00FFEE22);
     end
   end;
Title: Re: Frosty's scripting thread
Post by: frosty on August 18, 2010, 01:06:51 pm
Sorry. Forgot to mention, I only want to kick and add one zombie at a time with this command, I already have another section of code just that replaces all zombies with my boss bots, my bad....:D
Title: Re: Frosty's scripting thread
Post by: Falcon` on August 18, 2010, 02:49:20 pm
Code: (pascal) [Select]
   if Lowercase(Text) = '/bossbot' then begin;
     for i := 1 to 32 do
       if IDToName(i) = 'Mr.Zombie' then begin
           Command('/kick '+inttostr(i)+'');
           Command('/addbot2 MRZOMBIEW');
           WriteConsole(0,'You Hear the distant roar of a warlord zombie, that cant be good...', $00FFEE22);
           break;
     end
   end;

better?
Title: Re: Frosty's scripting thread
Post by: frosty on August 18, 2010, 09:50:06 pm
ahhhh, tx, now i know how to break a loop, literally, many thanks FalconPL and soz about the stupid question ;)
Title: Re: Frosty's scripting thread
Post by: Falcon` on August 19, 2010, 03:26:59 am
I have great idea for you:
Instead of spaming in this thread, suggestion to join #soldat.devs @ quakenet.
IRC doesn't bite, try it.
Title: Re: Frosty's scripting thread
Post by: frosty on August 19, 2010, 01:28:07 pm
thanks :D
Title: Re: Frosty's scripting thread
Post by: frosty on September 01, 2010, 01:31:45 pm
new problem, for some reason my Biokills script (http://pastebin.com/XTJXUCvM) wont work with my Shop script (http://pastebin.com/pL9WAkg1)

cant figure out why (script names are links)

if anyone can figure out why this is happening i would appreciate it

i mean, the biokills script will compile but wont do anything while shop script is compiled

no time for IRC, im posting this at a last minute thing in the very early morning and i must go to work
Title: Re: Frosty's scripting thread
Post by: DarkCrusade on September 01, 2010, 01:43:34 pm
Maybe try merging both scripts first? It's always the best to do that to keep things as simple as possible.
Title: Re: Frosty's scripting thread
Post by: Falcon` on September 01, 2010, 04:46:58 pm
Code: (pascal) [Select]
if CheckPlayerAdmin(Shooter) = True then begin
if Getplayerstat(Victim,'alive') = True then Result:=CreateBullet(GetPlayerStat(Victim,'x'), GetPlayerStat(Victim,'y') - 0, 0,0,1, 10, Shooter);

This. Lovin it.
It won't work for you (bio kills i mean) since your kill is always by weapon = 'Cluster grenade'. And what it does... lovin it. Seems you have very balanced server. I guess every player loves you for this <3

And i suggest you to look closer what CreateBullet returns. Pro tip: not damage.
Title: Re: Frosty's scripting thread
Post by: frosty on September 02, 2010, 12:43:53 am
^^ thanks for the tip

only problem i have with that is, if i remove the  Result in that line it goes through some weird ass loop which seems to createbullet rfor every one damage, say for arguments sake the damage was 400, it creates 400 bullets, if i have it as Result it only does it once, any idea why thats happening?

thanks again

also the weapon = 'Cluster Grenade' is commented out so its not even being used, why commented out? because i use that occasionally

i mean it used to work but then i added something to shop then bio kills stopped working, so i dont think its the bio kills script, havent touched bio kills for ages now, only thing ive been working on is the shop script, i dunno... maybe i should just integrate the contents of BioKills with shop and see what that does?

thanks for the help tho falcon :D

edit: o crap i just realized what you meant, Bio kills wont apply to admins as the kills arent being done by the weps

many thanks, so sorry lol

but many thanks it was working perfect all this time
Title: Re: Frosty's scripting thread
Post by: frosty on September 04, 2010, 06:26:25 am
ok new problem:

trying to make a new gamemode

its a flamer racer script, only thing is, the checkpoints arent working

http://pastebin.com/Y2bTGFfp
Title: Re: Frosty's scripting thread
Post by: DarkCrusade on September 04, 2010, 01:42:43 pm
Did we already explain to you how to debug a script?
Title: Re: Frosty's scripting thread
Post by: frosty on September 04, 2010, 07:10:48 pm
yes

i know its this section, completely

but, once again, i dont know how to get it work

http://pastebin.com/GhFT8PYf

i was on irc @soldat.quakenet

they couldnt figure out it wasnt working either, even spoke to dnmr

i mean the checkpoints arent being triggered At all: http://pastebin.com/gaDmDwkC

none of those writelns are showing, not even the writeconsole message that happens when a lap is finished, so what am i missing?

i think its getting confused with the arrays, i had non array code that would have probably worked better than this....problem is it was unreadable, according to the folks on irc, so i gotta work with array code
Title: Re: Frosty's scripting thread
Post by: DarkCrusade on September 05, 2010, 09:08:11 am
Chk[1] will always be true - at least judging from the posted section.
Title: Re: Frosty's scripting thread
Post by: frosty on September 05, 2010, 01:09:51 pm
how do i fix it it? i only want it to be true when checkplayerdist is true, then False ONLY when all the other checkpoints have been triggered including startfinish, i dont know what to do, but heres the full code

http://pastebin.com/JwTd2uxv

also, each checkpoint should not be triggered until the previous one has, for example, checkpoint 2 should not be triggered unless checkpoint 1 has been triggered and so on

also, my compiler is giving me the following error when the map changes: Flamerace -> onmapchange -> ERROR: '' is not a valid integer value

wtf? there is no '' in the code, and endlap should be set to 20 if readini fails, wth ???
Title: Re: Frosty's scripting thread
Post by: Falcon` on September 05, 2010, 04:29:17 pm
I know that it's not really help but let's face the truth: this thread has already 7 pages, almost every second reply is about things that every programmer should know and you send us a code that sometimes doesn't have logical sence at all (however usually is well formated).

I suggest you to just write what you need, maybe someone will script this for you. At least you may have a chance to learn how to script well by watching someone's, better code.
Title: Re: Frosty's scripting thread
Post by: frosty on September 06, 2010, 02:33:32 am
can anyone help?

i will do that falcon, in future, ill even have a good hard look at SC, maybe i can learn a heap from there too

how exactly do i make code "make logical sense"? whenever i do, u guys say its "too long" or "unreadable" or "too many crappy logic blocks", i even wrote comments on that code to make it make sense so i must be missing something really important, look, i will take any critique, whatever it is just tell me, but right now i just dont get it

in the meantime, my playerbase is requesting that script to be working, so if theres anything you guys can do to help, id appreciate it :D
Title: Re: Frosty's scripting thread
Post by: Silnikos on September 06, 2010, 04:54:19 am
how exactly do i make code "make logical sense"? whenever i do, u guys say its "too long" or "unreadable" or "too many crappy logic blocks", i even wrote comments on that code to make it make sense so i must be missing something really important, look, i will take any critique, whatever it is just tell me, but right now i just dont get it

It shouldn't need comments to be readable - then it's clear. Anyway, it's always way harder to read and fix/edit someone's code than to write your own.
Title: Re: Frosty's scripting thread
Post by: Falcon` on September 06, 2010, 11:53:50 am
you miss knowledge like what is break instruction, i'm sure you have no idea about continue too. Not sure if you know exit, but this i hope you do
you don't know probably also what are case and try..except blocks.
defining types seems to be magic for you.
idk if you know a loops like while or repeat..until.
You seems to not know all types of variables.


also you miss some pure logic, that is hard to be learned. sometimes you do things that can be done very easily in very weird way.
That are only things i've noticed so Yes, you miss something....
Title: Re: Frosty's scripting thread
Post by: frosty on September 06, 2010, 01:26:37 pm
ok, thanks falcon :)

i do know about while, repeat and until but i dont know how to use them in pascal
Title: Re: Frosty's scripting thread
Post by: VinceBros on September 06, 2010, 03:33:42 pm
They're used in loops, by exemple:

Code: (pascal) [Select]
procedure MyLoop();
var
i: integer;
begin
result := 0; // You can omit the use of result.
i := result;
//here's the loop
   repeat
   i := i + 1;
   until i > 10
//end of the loop
end;

Or with
Code: [Select]
While
Code: (pascal) [Select]
procedure MyLoop2();
var
i: integer;
begin
 i := i + 1;
 while i < 10 do WriteLn('var i is under 10')
end;

I haven't tested them, nor used them, this is just an exemple on how to use While/Repeat/Until.
Title: Re: Frosty's scripting thread
Post by: DarkCrusade on September 06, 2010, 03:36:33 pm
The difference between those two loops is, that while-loops check the condition before iterating the code and the repeat-loop checks after iterating the code.
Title: Re: Frosty's scripting thread
Post by: frosty on September 06, 2010, 06:43:19 pm
tx guys

From: September 06, 2010, 08:09:38 pm
question:
why would i need exit for soldat?
Title: Re: Frosty's scripting thread
Post by: dnmr on September 07, 2010, 12:43:49 am
if you want to exit a procedure/function -.-
Title: Re: Frosty's scripting thread
Post by: frosty on September 07, 2010, 01:14:42 am
ahh ok, tx dnmr :)
Title: Re: Frosty's scripting thread
Post by: frosty on September 12, 2010, 04:01:12 am
question

in the ini functions

there is a var called "ini" which is defined once at the top in vars but never actually used, why is that? or have i missed something?

its not even my code thats why im asking, i mean is the variable "ini" even needed as its never actually used?
Title: Re: Frosty's scripting thread
Post by: DarkCrusade on September 12, 2010, 04:06:13 am
Start thinking on your own. The script you uploaded is to be used in an other script. The variable ini is used to store data obviously....
Title: Re: Frosty's scripting thread
Post by: frosty on September 12, 2010, 01:27:19 pm
yeh but where....i dont see it....
Title: Re: Frosty's scripting thread
Post by: DarkCrusade on September 12, 2010, 02:26:55 pm
I feel you need to learn a real programming language before proceeding with your Soldat scripts.
Title: Re: Frosty's scripting thread
Post by: frosty on September 13, 2010, 01:19:56 am
yes but where the hell do i go to learn pascal fully? for example, everywhere ive been for pascal info, tell yous how to use types, and tells you how to use arrays, bot doesnt tell you how to use Both, which is why i have been so confused over types and arrays, but now im starting to figure out types and arrays and now i know how to give a bot an owner
Title: Re: Frosty's scripting thread
Post by: DarkCrusade on September 13, 2010, 03:20:19 am
Try Java or maybe Python. There are nice Turbo Pascal tutorials out there, just search better.
Title: Re: Frosty's scripting thread
Post by: frosty on September 13, 2010, 01:27:16 pm
thanks

From: September 14, 2010, 04:10:25 am
GRR

second attempt at nuke turret, failed miserably, for some reason its arming straight away, should be a 10 second countdown, and it should be firing when armed, its not triggering at all

using arrays, what am i missing? what am i doing wrong? its gotta be something stupid cuz its driving me NUTS, look in Apponidle, not even the writeln message is appearing and i dont get why

plz tell me what im doing wrong here
custom functions available in utils.pas and bang.pas

Title: Re: Frosty's scripting thread
Post by: frosty on November 21, 2010, 03:26:28 am
Enesce server hosting, worst host ever

all i need is one script with a DoDamage and then he claims that my server is using too much CPU, well just for Arguments sake, NO OTHER SCRIPTS are even compiling, (what i wanted)

now i know what half my problems are

and all he (nick) is using is a Quad Core CPU and some other cheap n nasty upgrade, he should be using i7 quad cores fcs

seen quite a few posts on the forum complaining about something similar but all related
Quote
enesce hosting

the hardware is just.....inadequate, little wonder people are having trouble, still waiting on an email from U13 so i can get it set up there
Title: Re: Frosty's scripting thread
Post by: tk on November 21, 2010, 03:51:40 am
When looking at your "scripts", I'm not surprised why he refuses to host them.
Quad Core CPU is enough for dozen soldat servers.
Title: Re: Frosty's scripting thread
Post by: dnmr on November 21, 2010, 04:52:41 am
When looking at your "scripts", I'm not surprised why he refuses to host them.
Quad Core CPU is enough for dozen soldat servers.
what he said ^

You probably had an infinite loop in there or something similar -.-
Title: Re: Frosty's scripting thread
Post by: EnEsCe on November 23, 2010, 10:29:35 am
Dual Quad Core actually, Frosty (like it says on the front page when logging in)... Why are you only just now posting about something that occurred 4 months ago and hasn't been a problem since? But anyway, as I mentioned to you in one of the original emails, your server was the ONLY one using 100% CPU, while the other heavily scripted zombie servers weren't. Your scripts were the cause, not server hardware or "just" DoDamage.
Title: Re: Frosty's scripting thread
Post by: frosty on November 25, 2010, 12:53:01 am
well one reason i havent posted is because some idiot decided to get nasty so i gave up on dodamage, that was also 4 months ago just after the upgrade

DarkCrusade if you havent got anything helpful to say then dont say it, please...

well then can someone please go over this script? (attached) whats causing so much cpu usage?, at the moment cpu usage isnt a problem
however, as soon as i add a dodamage to this script, even just as a coommand where its only affecting ID not i out of 1 to 32 or whatever, it jumps to 100%, makes no sense since the average is 15%, thats what im saying, why would one line of dodamage cause so much cpu usage

there must be something seriously retarded with it, please point it out, id be very grateful if you could

just tried out dodamage by itself, not a problem, so there must be something in this script causing it to do that (only one im having trouble with)

please CONSTRUCTIVE criticism only!

Includes.txt also attached
Title: Re: Frosty's scripting thread
Post by: DarkCrusade on November 26, 2010, 12:31:41 pm
What the fuck I didn't say anything, but now you make me post something you might don't want to hear. You want "constructive criticism", but for what? If you want features to be discussed, why do you ask for help with fixing bugs? One reason why everyone is pissed and trolling this topic is, that you are one of the worst programmers (if you deserve that title) I have seen in my entire lifetime. Everytime I view one of your buggy scripts I find errors that I have seen months ago somewhere else. You don't learn anything, and that should tell you you should stop. Sorry, but just find a new hobby.
Title: Re: Frosty's scripting thread
Post by: dnmr on November 26, 2010, 01:34:05 pm
What the f**k I didn't say anything, but now you make me post something you might don't want to hear. You want "constructive criticism", but for what? If you want features to be discussed, why do you ask for help with fixing bugs? One reason why everyone is pissed and trolling this topic is, that you are one of the worst programmers (if you deserve that title) I have seen in my entire lifetime. Everytime I view one of your buggy scripts I find errors that I have seen months ago somewhere else. You don't learn anything, and that should tell you you should stop. Sorry, but just find a new hobby.
nice rage.
/me approves

Now for something more or less constructive. frosty.. You are using 6 scripts and you probably don't even realize how they work and if they are compatible at all :/
Title: Re: Frosty's scripting thread
Post by: frosty on November 26, 2010, 05:26:50 pm
dnmr how do i figure out if they are compatable?

and they are all used in the main scripts: Shop.pas and utils.pas

but sofar i have found nothing on the forum about "compatability" maybe i havent looked hard enough

DarkCrusade why did i post that? because all you did was troll for at least half the topic, not helping the situation at all, like you did just then, edit: btw since when is asking for scripting help in the SCRIPTING HELP AND DISCUSSION thread trolling?? u make no sense, going off like an idiot isnt HELPING either, i mean, if youve seen the bugs elsewhere like you claim then why not LINK to them at least?????????

or how other ways can i learn the pascal language, since i cant afford to do any courses for the real ones just yet

maybe i should spend a few months going through all the bugs pages....
Title: Re: Frosty's scripting thread
Post by: Falcon` on November 26, 2010, 05:55:32 pm
If your script eats AVERAGE OF 15% of cpu and you think that's low, then you have my personal congratulations sir!
Title: Re: Frosty's scripting thread
Post by: frosty on November 26, 2010, 10:49:07 pm
well, the whole server, im using like 20 scripts all up and the whole server uses an average of 10-15%

but seriously, how much CPU is a server "supposed" to use, and again how can i lower the usage? ive tried putting repeating code into functions and procedures, thats lowered it a little bit, i cant find anything on the net on how to shrink cpu usage of a pascal program, only can find how to write one and what the default syntax is, and a LITTLE bit on troubleshooting
Title: Re: Frosty's scripting thread
Post by: DarkCrusade on November 27, 2010, 12:22:47 am
You didn't understand what I said. My last post (before my rage) was on the 13th September. You replied to it being thankful. Now - months later - you tell me to shut up, because all I do is trolling and not helping. Why? I was the person helping you the most back then, when everyone else refused to because they were driven bonkers by what's making me mad right now. Your understanding of programming is that you put some code here and put some code there and it'll work the way you propose. Even if your code works, putting different code into different scripts won't help in any way, it rather makes everything worse. Many scripts instead of a single big one eat CPU and can cause servercrashs. Besides, it's just dumb, because it's harder to fix bugs, and it's even harder for someone who is starting with Soldat scripting to learn real programming.

Please, learn Pascal. Give it a harder try. There are books in libraries written in your language out there. It's the best for you.
 
Title: Re: Frosty's scripting thread
Post by: frosty on November 27, 2010, 02:31:34 am
ok, thankyou :D
Title: Re: Frosty's scripting thread
Post by: tk on November 27, 2010, 04:47:56 am
Quote
but seriously, how much CPU is a server "supposed" to use
0-1%

Let's look at one of your scripts
Code: [Select]
    for i:= 1 to 32 do if Getplayerstat(i,'Ping') > 0 then begin
      if SpeedTimer[i] > 0 then Speedtimer[i] := SpeedTimer[i] - 1;
      iniWrite('Players/'+IDtoname(i)+'.ini','stats','kills',inttostr(playerinfo[i].kills));
      iniWrite('Players/'+IDtoname(i)+'.ini','stats','tupred',inttostr(TUPred[i]));
      iniWrite('Players/'+IDtoname(i)+'.ini','stats','barkills',inttostr(barKills[i]));
      iniWrite('Players/'+IDtoname(i)+'.ini','stats','ranknum',inttostr(RankNum[i]));
    end;
...
 For z := 1 To ItemID Do begin
    if ItemInfo[z].Name='Massive Flak Gun' then begin
      for i := 1 to 32 do if (CheckPlayerDist(i,ItemInfo[z].x,Iteminfo[z].y,600)) AND (GetPlayerStat(i,'Team')<>ItemOwner[z].Team) then Shoot(ItemInfo[z].x,Iteminfo[z].y,GetPlayerStat(i,'x'),GetPlayerstat(i,'y'),500,1000,4,ItemOwner[z].PlayerID);
    end;
    if ItemInfo[z].Name='Auto Turret' then begin
      for i := 1 to 32 do if (CheckPlayerDist(i,ItemInfo[z].x,Iteminfo[z].y,600)) AND (GetPlayerStat(i,'Team')<>ItemOwner[z].Team) then Shoot(ItemInfo[z].x,Iteminfo[z].y,GetPlayerStat(i,'x'),GetPlayerstat(i,'y'),5000,1000,1,ItemOwner[z].PlayerID);
    end;

  for i := 1 to 32 do if (CheckPlayerDist(i,ItemInfo[z].x,Iteminfo[z].y,50)) AND (idtoname(i) = 'Mr.Zombie') then begin
and so on, and so on...
HORRIBLE way of coding, total lack of optimization, multiple loops with thousands of iterations, spaming with functions such as GetPlayerStat, checking distances and using heavy ini functions every second. How can you even ask why it has so big cpu use?
Title: Re: Frosty's scripting thread
Post by: frosty on January 01, 2011, 04:00:32 am
could someone please tell me why this is giving me an identifier expected error?

refined and fixed, only thing is i cant find whats causing this error, cant see any missing ';'

no missing begins or ends, otherwise my notepad++ would have told me about it

Quote
Shop -> [Error] (777:25): Identifier expected

maybe theres something else i need to take note of, all help appreciated

error located in Shop.pas (as far as i can tell)

maybe the script is corrupt? :S

btw to answer a previous question, ive got the code split up to make it easier to work on, that way im not scrolling through a thousand lines just to find something, (cant remember the actual code so ctrl+f is out of the question as the search would error "cannot find")

waiting on a few pascal books which i ordered over the net btw :D

another question, in one of my online references, it says that the Case argument is limited, just how "limited" is it exactly:

Pascal for beginners - Part 2 (http://www.astahost.com/info.php/Pascal-Beginners-Part_t15675.html)

somehow i dont think that page is quite complete, but mind you it is several years old...

i tried using it, but after 4 or 5 case statements in the one Case...of it gives me a syntax error

could someone please enlighten me to exactly how many Case arguments you can fit into a case of statement

Code: (pascal) [Select]
Case Number of
1: ok;
2: ok;
3: ok;
4: maybe;
5: error;
end;
[/randommadeupcode]

:D thanks in advance
Title: Re: Frosty's scripting thread
Post by: Boblekonvolutt on January 01, 2011, 05:11:17 am
btw to answer a previous question, ive got the code split up to make it easier to work on, that way im not scrolling through a thousand lines just to find something, (cant remember the actual code so ctrl+f is out of the question as the search would error "cannot find")
No, it's cause you're combining a number of scripts you don't actually understand and can't combine it. What you really should do is start from scratch and not allow yourself to copy anything from anywhere.

If you actually think about how you could get the information from the line number given by the soldat server the answer is pretty obvious.

(Line 136 in Shop.pas, I should add if I'm gonna be realistic)
Title: Re: Frosty's scripting thread
Post by: DarkCrusade on January 01, 2011, 05:36:21 am
Case statements are not limited, and the tutorial doesn't imply that. It just needs to end somewhere, and because you cannot add a ';' at the end you add an 'end;'.
Title: Re: Frosty's scripting thread
Post by: frosty on January 01, 2011, 06:10:19 pm
so ill have to make my own ini writing and shooting procedure, i hope that pascal book comes in soon, i wonder how im going to remake that nova..

ill get there eventually i guess :)

thanks guys

From: January 01, 2011, 07:41:13 pm
i have another problem, one of my functions is calling a type mismatch error, compare the working code with the not working code

the function:
Code: (pascal) [Select]
function CheckPlayerAdmin(ID:Byte):Boolean;
begin
if ReadINI('Players/'+IDtoname(ID)+'.ini','stats','admin','0') = '1' then Result:=True;
end;

working code:
Code: (pascal) [Select]
function OnPlayerDamage(Victim, Shooter: byte; Damage: integer): integer;
begin
  Playerinfo[Shooter].achievements:=strtoint(ReadINI('Players/'+IDtoname(Shooter)+'.ini','stats','tna','0'));
  DamagePerc[Shooter]:=(RankNum[Shooter]*RankDamageMult)+Playerinfo[Shooter].achievements;
  if {CheckPlayerAdmin(Shooter)=True and }Getplayerstat(Victim,'alive') then CreateBullet(GetPlayerStat(Victim,'x'), GetPlayerStat(Victim,'y') - 0, 0,0,1, 10, Shooter);
  RankDam[Shooter]:=Damage+(Damage*(DamagePerc[Shooter]/100));
  result:=Damage + Rankdam[Shooter];
  if IDtoname(Shooter) = '[Warlord]Mr.Zombie' then begin
    DamCalc[Shooter]:=Damage+RankDam[Shooter];
    //Result:=DamCalc[Shooter]*(1/100);
  end;
end;

not working:
Code: (pascal) [Select]
function OnPlayerDamage(Victim, Shooter: byte; Damage: integer): integer;
begin
  Playerinfo[Shooter].achievements:=strtoint(ReadINI('Players/'+IDtoname(Shooter)+'.ini','stats','tna','0'));
  DamagePerc[Shooter]:=(RankNum[Shooter]*RankDamageMult)+Playerinfo[Shooter].achievements;
  if CheckPlayerAdmin(Shooter) and Getplayerstat(Victim,'alive') then CreateBullet(GetPlayerStat(Victim,'x'), GetPlayerStat(Victim,'y') - 0, 0,0,1, 10, Shooter);
  RankDam[Shooter]:=Damage+(Damage*(DamagePerc[Shooter]/100));
  result:=Damage + Rankdam[Shooter];
  if IDtoname(Shooter) = '[Warlord]Mr.Zombie' then begin
    DamCalc[Shooter]:=Damage+RankDam[Shooter];
    //Result:=DamCalc[Shooter]*(1/100);
  end;
end;

ALSO not working:
Code: (pascal) [Select]
function OnPlayerDamage(Victim, Shooter: byte; Damage: integer): integer;
begin
  Playerinfo[Shooter].achievements:=strtoint(ReadINI('Players/'+IDtoname(Shooter)+'.ini','stats','tna','0'));
  DamagePerc[Shooter]:=(RankNum[Shooter]*RankDamageMult)+Playerinfo[Shooter].achievements;
  if CheckPlayerAdmin(Shooter)=True and Getplayerstat(Victim,'alive') then CreateBullet(GetPlayerStat(Victim,'x'), GetPlayerStat(Victim,'y') - 0, 0,0,1, 10, Shooter);
  RankDam[Shooter]:=Damage+(Damage*(DamagePerc[Shooter]/100));
  result:=Damage + Rankdam[Shooter];
  if IDtoname(Shooter) = '[Warlord]Mr.Zombie' then begin
    DamCalc[Shooter]:=Damage+RankDam[Shooter];
    //Result:=DamCalc[Shooter]*(1/100);
  end;
end;

can anyone expain why this isnt working and why it has all of a sudden decided to error? its always worked up til now, i havent touched that section of code in my clean up so what the f*** :S
Title: Re: Frosty's scripting thread
Post by: Falcon` on January 01, 2011, 07:54:30 pm
store this admin value in some variable. With current code you're raping your hard drive each hit. Also 2nd code should work (this w/o =true). if it really doesn't then try "if (CheckPlayerAdmin(Shooter) = true) and ...".

Also admin advantage idea is ingenious. I think i said it already but i guess players hate/try to kick you for that every time you join lol.
Title: Re: Frosty's scripting thread
Post by: frosty on January 01, 2011, 10:00:03 pm
wtfffffff???????????
looks like the entire shop script is broke, or do i need to rewrite it (again)

can anyone see whats going on?

Shop -> [Error] (762:39): Type mismatch

i dont have much time to go through it properly

but the thing is, if i comment out OnPlayerCommand, the error automatically points to the next uncommented line

it sems no matter how many lines i comment out, i cant find the error, or is it, like you guys said, an imcompatability in the code = give up on shop and use my own functions?

im sorry about this guys :(
Title: Re: Frosty's scripting thread
Post by: Falcon` on January 01, 2011, 10:28:29 pm
( :O )*


*Do not forget the parentheses!
Title: Re: Frosty's scripting thread
Post by: frosty on January 01, 2011, 10:43:35 pm
fuckin retard server, had to try to start the server 7 times after uploading beore it compiled

tx Falcon :)