Page 1 of 1

Online character list?

Posted: Tue Apr 18, 2006 1:21 pm
by Poi
Sorry for me asking all the dumb questions lately, but i was wondering if someone could make/help me make a .online scipt shows all online characters.

Posted: Tue Apr 18, 2006 1:25 pm
by Yukiko
Try this one Poi:

Code: Select all

use uo;

global layout := {
	"nodispose",
	"page 0",
	"resizepic 0 20 2620 310 470",
	"gumppic 15 50 2621",
	"text 20 29 40 0",
};

global data := {
	"Online Characters",
	"Score"
};

program textcmd_online (character)
	if (CINT (GetObjProperty (character, "#checkonline")) > ReadGameClock())
		SendSysmessage (character, "That gump is already open!");
		return;
	endif
	SetObjProperty (character, "#checkonline", CINT(ReadGameClock() + 120));
	
	FillInArrays (character);
	local gump_return := SendDialogGump (character, layout, data);
	if (!gump_return and gump_return[0] != 0)
		SendSysMessage (character, "You must close other gumps before you can do this.");
	endif
	EraseObjProperty (character, "#checkonline");
endprogram


function FillInArrays (character)
	var all_players := EnumerateOnlineCharacters ();
	var players := {};
	foreach player in all_players
		if (player.cmdlevel)
			if (IsAGM (character))
				players.append (player);
			endif
		else
			players.append (player);
		endif
	endforeach

	var pagecount := 1;
	var ypos := 70;
	var string_counter := 2;
	var totalplayers := len (players);

	layout.append ("page " + pagecount);
	for playercount := 1 to totalplayers
		var player := players [playercount];
		layout.append ("text 20 " + ypos + " 40 " + string_counter);
		string_counter := string_counter + 1;
		ypos:= ypos + 20;

		
		if (!GetObjProperty (player, "private"))
				data.append (playercount +". " + player.name);
			else
				data.append (playercount +". " + player.name + " [AFK]");
			endif

		if (playercount = totalplayers)
			return;
		endif

		case (playercount)
			20:
			40:
			60:
			80:
			100:
				layout.append ("button 285 30 2648 2647 0 " + (pagecount + 1));
				pagecount := pagecount + 1;
				layout.append ("page " + pagecount);
				ypos := 70;
				layout.append ("button 255 30 2650 2651 0 " + (pagecount - 1));
		endcase
	endfor
endfunction



function IsAGM (character)
	if (character.cmdlevel)
		return 1;
	endif

	return 0;

endfunction
Not sure where I got it but it should do the trick.

Posted: Tue Apr 18, 2006 1:31 pm
by Poi
It will not ecompile it. And i dont know the error.. it closes to fast

Posted: Tue Apr 18, 2006 1:34 pm
by Yukiko
You will have to open a DOS command pronpot window from Programs --> Accessories and then run ecompile from there or download and use the Scite editor and use it. I have a copy of Scite at the following link: http://www.hopelives.us/Files/SciTe95.zip

It displays the compiler output at the bottom of its window.

Posted: Tue Apr 18, 2006 1:37 pm
by Poi
Also i added a line to the top of scripts, so -1 to eachof the #'s

->e:\pol\scripts\ecompile.exe
EScript Compiler v1.03
Copyright (C) 1994-2003 Eric N. Swanson

Compiling: E:/pol/scripts/online.src
Warning: Found deprecated token 'global' on line 4 of E:\pol\scripts\online.src
Expected expression following comma before right-brace in array initializer list

Error getting elements for array
Error compiling statement at E:\pol\scripts\online.src, Line 4
Compilation Error:
Near: global layout := {
File: E:\pol\scripts\online.src, Line 9
Execution aborted due to: Error compiling file

->

Posted: Tue Apr 18, 2006 1:37 pm
by Yukiko
If you use the DOS window method you will need to be in the ecompile directory to run ecompile. The list of switch commands that ecompile uses can be obtained by typing ecompile /? from the DOS prompt.

Posted: Tue Apr 18, 2006 1:38 pm
by Yukiko
OK. Thanks. I will fix it. Sorry. I forgot it's scripted for POL 94. Give me a few minutes

Posted: Tue Apr 18, 2006 1:41 pm
by Yukiko
OK here is the updated for POL 95 version. Sorry about the errors in the original. This one does compile in POL 95.

Code: Select all

use uo;

var layout := {
	"nodispose",
	"page 0",
	"resizepic 0 20 2620 310 470",
	"gumppic 15 50 2621",
	"text 20 29 40 0"
};

var data := {
	"Online Characters",
	"Score"
};

program textcmd_online (character)
	if (CINT (GetObjProperty (character, "#checkonline")) > ReadGameClock())
		SendSysmessage (character, "That gump is already open!");
		return;
	endif
	SetObjProperty (character, "#checkonline", CINT(ReadGameClock() + 120));
	
	FillInArrays (character);
	var gump_return := SendDialogGump (character, layout, data);
	if (!gump_return and gump_return[0] != 0)
		SendSysMessage (character, "You must close other gumps before you can do this.");
	endif
	EraseObjProperty (character, "#checkonline");
endprogram


function FillInArrays (character)
	var all_players := EnumerateOnlineCharacters ();
	var players := {};
	foreach player in all_players
		if (player.cmdlevel)
			if (IsAGM (character))
				players.append (player);
			endif
		else
			players.append (player);
		endif
	endforeach

	var pagecount := 1;
	var ypos := 70;
	var string_counter := 2;
	var totalplayers := len (players);

	layout.append ("page " + pagecount);
	for playercount := 1 to totalplayers
		var player := players [playercount];
		layout.append ("text 20 " + ypos + " 40 " + string_counter);
		string_counter := string_counter + 1;
		ypos:= ypos + 20;

		
		if (!GetObjProperty (player, "private"))
				data.append (playercount +". " + player.name);
			else
				data.append (playercount +". " + player.name + " [AFK]");
			endif

		if (playercount == totalplayers)
			return;
		endif

		case (playercount)
			20:
			40:
			60:
			80:
			100:
				layout.append ("button 285 30 2648 2647 0 " + (pagecount + 1));
				pagecount := pagecount + 1;
				layout.append ("page " + pagecount);
				ypos := 70;
				layout.append ("button 255 30 2650 2651 0 " + (pagecount - 1));
		endcase
	endfor
endfunction



function IsAGM (character)
	if (character.cmdlevel)
		return 1;
	endif

	return 0;
endfunction

Posted: Tue Apr 18, 2006 1:47 pm
by Poi
Thank you!

Posted: Tue Apr 18, 2006 1:50 pm
by Yukiko
Soitenly!