Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Stock System Help! (https://forums.graalonline.com/forums/showthread.php?t=67395)

cbk1994 07-16-2006 09:38 PM

Stock System Help!
 
Guys, I really need some help. I made a stock system, with basic functions ... The problem is, it uses a GUI, and that's only clientside ... How can I tell the NPC that you chose the 'buy' option? I've tried several things, but I'm out of ideas. !pissed! Thanks for any help!

Chris

Bl0nkt 07-16-2006 10:07 PM

Let's say you called the button 'buy'.

NPC Code:
function buy.onAction() { ... }


That will trigger when you click that button. If your question is how to get it to the serverside, use a triggeraction.

triggeraction(x, y, "action", "param", "param", "etc");

Angel_Light 07-16-2006 11:08 PM

or use a triggeraction to add the weapon

ForgottenLegacy 07-16-2006 11:29 PM

PHP Code:

new GuiButtonCtrl(MyGui_NameOfButton) {
  ...
}

MyGui_NameOfButton.onAction() {
  ...


That should do it. Look at what I did and you should be able to figure it out easily. Guis aren't hard at all.

ApothiX 07-17-2006 01:15 AM

Quote:

Originally Posted by ForgottenLegacy
PHP Code:

new GuiButtonCtrl(MyGui_NameOfButton) {
  ...
}

MyGui_NameOfButton.onAction() {
  ...


That should do it. Look at what I did and you should be able to figure it out easily. Guis aren't hard at all.

I'm pretty sure his problem is that he doesn't know how to communicate with the server.

My suggestion is to follow Bl0nkt's advice and use a triggerfunction, however instead of triggeraction, you should use triggerserver ( syntax: triggerserver("gui", <weaponname>, <actionname>, <param1>, <param2>, ...) )

cbk1994 07-17-2006 02:48 AM

Hello guys. Thanks for all the help. I really didn't expect to get so much help on this. Anyway, how do I talk to the client? I could add something in -System such as
PHP Code:

function onCreated() {
setTimer(0.05);
}
function 
onTimeOut() {
if (
client.stocksys != NULL) {
//blah blah blah, showing GUI ...
client.stocksys NULL;
}
//Other -System junk here
setTimer(0.05);
}
function 
button.onAction() {
//triggers here


and then from my NPC
PHP Code:

function onActionClick(account) {
with(account) {
client.stocksys = {itemnamepricestockweaponname};
}


and have it set it so it is NOT null so it knows to display the GUI from System, but is there a better way?

Thanks,
Chris

ZeekTheMan2 07-19-2006 06:56 AM

Are you using a guiCTR or a custom image for it like

new GuiButtonCtrl(MyGui_NameOfButton) {
...
}


or a showimg script based on your mousex and mousey

KuJi 07-19-2006 12:43 PM

Quote:

Originally Posted by cbkbud
Guys, I really need some help. I made a stock system, with basic functions ... The problem is, it uses a GUI, and that's only clientside ... How can I tell the NPC that you chose the 'buy' option? I've tried several things, but I'm out of ideas. !pissed! Thanks for any help!

Chris

http://wiki.graal.net/index.php/Creation/Dev/GScript

^-- Good source of information

cbk1994 07-19-2006 04:59 PM

Okay, thanks for all the help earlier, I managed to get it done.

Thanks guys.

Yen 07-19-2006 07:46 PM

Quote:

Originally Posted by KuJi

If the wiki were really that helpful, why would we need these forums?
'Why don't you contribute to it, then?'
Because I'm lazy. And there are already enough half-wit scripters.


Personally, I just don't put GUI in local NPCs. I hate it.
If I need a GUI for something, I make a new system to handle whatever needs the GUI.
i.e. if I want a shopping GUI, I'll make a Shopping system to deal with it rather than having each shop NPC create a new GUI on it's own.

ApothiX 07-21-2006 03:28 AM

Quote:

Originally Posted by Yen
Personally, I just don't put GUI in local NPCs. I hate it.
If I need a GUI for something, I make a new system to handle whatever needs the GUI.
i.e. if I want a shopping GUI, I'll make a Shopping system to deal with it rather than having each shop NPC create a new GUI on it's own.

That is good advice. NPCWs are called GuiScripts in the new engine for a reason.


All times are GMT +2. The time now is 07:01 AM.

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