SRL Archive - OSR Help

How to use Players correctly?


m34tcode

2011-12-19 17:23:30

My first problem is when i add multiplayer, Simba does not auto-complete when i type Players[0].

Simba doesn't recognize I'm using the variable Players, but it auto-completes the Players variable as 'Array of TUser'

What I mean by auto-complete is that it appears in the auto-complete popup list.

My other problem is when i use a template, or anyones script, that uses smart, I get this error:

[Error] C:\Simba\Includes\SRL/SRL/misc/smart.scar(9:10): Duplicate identifier 'ISKEYDOWN' at line 8
Compiling failed.

Searching found that the error is caused by not using smart… other peoples scripts should work then though. I'm doing the same thing AFAIK.


my code so far:

{$i srl/srl.scar}
{$i srl/srl/misc/smart.scar}
{*
are logs in inv?
begin burning
else
do we know if we have logs?
if yes, do we have logs?
bank for logs
else
exit
else
bank for logs

find suitable burn spot

begin burning



***
Burnin strategy loop
***

find next log to burn

if none
break
else
mouseover next log
wait till started moving BUT:
if stopped lighting
light next log
continue from start of loop;

light next log

if last position has excessive stack of logs
pickup those logs
go back to next burn spot





***
*}

{*
What logs to burn?
list logs
What to do with logs that player can burn but decided not to.
Drop, burn, or bank

Bank or woodcut for logs
choice

if bank then woodcut when supply is gone?
True or false

burn method
bow, inventory tinderbox, belt tinderbox

If woodcutting
what axe
bank for backup axes?

*}
const
{-----Breaking Settings-----}
TakeBreaks = True; // Take breaks?
HowOften = 90; // How often to break in minutes
HowOftenRandom = 90; // Added randomness to how often you break
minBreak = 10; // Minimum break length
maxBreak = 60; // maximum break length
{---------------------------}
{---SMART Setup Constants---}
WORLD = 121;// Set a world, if you'd like.
MEMBERS = False;// Is your first character a member?
SIGNED = True; // Set to faLse to allow two accounts on at one time
{---------------------------}
{--------Script Info--------}
Author = 'm34tcode';
Name = 'M34tFM';
Version = '0.1';

Var
BreakOften, BreakLength, BreakTimes: Integer;

procedure DeclarePlayers;
begin
HowManyPlayers := 1;
NumberOfPlayers(HowManyPlayers);
CurrentPlayer := 0;

Players[0].Name := ''; // Username
Players[0].Pass := ''; // Password
Players[0].Nick := ''; // 3-4 lowercase letters from username
Players[0].Active := True; // Keep this true if you want to use this player
Players[0].Pin := ''; // Leave blank if the player doesn't have a bank pin

//Add each log type you would like to burn.
// Valid choices are: plain
Players[0].Strings := ['plain','oak','willow'];


end;

procedure AntiBan;
begin
case Random(20) of
0: HoverSkill('Random', False);
1: begin
RandomMovement;
HoverSkill('Random', False);
end;
2,3: BoredHuman;
4: begin
RandomAngle(1);
HoverSkill('Random', False);
ExamineInv;
end;
end;
end;

procedure AntiRandoms;
begin
FindNormalRandoms;
end;

procedure BreakCheck;
begin
if not LoggedIn then
begin
Players[CurrentPlayer].Active := False;
Exit;
end;
BreakOften := ((HowOften*60000)-(HowOftenRandom*60000)+Random(HowOftenRandom*120000));
if GetTimeRunning >= BreakOften*BreakTimes then
begin
BreakLength := minBreak*60000+Random((maxBreak-minBreak)*60000);
Logout;
Wait(BreakLength);
LoginPlayer;
end;
end;

procedure ProgressReport;
begin
WriteLn('~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~');
WriteLn(Name + 'by' + Author + 'V' + Version);
WriteLn('~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~');
end;

begin
Smart_Server := WORLD;
Smart_Members := MEMBERS;
Smart_Signed := SIGNED;
Smart_SuperDetail := False;
SetupSRL;

DeclarePlayers;
LoginPlayer;
repeat
BreakCheck;

until AllPlayersInactive;
end.

nickrules

2011-12-19 19:00:58

From: m34tcode
My first problem is when i add multiplayer, Simba does not auto-complete when i type Players[0].

Simba doesn't recognize I'm using the variable Players, but it auto-completes the Players variable as 'Array of TUser'

What I mean by auto-complete is that it appears in the auto-complete popup list.




My other problem is when i use a template, or anyones script, that uses smart, I get this error:

[Error] C:\Simba\Includes\SRL/SRL/misc/smart.scar(9:10): Duplicate identifier 'ISKEYDOWN' at line 8
Compiling failed.



Declare the smart include BEFORE srl. It has to be BEFORE. otherwise it won't work.

your code:

{$i srl/srl.scar}
{$i srl/srl/misc/smart.scar}

what your code *should* be:

{$i srl/srl/misc/smart.scar}
{$i srl/srl.scar}

m34tcode

2011-12-19 19:08:49

Thank you. That worked. How do i use Players correctly?

m34tcode

2011-12-19 21:36:49

The tutorial doesn't quite show it.

nickrules

2011-12-20 11:19:59

From: m34tcode
The tutorial doesn't quite show it.


Which tutorial, and what do you want to do? My scripts are never really multiplayer (don't really need multiplayer…), but I do still have some grasp of how to do it.

I truthfully just copy a basic one I made that I know works.

procedure DeclarePlayers;
begin
HowManyPlayers := 1;
CurrentPlayer := 0;
NumberOfPlayers(HowManyPlayers);

with Players[0] do
begin
Name := '';
Pass := '';
Nick := '';
Pin := ''; // Bank Pin - leave alone if you don't have one.
Member := False;
Active := True;
end;

end;

Now, you can store much more data within each "player".
Let's take a look at the TUser;

  TUser = record
Name: string; // * User Name
Pass: string; // * User Pass
Pin: string; // * Current Users Pin Number
Member: boolean; // * For Login
WorldInfo: TVariantArray; // * [Members {Boolean}, World {Integer}, PVP {Boolean}]
Nick: string; // * Screen Name for random detection
{NickTPA: TPointArray; // * TPA Of Player Name}
Level: array[0..24] of Integer; // * Levels of all skills.
Active: Boolean; // * Set to True if Ok, False if Lost.
Loc: string; // * User Location
Status: string; // * User Status
Skill: string; // * User Action to Perform
Worked: Integer; // * Time User has worked
Banked: Integer; // * Number of Banks User has done
Rand: string; // * Current Random
Booleans: array of Boolean; // * For reports, etc.
Integers: array of Integer; // * For reports, etc.
Strings: array of string; // * For reports, etc.
Extendeds: array of Extended; // * For reports, etc.
Arrays: array of TVariantArray; // * For custom arrays.
BoxRewards: TStringArray; // * Partial texts for rewards, place in desired order.
end;

They are fairly well commented, so what to do with them is up to you. They are all optional, technically - but a few basic ones are needed [just about] every time:

Name
Pass
Nick
Active
Member
[and usually] Pin

——

"But niggleous, how do I add these to the player?"

Well, Let's say I want to set some extra crap

procedure DeclarePlayers;
begin
HowManyPlayers := 2;
CurrentPlayer := 0;
NumberOfPlayers(HowManyPlayers);

with Players[0] do
begin
Name := 'z00zima';
Pass := 'waffles';
Nick := '0zi';
Pin := '1243'; // Bank Pin - leave alone if you don't have one.
Member := False;
Active := True;
Integers[0] := 2000; //bows to fletch
integers[1] := 376; //this is also important, i guess....
booleans[0] := true; //Make the player dance on level up?
loc := 'VWB' //where are we currently?
end;

with Players[1] do
begin
Name := 'idontknowfamouspeople';
Pass := ''fapfapfap;
Nick := 'oxinsox';
Pin := '5831'; // Bank Pin - leave alone if you don't have one.
Member := True;
Active := True;
Integers[0] := 20056; //bows to fletch
integers[1] := 265; //this is also important, i guess....
booleans[0] := true; //Make the player dance on level up?
loc := 'VEB' //where are we currently?
end;

end;

Additionally, ALL the data values in TUser are there. They just aren't in that list - if that makes sense. Let me explain. Let's say we're using the Players array above.

So, since we're using several players, we can't just make a global variable to hold the number of bows made. How do we record the number of bows we've already made, but only for that player?

Well, like this.

Procedure Cutbows;
begin
//blahblahblah
if mouse(x,y,5,5,true) then //if we cut a bow
inc(players[currentplayer].integers[3]) //notice it's the 3rd integer value, not set above
end;

I hope that clears things up a bit. If not, explain your problemm better?

m34tcode

2011-12-20 14:05:40

That's what i had though but I haven't seen the difference between your code and mine, but Simba recognizes your players and shows auto-complete. I'm missing something. Ill write one from scratch and post if it doesn't work again. Thanks dude

EDIT: got it. I didn't use the s in Players. No idea how I missed that Lol