PDA

View Full Version : Help with Official First Script



imported_snu_woods
10-13-2006, 12:16 AM
Hi-
Here's my code...so far:
program New;
{.Include SRL\SRL.scar}
{.Include SRL\SRL\core\Login.scar}
{.Include SRL\SRL\core\Bank.scar}

var
result :integer;

begin
LoggedIn
If(result=true) Then
OpenBank3
Withdraw(3,1,15)
CloseBank;
end.

I know it's not much, but it's my first time using SRL and I don't really understand it, and I've been creating this script for around 15 minutes. I'd really appreciate it if someone could tell me what I've been doing wrong and what I need to do in the future.

Thanks
--
Wizard Snu

HatlessCow
10-13-2006, 12:43 AM
program New;
{.Include SRL\SRL.scar}
{.Include SRL\SRL\core\Login.scar}
{.Include SRL\SRL\core\Bank.scar}

var
result :integer;

begin
LoggedIn
If(result=true) Then
OpenBank3
Withdraw(3,1,15)
CloseBank;
end.

Well I haven't used SRL at all yet but I'm guessing LoggedIn is a function that checks if you are logged in. So just putting LoggedIn on it's own line will do nothing except check if you are logged in and result true. So instead of:

LoggedIn
If(result=true)Then


You would want to put

If(LoggedIn)Then
I didn't even have to put if(LoggedIn = true)then because in an if statement it will automatically check if it is true, if you wanted to check if it was false then you would have to put if(LoggedIn=false)then.

Also you have result declared as an integer. An integer is any negative or positive whole number, &or 0. You wanted to see if result was True in your if statement and that would mean it would have to be a declared as a boolean. However in this script you would not have to declare anything.


If(result=true) Then
OpenBank3
Withdraw(3,1,15)
CloseBank;

Aside from your if statement being wrong, right now, it will do OpenBank3 if the if statement is true. Withdraw and CloseBank it will do regardless of whether the if statement is true or not. You would want to code it like this:

If(LoggedIn)Then
begin
OpenBank3;
Withdraw(3,1,15);
CloseBank;
end;

By enclosing your bank process in a begin and end it's saying if loggedin, then, and it sees everything in the being to end instead of just the OpenBank.

Also notice how the end has a semi-colon after it, all ends have semi-colons after them except for the main routine statement of your script, the very last begin-end statement of the script which is the one that executes will have an end with a period after it to mark the end of the script.

Finally it should look like this if I've got everything correct:

program New;
{.Include SRL\SRL.scar}
{.Include SRL\SRL\core\Login.scar}
{.Include SRL\SRL\core\Bank.scar}

begin
If (loggedin) Then
begin
OpenBank3;
Withdraw(3,1,15);
CloseBank;
end;
end.

masquerader
10-13-2006, 01:54 AM
Login.scar and Bank.scar
are included when your put
{.Include SRL\SRL.scar}

imported_snu_woods
10-13-2006, 11:09 AM
You are the best! Thanks for the help.
I'll probably have a lot more question:D !

Thanks Again
--
Snu Woods

edit: Do I have to put "result :boolean;" then?

imported_snu_woods
10-13-2006, 11:40 AM
Here's my script now:program New;
{.Include SRL\SRL.scar}


begin
activateclient
wait(random(30)+350);
If(LoggedIn) Then
begin
OpenBank3
DepositALL
Withdraw(3,1,15)
CloseBank;
end;
end.



But, I get this error:[Runtime Error] : Exception: Access violation at address 006549BC in module 'scar.exe'. Read of address 00000000 in line 38 in script C:\Program Files\SCAR 2.03\includes\srl\srl\core\Bank.scar

Thanks
--
Snu Woods

Wizzup?
10-13-2006, 12:03 PM
Call SetupSRL; Once

frogy
10-13-2006, 01:13 PM
Um did you read the error?

Your missing your includes I think...




program New;
{.Include SRL\SRL.scar}


Like your first script it'll need to be

program New;
{.Include SRL\SRL.scar}
{.Include SRL\SRL\core\Login.scar}
{.Include SRL\SRL\core\Bank.scar}

Boreas
10-13-2006, 03:20 PM
I thought core files are inlcuded with {.Include SRL\SRL.scar}. It's everything else like misc that you have to put after.

da_professa
10-13-2006, 06:08 PM
I had tht same problem in my script... but it went away when i called SetupSRL;

also ppl please help me wid my trouble in the other topic named air rune crafter

IronTeapot
10-13-2006, 07:58 PM
Wizzup? is correct. To use the functions and precdures in the include, you need to call to it so it knows that it needs to be used. I dont know the answer to the access violation though.

Dankness
10-13-2006, 08:38 PM
Wizzup? is correct. To use the functions and precdures in the include, you need to call to it so it knows that it needs to be used. I dont know the answer to the access violation though.

The access violation is because your using a variable for a bitmap, dtm, etc, etc without ever setting it. Thats why you have to call SetupSRL to initalize all the variables, dtm's, bitmaps, arrays, etc, etc...

And by including SRL.Scar you do not need to include any other core includes IE : Login, Bank, Color, etc, etc because inside of SRL.Scar it includes all of them...

imported_snu_woods
10-15-2006, 01:28 AM
Hi-
Been busy lately....
this my seem n00bey, but what does calling mean?...{.include.....}?

Thank
--
Snu Woods

Junior
10-15-2006, 02:00 AM
Hi-
Been busy lately....
this my seem n00bey, but what does calling mean?...{.include.....}?

Thank
--
Snu Woods

Calling basically means to add something into your coding or to place a procedure in your coding/script. And include contains alot of procedures that can be placed into your coding to make it easier for you. For example instead of making a whole procedure you can just "Call" the procedure like this
Loginplayer; //This will login your player from login screen
Login player is already a procedure in your include so you will be able to just call/place it into your script instead of creating a whole procedure for it.
Hope this helps
~jR

imported_snu_woods
10-15-2006, 06:28 PM
Thanks...hopefully I'll be able to get this script out within the month;)