Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting
FAQ Members List Calendar Today's Posts

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 12-09-2011, 03:29 PM
Gunderak Gunderak is offline
Coder
Gunderak's Avatar
Join Date: Jun 2011
Location: Australia
Posts: 795
Gunderak is on a distinguished road
Alert(); In Graal!

Anyway I have made my own "Alert" function.
If you would like to see it here's how.

Step 1:
Make a new class and name it "alert".
Now place this code in the newly created class.
PHP Code:
//#CLIENTSIDE
function Alert(titlemessage) {
  new 
GuiWindowCtrl("Alert_Window") {
    
profile GuiBlueWindowProfile;
    
destroyonhide 1;
    
canmaximize false;
    
canminimize false;
    
canclose false;
    
canmove false;
    
isexternal 0;
    
width 320;
    
height 120;
    
text title;
    
screenwidth width 2;
    
screenheight height 2;
    new 
GuiScrollCtrl("Alert_Text_Container") {
      
profile GuiBlueScrollProfile;
      
6;
      
24;
      
width 308;
      
height 69;
      
hScrollBar "dynamic";
      
vScrollBar "dynamic";
      new 
GuiMLTextCtrl("Alert_Text") {
        
profile GuiBlueMLTextProfile;
        
text message;
        
width 287;
      }
    }
    new 
GuiButtonCtrl("Alert_Ok_Button") {
      
profile GuiBlueButtonProfile;
      
width 40;
      
height 20;
      
Alert_Window.width Alert_Ok_Button.width 7;
      
Alert_Window.height Alert_Ok_Button.height 7;
      
text "Ok";
    }
  }
}

function 
Alert_Ok_Button.onAction() {
  
Alert_Window.destroy();

Step 2:
This is how to use it.
On any script place this directly under onCreated on the clientside.
PHP Code:
this.join("alert"); 
Then to alert the player place this.
PHP Code:
Alert("Alert!""Hello world!"); 
It works like this:
Alert("TITLE", "MESSAGE");

-Enjoy
__________________

Gund for president.

Remote PM {P*}x (Graal813044) from eraiphone -> Stefan: I hav 1 qustion
*Gunderak: he hav 1
*Gunderak: qustion
Reply With Quote
  #2  
Old 12-09-2011, 04:14 PM
ff7chocoboknight ff7chocoboknight is offline
Skyzer Zolderon
ff7chocoboknight's Avatar
Join Date: Dec 2006
Location: New Hampshire, United States
Posts: 725
ff7chocoboknight is a name known to allff7chocoboknight is a name known to allff7chocoboknight is a name known to allff7chocoboknight is a name known to all
Send a message via AIM to ff7chocoboknight Send a message via MSN to ff7chocoboknight
Anyone who knows how to make GUIs can make that without any problems. -__-
__________________
Reply With Quote
  #3  
Old 12-09-2011, 05:43 PM
Hezzy002 Hezzy002 is offline
Registered User
Join Date: Jul 2011
Posts: 247
Hezzy002 is a jewel in the roughHezzy002 is a jewel in the rough
Thanks! I really needed this for my server.
Reply With Quote
  #4  
Old 12-09-2011, 05:47 PM
Gunderak Gunderak is offline
Coder
Gunderak's Avatar
Join Date: Jun 2011
Location: Australia
Posts: 795
Gunderak is on a distinguished road
Well I figured someone who doesn't now has this to learn off.
No need to be too sutle.
__________________

Gund for president.

Remote PM {P*}x (Graal813044) from eraiphone -> Stefan: I hav 1 qustion
*Gunderak: he hav 1
*Gunderak: qustion
Reply With Quote
  #5  
Old 12-09-2011, 06:03 PM
ffcmike ffcmike is offline
Banned
Join Date: Jul 2004
Location: London
Posts: 2,029
ffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond repute
Send a message via AIM to ffcmike Send a message via MSN to ffcmike
Quote:
Originally Posted by Gunderak View Post
Well I figured someone who doesn't now has this to learn off.
It would be much better to write a guide for making simple GUI windows.
Reply With Quote
  #6  
Old 12-09-2011, 06:21 PM
Gunderak Gunderak is offline
Coder
Gunderak's Avatar
Join Date: Jun 2011
Location: Australia
Posts: 795
Gunderak is on a distinguished road
There are already guides on that on the Graal Bible.
I just thought it would be nifty to be able to do alert(); in Graal.
__________________

Gund for president.

Remote PM {P*}x (Graal813044) from eraiphone -> Stefan: I hav 1 qustion
*Gunderak: he hav 1
*Gunderak: qustion
Reply With Quote
  #7  
Old 12-09-2011, 06:25 PM
ffcmike ffcmike is offline
Banned
Join Date: Jul 2004
Location: London
Posts: 2,029
ffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond repute
Send a message via AIM to ffcmike Send a message via MSN to ffcmike
It would also be much better if Alerts were created and destroyed dynamically, as if you were to receive multiple alerts in quick succession they would over-write eachother.

Alert: You've just won the Server Lottery, congratulations!

1 second later

Alert: Graal765432 has sent you a hug
Reply With Quote
  #8  
Old 12-09-2011, 06:30 PM
Gunderak Gunderak is offline
Coder
Gunderak's Avatar
Join Date: Jun 2011
Location: Australia
Posts: 795
Gunderak is on a distinguished road
Well maybe making an clientr variable as an index and then increasing it when an alert is created and decreasing when the close button is pressed..
I suppose that would work.
I didn't think of this when scripting it.
__________________

Gund for president.

Remote PM {P*}x (Graal813044) from eraiphone -> Stefan: I hav 1 qustion
*Gunderak: he hav 1
*Gunderak: qustion
Reply With Quote
  #9  
Old 12-09-2011, 06:32 PM
ffcmike ffcmike is offline
Banned
Join Date: Jul 2004
Location: London
Posts: 2,029
ffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond repute
Send a message via AIM to ffcmike Send a message via MSN to ffcmike
Quote:
Originally Posted by Gunderak View Post
Well maybe making an clientr variable as an index and then increasing it when an alert is created and decreasing when the close button is pressed..
I suppose that would work.
I didn't think of this when scripting it.
You don't need an array or index variable, it's possible to create GUIs with a variable name, then use catchevent(); to receive necessary actions on the correct GUI object.
Reply With Quote
  #10  
Old 12-09-2011, 06:35 PM
Gunderak Gunderak is offline
Coder
Gunderak's Avatar
Join Date: Jun 2011
Location: Australia
Posts: 795
Gunderak is on a distinguished road
I don't know how I would go about doing it using catchevent(); so il just stick with using an index for now.
__________________

Gund for president.

Remote PM {P*}x (Graal813044) from eraiphone -> Stefan: I hav 1 qustion
*Gunderak: he hav 1
*Gunderak: qustion
Reply With Quote
  #11  
Old 12-09-2011, 06:45 PM
ffcmike ffcmike is offline
Banned
Join Date: Jul 2004
Location: London
Posts: 2,029
ffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond repute
Send a message via AIM to ffcmike Send a message via MSN to ffcmike
Quote:
Originally Posted by Gunderak View Post
I don't know how I would go about doing it using catchevent(); so il just stick with using an index for now.
Lets say I was going to create a GUI object which name includes an increasing number to distinguish itself:

PHP Code:
public function alert(temp.titletemp.message){
  new 
GuiWindowCtrl("Alert_" thiso.alertcount) {
    new 
GuiButtonCtrl("Alert_Button_" thiso.alertcount) {
      
//stuff
      
thiso.catchevent(this.name"onAction""buttonPress");
    }
  }
  
this.alertcount ++;

This would be creating a separate GUI control for each alert, where catchevent will then catch the specified action and pass the GUI object as a parameter within the specified function name:

PHP Code:
function buttonPress(temp.gui){
  
temp.gui.destroy();

I believe this can also be done without even assigning a GUI control a name.

Last edited by ffcmike; 12-09-2011 at 07:19 PM..
Reply With Quote
  #12  
Old 12-09-2011, 10:00 PM
Tigairius Tigairius is offline
The Cat
Tigairius's Avatar
Join Date: Jan 2007
Location: Missouri, USA
Posts: 4,240
Tigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant future
You can also use:
PHP Code:
shared.adminMessage("text"); 
which will display a message even after being disconnected from the server.

One neat thing you might consider adding is perhaps some confirm function. For instance:
PHP Code:
response confirm("Are you sure you want to do this?");
if (
response) {
  
doit();
}else {
  
dontdoit();

Or by taking advantage of waitfor()
__________________


“Shoot for the moon. Even if you miss, you'll land among the stars.”
Reply With Quote
  #13  
Old 12-10-2011, 03:34 AM
Gunderak Gunderak is offline
Coder
Gunderak's Avatar
Join Date: Jun 2011
Location: Australia
Posts: 795
Gunderak is on a distinguished road
@Ffcmike thanks for the help, il try your idea out when I ye home.

@Tigarius I have used shared.adminMessage(); before but I wanted to make it have a title aswell. And shared.adminMessage(); I'm not sure it it would overwrite the pay if you get another message.
__________________

Gund for president.

Remote PM {P*}x (Graal813044) from eraiphone -> Stefan: I hav 1 qustion
*Gunderak: he hav 1
*Gunderak: qustion
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 01:19 PM.


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