Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Quick Gui Question (https://forums.graalonline.com/forums/showthread.php?t=134265348)

Alpho 12-21-2011 01:53 AM

Quick Gui Question
 
Quick scripting quesiton, How can I load text from a .txt file that is stored on the server and show it in a gui text control?

this is what I have so far;
PHP Code:

      new GuiMLTextCtrl("CMD_MultiLine1") {
        
profile GuiBlueMLTextProfile;
        
height 17;
        
horizsizing "width";
        
width 463;
        
text gettext("Staff_Commands.txt"); //Something like that?
      



ffcmike 12-21-2011 01:58 AM

Quote:

Originally Posted by Alpho (Post 1678874)
Quick scripting quesiton, How can I load text from a .txt file that is stored on the server and show it in a gui text control?

this is what I have so far;
PHP Code:

      new GuiMLTextCtrl("CMD_MultiLine1") {
        
profile GuiBlueMLTextProfile;
        
height 17;
        
horizsizing "width";
        
width 463;
        
text gettext("Staff_Commands.txt"); //Something like that?
      



GUI Controls are Clientside, if the text file is stored on the server you need to communicate between the client and server in order to retrieve its data.

fowlplay4 12-21-2011 01:59 AM

Here's a hint:

1. triggerserver requesting text
2. load text in onActionServerSide using loadstring
3. send text to client using triggerclient
4. set text based on data from onActionClientSide

Please try and search the forums about each topic.

My guide has links to content that will help as well, see my sig for that.

Alpho 12-21-2011 02:00 AM

Quote:

Originally Posted by ffcmike (Post 1678876)
GUI Controls are Clientside, if the text file is stored on the server you need to communicate between the client and server in order to retrieve its data.

Ok, thank you.

As for the function to get the data from the text file, what would that be?

Alpho 12-21-2011 02:01 AM

Quote:

Originally Posted by fowlplay4 (Post 1678877)
2. load text in onActionServerSide using loadstring

loadstring, thank you for that.
And I will check out your tutorial/guide =]

Alpho 12-21-2011 02:08 AM

Quote:

Originally Posted by fowlplay4 (Post 1678877)
My guide has links to content that will help as well, see my sig for that.

I looked for loadstring on your page and It says:
There is no page titled "loadstring".

Where do I upload the txt file to?

fowlplay4 12-21-2011 02:15 AM

Quote:

Originally Posted by Alpho (Post 1678880)
I looked for loadstring on your page and It says:
There is no page titled "loadstring".

Where do I upload the txt file to?

There's some examples under the File I/O section. Search the forums for loadstring as well, you should be able to find plenty of examples that way.

Alpho 12-21-2011 02:19 AM

Okay I got this:
PHP Code:

echo(loadlines("levels/Staff_Commands.txt")); 

though, it returns 0

ffcmike 12-21-2011 02:21 AM

Quote:

Originally Posted by Alpho (Post 1678886)
Okay I got this:
PHP Code:

echo(loadlines("levels/Staff_Commands.txt")); 

though, it returns 0

loadlines(); needs to be attached to a variable name:

PHP Code:

temp.l.loadlines("levels/Staff_Commands.txt");
echo(
temp.l); 


Alpho 12-21-2011 02:24 AM

Quote:

Originally Posted by ffcmike (Post 1678887)
loadlines(); needs to be attached to a variable name:

PHP Code:

temp.l.loadlines("levels/Staff_Commands.txt");
echo(
temp.l); 


Thank ffcmike! Helped a bunch!


All times are GMT +2. The time now is 03:00 PM.

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