WriteHtml

Get Help on scripting in POL with configurations, config setups, script trouble shooting, etc.
Post Reply
User avatar
MontuZ
Forum Regular
Posts: 338
Joined: Fri Feb 10, 2006 8:08 am

WriteHtml

Post by MontuZ »

Instead of this ....

Code: Select all


    Foreach Player in EnumerateOnlineCharacters()
    WriteHtml( Player.name + "<br>" );
    Endforeach

I would like to not have WriteHtml(); run a whole crap load of times to display the name. I want to speed things up a bit. So my idea was this.

Code: Select all


    Var TheHTML := Array;

    Foreach Player in EnumerateOnlineCharacters()
    TheHTML.Append( Player.name + "<br>" );
    Endforeach

    WriteHtml( TheHTML );

But when I tried that nothing comes up on the page.

If I do WriteHtmlRaw(); it shows up, but there's a bunch of
{,,,,,,,,,,,,,}
at the top of the page?
Mithril
New User
Posts: 25
Joined: Sat Feb 04, 2006 5:15 pm

Post by Mithril »

Hmm, would this do the trick?

Code: Select all

var zHtmlText := "";
foreach mPlayer in EnumerateOnlineCharacters()
  zHtmlText := zHtmlText + mPlayer.Name + "<br>";
endforeach

WriteHtml(zHtmlText);
My Html is pretty rusty so I don't remember if the <br> tag does a newline or not...
FreeSoul
Master Poster
Posts: 90
Joined: Sat Feb 04, 2006 9:14 am

Post by FreeSoul »

WriteHtml( html )
Parameters:
html: String
you cant use array in that function

<br> makes newline
User avatar
MontuZ
Forum Regular
Posts: 338
Joined: Fri Feb 10, 2006 8:08 am

Post by MontuZ »

I guess I always have to make things complicated, lol.

Worked, dunno why I didn't think of that first.

Here's the result. Players Online
Harley
Forum Regular
Posts: 360
Joined: Sat Mar 18, 2006 1:41 am

Post by Harley »

I'm verry sorry, but! Dear Unreal, how you have created Kills & Deaths info??? If you can help me, please.
Althalus
New User
Posts: 12
Joined: Fri Feb 17, 2006 5:34 pm

Post by Althalus »

probably from props :P
SetObjProperty(smbdy, "stats", {kills, deaths}); in combat and counting every kill/death;
then in view script
var stats := GetObjProperty(smbdy, "stats");
var kills := stats[1];
var deaths := stats[2];
:)
Harley
Forum Regular
Posts: 360
Joined: Sat Mar 18, 2006 1:41 am

Post by Harley »

I not verry good understand where "SetObjProperty(smbdy, "stats", {kills, deaths});" in combat, but! I have placed this lines at my statics script and I have one trouble:

Kills error{ errortext = "Property not found" }

Deaths error{ errortext = "Property not found" }

This is not good!

Please, paint to me lines what are necessary for display of statistics and write to me where they should be inserted! Thanks. p.s. I'm noob also has not reached yet up to properties. Big Thanks! :-* :roll: :D
FreeSoul
Master Poster
Posts: 90
Joined: Sat Feb 04, 2006 9:14 am

Post by FreeSoul »

in combat pkg

after dealing damage if (tgt.dead) kills + 1 /target was PC increase kills for attacker and death + 1 /increase deaths for defender
if (!tgt) kills + 1 // target was npc so there is no ghost of it

well

Code: Select all

(...)
applyrawdamage(defender,amt);
if (defender.dead && defender.acctname)
  if (!getobjproperty(defender,"DEATH"))
    setobjproperty(defender,"DEATH",1);
  else
    setobjproperty(defender,"DEATH",getobjproperty(defender,"DEATH")+1);
  endif
  if (attacker.acctname)
    if (!getobjproperty(attacker,"KILLS"))  
      setobjproperty(attacker,"KILLS",1);
    else
      setobjproperty(attacker,"KILLS",getobjproperty(attacker,"KILLS")+1);
    endif
  endif
elseif (!defender && !defender.acctname && attacker.acctname)
    if (!getobjproperty(attacker,"KILLS"))  
      setobjproperty(attacker,"KILLS",1);
    else
      setobjproperty(attacker,"KILLS",getobjproperty(attacker,"KILLS")+1);
    endif
endif
(...)
sth. like that. don't know is it working... (don't have time for tests)
Harley
Forum Regular
Posts: 360
Joined: Sat Mar 18, 2006 1:41 am

Post by Harley »

FreeSoul, I'm very much grateful to you, but! Where exactly I would insert these lines?

Unreal, if you read this top, help pleeease!!! I study scripting on Zulu Hotel, and I would think you could help me with it! You are master, can I be your Margarita, Unreal :)) :oops: :oops:

I will be for you very grateful!
MuadDib
Former Developer
Posts: 1091
Joined: Sun Feb 12, 2006 9:50 pm

Post by MuadDib »

Some will consider this useless, because of the extra characters (thus, enlarging the amount of bandwidth used), but I like it looking good too when I can.

Code: Select all

foreach Player in EnumerateOnlineCharacters() 
  zHtmlText := zHtmlText + mPlayer.Name + "<br> \n"; 
endforeach

WriteHtml(zHtmlText); 
Why the \n ? It will make the code dumped to the web browser to have newlines, and the code look a bit better in my opinion. Just a thought. :)
Marilla

Post by Marilla »

Yup, I prefer it like that myself, too, rather than having a single 'brick' of text, as it were.

Whenever I use the WWW service to emit XML, for example, I always like to have newlines in the appropriate places!
MuadDib
Former Developer
Posts: 1091
Joined: Sun Feb 12, 2006 9:50 pm

Post by MuadDib »

Might have to go through my old ShardStatus Aux system. Update it some, maybe make an addon for the Distro guild system like my old LS shard had for it (to give guild information and all also). Who knows.

Been debating releasing parts of the old LS code anyway even though a lot of it was incomplete. May spark ideas for people, never know, hehe.

Maybe even complete my MySQL export package :)
FreeSoul
Master Poster
Posts: 90
Joined: Sat Feb 04, 2006 9:14 am

Post by FreeSoul »

MYSQL export package
YES YES YES :)

now about death stats...

:combat:fight.inc

Code: Select all

use uo;
use util;
include "include/givefightpoints"

function DealDamage(defender, attacker, rawdamage,skill)
//here some code
  if (defender.dead || !defender)
        eraseobjproperty(defender,"wounded");
	fix_stats(attacker,defender);
  endif
endif
endfunction
include/givefightpoints.inc

Code: Select all

const ATT_KILLED_NPC    := 10;
const ATT_KILLED_PC     := 11;
const DEF_KILLED_BY_NPC := 21;

function fix_stats(attacker,defender)
	var tmp1,tmp2,tmp3,tmp4,def:=0,ata:=20,i;
	if (defender.acctname)
		def:=1;
		if (getobjproperty(defender,"deathstats"))
			tmp1:=getobjproperty(defender,"deathstats");
		else
			tmp1:=array("0","0","0","0");
		endif
		if (getobjproperty(defender,"viccas"))
			tmp3:=getobjproperty(defender,"viccas");
		else
			tmp3:=array("","","","","","","","","","","","","","","","");
		endif
	endif
	if (attacker.acctname)
		ata:=10;
		if (getobjproperty(attacker,"deathstats"))
			tmp2:=getobjproperty(attacker,"deathstats");
		else
			tmp2:=array("0","0","0","0");
		endif
		if (getobjproperty(attacker,"viccas"))
			tmp4:=getobjproperty(attacker,"viccas");
		else
			tmp4:=array("","","","","","","","","","","","","","","","");
		endif
	endif
	var przypadek:=def+ata;
	if (przypadek == ATT_KILLED_NPC)
		tmp2[1]:=cstr(cint(tmp2[1])+1);		
		setobjproperty(attacker,"deathstats",tmp2);
 		UpdMyKills(attacker, defender);
	endif
	if (przypadek == ATT_KILLED_PC)
		tmp2[2]:=cstr(cint(tmp2[2])+1);
		tmp1[4]:=cstr(cint(tmp1[4])+1);
		setobjproperty(attacker,"deathstats",tmp2);
		setobjproperty(defender,"deathstats",tmp1);
		for (i:=7;i>0;i:=i-1);
			tmp4[i+1]:=tmp4[i];
			tmp3[i+9]:=tmp3[i+8];
		endfor
		tmp4[1]:=defender.name;
		tmp3[9]:=attacker.name;
		setobjproperty(attacker,"viccas",tmp4);
		setobjproperty(defender,"viccas",tmp3);
  		UpdMyKills(attacker, defender);
		UpdMyDeaths(defender, attacker);
	endif
	if (przypadek == DEF_KILLED_BY_NPC)
		tmp1[3]:=cstr(cint(tmp1[3])+1);
		setobjproperty(defender,"deathstats",tmp1);
  		UpdMyDeaths(defender, attacker);
	endif
	
endfunction

// Victim Ref Could Be Null If It Was NPC - death.src Uses This Function Directly With CorpseRef As Victim //
function UpdMyKills(killer, victim)
 var mykills := GetObjProperty(killer, "my_kills");
 var tmp;
 var npc_temp := GetObjProperty(victim, "npctemplate");
 if (!mykills || (TypeOf(mykills) != "Dictionary"))
   mykills := dictionary;
 endif
 
 // Killed a PC //
 if (victim.acctname)
  var race := CInt(GetObjProperty(victim, "race"));
  if ((race < 0) || (race > 11))
    return;
  endif

  tmp := CInt(mykills[CStr(race)]);
  mykills[CStr(race)] := tmp + 1;
  SetObjProperty(killer, "my_kills", mykills);
 // Killed a NPC //
 elseif (npc_temp)

  tmp := CInt(mykills[CStr(npc_temp)]);
  mykills[CStr(npc_temp)] := tmp + 1;
  SetObjProperty(killer, "my_kills", mykills);
 endif
endfunction

// Here Killer Ref Is Always Valid //
function UpdMyDeaths(victim, killer)
 var mydeaths := GetObjProperty(victim, "my_deaths");
 var tmp;
 if (!mydeaths || (TypeOf(mydeaths) != "Dictionary"))
   mydeaths := dictionary;
 endif

 // Killed by a PC //
 if (killer.acctname)
  var race := CInt(GetObjProperty(killer, "race"));
  if ((race < 0) || (race > 11))
    return;
  endif

  tmp := CInt(mydeaths[CStr(race)]);
  mydeaths[CStr(race)] := tmp + 1;
  SetObjProperty(victim, "my_deaths", mydeaths);

 // Killed by a NPC //
 elseif (killer.npctemplate)

  tmp := CInt(mydeaths[CStr(killer.npctemplate)]);
  mydeaths[CStr(killer.npctemplate)] := tmp + 1;
  SetObjProperty(victim, "my_deaths", mydeaths);
 endif
endfunction
if (defender.dead || !defender)
eraseobjproperty(defender,"wounded");
fix_stats(attacker,defender);
endif

should be too after dealing damages by spells

var tmp1:=GetObjProperty(who,"deathstats");
var tmp2:=getobjproperty(defender,"viccas");
var tmp3:=GetObjProperty(who, "my_deaths");
var tmp4:=GetObjProperty(who, "my_kills");

and you have something like this (look only at data not design of usercard):
Image
Image
Image
Image
Image[/quote]
qrak
Grandmaster Poster
Posts: 198
Joined: Sun Feb 05, 2006 4:35 pm

Post by qrak »

Nice FreeSoul. Is it Endore shard? ;)
Harley
Forum Regular
Posts: 360
Joined: Sat Mar 18, 2006 1:41 am

Post by Harley »

Oh!!! Das ist Fantastisch! FreeSoul, please give me at private msg your icq. I have one business! Thanks.

p.s. But what me contain in a script of statistics of a server?
Post Reply