SRL Archive - Outdated / Broken

Player priorities


Markus

2007-07-10 13:50:33

This is a bit hard to explain, but I try as best as I can.

When you're running a script for profit, you want to run it as long as possible, for the highest possible profit. However, you want it to run on your elite characters, instead of your noobs, but you only have like three of them so the script can only run for six hours. But if you add your noob chars, your profit will go down drastically, but the script will run as long as possible.
That's why I want player priorities, that way you can give players priorities.
example:
Person A has 15 characters and wants to run a iron miner/banker.
He has five people level 60+, and wants to mine most on these chars. He gives them priority 0.
His other army members, 6-15, are only mining 16 and have steel pick, so it'll lower his profit. He gives them priority 1.
He starts the script and watches.
The script first starts on his lv60+ characters, the script doesn't use the lv16 characters.
But after 6 hours, all of his elite characters are false. He got like 400 iron an hour, so he'll earn some nice profit.
Now all his priority 0 chars are false, it'll switch over to the priority 1 chars, they are lower mining, but instead of earning no iron (all his high level chars are false), it'll continue on his lower level chars, instead of 0 iron now, it'll keep mining (but a bit slower), so he'll still earns profit.

This is also useful for training purposes, so you can train your lower level chars before training your higher level chars, so their levels become equal.

What do you guys think?

is this my longest post ever?

Dan Cardin

2007-07-10 13:56:13

definately a good idea. but how do u plan on doing it?like in a the player array adding
Players[x].integer1: 0;//priority number
? or something different

Markus

2007-07-10 13:59:35

players[0].priority := 1; or something

shaunthasheep

2007-07-10 14:56:44

idk if this works. Tell me if it does :)

program Priorities;
{.include SRL/SRL.scar}
var
CurrentPrioritie : integer;
HighestPrioritie : integer;

procedure DeclarePlayers;
begin
HowManyPlayers := 1; //No CurrentPlayer, The priorities will sort that out
CurrentPrioritie := 0; //Will start at this priorite, stops at highest prioritie (last group of players)
HighestPrioritie := 5;
NumberOfPlayers(HowManyPlayers);

Players[0].Name :='';
Players[0].Pass :='';
Players[0].Nick :='';
Players[0].Integer1 := 0; //Prioritie
Players[0].Active:= True;
end;

function AnyActive(Prioritie : integer) : boolean;
var
i, a : integer;
begin
a := GetArrayLength(Players) - 1;
for i := 0 to a do
if Players[i].integer1 = Prioritie then
if Players[i].Active then
begin
Result := True;
Exit;
end;
end;

procedure PNextPlayer(active : boolean);
var
i, a, LowestActivePrioritie : integer;
begin
Players[CurrentPlayer].Active := active;
if AnyActive(CurrentPrioritie) then
begin
a := GetArrayLength(Players) - 1;
for i := CurrentPlayer to a do
if Players[i].Integer1 = CurrentPrioritie then
if Players[i].Active then
begin
CurrentPlayer := i;
LoginPlayer;
Exit;
end;
end else
begin
if CurrentPrioritie = HighestPrioritie then
begin
if not AnyActive(HighestPrioritie) then
begin
Writeln('No More Players! Terminating!');
TerminateScript;
end;
end;
CurrentPrioritie := CurrentPrioritie + 1;
PNextPlayer(Active);
end;
end;

begin
SetupSrl;
DeclarePlayers;
PNextPlayer(false);
end.

Harry

2007-07-10 21:43:06

I posted up the same thing kinda.. http://www.srl-forums.com/forum/trueother-t14749.html?p=157092#post157092

shaunthasheep

2007-07-10 21:58:47

hy7, markus, here you go, i updated and tested now.

program Priorities;
{.include SRL/SRL.scar}
var
CurrentPrioritie : integer;
HighestPrioritie : integer;

procedure DeclarePlayers;
begin
HowManyPlayers := 9; //No CurrentPlayer, The priorities will sort that out
CurrentPrioritie := 0; //Will start at this priorite, stops at highest prioritie (last group of players)
HighestPrioritie := 5;
NumberOfPlayers(HowManyPlayers);

Players[0].Name :='apple0';
Players[0].Integer1 := 0; //Prioritie
Players[0].Active:= True;

Players[1].Name :='bill1';
Players[1].Integer1 := 1; //Prioritie
Players[1].Active:= True;

Players[2].Name :='chicken3';
Players[2].Integer1 := 3; //Prioritie
Players[2].Active:= True;

Players[3].Name :='dewww1';
Players[3].Integer1 := 1; //Prioritie
Players[3].Active:= True;

Players[4].Name :='eww2';
Players[4].Integer1 := 2; //Prioritie
Players[4].Active:= True;

Players[5].Name :='failure2';
Players[5].Integer1 := 2; //Prioritie
Players[5].Active:= True;

Players[6].Name :='giggity5';
Players[6].Integer1 := 5; //Prioritie
Players[6].Active:= True;

Players[7].Name :='holley5';
Players[7].Integer1 := 5; //Prioritie
Players[7].Active:= True;

Players[8].Name :='import6'; //shouldn't play, prioritie 6.
Players[8].Integer1 := 6; //Prioritie
Players[8].Active:= True;

end;

function AnyActive(Prioritie : integer) : boolean;
var
i, a : integer;
begin
a := GetArrayLength(Players) - 1;
for i := 0 to a do
if Players[i].integer1 = Prioritie then
if Players[i].Active then
begin
Result := True;
Exit;
end;
end;

function IsLastActiveInPrioritie(Player, Prioritie : integer) : boolean;
var
i,a : integer;
begin
result := True;
a := GetArrayLength(Players) - 1;
if Player = a then Exit;
for i := Player + 1 to a do
if Players[i].Active then
if Players[i].Integer1 = Prioritie then
begin
Result := False
Exit;
end;
end;

procedure PNextPlayer(active : boolean);
var
i, a : integer;
firstloop : boolean;
begin
Players[CurrentPlayer].Active := active;
if AnyActive(CurrentPrioritie) then
begin
a := GetArrayLength(Players) - 1;
if IsLastActiveInPrioritie(CurrentPlayer, CurrentPrioritie) then
CurrentPlayer := -1;
for i := CurrentPlayer + 1 to a do
if Players[i].Integer1 = CurrentPrioritie then
if Players[i].Active then
begin
CurrentPlayer := i;
LoginPlayer;
Writeln(Players[i].Name);
Exit;
end;
end else
begin
if CurrentPrioritie = HighestPrioritie then
begin
if not AnyActive(HighestPrioritie) then
begin
Writeln('No More Players! Terminating!');
TerminateScript;
end;
end;
CurrentPrioritie := CurrentPrioritie + 1;
PNextPlayer(Active);
end;
end;

begin
SetupSrl;
DeclarePlayers;
PNextPlayer(True);
PNextPlayer(True);
Writeln('setting currentPlayer false');
PNextPlayer(False);
PNextPlayer(True);
PNextPlayer(True);
PNextPlayer(True);
PNextPlayer(True);
PNextPlayer(True);
PNextPlayer(True);
PNextPlayer(True);
Writeln('setting 2 players false in a row');
PNextPlayer(False);
PNextPlayer(False);
PNextPlayer(True);
PNextPlayer(True);
PNextPlayer(True);
PNextPlayer(True);
PNextPlayer(True);
Writeln('setting 2 players false in a row');
PNextPlayer(False);
PNextPlayer(False);
PNextPlayer(True);
PNextPlayer(True);
PNextPlayer(True);
PNextPlayer(True);
PNextPlayer(True);
Writeln('setting currentPlayer false');
PNextPlayer(False);
PNextPlayer(True);
PNextPlayer(True);
PNextPlayer(True);
PNextPlayer(True);
Writeln('setting 1 players false');
PNextPlayer(False);
PNextPlayer(True);
PNextPlayer(True);
PNextPlayer(True);
PNextPlayer(True);
Writeln('setting player false');
PNextPlayer(False);
end.

pretty much declare those two variables, change declare players, add those 3 functions, and change NextPlayer(blah); with PNextPlayer(blah);

enjoy :)

EDIT: this does not work with HowManyPlayers and RandomNextPlayer. Right now it's set to getarrayLength(Players) - 1, just change stuff too HowManyPlayers - 1, and for RandomNextPlayer, you can code that yourself :p

Miitchyy

2007-07-12 10:07:00

Open Globals.Scar find
type
TUser = record
and under Worked: Integer or something, underneath it add
Priority: Integer; // * Priority level of character

I prefer it like this :P It looks more Professional, And it clears up Integer1 so it can be used by the script

That way you can use
Procedure DeclarePlayers;
begin

HowManyPlayers := 1;
NumberOfPlayers(HowManyPlayers);
CurrentPlayer := 0;

Players[0].User := 'I r teh makr0';
Players[0].Pass := 'Uber1337Yo';
Players[0].Nick := 'akr';
Players[0].Active := True;
Players[0].Priority := 0;

end;

function AnyActive(Priority : integer) : boolean;
var
i, a : integer;
begin
a := GetArrayLength(Players) - 1;
for i := 0 to a do
if Players[CurrentPlayer].Priority = Priority then
if Players[i].Active then
begin
Result := True;
Exit;
end;
end;

function IsLastActiveInPriority(Player, Priority : integer) : boolean;
var
i,a : integer;
begin
result := True;
a := GetArrayLength(Players) - 1;
if Player = a then Exit;
for i := Player + 1 to a do
if Players[i].Active then
if Players[CurrentPlayer].Priority = Priority then
begin
Result := False
Exit;
end;
end;

procedure PNextPlayer(active : boolean);
var
i, a : integer;
firstloop : boolean;
begin
Players[CurrentPlayer].Active := active;
if AnyActive(CurrentPriority) then
begin
a := GetArrayLength(Players) - 1;
if IsLastActiveInPriority(CurrentPlayer, CurrentPriority) then
CurrentPlayer := -1;
for i := CurrentPlayer + 1 to a do
if Players[CurrentPlayer].Priority = CurrentPriority then
if Players[i].Active then
begin
CurrentPlayer := i;
LoginPlayer;
Writeln(Players[i].Name);
Exit;
end;
end else
begin
if CurrentPriority = HighestPriority then
begin
if not AnyActive(HighestPriority) then
begin
Writeln('No More Players! Terminating!');
TerminateScript;
end;
end;
CurrentPriority := CurrentPriority + 1;
PNextPlayer(Active);
end;
end;

jhildy

2007-07-12 11:51:40

This should be added into LoginPlayer so people don't have to worry about doing anything further.

Jagex_Fagex

2007-07-12 11:56:29

or you could just add it into your scripts. and then devs can put into SRL after