Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   GUI Problem (https://forums.graalonline.com/forums/showthread.php?t=73365)

shadowjones 04-08-2007 05:58 PM

GUI Problem
 
I got a basic layout for a GUI on graal.net snippets and edited it a little bit. Problem is is that when online, the GUIs overlap with everyone else in that level..... here is the script

Quote:

//#CLIENTSIDE
if (created || timeout) {
showtext 0,32,64,Arial,b,Health: #s(clientr.player_hp)/#s(clientr.player_maxhp);
showtext 1,32,80,Arial,b,Mana: #s(clientr.player_mp)/#s(clientr.player_maxmp);
showtext 2,32,96,Arial,b,Type: #s(clientr.player_type);
showimg 4,toguilightest.png,16,16;
showimg 5,#3,32,32;
showtext 6,72,48,Arial,bi,#e(0,13,#n)#s(this.nick);
showtext 7,16*17+8,48,Arial,br,Talik: #v(player.rupees);
showtext 8,16*17+8,64,Arial,br,Shield: #v(playershieldpower);
showtext 9,16*17+8,80,Arial,br,Weapons: #s(this.enabweap);
showtext 10,16*17+8,96,Arial,br,Lvl. Type: #s(this.zonetype);
changeimgzoom 0,0.6;
changeimgzoom 1,0.6;
changeimgzoom 2,0.6;
changeimgzoom 3,0.6;
changeimgzoom 6,0.6;
changeimgzoom 7,0.6;
changeimgzoom 8,0.6;
changeimgzoom 9,0.6;
changeimgzoom 10,0.6;
changeimgzoom 11,0.6;
changeimgzoom 12,0.6;
changeimgzoom 13,0.6;
changeimgvis 0,4;
changeimgvis 1,4;
changeimgvis 2,4;
changeimgvis 3,4;
changeimgvis 4,4;
changeimgvis 5,4;
changeimgvis 6,4;
changeimgvis 7,4;
changeimgvis 8,4;
changeimgvis 9,4;
changeimgvis 10,4;
changeimgvis 11,4;
changeimgvis 12,4;
changeimgvis 13,4;
changeimgpart 5,0,64,32,32;
changeimgcolors 0,1,0,0,1;
changeimgcolors 1,0,1,1,1;
changeimgcolors 2,1,1,1,1;
changeimgcolors 3,1,1,1,1;
changeimgcolors 6,0,1,0,1;
changeimgcolors 7,1,1,1,1;
changeimgcolors 8,1,1,1,1;
changeimgcolors 9,1,1,1,1;
changeimgcolors 10,1,1,1,1;
changeimgcolors 11,1,1,1,1;
changeimgcolors 12,1,1,1,1;
changeimgcolors 13,1,1,1,1;
if (weaponsenabled) setstring this.enabweap,Enabled;
else setstring this.enabweap,Disabled;
if (nopkzone) setstring this.zonetype,No PKing;
else {
if (issparringzone) setstring this.zonetype,Sparring;
else setstring this.zonetype,PKing;
}
showstats 1024;
timeout = 0.05;
}

Make it compatible online please!

Rapidwolve 04-08-2007 06:00 PM

Oh god, first of all use GS2. Second your showtext and showimg index's should be atleast 200 to prevent other players from seeing it.

PHP Code:

//#CLIENTSIDE
function onCreated() onTimeout();
function 
onPlayerEnters() onTimeout();

function 
onTimeout(){
showtext(2003264"Arial""b"format("Health: %f/%f"clientr.player_hpclientr.player_maxhp));
showtext(2013280"Arial""b"format("Mana: %f/%f"clientr.player_mpclientr.player_maxmp));
showtext(2023296"Arial""b"format("Type: %s"clientr.player_type));
showimg(204"toguilightest.png"1616);
showimg(205player.headimg3232);
showtext(2067248"Arial""bi"player.nick.substring(013) @ this.nick);
showtext(207, (16*17+8), 48"Arial""br"format("Talik: %i"player.rupees));
showtext(208, (16*17+8), 64"Arial""br""Shield: " playershieldpower);
showtext(209, (16*17+8,80), "Arial""br""Weapons: " this.enabweap);
showtext(210, (16*17+8,96), "Arial""br""Lvl. Type: " this.zonetype);
for (
199250i++)
changeimgzoom(i0.6);

for (
199250j++)
  
changeimgvis(i4);

changeimgpart(2050643232);
changeimgcolors(2001001);
changeimgcolors(2010111);
changeimgcolors(2060101);

if (
weaponsenabledthis.enabweap "Enabled";
else 
this.enabweap "Disabled";
if (
level.nopkzonethis.zonetype "No PKing";
else {
if (
level.issparringzonethis.zonetype "Sparring";
else 
this.zonetype "PKing";
}
showstats(1024 256);
setTimer(.05);


Used the for() because I was lazy :)

godofwarares 04-08-2007 06:10 PM

Quote:

Originally Posted by Rapidwolve (Post 1298064)
Oh god, first of all use GS2. Second your showtext and showimg index's should be atleast 200 to prevent other players from seeing it.

Don't push him, Jeez read my thread.


-------------------

Try indexes higher than 201 to make it visible to you but nobody else.

Chandler 04-08-2007 06:36 PM

Here's what C' would do with that text stuff!

HTML Code:

//#CLIENTSIDE
function onCreated()
  {
  hideimgs(200, (200 + this.drawText.size()));
  this.drawText = {
  //{index, x, y, style, text, message, {colors}, layer, zoom}
    {200, 32, 64, "b", format(_("Health: %f/%f"), player.hearts, player.fullhearts), {1, 0.3, 0, 1}, 4, 0.8},
    {201, 32, 64, "bc", format(_("magic: %f/100"), playermp), {0, 0.3, 1, 1}, 4, 0.8}
  };
  for (temp.currentText: this.drawText)
    this.makeText(temp.currentText);
  }
function makeText(textData)
  {
  showText(temp.textData[0], temp.textData[1], temp.textData[2], "Arial", temp.textData[3], temp.textData[4]);
  changeimgvis(temp.textData[0], temp.textData[5]);
  changeimgcolors(temp.textData[0], temp.textData[4][0], temp.textData[4][1],temp.textData[4][2], temp.textData[4][3]);
  changeimgzoom(temp.textData[0], temp.textData[6]);
  }


DustyPorViva 04-08-2007 06:42 PM

EDIT: Chandler got to it before me and used the wonders of string/float nondiscrimination and multi-dimensional arrays in gs2 to his advantage :(

This isn't a long script because it's in GS1, it's just long because it's not coded efficiently.
Anyways, as said, <200=serverside, >=200=clientside.
And second, I really urge you to look into arrays and loops to optimize this script.

PHP Code:

//#CLIENTSIDE
function customize() {
  
setstring this.gui,toguilightest.png;
  
setstring this.text,
  
"Health: #s(clientr.player_hp)/#s(clientr.player_maxhp)",
  
"Mana: #s(clientr.player_mp)/#s(clientr.player_maxmp)",
  
"Type: #s(clientr.player_type)",
  
"#e(0,13,#n)#s(this.nick)",
  
"Talik: #v(player.rupees)",
  
"Shield: #v(playershieldpower)",
  
"Weapons: #s(this.enabweap)",
    
"Lvl. Type: #s(this.zonetype)";

  
// Display options for each text object
  // x,y,red,blue,green,style options
  // style options: 0=bold, 1=bold+italic, 2=bold+right
  
this.doptions={
    
32,64,1,0,0,0,
    
32,80,0,1,1,0,
    
32,96,1,1,1,0,
    
72,48,1,1,1,1,
    
280,48,0,1,0,2,
    
280,64,1,1,1,2,
    
280,80,1,1,1,2,
    
280,96,1,1,1,2,
      };
}

if (
created || timeout) {
  
customize();
  
this.img=200;
  
showimg this.img,#s(this.gui),16,16;
  
changeimgvis this.img,4;
  
this.img++;
  
showimg this.img,#3,32,32;
  
changeimgpart this.img,0,64,32,32;
  
changeimgvis this.img,4;
  
this.img++;

  for (
i=0;i<sarraylen(this.text);i++) {
    
tokenize b bi br;
    
setstring this.style,#t(this.doptions[5+i*6]);
    
showtext this.img+i,this.doptions[i*6],this.doptions[1+i*6],Arial,#s(this.style),#I(this.text,i);
    
changeimgcolors this.img+i,this.doptions[2+i*6],this.doptions[3+i*6],this.doptions[4+i*6],1;
    
changeimgzoom this.img+i,.6;
    
changeimgvis this.img+i,4;
    
this.img++;
  }
  if (
weaponsenabledsetstring this.enabweap,Enabled;
  else 
setstring this.enabweap,Disabled;
  if (
nopkzonesetstring this.zonetype,No PKing;
  else {
    if (
issparringzonesetstring this.zonetype,Sparring;
    else 
setstring this.zonetype,PKing;
  }
  
showstats 1024;
  
timeout 0.05;


I'll explain what I did with this. First, I have the string list at the top, each string contains what text you want to display(like you had one showimg for each text). Second I have the array. This is a little complicated, but I have it hold the options for each instance of text. We'll be able to access this in the loop to organize it.

Now I use the for loop to go through the information I need and display the text for each instance of text in the string list.

EDIT: forgot to explain the variable this.img.
this.img starts at 200(the index used to make the images clientside), and increases once for every time an image is show, therefor, all images are shown on their own unique index.

And looks like you've got three scripts to play with, aren't you the lucky one :)

godofwarares 04-08-2007 06:46 PM

Quote:

Originally Posted by DustyPorViva (Post 1298076)
Blah blah blah

You don't use quotes ("") in GS1, So it would be:

PHP Code:

setstring this.text,
  
Health#s(clientr.player_hp)/#s(clientr.player_maxhp),
  
Mana#s(clientr.player_mp)/#s(clientr.player_maxmp),
  
Type#s(clientr.player_type),
  #e(0,13,#n)#s(this.nick),
  
Talik#v(player.rupees),
  
Shield#v(playershieldpower),
  
Weapons#s(this.enabweap),
    
LvlType#s(this.zonetype); 


DustyPorViva 04-08-2007 06:49 PM

You have to with those. It closes the whole thing into one string, or else Graal will break it up into different strings in the string list.

xXziroXx 04-08-2007 07:56 PM

Quote:

Originally Posted by DustyPorViva (Post 1298085)
You have to with those. It closes the whole thing into one string, or else Graal will break it up into different strings in the string list.

Correct. Your example would be the correct version of a GS1 string array.

shadowjones 04-09-2007 07:44 AM

thanks for the help guys =D ^_^

cbk1994 04-10-2007 04:34 AM

Quote:

Originally Posted by DustyPorViva (Post 1298076)
PHP Code:

  setstring this.text,
  
"Health: #s(clientr.player_hp)/#s(clientr.player_maxhp)",
  
"Mana: #s(clientr.player_mp)/#s(clientr.player_maxmp)",
  
"Type: #s(clientr.player_type)",
  
"#e(0,13,#n)#s(this.nick)",
  
"Talik: #v(player.rupees)",
  
"Shield: #v(playershieldpower)",
  
"Weapons: #s(this.enabweap)",
    
"Lvl. Type: #s(this.zonetype)"


That makes me want to barf ... it makes no sense at all. No offense to anyone personally, it's good that people are learning how to script, but GS1 makes no sense ... quotes in almost EVERY programming language ... even BASIC ... represents a string.

Chandler 04-10-2007 07:40 AM

Quote:

Originally Posted by cbkbud (Post 1298651)
That makes me want to barf ... it makes no sense at all. No offense to anyone personally, it's good that people are learning how to script, but GS1 makes no sense ... quotes in almost EVERY programming language ... even BASIC ... represents a string.

Personally, I prefer GS1. It's more as easy. If that makes any sense...

DustyPorViva 04-10-2007 02:14 PM

GS1 was really the more 'easier' scripting for average people with no programming knowledge to pick up. I can say if I came to Graal around now and tried to learn gscript I'd probably be too intimidated with it. I'm already having a pretty rough time learning GS2 with my prior knowledge of GS1. I always felt GS1 kind of had a 'it does exactly it says it's doing' kind of feel to it. No doubt, GS2 is a lot more powerful, it just isn't as easy to pick up.

Twinny 04-10-2007 04:36 PM

Shadow, perhaps you should leave your threads open when they are resolved in case other people encounter the same problem?

shadowjones 04-10-2007 09:50 PM

Quote:

Originally Posted by Twinny (Post 1298737)
Shadow, perhaps you should leave your threads open when they are resolved in case other people encounter the same problem?

im used to WoW forums xD you keep a thread up to long and people get quite pissy >_<

Will do though =)

Inverness 04-10-2007 11:29 PM

Quote:

Originally Posted by DustyPorViva (Post 1298717)
GS1 was really the more 'easier' scripting for average people with no programming knowledge to pick up. I can say if I came to Graal around now and tried to learn gscript I'd probably be too intimidated with it. I'm already having a pretty rough time learning GS2 with my prior knowledge of GS1. I always felt GS1 kind of had a 'it does exactly it says it's doing' kind of feel to it. No doubt, GS2 is a lot more powerful, it just isn't as easy to pick up.

Thats not a good thing really, people just need an object-oriented mentality and scripting becomes easy to pick up.

DustyPorViva 04-10-2007 11:39 PM

Well the good thing about Graal back then was it was easy to pick up and edit for mostly everyone. If everyone had the object-oriented mentality, programming wouldn't be so hard for them. Graal didn't really propose that sort of problem because of it's simplicity.

shadowjones 04-11-2007 01:58 AM

Quote:

Originally Posted by DustyPorViva (Post 1298717)
GS1 was really the more 'easier' scripting for average people with no programming knowledge to pick up. I can say if I came to Graal around now and tried to learn gscript I'd probably be too intimidated with it. I'm already having a pretty rough time learning GS2 with my prior knowledge of GS1. I always felt GS1 kind of had a 'it does exactly it says it's doing' kind of feel to it. No doubt, GS2 is a lot more powerful, it just isn't as easy to pick up.

That's what I'm trying to do, I played graal in '99-03 with basic scripting knowledge, and just recently came back and lost all of what I knew and just learned there was a GS2! So I bought a server and I'm going to try to use GS1 on it, then I'm going to try to duplicate everything. As you can tell though with how many posts I put up with questions to help me get further...I blow at scripting. But at least I'm learning ^_^


All times are GMT +2. The time now is 07:25 PM.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.