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
  #31  
Old 01-03-2014, 10:29 PM
iDigzy iDigzy is offline
Registered User
Join Date: Apr 2013
Posts: 44
iDigzy is on a distinguished road
Quote:
Originally Posted by cbk1994 View Post
In the future please use [PHP] tags to format code.

Your trigger is fine except that it looks like you're using the code in an NPC (since you use onPlayerTouchsMe). You can't trigger NPCs the same way you trigger weapons. You would either have to do a triggerAction at the NPC's position, or a fancier trigger (like triggering a weapon or DB NPC).

However, since you're using it in an NPC, you don't even need a trigger. onPlayerTouchsMe gets called serverside, too, so you can just do...

PHP Code:
function onPlayerTouchsMe() {
  
// you can move this line clientside if you don't want everyone to see
  // the chat change
  
this.chat player.nick SPC "welcome to Castaway! To get started talk to Brian the skiller outside just outside of here";
  
player.clientr.tutorial 1;

(if this doesn't work, you may need to set the shape of the NPC serverside by using setShape).
Thanks for the quick response , that seems to work. However if I try to make it work for clientside so only the player sees the chat it does not work. I was wondering if it would make much of a difference if I used player.client.tutorial=1; instead of clientr as client seems to work on clientside. Or would it be better to do a trigger in an npc so it can use clientr?
__________________
Reply With Quote
  #32  
Old 01-03-2014, 10:33 PM
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 iDigzy View Post
Thanks for the quick response , that seems to work. However if I try to make it work for clientside so only the player sees the chat it does not work. I was wondering if it would make much of a difference if I used player.client.tutorial=1; instead of clientr as client seems to work on clientside. Or would it be better to do a trigger in an npc so it can use clientr?
You probably only want to move the chat line clientside.

PHP Code:
function onPlayerTouchsMe() {
  
player.clientr.tutorial 1
}

//#CLIENTSIDE
function onPlayerTouchsMe() {
  
this.chat player.nick SPC "welcome to Castaway! To get started talk to Brian the skiller outside just outside of here";

Alternatively, yes, you can use player.client instead as long as you don't care that cheating players can easily tamper with that variable.
__________________
Reply With Quote
  #33  
Old 01-14-2014, 09:59 PM
iDigzy iDigzy is offline
Registered User
Join Date: Apr 2013
Posts: 44
iDigzy is on a distinguished road
I started working on a simple shop script, however I have already ran into another problem. I want to trigger a weapon so whenever the player clicks the object it will trigger the simple shop gui I made. How would I go about triggering a weapon from an npc :o?
__________________
Reply With Quote
  #34  
Old 01-14-2014, 10:13 PM
Torankusu Torankusu is offline
Elite Member
Torankusu's Avatar
Join Date: Jun 2001
Posts: 10,065
Torankusu has a spectacular aura aboutTorankusu has a spectacular aura about
in the item you are clicking on, you need this:

PHP Code:
function onActionRightMouse(){ //or if you want left click, switch Right for Left ;]
  
triggerClient("weapon""<WEAPONNAME>""actionorwhatever"additional params available);

and then in your weapon you will need to check for the trigger...
ex:
PHP Code:
//#CLIENTSIDE
function onActionClientside(actionorwhateverhereadditionalparamspossible..) 

  
//can do conditional or switch statement depending on the actionorwhatever
  //and how many things you want to check here..
  
displayPurchaseMenu(); // or whatever you want to call the function to display your menu

Be careful here, because you need to set up some serverside security as well, such as checking to ensure that the item the client is sending that they want to purchase is the correct item, as well as the price is the correct price that it should be (check a DB or something that stores the price information serverside so that it can not be manipulated). The reason for the additional security is because someone could essentially buy anything they wanted for FREE if all of the purchasing was handled on the clientside (adding items and things should be handled on serverside anyway)

--Hopefully someone can chime in with better examples of the above paragraph, as I have not fooled with it recently. ;]

Here are a few examples and helpful posts:
Skyld's Shop Script
That one is somewhat outdated, but still relevant (note, the triggeraction used there has since been replaced -> use triggerClient instead)

Also, it might be noted, that Skyld's example stores the items information in a Database (multiple) -- This could now be redone to support SQLite..

Also, some helpful posts for triggering:

Serverside / Clientside actions explained
http://forums.graalonline.com/forums...84&postcount=6

good trigger examples both ways:
http://forums.graalonline.com/forums...17&postcount=4

Trigger DB from Level NPC
http://forums.graalonline.com/forums...41&postcount=9
__________________
Quote:
Originally posted by Spark910
Think befreo you type.
Reply With Quote
  #35  
Old 01-14-2014, 10:46 PM
iDigzy iDigzy is offline
Registered User
Join Date: Apr 2013
Posts: 44
iDigzy is on a distinguished road
@Torankusu

Thank you , I'll play around with it and see what I can do for adding security. I''m pretty sure the ActionLeftMouse works on serverside as well, would it be better to make the trigger that triggers the weapon serverside also?
__________________
Reply With Quote
  #36  
Old 01-14-2014, 11:29 PM
Torankusu Torankusu is offline
Elite Member
Torankusu's Avatar
Join Date: Jun 2001
Posts: 10,065
Torankusu has a spectacular aura aboutTorankusu has a spectacular aura about
onActionLeftMouse () or right,

Will work on serverside.
You want to send serverside info to the client, so keep the trigger on serverside, and detect it in the weapon npc on clientside. (Note my usage: triggerClient [serverside to clientside] -- causes the event onActionClientside [clientside...].

My terminology might be incorrect, but look at the examples and how they are set up. Also check the other posts by cbk, they are really helpful.
__________________
Quote:
Originally posted by Spark910
Think befreo you type.
Reply With Quote
  #37  
Old 01-15-2014, 08:11 PM
iDigzy iDigzy is offline
Registered User
Join Date: Apr 2013
Posts: 44
iDigzy is on a distinguished road
I just haven't been able to get it to work. Am I doing something wrong?
I put this into the npc
PHP Code:
function onActionRightMouse(){
  
triggerClient("weapon""<guishop>""openshop");

than I use this for the weapon script, named guishop
PHP Code:
//#CLIENTSIDE
function onActionClientside(openshop){
  new 
GuiWindowCtrl("MyGUI_Window1") {
    
profile GuiBlueWindowProfile;
    
clientrelative true;
    
clientextent "320,240";

    
canmove true;
    
canresize true;
    
closequery false;
    
destroyonhide false;
    
text "Window 1";
    
849;
    
167;
  }

__________________
Reply With Quote
  #38  
Old 01-15-2014, 08:46 PM
Emera Emera is offline
Delterian Hybrid
Emera's Avatar
Join Date: Mar 2011
Location: Newcastle Upon-Tyne
Posts: 1,704
Emera is a jewel in the roughEmera is a jewel in the rough
Remove the < and >
__________________
Reply With Quote
  #39  
Old 01-23-2014, 07:03 PM
iDigzy iDigzy is offline
Registered User
Join Date: Apr 2013
Posts: 44
iDigzy is on a distinguished road
How would you make it so it knows what row is selected on a gui text list? I tried doing a few things, would this work?
PHP Code:
  function Tools.onSelect(temp.i) {
  if (
rowselected == 0){
  
Player.chat I clicked a row!;
  } 
this is the current code I have to get a better idea of what I mean, not too sure if my post is that clear..
http://pastebin.com/svjPXSGe
__________________
Reply With Quote
  #40  
Old 01-23-2014, 09:59 PM
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
PHP Code:
function Tools.onSelect(entryid,entrytext,entryindex) {
  
// use entryid, entrytext, or entryindex however you want
  
echo("Clicked " entrytext);

__________________
Quote:
Reply With Quote
  #41  
Old 01-24-2014, 01:44 AM
Torankusu Torankusu is offline
Elite Member
Torankusu's Avatar
Join Date: Jun 2001
Posts: 10,065
Torankusu has a spectacular aura aboutTorankusu has a spectacular aura about
There are a few things you could change with what you have written up so far..

We'll start from the beginning, excluding the onSelect event...we'll get back to that, but first:

PHP Code:
//#CLIENTSIDE
/*ignore this...
function Tools.onSelect(temp.i) {
  if (row == 0){
    player.chat = this.items[temp.i][0] SPC "Selected";
  }
}
keep ignoring this..*/

//THIS:
this.tools = {
  {
"Boots"1"no-icon.gif"}, 
  {
"a"2"no-icon.gif"}
}; 
Try not to define arrays or variables outside of a function or an event (if it is not a constant.)
Putting this inside of onCreated() { this.tools = {blah...}; } will work, but I'd recommend an alternative method for defining the tools list (possibly something serverside if this is a shop menu and sending it to the client).

Continuing on...

PHP Code:
function onCreated() {
  new 
GuiWindowCtrl("MyGUI_Window1") {
    
profile GuiBlueWindowProfile;
    
clientrelative true;
    
clientextent "180,218";

    
canmove true;
    
canresize true;
    
closequery false;
    
destroyonhide false;
    
text "Tools";
    
1170// <----THIS... 
Alright...so what that's saying is it needs to start at 1170 pixels from the left of the screen, but not every user has a screen/w!ndow that wide

Use
PHP Code:
GraalControl.width this.width
That takes into account the width of their graal/client w!ndow and positions the new menu where you want it...

In your code, your list control is this:
PHP Code:
    new GuiTextListCtrl("Test_List") {
     
profile GuiBlueTextListProfile;
     
0;
     
width 140;
     
fitparentwidth true;
 
     
clearrows();
      for (
temp.ithiso.tools) {
          
addrow(temp.ntemp.i[0]);
          
temp.n++;
        }
     
setSelectedRow(0);
      } 
"Test_List", but in the function you are drawing up or testing, you reference it as "Tools" -- but there is not a control with the name tools...

It should be:

PHP Code:
function Test_List.onSelect(entryid,entrytext,entryindex) {
  
// use entryid, entrytext, or entryindex however you want
  
echo("Clicked " entrytext);

Also, please note, that this ECHO will have to be viewed by pressing F2 and looking at the output there since this is clientside.
__________________
Quote:
Originally posted by Spark910
Think befreo you type.
Reply With Quote
  #42  
Old 01-24-2014, 07:18 PM
iDigzy iDigzy is offline
Registered User
Join Date: Apr 2013
Posts: 44
iDigzy is on a distinguished road
@Fowlplay Thanks, I couldn't find a thing to use, that's just the kind of thing I was looking for

@Torankusu Thanks for looking through it, it's more of just a random thing I was working on to get more practice with gui's etc, so I didn't think of adding serverside protection or whatever for the array. As for the rest, thanks I'm gonna take a look at my code and see if I can fix these errors
__________________
Reply With Quote
  #43  
Old 01-24-2014, 08:50 PM
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 can find more events for GUI objects here:

http://wiki.graal.net/index.php/Crea...ent/GuiControl
__________________
Quote:
Reply With Quote
  #44  
Old 02-01-2014, 03:03 AM
iDigzy iDigzy is offline
Registered User
Join Date: Apr 2013
Posts: 44
iDigzy is on a distinguished road
I am having trouble with params. I am really not sure how to phrase this question I will try the best I can. Ok so I was making a small shop menu, and I wanted to have the npc trigger the shop menu. In the npc trigger to the shop it would contain the price and other params. I want to be able to use these params in the weapon it triggers and for example make the price.txt = the param price. I also am confused on how the script will know what the trigger is and to make it so it only uses the param of that trigger. For example, if you had more than one triggers going to a weapon script and you wanted to make a gui txt say param 3, how would you be able to tell it to only use param 3 of a certain trigger? I pasted my current script also, as I''m pretty sure I did not phrase any of this right D:
Npc - http://pastebin.com/uiBWRAUL
Weapon - http://pastebin.com/W87eGjhX
__________________
Reply With Quote
  #45  
Old 02-03-2014, 03:51 PM
iDigzy iDigzy is offline
Registered User
Join Date: Apr 2013
Posts: 44
iDigzy is on a distinguished road
Never mind on my last post. I was over thinking something simple.
__________________
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 09:29 AM.


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