Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   New Scripting Engine (GS2) (https://forums.graalonline.com/forums/forumdisplay.php?f=153)
-   -   Buy System Help! (https://forums.graalonline.com/forums/showthread.php?t=134262199)

Astram 02-23-2011 12:38 AM

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!

fowlplay4 02-23-2011 12:45 AM

You have to use thiso. instead of just this because of where you're using the variables.

Astram 02-23-2011 12:49 AM

Quote:

Originally Posted by fowlplay4 (Post 1632726)
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!!!

fowlplay4 02-23-2011 12:53 AM

Quote:

Originally Posted by Astram (Post 1632728)
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;
  }



Astram 02-23-2011 12:54 AM

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!

fowlplay4 02-23-2011 12:55 AM

Quote:

Originally Posted by Astram (Post 1632732)
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.

Astram 02-23-2011 12:56 AM

Is this the same as addweapon();?

fowlplay4 02-23-2011 01:01 AM

Quote:

Originally Posted by Astram (Post 1632735)
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.

Astram 02-23-2011 01:01 AM

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

Astram 02-23-2011 01:02 AM

OOPS LMAO!!!
I put...
} and //#CLIENTSIDE
on the same line... xD!

Astram 02-23-2011 01:03 AM

Quote:

Originally Posted by Astram (Post 1632740)
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

fowlplay4 02-23-2011 01:11 AM

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"



Astram 02-23-2011 01:16 AM

That Class still doesnt add the weapon and substract the gralats...
I tried your NPC as well...

gwFCCtennis 02-23-2011 01:37 AM

Quote:

Originally Posted by Astram (Post 1632747)
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";  



fowlplay4 02-23-2011 01:57 AM

Quote:

Originally Posted by Astram (Post 1632747)
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.

Mark Sir Link 02-23-2011 02:05 AM

Quote:

Originally Posted by fowlplay4 (Post 1632758)
Right, well it doesn't work because you're trying to use triggerserver in a level npc.

Quote:

Originally Posted by Astram (Post 1632738)
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.

fowlplay4 02-23-2011 03:28 AM

Quote:

Originally Posted by Mark Sir Link (Post 1632760)
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"); 
  }



Astram 02-23-2011 04:58 AM

Quote:

Originally Posted by fowlplay4 (Post 1632758)
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... x_x

fowlplay4 02-23-2011 05:11 AM

Quote:

Originally Posted by Astram (Post 1632807)
So then seriously what am I supposed to do... x_x

Read my last post, I clarified and showed you the alternative.

cbk1994 02-23-2011 05:42 AM

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.

Astram 02-23-2011 10:53 PM

Quote:

Originally Posted by cbk1994 (Post 1632815)
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...

Astram 02-24-2011 12:00 AM

I still dont understand x_X

fowlplay4 02-24-2011 12:10 AM

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");



Astram 02-24-2011 02:14 AM

Quote:

Originally Posted by fowlplay4 (Post 1632962)
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 >>>:noob:<<< at scripting... x_x

fowlplay4 02-24-2011 02:28 AM

Quote:

Originally Posted by Astram (Post 1632998)
Idk how to use params.. 0.0 sorry im kind of a >>>:noob:<<< at scripting... x_x

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.

cbk1994 02-24-2011 02:31 AM

Quote:

Originally Posted by Astram (Post 1632998)
Idk how to use params.. 0.0 sorry im kind of a >>>:noob:<<< at scripting... x_x

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;



Astram 02-24-2011 03:52 AM

Quote:

Originally Posted by cbk1994 (Post 1633005)
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 :D Im going to see what I can do, hopefully I complete my misson of creating this!

Astram 02-24-2011 04:06 AM

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

salesman 02-24-2011 04:13 AM

Quote:

Originally Posted by Astram (Post 1633018)
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)

Astram 02-24-2011 04:16 AM

Quote:

Originally Posted by salesman (Post 1633020)
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?

cbk1994 02-24-2011 04:28 AM

Add an echo into the onActionSeverSide event in the DB NPC and see if the trigger is being received.

Astram 02-24-2011 04:33 AM

Quote:

Originally Posted by cbk1994 (Post 1633025)
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;



salesman 02-24-2011 04:34 AM

Quote:

Originally Posted by Astram (Post 1633022)
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.

cbk1994 02-24-2011 04:39 AM

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!";
      }
    }
  }




All times are GMT +2. The time now is 11:40 PM.

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