Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Raelyn's Big Book of Scripting Questions. (https://forums.graalonline.com/forums/showthread.php?t=85091)

Raelyn 04-11-2009 10:18 AM

Raelyn's Big Book of Scripting Questions.
 
Ok, because I am a newbie to GS2 scripting (and was never that good at GS1 either admittedly) and am genuinely trying to learn it, I know I am going to have a million questions, and I am already seeing myself making alot of threads, so rather than do that, I am going to compile all my questions into this thread, which should also make for a neat little resource for other new scripters. (I hope.)

Thank you all who have answered my questions so far, and thanks in advance to anyone else who does. I'm really glad to have a community of knowledgeable people to turn to. ^^

Ok, just for the purpose of converging all my questions here, for my own reference if for no other reason, I am going to add the questions and answers that I already asked!

Raelyn 04-11-2009 10:18 AM

Question #1
 
Question #1:
"Ok, I have a weapon NPC on the server that has alot of chat commands etc, but currently I have to add it to people for them to have it, what is the easiest method to have the NPC server check and add it to anyone who doesn't have it when they log on?"

Answer #1:
Quote:

Originally Posted by Tigairius (Post 1482863)
-Click on your NPCs button (the button on the far left of your NPC-Control).
-Right click Control-NPC and edit the script.
-If the script is blank, add this:
PHP Code:

function onActionPlayerOnline() {
  
player.addWeapon("weapon name");


-If the script is not blank, just add player.addWeapon("weapon name"); in your actionplayeronline function.


Raelyn 04-11-2009 10:22 AM

Question #2
 
Question #2:
What is the GS2 equivalent of the lay and lay2 commands?

Answer #2:
Quote:

Originally Posted by Tigairius (Post 1482911)
"lay", "lay2", and "shoot" commands are all deprecated commands that were only left for compatibility and are not actually recommended to use.

An example of laying a green rupee could be replicated (depending on your 'gralats' class) with something as simple as:
PHP Code:

with (putnpc2(xy"join gralats;")) {
  
this.type 1// 0 = green, 1 = blue, 2 = red, 3 = gold


Other commands, like shootarrow() can be replicated using a shoot() command.

PHP Code:

//#CLIENTSIDE
function onWeaponFired() {
  
// TServerLevel.shoot(x,y,z,angle,zangle,strength,ani,aniparams)
  
shoot(player.1.5 vecx(player.dir), player.vecy(player.dir), player.zgetangle(vecx(player.dir), vecy(player.dir)), NULLNULL"arrow"NULL);


You would have to make a gani called 'arrow' with an arrow facing all four directions, of course. It's my recommendation that you don't use any of those older commands, and re-script most of that kind of stuff.


Raelyn 04-11-2009 10:25 AM

Question #3
 
Question #3:
I have a script for setani in GS1, how would I setani in GS2?

Answer #3:
Quote:

Originally Posted by Tigairius (Post 1482911)
Simple animation changes are:
PHP Code:

setCharAni("idle"NULL); // This will set the NPC's ani to idle, replace "NULL" with an additional PARAM1 if necessary.

setAni("idle"NULL); // This will set the player's ani to idle, replace "NULL" with an additional PARAM1 if necessary.

replaceAni("walk""newwalk"); // Replaces 'walk' with 'newwalk'. 

The top two commands for ganis work both clientside and serverside.


Raelyn 04-11-2009 10:29 AM

Question #4
 
Question #4:
Where can I get the commands.rtf for GS2? I only have the GS1 commands...

Answer #4:
Quote:

Originally Posted by Stefan (Post 1482479)
commands.rtf -> ./Graal.exe -listscriptfunctions

The /scripthelp command shows all functions and built-in variables, although there are some which don't have a description yet. Also the events are not displayed right now although they have been added to -listscriptfunctions in the recent months.

Update: added description of server-side object events to /scripthelp to the next npcserver release.


Raelyn 04-11-2009 10:33 AM

Question #5
 
Question #5:
I have seen on my friend's server some of his weapons have '-' in front of them such as '-System' and '-Admin'. What is the significance of the '-' in front of the weapon name, if any?

Answer #5:
Quote:

Originally Posted by Schetti
the answer to your 5# question:
- weapons arent in inventory

-System/Summon, isnt in your inventory, its an invisible weapon.
EVERY weapo starts iht and - doesnt shine up in your inventory, thats the use if it


[email protected] 04-11-2009 10:50 AM

It's better to organize, however if you're using the default Graal inventory, adding the '-' in front of the weapon name won't show that weapon in the inventory.

Raelyn 04-11-2009 12:46 PM

Question #6
 
Question #6

Schetti suggested naming for instance staff boots as '-System/Boots' however when I tried this, the RC produced an error.

Quote:

Raelyn prob: No write rights for WEAPONS/-System/Boots
I made a seperate weapon called '-StaffBoots' which worked fine. What causes this?

Answer #6
Quote:

Originally Posted by xXziroXx (Post 1482942)
The / token is considered as a separator of sorts, and you have to add rights to whatever is behind it.


PHP Code:

rw WEAPONS/*
rw WEAPONS/*/
*
rw WEAPONS/*/*/*         <---- Doubt you'll need to go this far. 



Raelyn 04-11-2009 12:46 PM

Quote:

Originally Posted by [email protected] (Post 1482930)
It's better to organize, however if you're using the default Graal inventory, adding the '-' in front of the weapon name won't show that weapon in the inventory.

Thanks. :)

Crow 04-11-2009 12:49 PM

Quote:

Originally Posted by Raelyn (Post 1482937)
Question #6

Schetti suggested naming for instance staff boots as '-System/Boots' however when I tried this, the RC produced an error.



I made a seperate weapon called '-StaffBoots' which worked fine. What causes this?

I suppose you only have "rw WEAPONS/*" in your folder rights. Slashs are counted as a new folder, which means you also need to give "rw WEAPONS/*/*".

Raelyn 04-11-2009 12:51 PM

Quote:

Originally Posted by Crow (Post 1482939)
I suppose you only have "rw WEAPONS/*" in your folder rights. Slashs are counted as a new folder, which means you also need to give "rw WEAPONS/*/*".


Uh, seems to me like if you have access to a folder, you would have access to all sub-folders by default, no?

xXziroXx 04-11-2009 12:57 PM

Quote:

Originally Posted by Raelyn (Post 1482940)
Uh, seems to me like if you have access to a folder, you would have access to all sub-folders by default, no?

The / token is considered as a separator of sorts, and you have to add rights to whatever is behind it.


PHP Code:

rw WEAPONS/*
rw WEAPONS/*/
*
rw WEAPONS/*/*/*         <---- Doubt you'll need to go this far. 


Raelyn 04-11-2009 12:58 PM

Question #7
I have several NPCs with the following script.

PHP Code:

if (created) {
  
setshape 1,32,16;
}

if (
playertouchsme){
  
say2 Says_stuff_here;


What is the GS2 equivalent for the say2 command? And is there something wrong about the functionality of this script (bad formatting aside)? Because I have 4 of them on the gmap, and two work, and two don't. All identical, the only difference is the sign text. :confused:

Raelyn 04-11-2009 01:01 PM

Quote:

Originally Posted by xXziroXx (Post 1482942)
The / token is considered as a separator of sorts, and you have to add rights to whatever is behind it.


PHP Code:

rw WEAPONS/*
rw WEAPONS/*/
*
rw WEAPONS/*/*/*         <---- Doubt you'll need to go this far. 


Roger that, thanks Ziro.

xXziroXx 04-11-2009 01:23 PM

Quote:

Originally Posted by Raelyn (Post 1482943)
Question #7
I have several NPCs with the following script.

PHP Code:

if (created) {
  
setshape 1,32,16;
}

if (
playertouchsme){
  
say2 Says_stuff_here;


What is the GS2 equivalent for the say2 command? And is there something wrong about the functionality of this script (bad formatting aside)? Because I have 4 of them on the gmap, and two work, and two don't. All identical, the only difference is the sign text. :confused:

say2 is a clientsided command, and thus can't be used on serverside.

PHP Code:

//#CLIENTSIDE
function onPlayerTouchsMe()
{
  
say2("Insert your fancy stuff here!");




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

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