Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   New Scripting Engine (GS2) (https://forums.graalonline.com/forums/forumdisplay.php?f=153)
-   -   GUI Issue (https://forums.graalonline.com/forums/showthread.php?t=76916)

Mark Sir Link 09-24-2007 02:31 PM

GUI Issue
 
I'm new to the GUI functions in Graal and I'm certain I'm overlooking something simple with this error, but here goes.

I am writing a Class NPC to implement the flier script Ziplock had requested be made awhile back, if anyone remembers that.

Right now, I have the window being created in Clientside in the CLASS.


However, when if I hit the red X, the GUI window disappears and walking into the flier image again will not open the GUI window back up.

Do I need to implement onCloseQuery to get this to work desirably?

PHP Code:

//#CLIENTSIDE
function onPlayerTouchsMe()
{
FlierWindow = new GuiWindowCtrl("Flier_" this.number);
  
with (FlierWindow)
  {
    
profile "GuiBlueWindowProfile";
    
position "30 30";
    
extent "300 300";
    
canMove true;
    
canResize false;
    
canClose true;
    
tile true;
    
text "Flier by " this.owner.account;
  }
  
GraalControl.addControl(FlierWindow);



Mark Sir Link 09-24-2007 02:36 PM

Resolved:

for future reference, enabling destroyonhide will fix this.

Twinny 09-24-2007 03:07 PM

Quote:

Originally Posted by Mark Sir Link (Post 1349392)
Resolved:

for future reference, enabling destroyonhide will fix this.

that or use

if (guiwindowname != NULL) guiwindowname.destroy();

When redrawing guis.

Mark Sir Link 09-26-2007 01:29 PM

rather than make anew thread, I'll insert this issue here.

Again, I am sure this the noobness instead of a legitimate issue here, but...

in Scroll Control, inside a Window Control, I am attempting to add text using a MLTextObject.

PHP Code:

new GuiMLTextCtrl("Test_MultiLineText") {
  
profile "GuiBlueMLTextProfile";
  
position "5 5";
  
extent "250 250";
  
text format("<font size = 16> %s </font>"this.text); 

the issue as I'm sure you'll notice is with the text.

I have tried appending the text and then anotehr </font> tag, I have tried using the format functionality - Tests have shown this.text is a valid string so I am certain the issue isn't with actually getting data.

Could use help with this.


UPDATE:

Upon further review, I am finding that the this.text actually doesn't exist clientside but it does serverside.

I tried using a triggerclient in the class but found that doesn't work for getting the string to clientside.

Any suggestions?

xXziroXx 09-26-2007 02:58 PM

Since you're accessing a GUI control, you'll need to use thiso.text rather then this.text.

Mark Sir Link 09-26-2007 04:45 PM

Quote:

Originally Posted by xXziroXx (Post 1349630)
Since you're accessing a GUI control, you'll need to use thiso.text rather then this.text.


Uh, regardless, this.text isn't transitioning properly from serverside to clientside. Once I get that fixed, the other errors should be fixed.

So, any ideas on how to synchronize across serverside and clientside?

Googi 09-26-2007 08:07 PM

Quote:

Originally Posted by Mark Sir Link (Post 1349643)
So, any ideas on how to synchronize across serverside and clientside?

Use attr[] or (depreciated?) save[], use a clientr.var instead...

I don't see why you wouldn't be able to pass it by triggering the client though.

Mark Sir Link 09-26-2007 08:19 PM

Quote:

Originally Posted by Googi (Post 1349664)
Use attr[] or (depreciated?) save[], use a clientr.var instead...

clientr would be worthless since the text is intended to be readable by many people in a GUI, and is being passed to a class.

Server is impractible because there is a potential for over 9000 (:)) NPCs to join the class and use it.




Alright, further research has shown that a Class NPC cannot do what I am looking for it to do (triggerclient doesn't work for non weapon/GUI scripts).


So I guess my next question would be, can I triggeraction to the client if I use an on function?

Ok, verified I can't.

am I to assume I am out of luck and it is impossible to pass information the clientside of a Class NPC?

xXziroXx 09-27-2007 01:55 AM

Quote:

Originally Posted by Mark Sir Link (Post 1349643)
Uh, regardless, this.text isn't transitioning properly from serverside to clientside. Once I get that fixed, the other errors should be fixed.

So, any ideas on how to synchronize across serverside and clientside?

That's what I get for not reading properly. :noob:

napo_p2p 09-27-2007 02:35 AM

Quote:

Originally Posted by Mark Sir Link (Post 1349665)
am I to assume I am out of luck and it is impossible to pass information the clientside of a Class NPC?

Like Googi said, try using this.attr[] (and when you access from within the new Gui Control, use thiso.attr[]).

Mark Sir Link 09-28-2007 01:15 PM

Alright. Still not working as intended unfortunately, but I'm willing to guess I messed up somewhere since I've never tried using attributes like this.
PHP Code:

//Serverside, function onCreated()...
this.attr[0] = this.text;

//#CLIENTSIDE
text format("<font size = 16> %s lolol</font>"thiso.attr[0]); 

Before we tear apart the format part, let it be known that when setting player.chat to this.attr[0], it is still coming up null.

xXziroXx 09-28-2007 02:30 PM

Mind posting the entire code?

Mark Sir Link 09-28-2007 02:34 PM

Class script:
PHP Code:

function onCreated()
{
setimg("classic_warpicon_gcstudios.png");
this.attr[0] = this.text;
}

function 
onActionRemoveFlier()
  {
  
destroy();
}

//#CLIENTSIDE
function onPlayerTouchsMe()
{
player.chat this.attr[0];
FlierWindow = new GuiWindowCtrl("Flier_" this.number);
  
with (FlierWindow)
  {
    
profile "GuiBlueWindowProfile";
    
this.posx screenwidth/-150 ;
    
this.posy screenheight/150;
    
position = {this.posxthis.posy};
    
extent "300 300";
    
canMove true;
    
canResize false;
    
canClose true;
    
tile true;
    
canmaximize false;
    
text "Flier by " thiso.owner.account;
    
destroyonhide true;
    
    new 
GuiScrollCtrl("Test_ScrollField") {
  
profile GuiBlueScrollProfile;
  
position "5 23";
  
extent "290 270";
  
hScrollBar "dynamic";
  
vScrollBar "alwaysOn";
  
  new 
GuiMLTextCtrl("Test_MultiLineText") {
  
profile "GuiBlueMLTextProfile";
  
position "5 0";
  
extent "250 250";
  
text format("<font size = 16> %s lolol</font>"thiso.attr[0]);
}

}
  }
  
GraalControl.addControl(FlierWindow);


NPC Script (Kinda Messy because of checks I was doing, etc)
PHP Code:

//Coded by Kevin Azite
//Under Progress

function onActionServerside()
  {
  if(
params[0] == "place")
    {
    
temp.npc putnpc2(params[1], params[2], "join fliers;");
    
temp.npc.text params[3];
    
temp.npc.owner player;
  }
}
//#CLIENTSIDE
function onPlayerChats()
  {
  if(
player.chat.starts("/flier"))
  {
  
this.text player.chat.substring(6);
  
player.chat this.text;
  
  if(
player.dir == 0)
  {
  if(
onwall(player.x+.5player.1.5))
  {
  
triggeraction(00"serverside""Fliers""place"player.x+.5player.y-1this.text);
}
}
}
}
function 
onMouseDown(button)
  {
  if(
button "right")
    {
    
triggeraction(mousexmousey"RemoveFlier"null);
  }
  } 


xXziroXx 09-28-2007 03:42 PM

I dont see this.text being declared in either of the scripts serversided, that's why it returns NULL.

Mark Sir Link 09-28-2007 04:39 PM

Quote:

Originally Posted by xXziroXx (Post 1349935)
I dont see this.text being declared in either of the scripts serversided, that's why it returns NULL.

temp.npc.text = params[3]


that means in the NPC, this.text will become whatever the params were.

xXziroXx 09-28-2007 04:52 PM

Doh, there I go not reading properly again, sorry.

Try debugging it by doing:

PHP Code:

function onCreated()
{
setimg("classic_warpicon_gcstudios.png");
this.text "test";
this.attr[0] = this.text;
echo(
this.text SPC "|" SPC this.attr[0]);



Mark Sir Link 09-28-2007 04:59 PM

this.text displays "test", this.attr[0] is coming null.

So it seems that using an attr will be impossible, which leaves me in quite a predicament if I can't triggerclient in a class.

:(

napo_p2p 09-28-2007 05:17 PM

Try using this.attr[1]. I don't think attr[0] works.

Crow 09-28-2007 05:22 PM

Yea, isnt attr[0] non-existant?

Mark Sir Link 09-28-2007 05:30 PM

this.attr[1] resolves the issue.

Thanks guys :D

xXziroXx 09-28-2007 05:36 PM

Quote:

Originally Posted by napo_p2p (Post 1349946)
Try using this.attr[1]. I don't think attr[0] works.

Thanks for teaching an old dog something new! :D

Mark Sir Link 10-23-2007 05:48 PM

3 Attachment(s)
Hmm...

gonna bump this thread rather than creating a new one.

I'm trying to create a custom GUI profile, and I'm sticking this in a class so I can easily use each profile in multiple NPCs. However, when I call createGUIs, the new profiles aren't working properly.

NPC Code
PHP Code:

function onCreated()
{
this.join("customgui");
createGUIs();


in class "customgui".
PHP Code:

//vampiro_button.png
//vampiro_scroll.png
//vampiro_window.png
//#CLIENTSIDE
function createGUIs()
{
new 
GuiWindowCtrlProfile("VampiroWindowProfile")
{

bitmap "vampiro_window.png";

opaque false;
transparency 0.5;
}

new 
GuiScrollCtrlProfile("VampiroScrollProfile")
{

bitmap "vampiro_scroll.png";

opaque false;
transparency 0.5;
}

new 
GuiButtonCtrlProfile("VampiroButtonProfile")
{

bitmap "vampiro_button.png";

opaque false;
transparency 0.5;
}



Twinny 10-23-2007 05:54 PM

Not sure if it helps but I generally make functions public inside classes if they are going to be called outside the class.

Then again whats the actual problem? Does nothing happen or does the profile look all weird?

Crow 10-23-2007 05:56 PM

The function itself is clientside, though you are calling it serverside :oo:

zokemon 10-23-2007 10:33 PM

He's not calling the function outside of the original NPC so he doesn't need it to be public. Also, you only need to create profiles one time (do it from like a system WNPC) not for every npc. Profiles are global variables just like GUIs so once you create them, every npc can use them.


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

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