Graal Forums  

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

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
  #16  
Old 02-23-2011, 02:05 AM
Mark Sir Link Mark Sir Link is offline
Kevin Azite
Mark Sir Link's Avatar
Join Date: Sep 2005
Posts: 1,489
Mark Sir Link is just really niceMark Sir Link is just really nice
Send a message via AIM to Mark Sir Link
Quote:
Originally Posted by fowlplay4 View Post
Right, well it doesn't work because you're trying to use triggerserver in a level npc.
Quote:
Originally Posted by Astram View Post
PHP Code:
function onActionServerSide(cmd)
{
if (
cmd == "buy")
{
player.rupees -= thiso.price;
addweapon(thiso.weapon);
}

thiso.price and thiso.weapon are undefined on the serverside, you need to use the params you are sending in triggerserver, you need to invoke the object for addweapon (player.addweapon())

You also really shouldn't define the weapon name and cost on the clientside since it opens it up for all sorts of abuse.
Reply With Quote
  #17  
Old 02-23-2011, 03:28 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 Mark Sir Link View Post
thiso.price and thiso.weapon are undefined on the serverside, you need to use the params you are sending in triggerserver, you need to invoke the object for addweapon (player.addweapon())

You also really shouldn't define the weapon name and cost on the clientside since it opens it up for all sorts of abuse.
He says he's using a class and a level npc, therefore using triggerserver won't work for what he's trying to do.

Also there's no problem with defining it client-side (saves a trip for sending the data via triggerclient, attribute or similar), the problem comes into play when you're not validating it on the server-side or when you don't keep them in sync (the same).

So we can setup a weapon system to do this or use the simple triggeraction method which is a little more newbie friendly.

Syntax: triggeraction(x, y, actionName, param0, param1, [...])

x - The x coordinate to trigger
y - The y coordinate to trigger
actionName - The actionEvent to hit. I.e: Passing "Buy" will trigger onActionBuy on the server-side
param0, param1, ... - Parameter data/message to send to the server.

Example usage:

PHP Code:
function onCreated() {
  
// Give the object shape on the server-side
  // This is very important or else the triggeraction won't "hit" it.
  
this.setshape(13232);
}

function 
onActionBuy() {
  
// Check the ID passed
  // Prevents stacked NPCs from reacting to triggers that don't concern them.
  
if (params[0] == this.id) {
    
player.chat "Bought an " params[1] @ "!";
  }
}

//#CLIENTSIDE

function onCreated() {
  
this.chat "Say '/buy' to execute this example!";
}

function 
onPlayerChats() {
  if (
player.chat == "/buy") {
    
// Sends a "Buy" trigger to the coordinates
    // this calls onActionBuy on both server and client sides.
    
triggeraction(this.1this.1"Buy"this.id"example"); 
  }

__________________
Quote:

Last edited by fowlplay4; 02-23-2011 at 03:49 AM..
Reply With Quote
  #18  
Old 02-23-2011, 04:58 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
Right, well it doesn't work because you're trying to use triggerserver in a level npc.
So then seriously what am I supposed to do...
__________________
-Toad
The worlds biggest Toad fan...
Era iPhone FTW!


Reply With Quote
  #19  
Old 02-23-2011, 05: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
Quote:
Originally Posted by Astram View Post
So then seriously what am I supposed to do...
Read my last post, I clarified and showed you the alternative.
__________________
Quote:
Reply With Quote
  #20  
Old 02-23-2011, 05:42 AM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
Suggestion: Have one DB NPC named something like "ShopControl" and trigger that using triggerserver. Triggering serverside to level NPCs is a pain in the ass.
__________________
Reply With Quote
  #21  
Old 02-23-2011, 10:53 PM
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 cbk1994 View Post
Suggestion: Have one DB NPC named something like "ShopControl" and trigger that using triggerserver. Triggering serverside to level NPCs is a pain in the ass.
I'm not to familiar with DB NPCs...
__________________
-Toad
The worlds biggest Toad fan...
Era iPhone FTW!


Reply With Quote
  #22  
Old 02-24-2011, 12:00 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
I still dont understand x_X
__________________
-Toad
The worlds biggest Toad fan...
Era iPhone FTW!


Reply With Quote
  #23  
Old 02-24-2011, 12:10 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
Triggering a DB-NPC with triggerserver.

DB-NPC (The dragon button): ShopControl

PHP Code:
function onActionServerSide() {
  
sendtorc(params[0SPC "and" SPC params[1]);

Level NPC:

PHP Code:
//#CLIENTSIDE
function onCreated() {
  
triggerserver("npc""ShopControl""hey now!""bababooey to you all");

__________________
Quote:
Reply With Quote
  #24  
Old 02-24-2011, 02:14 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
Triggering a DB-NPC with triggerserver.

DB-NPC (The dragon button): ShopControl

PHP Code:
function onActionServerSide() {
  
sendtorc(params[0SPC "and" SPC params[1]);

Level NPC:

PHP Code:
//#CLIENTSIDE
function onCreated() {
  
triggerserver("npc""ShopControl""hey now!""bababooey to you all");

Idk how to use params.. 0.0 sorry im kind of a >>><<< at scripting...
__________________
-Toad
The worlds biggest Toad fan...
Era iPhone FTW!


Reply With Quote
  #25  
Old 02-24-2011, 02:28 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
Idk how to use params.. 0.0 sorry im kind of a >>><<< at scripting...
Play with the examples I've provided, I'm not sure how I can make it any clearer for you without just making the script for you.
__________________
Quote:
Reply With Quote
  #26  
Old 02-24-2011, 02:31 AM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
Quote:
Originally Posted by Astram View Post
Idk how to use params.. 0.0 sorry im kind of a >>><<< at scripting...
Parameters are passed to a function.

PHP Code:
function onCreated() {
  
this.myFunction("bob""hello there");
}

function 
myFunction() {
  
player.chat params[0] @ " says " params[1];

params is an array that you can use to see what data was given to the function. This makes it possible to use functions for many things.

Instead of using the params array, you should usually assign parameters a name, like so:

PHP Code:
function myFunction(personmsg) {
  
player.chat person " says " msg;

__________________
Reply With Quote
  #27  
Old 02-24-2011, 03:52 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 cbk1994 View Post
Parameters are passed to a function.

PHP Code:
function onCreated() {
  
this.myFunction("bob""hello there");
}

function 
myFunction() {
  
player.chat params[0] @ " says " params[1];

params is an array that you can use to see what data was given to the function. This makes it possible to use functions for many things.

Instead of using the params array, you should usually assign parameters a name, like so:

PHP Code:
function myFunction(personmsg) {
  
player.chat person " says " msg;

This is helpful, thanks chris Im going to see what I can do, hopefully I complete my misson of creating this!
__________________
-Toad
The worlds biggest Toad fan...
Era iPhone FTW!


Reply With Quote
  #28  
Old 02-24-2011, 04:06 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
Okay so I have this and it seems to be working, other then the part that the DB NPC only supports the item name custom to the script, I tried thiso.weapon for a, and thiso.price for b.

Current DB NPC: "Buy"
PHP Code:
function onActionServerSide(cmd)
{
if (
cmd == "buy")
{
purchase("Morphs/Ghost""2500");
}
}
function 
Purchase(ab)
{
addweapon(a);
player.rupees -= b;

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("npc","Buy","buy");
  
player.chat "Bought "@thiso.item@"!";

NPC:
PHP Code:
join("object_buy");

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

//#CLIENTSIDE

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

Help :0 seems like only the DB NPC needs work
__________________
-Toad
The worlds biggest Toad fan...
Era iPhone FTW!


Reply With Quote
  #29  
Old 02-24-2011, 04:13 AM
salesman salesman is offline
Finger lickin' good.
salesman's Avatar
Join Date: Nov 2008
Location: Colorado
Posts: 1,865
salesman has much to be proud ofsalesman has much to be proud ofsalesman has much to be proud ofsalesman has much to be proud ofsalesman has much to be proud ofsalesman has much to be proud ofsalesman has much to be proud of
Quote:
Originally Posted by Astram View Post
snip
Take a look at this line:
PHP Code:
triggerserver("npc","Buy","buy"); 
and you should be able to figure your problem out. (or at least one of them =p)
__________________
Reply With Quote
  #30  
Old 02-24-2011, 04: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
Quote:
Originally Posted by salesman View Post
Take a look at this line:
PHP Code:
triggerserver("npc","Buy","buy"); 
and you should be able to figure your problem out. (or at least one of them =p)
I seriously dont notice?
NPC, DBNPC Name, param...
Should I include thiso.weapon, and thiso.price?
__________________
-Toad
The worlds biggest Toad fan...
Era iPhone FTW!


Reply With Quote
  #31  
Old 02-24-2011, 04:28 AM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
Add an echo into the onActionSeverSide event in the DB NPC and see if the trigger is being received.
__________________
Reply With Quote
  #32  
Old 02-24-2011, 04:33 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 cbk1994 View Post
Add an echo into the onActionSeverSide event in the DB NPC and see if the trigger is being received.
Yes the trigger is recived... Though, the script doesnt work...
PHP Code:
function onActionServerSide(cmd)
{
if (
cmd == "buy")
{
purchase(thiso.weaponthiso.price);
}
}
function 
Purchase(ab)
{
addweapon(a);
player.rupees -= b;

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


Reply With Quote
  #33  
Old 02-24-2011, 04:34 AM
salesman salesman is offline
Finger lickin' good.
salesman's Avatar
Join Date: Nov 2008
Location: Colorado
Posts: 1,865
salesman has much to be proud ofsalesman has much to be proud ofsalesman has much to be proud ofsalesman has much to be proud ofsalesman has much to be proud ofsalesman has much to be proud ofsalesman has much to be proud of
Quote:
Originally Posted by Astram View Post
I seriously dont notice?
NPC, DBNPC Name, param...
Should I include thiso.weapon, and thiso.price?
My bad, I misread and thought you weren't catching the trigger inside the Buy NPC.
__________________
Reply With Quote
  #34  
Old 02-24-2011, 04:39 AM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
The problem is that the weapon and the price aren't defined. You'll need to have the client send information on the weapon when it sends the trigger. You could also have it send the price but that's a security risk.

My suggestion (since I doubt you want to use NPC registration, which is what I would do) is to have a list of prices for each weapon:

PHP Code:
function onCreated() {
  
this.price.Sword 100;
}

function 
onActionServerSide(cmditem) {
  if (
cmd == "buy") {
    if (
this.price.(@ item) > 0) {
      if (
player.rupees this.price.(@ item)) {
        
player.rupees -= this.price.(@ item);
        
player.addWeapon(item);
      } else {
        
player.chat "I don't have enough money to buy this item!";
      }
    }
  }

__________________
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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:48 AM.


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