Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   leftmousebutton problem (https://forums.graalonline.com/forums/showthread.php?t=134268686)

Trakan 09-02-2013 09:06 AM

leftmousebutton problem
 
So i'm doing a kind of panel, basically i want to show it when you click on the panel image:
http://puu.sh/4h7Lc.png

But when i click, (everywhere else, don't matter if its on the image or not), it shows correctly.

How can i make it show only if i click on the image?

Class:
PHP Code:

// Scripted by *Trakan

function onActionServerSide(null) {
  
serverr.available_quests += 1;
}
//#CLIENTSIDE
  
if (leftmousebutton) {
QuestMenu_Window1.show();
}
function 
onCreated() {
  
onTimeout();


  new 
GuiWindowCtrl("QuestMenu_Window1") {
    
clientrelative true;
    
clientextent "570,374";
    
canmaximize false;
    
profile GuiBlueWindowProfile;
    
useOwnProfile true;
    
canmove true;
    
canresize false;
    
closequery false;
    
destroyonhide false;
    
text "Available Quests";
    
screenheight/2;
    
50;
    
profile.bitmap "gh_gui-general.png";
    
profile.fillColor = {58,63,37};

    new 
GuiTextCtrl("QuestMenu_Text1") {
      
profile GuiBlueTextProfile;
      
height 25;
      
horizsizing "center";
      
text "Available Quests (" serverr.available_quests "/" serverr.maxquests ")";
      
width 140;
      
225;
      
5;
    }
    new 
GuiBitmapButtonCtrl("QuestMenu_Button1") {
      
text "   JOIN";
         
width 48;
         
heigh 24;
      
462;
      
40;
   
normalbitmap "gh_gui-button.png";
   
mouseoverbitmap "gh_gui-button.png";
   
pressedbitmap "gh_gui-button.png";
    }

        new 
GuiBitmapButtonCtrl("QuestMenu_Button2") {
      
text "  INFO+";
         
width 48;
         
heigh 24;
      
515;
      
40;
   
normalbitmap "gh_gui-button.png";
   
mouseoverbitmap "gh_gui-button.png";
   
pressedbitmap "gh_gui-button.png";
    }
    new 
GuiTextCtrl("QuestMenu_Text2") {
      
profile GuiBlueTextProfile;
      
height 20;
      
text "Type: Recolte";
      
width 80;
      
367;
      
46;
    }
    new 
GuiTextCtrl("QuestMenu_Text3") {
      
profile GuiBlueTextProfile;
      
height 20;
      
text "RANK: ";
      
width 74;
      
268;
      
46;
    }
    new 
GuiTextCtrl("QuestMenu_Text4") {
      
profile GuiBlueTextProfile;
      
height 20;
      
text "Quest: " serverr.quest1_questname;
      
width 206;
      
35;
      
46;
    }
    new 
GuiBitmapCtrl("QuestMenu_Bitmap1") {
      
profile GuiDefaultProfile;
      
bitmap "gh_icon_health-potion.png";
      
fullbitmap false;
      
height 62;
      
7;
      
43;
    }
}
}
function 
QuestMenu_Button1.onAction() {
 if (
serverr.available_quests != serverr.maxquests) {
triggerserver("gui"this.namenull);
}

}

function 
onTimeout()
  {
if (
serverr.quest1_available == true) {
QuestMenu_Button1.hide();
QuestMenu_Button2.hide();
QuestMenu_Text2.hide();
QuestMenu_Text3.hide();
QuestMenu_Text4.hide();
QuestMenu_Bitmap1.hide();
} else if (
serverr.quest1_available == false) {
QuestMenu_Button1.show();
QuestMenu_Button2.show();
QuestMenu_Text2.show();
QuestMenu_Text3.show();
QuestMenu_Text4.show();
QuestMenu_Bitmap1.show();
}

  
QuestMenu_Text1.text "Available Quests (" serverr.available_quests "/" serverr.maxquests " )";
  
setTimer(0.1);



cbk1994 09-02-2013 08:36 PM

First of all, please style your code before posting it. Secondly, put that check into a function. Third, leftmousebutton is a boolean indicating whether the left mouse button is pressed or not. It doesn't have anything to do with whether the mouse is over top of your object or not. For that check mousex and mousey. Something like:

PHP Code:

if (leftmousebutton && mousex in |this.xthis.this.width| && mousey in |this.ythis.this.height|) {
  
// open


You'll need to put that into a timeout. Note that the preferred way to do it would use onMouseDown instead so you don't need a timeout.

Torankusu 09-02-2013 10:23 PM

Quote:

Originally Posted by cbk1994 (Post 1722221)
First of all, please style your code before posting it. Secondly, put that check into a function. Third, leftmousebutton is a boolean indicating whether the left mouse button is pressed or not. It doesn't have anything to do with whether the mouse is over top of your object or not. For that check mousex and mousey. Something like:

PHP Code:

if (leftmousebutton && mousex in |this.xthis.this.width| && mousey in |this.ythis.this.height|) {
  
// open


You'll need to put that into a timeout. Note that the preferred way to do it would use onMouseDown instead so you don't need a timeout.


Thanks for confirming this. I thought it was weird he wasn't checking if the sign itself was clicked, but didn't want to give him bad advice.

Angel_Light 09-02-2013 10:55 PM

1 Attachment(s)
You need to use a function to catch if the left mouse button is pushed. Usually GraalControl.onMouseDown()
I modified the script some, the forums still don't allow me to post PHP sometimes, so I've just attached it in a txt file.

BlueMelon 09-03-2013 01:12 AM

Quote:

Originally Posted by Trakan (Post 1722204)
But when i click, (everywhere else, don't matter if its on the image or not), it shows correctly.

By looking at your script I assume it's in a weapon?
Have you considered catching the mouse event when the player clicks the NPC rather then catching it at every click and comparing x/y's in a range?

You can then trigger an action to open the GUI

Trakan 09-03-2013 12:39 PM

Ok everyone, everything is working so far :).
Thanks alot! And sorry, i'm starting scripting

Angel_Light 09-04-2013 09:05 AM

Feel free to pm me anytime if you have any questions. =]


All times are GMT +2. The time now is 04:44 AM.

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