Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting
FAQ Members List Calendar Today's Posts

 
 
Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #6  
Old 07-30-2017, 05:43 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 maximus_asinus View Post
I understand that "deposit" is a custom function. Is it being called by the triggerserver command? And how is "temp.amountToDeposit" assigned a value? I assume triggerserver is passing the value of the chat, similar to how tokenize worked in GS1, to the function?
It's called by the serverside half of the ATM weapon:

PHP Code:
    this.deposit(temp.amount); 
Because the weapon has joined functions_bank, the deposit function is available inside the weapon without copy-pasting it. It gets called at the "this.deposit(temp.amount)" line, after the trigger is received on serverside from the client.

Quote:
Does including the variable name in the function act similarly to assigning the variable value? Like "temp.amountToDeposit = player.chat.substring(9).trim());" ?

Again, how does "temp.cmd" and "temp.amount" get assigned values? In the deposit function I can sort of understand that triggerserver calls the function. Does "onActionServerSide" also catch the values that are being sent? Maybe it would help if you posted the format of how triggerserver is to be used.
When you use a trigger from clientside to serverside like this, the arguments passed to the function here (after "gui" and the weapon name):

PHP Code:
triggerServer("gui"this.name"deposit"player.chat.substring(9).trim()); 
...end up as the arguments to onActionServerSide function on serverside. So temp.cmd ends up as "deposit", tmp.amount ends up with the value of "player.chat.substring(9).trim()".

You're right that substring is similar to tokenize, it could alternatively be written:


PHP Code:
triggerServer("gui"this.name"deposit"player.chat.tokenize()[1]); 
The difference is that tokenize breaks up the line of chat into words, whereas substring takes everything after the ninth character. Tokenize is probably actually a better choice here anyway.

So the flow in this script is [play chats clientside] => [trigger is sent from clientside to serverside] => [trigger arrives in onActionServerSide block] => [onActionServerSide block calls this.deposit].

Triggers are a quirky feature of GScript (and I probably should've picked an example that didn't use them -- sorry), there are some good explanations at http://www.graal.net/index.php/Creat.../Helpful_Posts and in particular this post: http://forums.graalonline.com/forums...84&postcount=6

Quote:
Originally Posted by Crono View Post
damn chris out of nowhere
<3
__________________
Reply With Quote
 


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


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