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
  #16  
Old 11-27-2013, 06:12 PM
Jakov_the_Jakovasaur Jakov_the_Jakovasaur is offline
Deleted by Darlene159
Jakov_the_Jakovasaur's Avatar
Join Date: Sep 2013
Location: Deleted by Darlene159
Posts: 353
Jakov_the_Jakovasaur has much to be proud ofJakov_the_Jakovasaur has much to be proud ofJakov_the_Jakovasaur has much to be proud ofJakov_the_Jakovasaur has much to be proud ofJakov_the_Jakovasaur has much to be proud ofJakov_the_Jakovasaur has much to be proud ofJakov_the_Jakovasaur has much to be proud of
Quote:
Originally Posted by iDigzy View Post
Well I haven't posted a question on here in a bit, but I ran into another problem. I want to make a script that sets the players tag. I'm not sure if this script is correct in any way/or if I over thought it. Can someone tell me whats wrong :o?
PHP Code:
function onActionSeverside(tags){
if (
tokens[0] == "/tag"){
player.guild "Elepahnt";
}
}

//#CLIENTSIDE
function onPlayerChats(){
if (
player.chat == "/tag"){
temp.tokens player.chat.tokenize();
triggerServer("gui"this,nametags);
}

  • the 2nd parameter for triggerserver(); is the name of the object you are communicating with, you have a comma after 'this' instead of a dot
  • you are storing 'player.chat.tokenize()' as 'temp.tokens', but you are not sending temp.tokens as a parameter, you are sending 'tags' which is undefined
  • because you have already established the player is using the tag command on clientside, it is not necessary to check this condition on serverside
  • it is not necessary to send the full array of tokenized chat, you only need to send the 2nd value, which is temp.tokens[1]

PHP Code:
function onActionSeverside(temp.tag){ 
  
player.guild temp.tag;


//#CLIENTSIDE 
function onPlayerChats(){ 
  if (
player.chat.starts("/tag")){ 
    
temp.tokens player.chat.tokenize(); 
    
triggerServer("gui"this.nametemp.tokens[1]); 
  } 

__________________
This signature has been deleted by Darlene159.

Last edited by Jakov_the_Jakovasaur; 11-27-2013 at 09:44 PM.. Reason: thank you!
Reply With Quote
  #17  
Old 11-27-2013, 09:03 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 Jakov_the_Jakovasaur View Post
PHP Code:
if (player.chat == "/tag"){ 
Also, this line should probably be:

PHP Code:
if (player.chat.starts("/tag")) { 
__________________
Reply With Quote
  #18  
Old 12-10-2013, 04:00 PM
iDigzy iDigzy is offline
Registered User
Join Date: Apr 2013
Posts: 44
iDigzy is on a distinguished road
Thanks for the reply's, they helped a lot
Reply With Quote
  #19  
Old 12-10-2013, 04:03 PM
iDigzy iDigzy is offline
Registered User
Join Date: Apr 2013
Posts: 44
iDigzy is on a distinguished road
I have a problem I ran into when making a simple shop GUI, I have tried several things, but I can't seem to get the price text to change when I click on a different row. I posted the entire script, but I marked where I am having the problem and have tried a few things. I am not sure how I can get the row and make the text change when I click it.
http://pastebin.com/d1RrM6Kb - I kept getting an error when posting on here, I posted it on paste bin for now. I marked the part where I am having trouble with. Hopefully someone can tell me what I can use there/explain why it wont work.
Reply With Quote
  #20  
Old 12-10-2013, 06:38 PM
Jakov_the_Jakovasaur Jakov_the_Jakovasaur is offline
Deleted by Darlene159
Jakov_the_Jakovasaur's Avatar
Join Date: Sep 2013
Location: Deleted by Darlene159
Posts: 353
Jakov_the_Jakovasaur has much to be proud ofJakov_the_Jakovasaur has much to be proud ofJakov_the_Jakovasaur has much to be proud ofJakov_the_Jakovasaur has much to be proud ofJakov_the_Jakovasaur has much to be proud ofJakov_the_Jakovasaur has much to be proud ofJakov_the_Jakovasaur has much to be proud of
i can see two big problems

you have the onSelect function wrapped within the gui container, it should be outside of the onCreated function with the gui name before the event name

you still arent comparing variables properly, it should be '==', just one '=' is for assigning variables

a better way to accomplish this would be to have an array of item data, and loop through the array when building the list,
the onSelect() function already returns the index of the list item you click, which can then be used to reference the price within the array

PHP Code:
//#CLIENTSIDE
function onCreated(){
  
//setup item data, {name, price}
  
this.items = {
    {
"Red Sword"100},
    {
"Flintlock Pistol"500}
  };

  
//loop through item array to build list
  
clearrows();
  for(
temp.thiso.items){
     
addrow(temp.ntemp.i[0]);
    
temp.++;
  }
  
//invoke the select action on the default row
  
setselectedrow(0);

}

//select event has list index parameter, use this to obtain price from array
function Items.onSelect(temp.i){
  
Price.text this.items[temp.i][1];

it is also worth mentioning that the parameter when building a new gui should not be passed as a string even though it would still work, its best to remove the " " quotes

you will also want to avoid using such a script within level npcs if theres going to be more than one shop, because they would conflict with eachother even if they are in a different level

the best method is to put gui scripts in a weapon, and then call a public function from the level npc script to the weapon script in order to invoke the display, and pass a parameter to identify the npc which called it
__________________
This signature has been deleted by Darlene159.

Last edited by Jakov_the_Jakovasaur; 12-10-2013 at 08:22 PM..
Reply With Quote
  #21  
Old 12-10-2013, 08:55 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
slightly related to his inquiry, but I am looking for a bit more insight on putting rows / columns into a GUI display as well (similar to SQL Explorer, but not as indepth.)

Not for the same purposes, but I will be displaying data in a table format. :[
__________________
Quote:
Originally posted by Spark910
Think befreo you type.
Reply With Quote
  #22  
Old 12-11-2013, 10:34 PM
iDigzy iDigzy is offline
Registered User
Join Date: Apr 2013
Posts: 44
iDigzy is on a distinguished road
I am having trouble getting the rows to show now, I looked at Jakov's post and managed to get it working one time. But when I went to add an extra row it will not show now.
PHP Code:
  this.items = { 
    {
"Red Sword"100"Red-Sword-icon.gif"}, 
    {
"Flintlock Pistol"500"FlintLock-icon.gif"},
    {
"Blue Sword"250"Bluesword-icon.gif"
  }; 
  
clearrows(); 
  for(
temp.this.items){ 
     
addrow(temp.ntemp.i[0]); 
    
temp.++;
  } 
  
setselectedrow(0); 
function 
items.onSelect(temp.i){ 
  
Price.text this.items[temp.i][1]; 

the entire script is http://pastebin.com/ykGNj85y if it can help to show what I am having trouble with.
Reply With Quote
  #23  
Old 12-11-2013, 11:13 PM
Jakov_the_Jakovasaur Jakov_the_Jakovasaur is offline
Deleted by Darlene159
Jakov_the_Jakovasaur's Avatar
Join Date: Sep 2013
Location: Deleted by Darlene159
Posts: 353
Jakov_the_Jakovasaur has much to be proud ofJakov_the_Jakovasaur has much to be proud ofJakov_the_Jakovasaur has much to be proud ofJakov_the_Jakovasaur has much to be proud ofJakov_the_Jakovasaur has much to be proud ofJakov_the_Jakovasaur has much to be proud ofJakov_the_Jakovasaur has much to be proud of
you need to set the this.items array outside of the gui container, because that is otherwise applying the array variable to the container itself instead of the parent object, which is then not being found within the onSelect event

then if you just use 'thiso' within gui container like shown in my example it will reference the parent object

you are also looping through the items array outside of the gui container, which is why the rows arent adding properly, and you are closing the onCreated() bracket in the wrong place

http://pastebin.com/vb9hhr7y
__________________
This signature has been deleted by Darlene159.
Reply With Quote
  #24  
Old 12-12-2013, 09:07 PM
iDigzy iDigzy is offline
Registered User
Join Date: Apr 2013
Posts: 44
iDigzy is on a distinguished road
Quote:
Originally Posted by Jakov_the_Jakovasaur View Post
you need to set the this.items array outside of the gui container, because that is otherwise applying the array variable to the container itself instead of the parent object, which is then not being found within the onSelect event

then if you just use 'thiso' within gui container like shown in my example it will reference the parent object

you are also looping through the items array outside of the gui container, which is why the rows arent adding properly, and you are closing the onCreated() bracket in the wrong place

http://pastebin.com/vb9hhr7y
Thanks, I'll take a look at it and see where I put brackets. I thought I had messed up when closing them, but I assumed I fixed it. I guess it was still a mess.
Reply With Quote
  #25  
Old 12-12-2013, 09:10 PM
callimuc callimuc is offline
callimuc's Avatar
Join Date: Nov 2010
Location: Germany
Posts: 1,015
callimuc is a splendid one to beholdcallimuc is a splendid one to beholdcallimuc is a splendid one to beholdcallimuc is a splendid one to beholdcallimuc is a splendid one to behold
Quote:
Originally Posted by iDigzy View Post
Thanks, I'll take a look at it and see where I put brackets. I thought I had messed up when closing them, but I assumed I fixed it. I guess it was still a mess.
thats why it is important to style your script
__________________
MEEP!
Reply With Quote
  #26  
Old 12-14-2013, 12:06 AM
iDigzy iDigzy is offline
Registered User
Join Date: Apr 2013
Posts: 44
iDigzy is on a distinguished road
Ok, I'm really not sure. I tried everything to get this to work. It seems I am missing something obvious or something of the sort? I took my script and fix everything mentioned so far. I also threw it through the gs2 beautifier by fowlplay to make sure I could find any errors if I was just not styling it right and placing parts in wrong spots still. I could not find anything D:. This is my current script would anyone be able to find where I am messing up?
http://pastebin.com/diQgMxh8
Reply With Quote
  #27  
Old 12-14-2013, 01:25 AM
Starfire2001 Starfire2001 is offline
Unholy Nation
Starfire2001's Avatar
Join Date: Dec 2010
Location: The streets.
Posts: 156
Starfire2001 will become famous soon enough
Quote:
Originally Posted by Jakov_the_Jakovasaur View Post
you need to set the this.items array outside of the gui container[/URL]
You still have this problem. And your brackets are still messed up. You have
PHP Code:
function Items.onSelect(temp.i) {
  
Price.text this.items[temp.i][1];

inside of onCreated.
__________________
-Ph8
Reply With Quote
  #28  
Old 12-14-2013, 03:22 AM
iDigzy iDigzy is offline
Registered User
Join Date: Apr 2013
Posts: 44
iDigzy is on a distinguished road
Quote:
Originally Posted by Starfire2001 View Post
You still have this problem. And your brackets are still messed up. You have
PHP Code:
function Items.onSelect(temp.i) {
  
Price.text this.items[temp.i][1];

inside of onCreated.
After re-reading that it finally occurred to me the mistake I kept making. Thanks
Reply With Quote
  #29  
Old 01-03-2014, 09:25 PM
iDigzy iDigzy is offline
Registered User
Join Date: Apr 2013
Posts: 44
iDigzy is on a distinguished road
It's been a while since I've run into another problem while learning, but I am currently stuck on making a trigger to set the clientr of a player. I have tried a few things with no luck. Would anyone be able to tell me what is wrong with this?
Quote:
function onActionServerSide(cmd) {
if (cmd == "tutorial"){
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";
triggerserver("gui",this.name,"tutorial");
}
Reply With Quote
  #30  
Old 01-03-2014, 10:13 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
It's been a while since I've run into another problem while learning, but I am currently stuck on making a trigger to set the clientr of a player. I have tried a few things with no luck. Would anyone be able to tell me what is wrong with this?
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).
__________________
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 04:07 PM.


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