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 04-28-2007, 02:34 AM
oo_jazz_oo oo_jazz_oo is offline
Jazz teh Awesome
oo_jazz_oo's Avatar
Join Date: Jul 2006
Location: California
Posts: 596
oo_jazz_oo is a jewel in the roughoo_jazz_oo is a jewel in the rough
Send a message via MSN to oo_jazz_oo
Classes with guis

Ok, so, I am trying to make a sale system. Its just a basic gui that displays the item name, image, and a buy or cancel button.
The only thing is, I cant get it to display data. ><

My npc in the level:
HTML Code:
this.join("shops");
//#CLIENTSIDE
this.shopname = "John's Shop";
this.itemname = "Tommy Gun";
The class:
HTML Code:
//#CLIENTSIDE
function onCreated(){

}
function onActionLeftMouse(){
new GuiWindowCtrl("shopwin") {
  profile = GuiBlueWindowProfile;
  x = 10;
  y = 10;
  destroyonhide=true;
  width = 160;
  height = 80;
  text = ""
  
new GuiMLTextCtrl("shopitem") {
  profile = GuiBlueMLTextProfile;
  x = 10;
  y = 20;
  width = 160;
  height = 1;
  text = @this.itemname;
}
  
}
}
Now, when you click the item, a blank gui pops up, and it doesnt display the item name. =/
Reply With Quote
  #2  
Old 04-28-2007, 02:58 AM
DustyPorViva DustyPorViva is offline
Will work for food. Maybe
DustyPorViva's Avatar
Join Date: Sep 2003
Location: Maryland, USA
Posts: 9,589
DustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond repute
Send a message via AIM to DustyPorViva Send a message via MSN to DustyPorViva
text = this.itemname;

?
Reply With Quote
  #3  
Old 04-28-2007, 03:11 AM
killerogue killerogue is offline
Registered Omega
killerogue's Avatar
Join Date: Apr 2006
Location: United States
Posts: 1,920
killerogue is on a distinguished road
Send a message via AIM to killerogue Send a message via MSN to killerogue
Well, why do you have the onCreated event in there man you don't need that. Just use mouse down as well instead of on action mouse. Give me a few moments to fix that up for you.


PHP Code:
//#CLIENTSIDE
function onMouseDown(mousebutton){
  if ( 
mousebutton == "leftmousebutton" )
  {
    new 
GuiWindowCtrlshopwin ) {
      
profile GuiBlueWindowProfile;
      
10;
      
10;
      
destroyonhide=true;
      
width 160;
      
height 80;

             new 
GuiMLTextCtrlshopitem ) {
               
profile GuiBlueMLTextProfile;
               
10;
               
20;
               
width 160;
               
height 1;
               
text this.itemname;
             }
           }
         }
       } 
Also a suggestion would be to format your scripts with styling so they are more readable bro. Otherwise nice work.
__________________


REMEMBER, IF YOU REP ME, LEAVE A NAME!

Quote:
Originally Posted by haunter View Post
Graal admins don't die. They go to hell and regroup.
Quote:
Originally Posted by Inverness View Post
Without scripters, your graphics and levels wouldn't do anything but sit there and look pretty.
Reply With Quote
  #4  
Old 04-28-2007, 03:20 AM
JkWhoSaysNi JkWhoSaysNi is offline
Ruler of the graalaxy
Join Date: Feb 2005
Location: Great Britain
Posts: 488
JkWhoSaysNi is on a distinguished road
Send a message via ICQ to JkWhoSaysNi
Your problem is simply that the class needs to be joined clientside:

NPC Code:

//#CLIENTSIDE
this.shopname = "John's Shop";
this.itemname = "Tommy Gun";
this.join("shops");


__________________

Coming soon (Hopefully:P)

Last edited by JkWhoSaysNi; 04-28-2007 at 03:20 AM.. Reason: stupid typo
Reply With Quote
  #5  
Old 04-28-2007, 03:26 AM
oo_jazz_oo oo_jazz_oo is offline
Jazz teh Awesome
oo_jazz_oo's Avatar
Join Date: Jul 2006
Location: California
Posts: 596
oo_jazz_oo is a jewel in the roughoo_jazz_oo is a jewel in the rough
Send a message via MSN to oo_jazz_oo
Ok, killer, all you did was change the mouse down part, and it didnt work.(the gui wouldnt even show. -.-)
Jk, your meathod didnt work either. =/
Reply With Quote
  #6  
Old 04-28-2007, 03:56 AM
godofwarares godofwarares is offline
Webmaster
godofwarares's Avatar
Join Date: Dec 2006
Location: Florida
Posts: 552
godofwarares is on a distinguished road
Send a message via ICQ to godofwarares Send a message via AIM to godofwarares Send a message via MSN to godofwarares Send a message via Yahoo to godofwarares
I see a few typos:

Quote:
function onActionLeftMouse(){
new GuiWindowCtrl("shopwin") {
profile = GuiBlueWindowProfile;
x = 10;
y = 10;
destroyonhide=true;
width = 160;
height = 80;
text = "" No Semicolon

new GuiMLTextCtrl("shopitem") {
profile = GuiBlueMLTextProfile;
x = 10;
y = 20;
width = 160;
height = 1; This would make the text 1 pixel in length I believe.
text = @this.itemname; No need for @
}
Fix those and tell us the result.
__________________
What signature? I see no signature?
Reply With Quote
  #7  
Old 04-28-2007, 04:20 AM
oo_jazz_oo oo_jazz_oo is offline
Jazz teh Awesome
oo_jazz_oo's Avatar
Join Date: Jul 2006
Location: California
Posts: 596
oo_jazz_oo is a jewel in the roughoo_jazz_oo is a jewel in the rough
Send a message via MSN to oo_jazz_oo
When you do just this.itemname, without @ it appears as 0.
And it doesnt matter is height = 1 or 60, it still doesnt show.
Reply With Quote
  #8  
Old 04-28-2007, 04:38 AM
DustyPorViva DustyPorViva is offline
Will work for food. Maybe
DustyPorViva's Avatar
Join Date: Sep 2003
Location: Maryland, USA
Posts: 9,589
DustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond repute
Send a message via AIM to DustyPorViva Send a message via MSN to DustyPorViva
It doesn't matter the outcome, there's no need for the @.
Reply With Quote
  #9  
Old 04-28-2007, 05:08 AM
oo_jazz_oo oo_jazz_oo is offline
Jazz teh Awesome
oo_jazz_oo's Avatar
Join Date: Jul 2006
Location: California
Posts: 596
oo_jazz_oo is a jewel in the roughoo_jazz_oo is a jewel in the rough
Send a message via MSN to oo_jazz_oo
So, why wont it show then? ><
I have tried everything.
It has to do with the gui, cause in the class, if you put say2(this.itemname); or message(this.itemname);
it shows the correct data.
But when you try in a gui, it just doesnt work.
Reply With Quote
  #10  
Old 04-28-2007, 05:23 AM
Rapidwolve Rapidwolve is offline
Registered User
Join Date: Jul 2006
Posts: 1,241
Rapidwolve is an unknown quantity at this point
Use thiso.itemname for GUI Controls
Reply With Quote
  #11  
Old 04-28-2007, 05:36 AM
xXziroXx xXziroXx is offline
Master of Puppets
xXziroXx's Avatar
Join Date: May 2004
Location: Sweden
Posts: 5,288
xXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant future
Send a message via AIM to xXziroXx Send a message via MSN to xXziroXx
Quote:
Originally Posted by Rapidwolve View Post
Use thiso.itemname for GUI Controls
Wow, finally someone said it.
__________________

"A delayed game is eventually good, but a rushed game is forever bad." - Shigeru Miyamoto
Reply With Quote
  #12  
Old 04-28-2007, 05:51 AM
oo_jazz_oo oo_jazz_oo is offline
Jazz teh Awesome
oo_jazz_oo's Avatar
Join Date: Jul 2006
Location: California
Posts: 596
oo_jazz_oo is a jewel in the roughoo_jazz_oo is a jewel in the rough
Send a message via MSN to oo_jazz_oo
Omg!
It was that simple!?
Now I feel like a complete idiot. -.-
Reply With Quote
  #13  
Old 04-28-2007, 05:52 AM
Rapidwolve Rapidwolve is offline
Registered User
Join Date: Jul 2006
Posts: 1,241
Rapidwolve is an unknown quantity at this point
Yeah, when you are editing variables inside a control its pretty much like 'this.variable = value;'

To go outside of the current control you must use the thiso. prefix
Reply With Quote
  #14  
Old 04-28-2007, 05:57 AM
Twinny Twinny is offline
My empire of dirt
Twinny's Avatar
Join Date: Mar 2006
Location: Australia
Posts: 2,422
Twinny is just really niceTwinny is just really nice
Send a message via AIM to Twinny
I was reading this thread from the top going, "oh come on!" . Whenever you are using with (obj) { or new obj {, you are no longer accessing the original object so using this. won't find your original values. thiso. uses the original object you were working from.
Reply With Quote
  #15  
Old 04-28-2007, 06:49 AM
oo_jazz_oo oo_jazz_oo is offline
Jazz teh Awesome
oo_jazz_oo's Avatar
Join Date: Jul 2006
Location: California
Posts: 596
oo_jazz_oo is a jewel in the roughoo_jazz_oo is a jewel in the rough
Send a message via MSN to oo_jazz_oo
One last thing. ><
I cant get the weapon to add to the player. =/
I have tried everything....whats wrong with this?

HTML Code:
//#CLIENTSIDE
function onCreated(){
setTimer(.05);
}
function onActionLeftMouse(){
new GuiWindowCtrl("shopwin") {
  profile = GuiBlueWindowProfile;
  x = 10;
  y = 100;
  destroyonhide=true;
  canresize=false;
  canminimize=false;
  canmaximize=false;
  canclose=false;
  canmove=true;
  width = 160;
  height = 140;
  text = "";
  
new GuiMLTextCtrl("shopitem") {
  profile = GuiBlueMLTextProfile;
  x = 0;
  y = 25;
  width = 160;
  height = 1;
  text = "<center>"@thiso.itemname@"</center>";
}

new GuiMLTextCtrl(shoppri) {
  profile = GuiBlueMLTextProfile;
  x = 0;
  y = 45;
  width = 160;
  height = 1;
  text = "<center>Price:</center>";
}

new GuiMLTextCtrl(shopprice) {
  profile = GuiBlueMLTextProfile;
  x = 0;
  y = 65;
  width = 160;
  height = 1;
  text = "<center>"@thiso.price@" $</center>";
}

 new GuiFrameSetCtrl("Test_Frames") {
   x = 10;
   y = 65;
   width = 140;
   height = 15;
   rowcount = 1;
   columncount = 1;
   setColumnOffset(1,80);
   setRowOffset(1,80);
   bordercolor = {128,128,255,128};
   
   new GuiScrollCtrl("Test_Frame1") {
     profile = GuiBlueScrollProfile;
     hScrollBar = "dynamic";
     vScrollBar = "dynamic";
   }
 }
 
 new GuiButtonCtrl("cancelb") {
   profile = GuiBlueButtonProfile;
   x = 10;
   y = 90;
   width = 50;
   height = 20;
   text = "Cancel";
 }
 
  new GuiButtonCtrl("buyb") {
   profile = GuiBlueButtonProfile;
   x = 100;
   y = 90;
   width = 50;
   height = 20;
   text = "Buy";
 }

 
}
Test_Frames.PushtoBack();
}

function cancelb.onAction(){
shopwin.destroy();
}
function buyb.onAction(){
if (client.money >[email protected]){
client.money -=this.price;
triggeraction(0,0,"serverside","-Shop","addw",@this.item);
}
}
-Shop npc:
HTML Code:
function onActionServerside(){
 if (params[0] == "addw") {
addweapon(@params[1]);
      }
    }
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 06:46 PM.


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