Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting > New Scripting Engine (GS2)
FAQ Members List Calendar Today's Posts

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 02-23-2011, 12:38 AM
Astram Astram is offline
Era iPhone PR
Astram's Avatar
Join Date: Aug 2010
Posts: 324
Astram can only hope to improve
Send a message via AIM to Astram
Post Buy System Help!

Class:
PHP Code:
//#CLIENTSIDE
function onActionLeftMouse() {
Buy_Window1.show();
  new 
GuiWindowCtrl("Buy_Window1") {
    
profile GuiBlueWindowProfile;
    
clientrelative true;
    
clientextent "320,240";

    
canclose false;
    
canmaximize false;
    
canminimize false;
    
canmove true;
    
canresize true;
    
closequery false;
    
destroyonhide false;
    
text "Buy This Item?";
    
509;
    
203;

    new 
GuiButtonCtrl("Buy_Button1") {
      
profile GuiBlueButtonProfile;
      
text "Buy Item";
      
width 80;
      
118;
      
133;
    }
    new 
GuiTextCtrl("Buy_Text1") {
      
profile GuiBlueTextProfile;
      
height 20;
      
width 8;
      
143;
      
9;
    }
    new 
GuiTextCtrl("Buy_Text2") {
      
profile GuiBlueTextProfile;
      
height 20;
      
text "Would you like to buy?";
      
width 108;
      
106;
      
35;
    }
    new 
GuiTextCtrl("Buy_Text3") {
      
profile GuiBlueTextProfile;
      
height 20;
      
text this.item;
      
width 39;
      
135;
      
51;
    }
    new 
GuiTextCtrl("Buy_Text4") {
      
profile GuiBlueTextProfile;
      
height 20;
      
text "For...";
      
width 25;
      
145;
      
66;
    }
    new 
GuiTextCtrl("Buy_Text5") {
      
profile GuiBlueTextProfile;
      
height 20;
      
text this.price;
      
width 44;
      
132;
      
86;
    }
    new 
GuiButtonCtrl("Buy_Button2") {
      
profile GuiBlueButtonProfile;
      
text "No thank you.";
      
width 80;
      
118;
      
185;
    }
  }
  
Buy_Window2.hide();
  new 
GuiWindowCtrl("Buy_Window2") {
    
profile GuiBlueWindowProfile;
    
clientrelative true;
    
clientextent "320,206";

    
canclose false;
    
canmaximize false;
    
canminimize false;
    
canmove true;
    
canresize true;
    
closequery false;
    
destroyonhide false;
    
text "Receipt";
    
853;
    
88;

    new 
GuiTextCtrl("Buy_Text6") {
      
profile GuiBlueTextProfile;
      
height 20;
      
text "Item:";
      
width 22;
      
140;
      
24;
    }
    new 
GuiTextCtrl("Buy_Text7") {
      
profile GuiBlueTextProfile;
      
height 20;
      
text this.item;
      
width 39;
      
131;
      
44;
    }
    new 
GuiTextCtrl("Buy_Text8") {
      
profile GuiBlueTextProfile;
      
height 20;
      
text "Receipt";
      
width 36;
      
134;
    }
    new 
GuiTextCtrl("Buy_Text9") {
      
profile GuiBlueTextProfile;
      
height 20;
      
text "Price:";
      
width 27;
      
135;
      
70;
    }
    new 
GuiTextCtrl("Buy_Text10") {
      
profile GuiBlueTextProfile;
      
height 20;
      
text this.price;
      
width 44;
      
126;
      
92;
    }
    new 
GuiButtonCtrl("Buy_Button3") {
      
profile GuiBlueButtonProfile;
      
height 22;
      
text "Take My Item, I agree that I bought this item!";
      
width 320;
      
184;
    }
    new 
GuiTextCtrl("Buy_Text11") {
      
profile GuiBlueTextProfile;
      
height 20;
      
text "Weapon Name:";
      
width 73;
      
115;
      
114;
    }
    new 
GuiTextCtrl("Buy_Text12") {
      
profile GuiBlueTextProfile;
      
height 20;
      
text this.weapon;
      
width 60;
      
122;
      
141;
    }
    
Buy_Window2.hide();
  }
}

function 
Buy_Button1.onAction() {
  
Buy_Window1.hide();
  
Buy_Window2.show();
}

function 
Buy_Button2.onAction() {
  
Buy_Window1.hide();
}

function 
Buy_Button3.onAction() {
  
Buy_Window2.hide();
  
buy2(this.weaponthis.pricethis.item);

The public function buy2
PHP Code:
public function buy2(abc)
{
temp.weapon;
temp.price;
temp.name;
player.rupees -= temp.price;
addweapon(temp.weapon);
player.chat "I bought a "@temp.name@"! For "@temp.price@"!";

The NPC
PHP Code:
join("object_buy");
//#CLIENTSIDE
function onCreated()
  {
  
this.item "Ghost";
  
this.price "2500";
  
this.weapon "Morphs/Ghost";

What I need help with?
Whenever I use the system this.item, this.price, and this.weapon ALWAYS = 0 in the actual GUI when you use it! Now I dont really know how to get that to say the NPCs variables, please help!
__________________
-Toad
The worlds biggest Toad fan...
Era iPhone FTW!


Reply With Quote
  #2  
Old 02-23-2011, 12:45 AM
fowlplay4 fowlplay4 is offline
team canada
fowlplay4's Avatar
Join Date: Jul 2004
Location: Canada
Posts: 5,200
fowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond repute
You have to use thiso. instead of just this because of where you're using the variables.
__________________
Quote:
Reply With Quote
  #3  
Old 02-23-2011, 12:49 AM
Astram Astram is offline
Era iPhone PR
Astram's Avatar
Join Date: Aug 2010
Posts: 324
Astram can only hope to improve
Send a message via AIM to Astram
Quote:
Originally Posted by fowlplay4 View Post
You have to use thiso. instead of just this because of where you're using the variables.
Thanks so much
I finally got it to work!!!
__________________
-Toad
The worlds biggest Toad fan...
Era iPhone FTW!


Reply With Quote
  #4  
Old 02-23-2011, 12:53 AM
fowlplay4 fowlplay4 is offline
team canada
fowlplay4's Avatar
Join Date: Jul 2004
Location: Canada
Posts: 5,200
fowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond repute
Quote:
Originally Posted by Astram View Post
Just replace thiso with this, on ALL of the scripts above?
No, only in the sections where you try to set GUI text to "this." values.

Reason: this. when used in the scope of another object refers to that object, so you have to get the values from the origin "thiso." object.

If you look at the output you'll see what's going on.

PHP Code:
//#CLIENTSIDE
function onCreated() {
  
this.example "Hello World!";
  new 
GuiWindowCtrl("Example") {
    
0;
    
0;
    
width height 200;

    
// Check F2 Logs for Output
    
echo("this.name: " this.name " this.example: " this.example);
    echo(
"thiso.name: " thiso.name " thiso.example: " thiso.example);

    
text thiso.example;
  }

__________________
Quote:
Reply With Quote
  #5  
Old 02-23-2011, 12:54 AM
Astram Astram is offline
Era iPhone PR
Astram's Avatar
Join Date: Aug 2010
Posts: 324
Astram can only hope to improve
Send a message via AIM to Astram
Do you know how to fix the problem when gralats go down then back up?
Like
player.rupees -= this.price;
The players rupees go down for .5 of a second then back up to the original rupees!
__________________
-Toad
The worlds biggest Toad fan...
Era iPhone FTW!


Reply With Quote
  #6  
Old 02-23-2011, 12:55 AM
fowlplay4 fowlplay4 is offline
team canada
fowlplay4's Avatar
Join Date: Jul 2004
Location: Canada
Posts: 5,200
fowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond repute
Quote:
Originally Posted by Astram View Post
Do you know how to fix the problem when gralats go down then back up?
Like
player.rupees -= this.price;
The players rupees go down for .5 of a second then back up to the original rupees!
You have to change it on the server-side, not the client-side.
__________________
Quote:
Reply With Quote
  #7  
Old 02-23-2011, 12:56 AM
Astram Astram is offline
Era iPhone PR
Astram's Avatar
Join Date: Aug 2010
Posts: 324
Astram can only hope to improve
Send a message via AIM to Astram
Is this the same as addweapon();?
__________________
-Toad
The worlds biggest Toad fan...
Era iPhone FTW!


Reply With Quote
  #8  
Old 02-23-2011, 01:01 AM
fowlplay4 fowlplay4 is offline
team canada
fowlplay4's Avatar
Join Date: Jul 2004
Location: Canada
Posts: 5,200
fowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond repute
Quote:
Originally Posted by Astram View Post
Is this the same as addweapon();?
I guess they're same in the sense that you have to call them both on the server-side.
__________________
Quote:
Reply With Quote
  #9  
Old 02-23-2011, 01:01 AM
Astram Astram is offline
Era iPhone PR
Astram's Avatar
Join Date: Aug 2010
Posts: 324
Astram can only hope to improve
Send a message via AIM to Astram
New Script Still Needs help, now it doesnt view the gui, and it hides on clicked. Nothing happens... I need major help...

Class:
PHP Code:
function onActionServerSide(cmd)
{
if (
cmd == "buy")
{
player.rupees -= thiso.price;
addweapon(thiso.weapon);
}
}
//#CLIENTSIDE
function onActionLeftMouse() {
Buy_Window1.show();
  new 
GuiWindowCtrl("Buy_Window1") {
    
profile GuiBlueWindowProfile;
    
clientrelative true;
    
clientextent "320,240";

    
canclose false;
    
canmaximize false;
    
canminimize false;
    
canmove true;
    
canresize true;
    
closequery false;
    
destroyonhide false;
    
text "Buy This Item?";
    
509;
    
203;

    new 
GuiButtonCtrl("Buy_Button1") {
      
profile GuiBlueButtonProfile;
      
text "Buy Item";
      
width 80;
      
118;
      
133;
    }
    new 
GuiTextCtrl("Buy_Text1") {
      
profile GuiBlueTextProfile;
      
height 20;
      
width 8;
      
143;
      
9;
    }
    new 
GuiTextCtrl("Buy_Text2") {
      
profile GuiBlueTextProfile;
      
height 20;
      
text "Would you like to buy?";
      
width 108;
      
106;
      
35;
    }
    new 
GuiTextCtrl("Buy_Text3") {
      
profile GuiBlueTextProfile;
      
height 20;
      
text thiso.item;
      
width 39;
      
135;
      
51;
    }
    new 
GuiTextCtrl("Buy_Text4") {
      
profile GuiBlueTextProfile;
      
height 20;
      
text "For...";
      
width 25;
      
145;
      
66;
    }
    new 
GuiTextCtrl("Buy_Text5") {
      
profile GuiBlueTextProfile;
      
height 20;
      
text thiso.price;
      
width 44;
      
132;
      
86;
    }
    new 
GuiButtonCtrl("Buy_Button2") {
      
profile GuiBlueButtonProfile;
      
text "No thank you.";
      
width 80;
      
118;
      
185;
    }
  }
  new 
GuiWindowCtrl("Buy_Window2") {
    
profile GuiBlueWindowProfile;
    
clientrelative true;
    
clientextent "320,206";
    
canclose false;
    
canmaximize false;
    
canminimize false;
    
canmove true;
    
canresize true;
    
closequery false;
    
destroyonhide false;
    
text "Receipt";
    
853;
    
88;

    new 
GuiTextCtrl("Buy_Text6") {
      
profile GuiBlueTextProfile;
      
height 20;
      
text "Item:";
      
width 22;
      
140;
      
24;
    }
    new 
GuiTextCtrl("Buy_Text7") {
      
profile GuiBlueTextProfile;
      
height 20;
      
text thiso.item;
      
width 39;
      
131;
      
44;
    }
    new 
GuiTextCtrl("Buy_Text8") {
      
profile GuiBlueTextProfile;
      
height 20;
      
text "Receipt";
      
width 36;
      
134;
    }
    new 
GuiTextCtrl("Buy_Text9") {
      
profile GuiBlueTextProfile;
      
height 20;
      
text "Price:";
      
width 27;
      
135;
      
70;
    }
    new 
GuiTextCtrl("Buy_Text10") {
      
profile GuiBlueTextProfile;
      
height 20;
      
text thiso.price;
      
width 44;
      
126;
      
92;
    }
    new 
GuiButtonCtrl("Buy_Button3") {
      
profile GuiBlueButtonProfile;
      
height 22;
      
text "Take My Item, I agree that I bought this item!";
      
width 320;
      
184;
    }
    new 
GuiTextCtrl("Buy_Text11") {
      
profile GuiBlueTextProfile;
      
height 20;
      
text "Weapon Name:";
      
width 73;
      
115;
      
114;
    }
    new 
GuiTextCtrl("Buy_Text12") {
      
profile GuiBlueTextProfile;
      
height 20;
      
text thiso.weapon;
      
width 200;
      
122;
      
141;
    }
    
Buy_Window2.hide();
  }
}

function 
Buy_Button1.onAction() {
  
Buy_Window1.hide();
  
Buy_Window2.show();
}

function 
Buy_Button2.onAction() {
  
Buy_Window1.hide();
}

function 
Buy_Button3.onAction() {
  
Buy_Window2.hide();
  
triggerserver("gui",thiso.name,"buy");
  
player.chat "Bought "@thiso.item@"!";

(deleted the public function buy2)...

NPC:
PHP Code:
join("object_buy");
//#CLIENTSIDE
function onCreated()
  {
  
thiso.item "Ghost";
  
thiso.price "2500";
  
thiso.weapon "Morphs/Ghost";

Help... :o
__________________
-Toad
The worlds biggest Toad fan...
Era iPhone FTW!


Reply With Quote
  #10  
Old 02-23-2011, 01:02 AM
Astram Astram is offline
Era iPhone PR
Astram's Avatar
Join Date: Aug 2010
Posts: 324
Astram can only hope to improve
Send a message via AIM to Astram
OOPS LMAO!!!
I put...
} and //#CLIENTSIDE
on the same line... xD!
__________________
-Toad
The worlds biggest Toad fan...
Era iPhone FTW!


Reply With Quote
  #11  
Old 02-23-2011, 01:03 AM
Astram Astram is offline
Era iPhone PR
Astram's Avatar
Join Date: Aug 2010
Posts: 324
Astram can only hope to improve
Send a message via AIM to Astram
Quote:
Originally Posted by Astram View Post
OOPS LMAO!!!
I put...
} and //#CLIENTSIDE
on the same line... xD!
Though it still doesnt work when I corrected, the addweapon and subtracting the gralats
__________________
-Toad
The worlds biggest Toad fan...
Era iPhone FTW!


Reply With Quote
  #12  
Old 02-23-2011, 01:11 AM
fowlplay4 fowlplay4 is offline
team canada
fowlplay4's Avatar
Join Date: Jul 2004
Location: Canada
Posts: 5,200
fowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond repute
The variables are only accessible on the client-side in your script above.

You can simply just place them on the server-side.

PHP Code:
join("object_buy");

function 
onCreated() 

  
this.item "Ghost"
  
this.price "2500"
  
this.weapon "Morphs/Ghost"
}

//#CLIENTSIDE

function onCreated() 

  
this.item "Ghost"
  
this.price "2500"
  
this.weapon "Morphs/Ghost"

__________________
Quote:
Reply With Quote
  #13  
Old 02-23-2011, 01:16 AM
Astram Astram is offline
Era iPhone PR
Astram's Avatar
Join Date: Aug 2010
Posts: 324
Astram can only hope to improve
Send a message via AIM to Astram
That Class still doesnt add the weapon and substract the gralats...
I tried your NPC as well...
__________________
-Toad
The worlds biggest Toad fan...
Era iPhone FTW!


Reply With Quote
  #14  
Old 02-23-2011, 01:37 AM
gwFCCtennis gwFCCtennis is offline
Chaotic
gwFCCtennis's Avatar
Join Date: Aug 2010
Location: VA
Posts: 229
gwFCCtennis is on a distinguished road
Send a message via AIM to gwFCCtennis
Quote:
Originally Posted by Astram View Post
That Class still doesnt add the weapon and substract the gralats...
I tried your NPC as well...
I think he was comparing the two scripts, showing not to do clientside, and the correct one to use was the top one which was
PHP Code:
join("object_buy"); 

function 
onCreated()  
{  
  
this.item "Ghost";  
  
this.price "2500";  
  
this.weapon "Morphs/Ghost";  

Reply With Quote
  #15  
Old 02-23-2011, 01:57 AM
fowlplay4 fowlplay4 is offline
team canada
fowlplay4's Avatar
Join Date: Jul 2004
Location: Canada
Posts: 5,200
fowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond repute
Quote:
Originally Posted by Astram View Post
That Class still doesnt add the weapon and substract the gralats...
I tried your NPC as well...
Right, well it doesn't work because you're trying to use triggerserver in a level npc.
__________________
Quote:
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 11:59 AM.


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