Graal Forums  

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

Reply
 
Thread Tools Search this Thread Display Modes
  #41  
Old 04-29-2009, 11:47 AM
Pelikano Pelikano is offline
Registered User
Pelikano's Avatar
Join Date: Oct 2008
Posts: 1,133
Pelikano has a little shameless behaviour in the past
People hate reading GS1 xD
Reply With Quote
  #42  
Old 04-29-2009, 12:37 PM
Skyld Skyld is offline
Script-fu
Skyld's Avatar
Join Date: Jan 2002
Location: United Kingdom
Posts: 3,914
Skyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud of
Send a message via AIM to Skyld
Quote:
Originally Posted by Raelyn View Post
Because I don't know GS2 yet, and because I am silly?
Learn GScript2. Old GScript is not worth so much as a moment of your time, and basically, GScript2 is better in absolutely every way.
Reply With Quote
  #43  
Old 04-29-2009, 01:43 PM
Codein Codein is offline
jwd
Codein's Avatar
Join Date: Oct 2005
Location: Greater Manchester
Posts: 2,423
Codein has a spectacular aura aboutCodein has a spectacular aura about
Send a message via AIM to Codein Send a message via MSN to Codein
Quote:
Originally Posted by Skyld View Post
Learn GScript2. Old GScript is not worth so much as a moment of your time, and basically, GScript2 is better in absolutely every way.
Agreed.
Reply With Quote
  #44  
Old 04-29-2009, 01:51 PM
Raelyn Raelyn is offline
the Professional.
Raelyn's Avatar
Join Date: Sep 2003
Location: Zormite
Posts: 964
Raelyn will become famous soon enough
Quote:
Originally Posted by Pelikano View Post
People hate reading GS1 xD
Well that's lame. :/

Do classes operate like global functions? Like, if I put all my functions into classes, I can call them up in any scripts on the server?
__________________
*Don't let the door hit you on the way out.*
Reply With Quote
  #45  
Old 04-29-2009, 02:29 PM
Chompy Chompy is offline
¯\(º_o)/¯
Chompy's Avatar
Join Date: Sep 2006
Location: Norway
Posts: 2,815
Chompy is just really niceChompy is just really niceChompy is just really nice
Send a message via MSN to Chompy
Quote:
Originally Posted by Raelyn View Post
Well that's lame. :/

Do classes operate like global functions? Like, if I put all my functions into classes, I can call them up in any scripts on the server?
You'd have to join that class to use it's content.

Lets say this is a class called fibonacci:

PHP Code:
function fib(n) {
  return (((
1+5^0.5)/2)^- ((1-5^0.5)/2)^n)/(5^0.5)


To use that function, I would have to do:

PHP Code:
function onCreated() {
  
join("fibonacci");

  echo(
fib(7)); // 13

__________________
Reply With Quote
  #46  
Old 04-29-2009, 03:52 PM
Raelyn Raelyn is offline
the Professional.
Raelyn's Avatar
Join Date: Sep 2003
Location: Zormite
Posts: 964
Raelyn will become famous soon enough
Quote:
Originally Posted by Chompy View Post
You'd have to join that class to use it's content.

Lets say this is a class called fibonacci:

PHP Code:
function fib(n) {
  return (((
1+5^0.5)/2)^- ((1-5^0.5)/2)^n)/(5^0.5)


To use that function, I would have to do:

PHP Code:
function onCreated() {
  
join("fibonacci");

  echo(
fib(7)); // 13

Ok, thanks.
__________________
*Don't let the door hit you on the way out.*
Reply With Quote
  #47  
Old 04-29-2009, 05:11 PM
Deas_Voice Deas_Voice is offline
Deas
Deas_Voice's Avatar
Join Date: Jun 2007
Location: Sweden
Posts: 2,264
Deas_Voice is a jewel in the roughDeas_Voice is a jewel in the rough
Send a message via AIM to Deas_Voice Send a message via MSN to Deas_Voice Send a message via Yahoo to Deas_Voice
one thing i always wondered when it comes to join(),
should i join it on serverside or clientside?
or even both?
__________________
.
WTF is real life, and where do I Download it?
There is no Real Life, just AFK!
since 2003~
I Support~
ღAeonღ | ღTestbedღ | ღDelteriaღ

if you are going to rep me, don't be an idiot, leave your name!
I got nothing but love for you
Reply With Quote
  #48  
Old 04-29-2009, 05:19 PM
Chompy Chompy is offline
¯\(º_o)/¯
Chompy's Avatar
Join Date: Sep 2006
Location: Norway
Posts: 2,815
Chompy is just really niceChompy is just really niceChompy is just really nice
Send a message via MSN to Chompy
Quote:
Originally Posted by Deas_Voice View Post
one thing i always wondered when it comes to join(),
should i join it on serverside or clientside?
or even both?
Depends on where you'll be using the class' content.
__________________
Reply With Quote
  #49  
Old 04-29-2009, 05:42 PM
Deas_Voice Deas_Voice is offline
Deas
Deas_Voice's Avatar
Join Date: Jun 2007
Location: Sweden
Posts: 2,264
Deas_Voice is a jewel in the roughDeas_Voice is a jewel in the rough
Send a message via AIM to Deas_Voice Send a message via MSN to Deas_Voice Send a message via Yahoo to Deas_Voice
Quote:
Originally Posted by Chompy View Post
Depends on where you'll be using the class' content.
both sides.
sometimes clientside or serverside.
__________________
.
WTF is real life, and where do I Download it?
There is no Real Life, just AFK!
since 2003~
I Support~
ღAeonღ | ღTestbedღ | ღDelteriaღ

if you are going to rep me, don't be an idiot, leave your name!
I got nothing but love for you
Reply With Quote
  #50  
Old 04-29-2009, 07:25 PM
napo_p2p napo_p2p is offline
oh snaps
napo_p2p's Avatar
Join Date: Sep 2003
Location: Pismo Beach, California
Posts: 2,118
napo_p2p has a spectacular aura aboutnapo_p2p has a spectacular aura about
Send a message via AIM to napo_p2p Send a message via MSN to napo_p2p
Quote:
Originally Posted by Deas_Voice View Post
both sides.
sometimes clientside or serverside.
If you join it serverside, then both clientside and serverside parts of the class will work. If you join it clientisde, then only the clientside part of the class will work.
__________________
Scito hoc super omnia.
Haec vita est tua una sola.
Dum vita superest, utere maxime quoque puncto, momento, et hora quae habes.
Tempus neminem non manet.
Noli manere tempus.
Carpe Diem

Seize the Day.
Reply With Quote
  #51  
Old 04-29-2009, 08:53 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
I've noticed on the clientside if you join a class clientside you can't use the functions from the class right away.

ex:

PHP Code:
//class: whatever
//#CLIENTSIDE
function somefunc() {
  echo(
"!");

Then doing following..

PHP Code:
//#CLIENTSIDE
function onCreated() {
  
join("whatever");
  
somefunc(); // the somefunc in the class would not actually be called..
  
this.trigger("WildEvent"""); // so I would use a trigger..
}

function 
onWildEvent() {
  
somefunc(); // and ! would be displayed in F2

__________________
Quote:
Reply With Quote
  #52  
Old 04-29-2009, 09:16 PM
napo_p2p napo_p2p is offline
oh snaps
napo_p2p's Avatar
Join Date: Sep 2003
Location: Pismo Beach, California
Posts: 2,118
napo_p2p has a spectacular aura aboutnapo_p2p has a spectacular aura about
Send a message via AIM to napo_p2p Send a message via MSN to napo_p2p
Quote:
Originally Posted by fowlplay4 View Post
I've noticed on the clientside if you join a class clientside you can't use the functions from the class right away.

ex:

PHP Code:
//class: whatever
//#CLIENTSIDE
function somefunc() {
  echo(
"!");

Then doing following..

PHP Code:
//#CLIENTSIDE
function onCreated() {
  
join("whatever");
  
somefunc(); // the somefunc in the class would not actually be called..
  
this.trigger("WildEvent"""); // so I would use a trigger..
}

function 
onWildEvent() {
  
somefunc(); // and ! would be displayed in F2

That's weird. Have you tried:
PHP Code:
whatever::somefunc(); 
??
__________________
Scito hoc super omnia.
Haec vita est tua una sola.
Dum vita superest, utere maxime quoque puncto, momento, et hora quae habes.
Tempus neminem non manet.
Noli manere tempus.
Carpe Diem

Seize the Day.
Reply With Quote
  #53  
Old 04-29-2009, 09:21 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
It might take a minute to join, I've had trouble with that before as well.
__________________
Reply With Quote
  #54  
Old 04-30-2009, 12:28 AM
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
Quote:
Originally Posted by napo_p2p View Post
That's weird. Have you tried:
PHP Code:
whatever::somefunc(); 
??
Just tried it, it only happens when you login/connect though, not when you update the script.

My above script didn't work with the trigger, however this worked fine and isn't noticable.

PHP Code:
//#CLIENTSIDE
function onCreated() {
  
join("whatever");
  
whatever::somefunc(); // the somefunc in the class would not actually be called..
  
this.scheduleevent(0.1"WildEvent"""); // so I would use a trigger..
}

function 
onWildEvent() {
  
somefunc(); // and ! would be displayed in F2

So I'd recommend joining serverside if you don't want to deal with the workaround above..

PHP Code:
function onCreated() {
  
join("whatever");
}
//#CLIENTSIDE
function onCreated() { 
  
somefunc(); // the somefunc in the class is called.

__________________
Quote:
Reply With Quote
  #55  
Old 04-30-2009, 12:43 AM
napo_p2p napo_p2p is offline
oh snaps
napo_p2p's Avatar
Join Date: Sep 2003
Location: Pismo Beach, California
Posts: 2,118
napo_p2p has a spectacular aura aboutnapo_p2p has a spectacular aura about
Send a message via AIM to napo_p2p Send a message via MSN to napo_p2p
You know, now that I think of it, it's requesting the script from the server when you call join(), which results in a small delay.

So, yea. It's easiest just to do all joins serverside.
__________________
Scito hoc super omnia.
Haec vita est tua una sola.
Dum vita superest, utere maxime quoque puncto, momento, et hora quae habes.
Tempus neminem non manet.
Noli manere tempus.
Carpe Diem

Seize the Day.
Reply With Quote
  #56  
Old 04-30-2009, 12:38 PM
xXziroXx xXziroXx is offline
Malorian
xXziroXx's Avatar
Join Date: May 2004
Posts: 5,289
xXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant future
Jerret, you're actually missing something.

It's not being updated on clientside when you join it clientsided, true. But it's also not updated clientsided if you join it serversided. Note that sometimes both works, sometimes they don't - and when it doesn't work, it's updated if you reconnect with your client.

This is why I never "release" an updated clientsided class before manually reconnecting all current clients to ensure that they all got the update.
__________________
Follow my work on social media post-Graal:Updated august 2025.
Reply With Quote
  #57  
Old 04-30-2009, 08:26 PM
Raelyn Raelyn is offline
the Professional.
Raelyn's Avatar
Join Date: Sep 2003
Location: Zormite
Posts: 964
Raelyn will become famous soon enough
Ok, maybe I should ask this differently.. I wrote these scripts in GS1, but now I want to put them on my server, so can they be converted to GS2 easier with syntax changes? Or do I have to re-write them entirely?
__________________
*Don't let the door hit you on the way out.*
Reply With Quote
  #58  
Old 04-30-2009, 08:51 PM
napo_p2p napo_p2p is offline
oh snaps
napo_p2p's Avatar
Join Date: Sep 2003
Location: Pismo Beach, California
Posts: 2,118
napo_p2p has a spectacular aura aboutnapo_p2p has a spectacular aura about
Send a message via AIM to napo_p2p Send a message via MSN to napo_p2p
Quote:
Originally Posted by Raelyn View Post
Ok, maybe I should ask this differently.. I wrote these scripts in GS1, but now I want to put them on my server, so can they be converted to GS2 easier with syntax changes? Or do I have to re-write them entirely?
You might get away with just putting the GS1 script up, but it's good practice to use only GS2 online.

You can mostly go line-by-line and make a direct change from GS1->GS2.

If you haven't checked it out already:
http://wiki.graal.net/index.php/Creation/Dev/GS1_To_GS2

That article gives a pretty good overview of the types of changes you need to make.
__________________
Scito hoc super omnia.
Haec vita est tua una sola.
Dum vita superest, utere maxime quoque puncto, momento, et hora quae habes.
Tempus neminem non manet.
Noli manere tempus.
Carpe Diem

Seize the Day.
Reply With Quote
  #59  
Old 04-30-2009, 09:27 PM
Raelyn Raelyn is offline
the Professional.
Raelyn's Avatar
Join Date: Sep 2003
Location: Zormite
Posts: 964
Raelyn will become famous soon enough
Quote:
Originally Posted by napo_p2p View Post
You might get away with just putting the GS1 script up, but it's good practice to use only GS2 online.

You can mostly go line-by-line and make a direct change from GS1->GS2.

If you haven't checked it out already:
http://wiki.graal.net/index.php/Creation/Dev/GS1_To_GS2

That article gives a pretty good overview of the types of changes you need to make.
Ok, well for displaying showtext I presume this is the GS2 equivalent of what I have done for my hud.

PHP Code:
function onCreated() {
  
temp.= {55};
  
  
temp.txt "HP:" clientr.player_hp "/" clientr.player_hpmax;
  
temp.showtext(200temp.p[0], temp.p[1], "Arial""b"temp.txt);
  
temp.i.layer 4;

  
temp.txt "MP:" clientr.player_mp "/" clientr.player_mpmax;
  
temp.showtext(201temp.p[0], temp.p[1] + 20"Arial""b"temp.txt);
  
temp.i.layer 4;

As far as I can tell, this works the same, but I don't understand "temp.p" and "temp.i", "temp.i.layer". I presume temp.i.layer is the same as changeimgvis, but what I don't understand is why the text being on layer 4 works, when I thought only 5 and up works for the screen instead of the playing field?

This script is something another scripter made/posted on my RC and I'm trying to learn off it and/or convert it to match what I have done in GS1, since it seems nearly identical but with strange syntax differences.

This really confuses me as to why everyone says "GS2 is easier to understand" or "GS2 makes more sense" because GS1 makes sense to me, but looking at this stuff, I am like.. what?!
__________________
*Don't let the door hit you on the way out.*
Reply With Quote
  #60  
Old 04-30-2009, 09:35 PM
Raelyn Raelyn is offline
the Professional.
Raelyn's Avatar
Join Date: Sep 2003
Location: Zormite
Posts: 964
Raelyn will become famous soon enough
Quote:
Originally Posted by Chompy View Post
You'd have to join that class to use it's content.

Lets say this is a class called fibonacci:

PHP Code:
function fib(n) {
  return (((
1+5^0.5)/2)^- ((1-5^0.5)/2)^n)/(5^0.5)


To use that function, I would have to do:

PHP Code:
function onCreated() {
  
join("fibonacci");

  echo(
fib(7)); // 13

Ok, so if I take all my functions from my base system script, and make the classes all functions, I can just go through and replace all the functions listed in the script with:

PHP Code:
function onCreated() {
join("class_name");

Is that right? What is the echo? And will GS1 and GS2 mix? It seems like they mix, but only that GS2 doesn't work offline.. is that right?
__________________
*Don't let the door hit you on the way out.*
Reply With Quote
  #61  
Old 04-30-2009, 09:42 PM
Raelyn Raelyn is offline
the Professional.
Raelyn's Avatar
Join Date: Sep 2003
Location: Zormite
Posts: 964
Raelyn will become famous soon enough
Quote:
Originally Posted by Deas_Voice View Post
one thing i always wondered when it comes to join(),
should i join it on serverside or clientside?
or even both?
How do you designate one or the other?
__________________
*Don't let the door hit you on the way out.*
Reply With Quote
  #62  
Old 04-30-2009, 09:46 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:
As far as I can tell, this works the same, but I don't understand "temp.p" and "temp.i", "temp.i.layer". I presume temp.i.layer is the same as changeimgvis, but what I don't understand is why the text being on layer 4 works, when I thought only 5 and up works for the screen instead of the playing field?
Layers 4+ are screen layers.

"temp.i" is a variable, which is pointing to the image object. When you use 'showtext' or 'showimg', it returns the actual image created (can also be obtained through findImg(index)).

Which means you could even do like (though it's not a good idea)

PHP Code:
//#CLIENTSIDE
function onCreated() {
  
this.msg showtext(2003030"Arial""b""hi");
}
function 
changeText(text) {
  
this.msg.text text;

Kinda odd the way you're doing it. I would do it either like this:

PHP Code:
with (findimg(200)) {
  
500;
  
500;
  
  
text "Hello, world!";
  
  
font "Arial"// not sure if this is the variable name, use /scripthelp
  
fontface "b"// see above line
  
  
layer 4;
  
  
red 1;
  
blue .5;
  
green .5;
  
  
alpha 1;

or

PHP Code:
showtext(200500500 "Arial""b""Hello, world!");
changeimgvis(2004);
changeimgcolors(2001.5.51); 
Either works, but the top one is probably preferred (though I could be wrong; the top one seems to agree with GS2 standards whereas the bottom is for compatibility).
Quote:
This really confuses me as to why everyone says "GS2 is easier to understand" or "GS2 makes more sense" because GS1 makes sense to me, but looking at this stuff, I am like.. what?!
GS2 makes a lot more sense, and you'll understand it when you've been working with it longer.
Quote:
Originally Posted by Raelyn View Post
Ok, so if I take all my functions from my base system script, and make the classes all functions, I can just go through and replace all the functions listed in the script with:

PHP Code:
function onCreated() {
join("class_name");

Is that right? What is the echo? And will GS1 and GS2 mix? It seems like they mix, but only that GS2 doesn't work offline.. is that right?
GS1 and GS2 can mix, but it's strongly discouraged.

echo(message) simply outputs the message to NC (or RC if you have the server option enabled), and since he's echoing a function, it will echo whatever that function returns.

And yes, you can take all the functions you want to be in a shared class from the individual scripts and put them in a class, then join that class.


Edit (in response to designating clientside/serverside):
PHP Code:
join("class"); // serverside
//#CLIENTSIDE
function onCreated() {
  
classFunctionThatWillAlreadyWork();

or

PHP Code:
//#CLIENTSIDE
function onCreated() {
  
join("class"); // clientside (not a good idea)
  
classFunctionThatWillNotWorkBecauseOfDelaysAndWillReportAnErrorToF2(); // ;)

__________________
Reply With Quote
  #63  
Old 04-30-2009, 09:52 PM
Raelyn Raelyn is offline
the Professional.
Raelyn's Avatar
Join Date: Sep 2003
Location: Zormite
Posts: 964
Raelyn will become famous soon enough
Ok, so I put the functions in classes, and uploaded the rest of the main script as a weapon, and this is the errors I got:

Quote:
Script: Function disableselectweapons not found at line 126 in script of -Player
Script: Function showstats not found at line 127 in script of -Player
Script: Callstack overrun at line 104 in script of -Player
So, disableselectweapons and showstats don't work online? And what is callstack overrun?
__________________
*Don't let the door hit you on the way out.*
Reply With Quote
  #64  
Old 04-30-2009, 10:10 PM
Chompy Chompy is offline
¯\(º_o)/¯
Chompy's Avatar
Join Date: Sep 2006
Location: Norway
Posts: 2,815
Chompy is just really niceChompy is just really niceChompy is just really nice
Send a message via MSN to Chompy
Quote:
Originally Posted by Raelyn View Post
Ok, so if I take all my functions from my base system script, and make the classes all functions, I can just go through and replace all the functions listed in the script with:

PHP Code:
function onCreated() {
join("class_name");

Is that right? What is the echo? And will GS1 and GS2 mix? It seems like they mix, but only that GS2 doesn't work offline.. is that right?
Well, echo() will output test into RC serverside, and into F2 clientside.

What join() do, is that it takes the content of the class (all the functions and such) and applies it to the script/object that is joining the class.
__________________
Reply With Quote
  #65  
Old 04-30-2009, 10:18 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 Raelyn View Post
Ok, so I put the functions in classes, and uploaded the rest of the main script as a weapon, and this is the errors I got:



So, disableselectweapons and showstats don't work online? And what is callstack overrun?
As far as I know, callstack overrun means you're calling a function too many times, e.g.

PHP Code:
function onCreated() {
  
badLoop();
}
function 
badLoop() {
  
// bad loop stuff here
  
badLoop();

and no ... showstats an disableselectweapons are clientside, which means you need to do this in your system weapons:

PHP Code:
//#CLIENTSIDE
function onCreated() {
  
initStats();
}
function 
initStats() {
  
showstats(allstats whatever);
  
disableselectweapons();

though for disableselectweapons, it's better to use "enablefeatures" if you don't plan on ever enabling it.

PHP Code:
//#CLIENTSIDE
function onCreated() {
  
initStats();
}
function 
initStats() {
  
showstats(1024);
  
enablefeatures(allfeatures 4);

Here are the rest of the game features:

__________________
Reply With Quote
  #66  
Old 04-30-2009, 10:22 PM
napo_p2p napo_p2p is offline
oh snaps
napo_p2p's Avatar
Join Date: Sep 2003
Location: Pismo Beach, California
Posts: 2,118
napo_p2p has a spectacular aura aboutnapo_p2p has a spectacular aura about
Send a message via AIM to napo_p2p Send a message via MSN to napo_p2p
Quote:
Originally Posted by Raelyn View Post
So, disableselectweapons and showstats don't work online? And what is callstack overrun?
disableselectweapons and showstats are clientside only functions. They affect the player only. It looks like you need to run the code clientside. Put //#CLIENTSIDE at the top of your scripts.

The callstack overrun happens when your script is executing too many functions too quickly. It'll probably go away if you switch the script over to clientside. (I bet you have a 0.05 timeout, which is too much for the server to handle).
__________________
Scito hoc super omnia.
Haec vita est tua una sola.
Dum vita superest, utere maxime quoque puncto, momento, et hora quae habes.
Tempus neminem non manet.
Noli manere tempus.
Carpe Diem

Seize the Day.
Reply With Quote
  #67  
Old 04-30-2009, 10:23 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 napo_p2p View Post
disableselectweapons and showstats are clientside only functions. They affect the player only. It looks like you need to run the code clientside. Put //#CLIENTSIDE at the top of your scripts.

The callstack overrun happens when your script is executing too many functions too quickly. It'll probably go away if you switch the script over to clientside. (I bet you have a 0.05 timeout, which is too much for the server to handle).
Timeouts faster than a tenth of a second are automagically changed to .1 on serverside.

And yeah, I didn't think about the fact that //#CLIENTSIDE isn't required in the level editor for clientside scripts. Good catch.
__________________
Reply With Quote
  #68  
Old 04-30-2009, 10:27 PM
Raelyn Raelyn is offline
the Professional.
Raelyn's Avatar
Join Date: Sep 2003
Location: Zormite
Posts: 964
Raelyn will become famous soon enough
Quote:
Originally Posted by cbk1994 View Post
Layers 4+ are screen layers.

"temp.i" is a variable, which is pointing to the image object. When you use 'showtext' or 'showimg', it returns the actual image created (can also be obtained through findImg(index)).
This confuses the piss out of me, doesn't it just make more sense to reference the index directly than to try calling a variable pointing to the index?

Quote:
Originally Posted by cbk1994 View Post
Kinda odd the way you're doing it. I would do it either like this:
Heh, that was someone elses little snippet of code, like I said, I was trying to read/understand it, I actually did your suggestion below in MY script:

Quote:
Originally Posted by cbk1994 View Post
PHP Code:
showtext(200500500 "Arial""b""Hello, world!");
changeimgvis(2004);
changeimgcolors(2001.5.51); 
Quote:
Originally Posted by cbk1994 View Post
GS1 and GS2 can mix, but it's strongly discouraged.
Any specific reason? Functionally is bad? Or some "purist" idealism?


Quote:
Originally Posted by cbk1994 View Post
echo(message) simply outputs the message to NC (or RC if you have the server option enabled), and since he's echoing a function, it will echo whatever that function returns.
So basically, it's not needed to join a class?

Quote:
Originally Posted by cbk1994 View Post
Edit (in response to designating clientside/serverside):
PHP Code:
join("class"); // serverside
//#CLIENTSIDE
function onCreated() {
  
classFunctionThatWillAlreadyWork();

I thought anything behind // isn't read by the system, so how does tagging //serverside produce a difference in the code?
__________________
*Don't let the door hit you on the way out.*
Reply With Quote
  #69  
Old 04-30-2009, 10:29 PM
Raelyn Raelyn is offline
the Professional.
Raelyn's Avatar
Join Date: Sep 2003
Location: Zormite
Posts: 964
Raelyn will become famous soon enough
Quote:
Originally Posted by Chompy View Post
Well, echo() will output test into RC serverside, and into F2 clientside.

What join() do, is that it takes the content of the class (all the functions and such) and applies it to the script/object that is joining the class.
Ok, so join() works like putnpc, but it called from a class instead of a text file, and inserts all commands in the class in order below the join() command.. Gotcha..
__________________
*Don't let the door hit you on the way out.*
Reply With Quote
  #70  
Old 04-30-2009, 10:36 PM
Raelyn Raelyn is offline
the Professional.
Raelyn's Avatar
Join Date: Sep 2003
Location: Zormite
Posts: 964
Raelyn will become famous soon enough
Quote:
Originally Posted by napo_p2p View Post
disableselectweapons and showstats are clientside only functions. They affect the player only. It looks like you need to run the code clientside. Put //#CLIENTSIDE at the top of your scripts.

The callstack overrun happens when your script is executing too many functions too quickly. It'll probably go away if you switch the script over to clientside. (I bet you have a 0.05 timeout, which is too much for the server to handle).
Inserting //#CLIENTSIDE at the top seems to have removed the errors. Thanks. But now won't my player's stats be vulnerable to cheap string editng kiddies? :P
__________________
*Don't let the door hit you on the way out.*
Reply With Quote
  #71  
Old 04-30-2009, 10:52 PM
Raelyn Raelyn is offline
the Professional.
Raelyn's Avatar
Join Date: Sep 2003
Location: Zormite
Posts: 964
Raelyn will become famous soon enough
Ok, so I have inserted my baddy script into a class, if I wanted to place baddies on the map with the baddie class as their script, would I be able to do something like a weapon with a trigger and some sort of putnpc script referencing back to the class? How would I do that serverside? I want the baddie to be seen the same by all players... would putnpc work with a class?
__________________
*Don't let the door hit you on the way out.*
Reply With Quote
  #72  
Old 04-30-2009, 11:11 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
These wiki pages should help you a bit with your understanding of clientside/serverside:
http://wiki.graal.net/index.php/Clientside
http://wiki.graal.net/index.php/Serverside
http://www.graal.net/index.php/Creat...Starting_Guide
http://wiki.graal.net/index.php/Crea.../Script/Client (explains how to communicate between serverside and clientside)

Quote:
Originally Posted by Raelyn View Post
This confuses the piss out of me, doesn't it just make more sense to reference the index directly than to try calling a variable pointing to the index?
What?
Quote:
Any specific reason? Functionally is bad? Or some "purist" idealism?
Not sure exactly, but Stefan said at several times not to, so that suggests to me that perhaps he checks what the script is in and decides how to parse it or something like that could be added later.

And yeah, GS1 just uglifies a beautiful script. GS2 is also considerably more efficient than GS1.
Quote:
So basically, it's not needed to join a class?
Haha yes, correct.
Quote:
I thought anything behind // isn't read by the system, so how does tagging //serverside produce a difference in the code?
It doesn't, the only time the parser reads anything that starts with "//" is when it is //#CLIENTSIDE. The ones I placed after the join were just labels.
Quote:
Originally Posted by Raelyn View Post
Ok, so join() works like putnpc, but it called from a class instead of a text file, and inserts all commands in the class in order below the join() command.. Gotcha..
You should always use putnpc2 now anyway; just put the code in a class rather than a text file.
Quote:
Originally Posted by Raelyn View Post
Inserting //#CLIENTSIDE at the top seems to have removed the errors. Thanks. But now won't my player's stats be vulnerable to cheap string editng kiddies? :P
Only if you used 'client.' vars. You should always use clientr (or serverside player. vars) for storing sensitive information.
Quote:
Originally Posted by Raelyn View Post
Ok, so I have inserted my baddy script into a class, if I wanted to place baddies on the map with the baddie class as their script, would I be able to do something like a weapon with a trigger and some sort of putnpc script referencing back to the class? How would I do that serverside? I want the baddie to be seen the same by all players... would putnpc work with a class?
If you want them to be dynamic (randomly placed), you should use a database NPC with something like the following

PHP Code:
function onCreated() {
  
// init vars
  
this.mapSize = {33}; // width, height in levels
  
this.classesToDrop = {"baddy"};
  
  
onTimeOut();
}
function 
onTimeOut() {
  
temp.tries 0;
  
  while (
tries ) {
    
temp.dpos = {random(0this.mapSize[0] * 64), random(0this.mapSize[1] * 64)};
    
    if (! 
onwall2(dpos[0] - 3dpos[1] - 366)) {
      
// should improve the above checks, it's just an example.
      
temp.classToJoin this.classesToDrop[int(random(0this.classesToDrop.size()))];
      
      
temp.drop putnpc2(dpos[0], dpos[1], "");
      
drop.join(classToJoin);
    }
    
tries ++;
  }
  
  
setTimer(360); // could also add a way to check how many baddies there are.

Otherwise, if you want them in static locations, just make a level NPC (with level editor) with this:

PHP Code:
join("baddy"); // or the other class 
__________________
Reply With Quote
  #73  
Old 04-30-2009, 11:56 PM
Raelyn Raelyn is offline
the Professional.
Raelyn's Avatar
Join Date: Sep 2003
Location: Zormite
Posts: 964
Raelyn will become famous soon enough
Quote:
Originally Posted by cbk1994 View Post
These wiki pages should help you a bit with your understanding of clientside/serverside:
http://wiki.graal.net/index.php/Clientside
http://wiki.graal.net/index.php/Serverside
http://www.graal.net/index.php/Creat...Starting_Guide
http://wiki.graal.net/index.php/Crea.../Script/Client (explains how to communicate between serverside and clientside)


What?

Not sure exactly, but Stefan said at several times not to, so that suggests to me that perhaps he checks what the script is in and decides how to parse it or something like that could be added later.

And yeah, GS1 just uglifies a beautiful script. GS2 is also considerably more efficient than GS1.

Haha yes, correct.

It doesn't, the only time the parser reads anything that starts with "//" is when it is //#CLIENTSIDE. The ones I placed after the join were just labels.

You should always use putnpc2 now anyway; just put the code in a class rather than a text file.

Only if you used 'client.' vars. You should always use clientr (or serverside player. vars) for storing sensitive information.

If you want them to be dynamic (randomly placed), you should use a database NPC with something like the following

PHP Code:
function onCreated() {
  
// init vars
  
this.mapSize = {33}; // width, height in levels
  
this.classesToDrop = {"baddy"};
  
  
onTimeOut();
}
function 
onTimeOut() {
  
temp.tries 0;
  
  while (
tries ) {
    
temp.dpos = {random(0this.mapSize[0] * 64), random(0this.mapSize[1] * 64)};
    
    if (! 
onwall2(dpos[0] - 3dpos[1] - 366)) {
      
// should improve the above checks, it's just an example.
      
temp.classToJoin this.classesToDrop[int(random(0this.classesToDrop.size()))];
      
      
temp.drop putnpc2(dpos[0], dpos[1], "");
      
drop.join(classToJoin);
    }
    
tries ++;
  }
  
  
setTimer(360); // could also add a way to check how many baddies there are.

Otherwise, if you want them in static locations, just make a level NPC (with level editor) with this:

PHP Code:
join("baddy"); // or the other class 
Ok, I used clientr. not sure why, but that's what I saw everyone else using so I thought it appropriate to follow suit, what is the difference between clientr. and player. ?

I will have to lookup putnpc2 since I have never used it.

Also, if I wanted to do something like a toggle, say:

PHP Code:
if (keypressed){
   if (
strequals()){
      if (
showimgIsAlreadyShown){
         
hideimg;
      } else {
         
showimg;
      }
   }

How would I detect if said image is shown already?
__________________
*Don't let the door hit you on the way out.*
Reply With Quote
  #74  
Old 05-01-2009, 12:35 AM
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 Raelyn View Post
Ok, I used clientr. not sure why, but that's what I saw everyone else using so I thought it appropriate to follow suit, what is the difference between clientr. and player. ?
clientr. can only be changed serverside, so you'll have to change your existing code. clientr. vars can be read clientside, though.

player.vars can be added serverside or clientside (and changed), but there are some disadvantages (and advantages).

For serverside, you can add a player.var. This is not synchronized with clientside. For example, "player.staffLevel = 4".

On clientside, you can use it for storing objects or something. However, they are cleared when the player logs off. You can do stuff like "player.equippedItem = this" for equipping standard weapons.

Quote:
I will have to lookup putnpc2 since I have never used it.
Just use it like

PHP Code:
putnpc2(xyscript);

// You can also do

putnpc2(3232"join block;");

// but that's GS1 and poor scripting
// instead, you can use GS2

putnpc2(3232"join(\"block\");");

// but that's a mess and hard to read
// which is why I prefer to do

temp.npc putnpc2(3232"");
npc.join("block");

// and it's also easier to set attributes this way, such as

npc.spawned true
Quote:
Also, if I wanted to do something like a toggle, say:

PHP Code:
if (keypressed){
   if (
strequals()){
      if (
showimgIsAlreadyShown){
         
hideimg;
      } else {
         
showimg;
      }
   }

How would I detect if said image is shown already?
Try this:

PHP Code:
function onKeyPressed(codekeychar) {
  if (
key == "p") {
    
temp.img findImg(200);
    
img.visible = ! img.visible;
  }

__________________
Reply With Quote
  #75  
Old 05-01-2009, 01:00 AM
Raelyn Raelyn is offline
the Professional.
Raelyn's Avatar
Join Date: Sep 2003
Location: Zormite
Posts: 964
Raelyn will become famous soon enough
Quote:
Originally Posted by cbk1994 View Post
clientr. can only be changed serverside, so you'll have to change your existing code. clientr. vars can be read clientside, though.

player.vars can be added serverside or clientside (and changed), but there are some disadvantages (and advantages).

For serverside, you can add a player.var. This is not synchronized with clientside. For example, "player.staffLevel = 4".

On clientside, you can use it for storing objects or something. However, they are cleared when the player logs off. You can do stuff like "player.equippedItem = this" for equipping standard weapons.


Just use it like

PHP Code:
putnpc2(xyscript);

// You can also do

putnpc2(3232"join block;");

// but that's GS1 and poor scripting
// instead, you can use GS2

putnpc2(3232"join(\"block\");");

// but that's a mess and hard to read
// which is why I prefer to do

temp.npc putnpc2(3232"");
npc.join("block");

// and it's also easier to set attributes this way, such as

npc.spawned true

Try this:

PHP Code:
function onKeyPressed(codekeychar) {
  if (
key == "p") {
    
temp.img findImg(200);
    
img.visible = ! img.visible;
  }

Awesome.

Another thing, I was under the impression that variable type is automatically detected, but it seems like setting a variable to a string of text doesn't work?

Trying to do something like this:

PHP Code:
clientr.weapon_img weaponname.png;

if (
trigger){
   
showimg index,clientr.weapon_img,,,;

Also, I tried using:

PHP Code:
function onKeyPressed(codekeychar) {
  if (
key == "p") {
    
temp.img findImg(200);
    
img.visible = ! img.visible;
  }

Not sure how to implement this, as a function, isn't it redundant to do this?:

PHP Code:
if (keypressed){
  
onKeyPressed(,p,);

Hrrm, am I doing this properly?


Doesn't this work?

PHP Code:
showimg 200,imagename.png,,,;
hideimg 200;

if (
keypressed) {
  if (
strequals(#p(1),p)) {
    
temp.img findImg(200);
    
img.visible = ! img.visible;
  }

__________________
*Don't let the door hit you on the way out.*

Last edited by Raelyn; 05-01-2009 at 01:29 AM.. Reason: Ohsnap, another edit.
Reply With Quote
  #76  
Old 05-01-2009, 01:53 AM
Raelyn Raelyn is offline
the Professional.
Raelyn's Avatar
Join Date: Sep 2003
Location: Zormite
Posts: 964
Raelyn will become famous soon enough
Ugh, I don't know how else to do this.

I want the weapon icon to be displayed dependant on the type of weapon equipped, so..

PHP Code:

if (clientr.weapon 0001;){
   
clientr.weapon_img weaponicon.png;
}

showimg indexclientr.weapon_img,,,; 
I would assume this would basically do the same as:

PHP Code:
showimg indexweaponicon.png,,,; 
but it's not doing that at all, I'm confused...
__________________
*Don't let the door hit you on the way out.*
Reply With Quote
  #77  
Old 05-01-2009, 02:00 AM
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 Raelyn View Post
Awesome.

Another thing, I was under the impression that variable type is automatically detected, but it seems like setting a variable to a string of text doesn't work?

Trying to do something like this:

PHP Code:
clientr.weapon_img weaponname.png;

if (
trigger){
   
showimg index,clientr.weapon_img,,,;

Use:

PHP Code:
clientr.weapon_img "weaponname.png"
for strings

Quote:
Also, I tried using:

PHP Code:
function onKeyPressed(codekeychar) {
  if (
key == "p") {
    
temp.img findImg(200);
    
img.visible = ! img.visible;
  }

Not sure how to implement this, as a function, isn't it redundant to do this?:

PHP Code:
if (keypressed){
  
onKeyPressed(,p,);

onKeyPressed is called on default. Basically all of the event if's were converted to "function onEvent", such as "onPlayerTouchsMe", "onCreated", and "onPlayerEnters". There's no need for the if (keypressed) statement.

Quote:
Hrrm, am I doing this properly?


Doesn't this work?

PHP Code:
showimg 200,imagename.png,,,;
hideimg 200;

if (
keypressed) {
  if (
strequals(#p(1),p)) {
    
temp.img findImg(200);
    
img.visible = ! img.visible;
  }

hideimg might be actually destroying the image (actually, I'm pretty sure it does). Just hide it with findImg().visible. And, I don't think showimg has that many paramaters.

Plus.... you're combining GS1 and GS2 in a horrible way

Quote:
Originally Posted by Raelyn View Post
Ugh, I don't know how else to do this.

I want the weapon icon to be displayed dependant on the type of weapon equipped, so..

PHP Code:

if (clientr.weapon 0001;){
   
clientr.weapon_img weaponicon.png;
}

showimg indexclientr.weapon_img,,,; 
Something like this I guess...

PHP Code:
//#CLIENTSIDE
function onCreated() {
  
this.wep_type.sword "sword.png";
}
function 
displayImage() {
  
showimg(200getImageForType(clientr.weaponType), 00);
}
function 
getImageForType(wep) {
  return 
this.wep_type.(@ wep);

and just set clientr.weaponType or another variable when you change the player's weapon. Also, there's really no reason to use clientr. for a weapon image.

And, I'm pretty sure you're adding an extra parameter to showimg almost everywhere. Press F2 and click on "Scripts", it may be giving an error.
__________________
Reply With Quote
  #78  
Old 05-01-2009, 02:43 AM
Raelyn Raelyn is offline
the Professional.
Raelyn's Avatar
Join Date: Sep 2003
Location: Zormite
Posts: 964
Raelyn will become famous soon enough
Quote:
Originally Posted by cbk1994 View Post
Use:

PHP Code:
clientr.weapon_img "weaponname.png"
for strings


onKeyPressed is called on default. Basically all of the event if's were converted to "function onEvent", such as "onPlayerTouchsMe", "onCreated", and "onPlayerEnters". There's no need for the if (keypressed) statement.



hideimg might be actually destroying the image (actually, I'm pretty sure it does). Just hide it with findImg().visible. And, I don't think showimg has that many paramaters.

Plus.... you're combining GS1 and GS2 in a horrible way


Something like this I guess...

PHP Code:
//#CLIENTSIDE
function onCreated() {
  
this.wep_type.sword "sword.png";
}
function 
displayImage() {
  
showimg(200getImageForType(clientr.weaponType), 00);
}
function 
getImageForType(wep) {
  return 
this.wep_type.(@ wep);

and just set clientr.weaponType or another variable when you change the player's weapon. Also, there's really no reason to use clientr. for a weapon image.

And, I'm pretty sure you're adding an extra parameter to showimg almost everywhere. Press F2 and click on "Scripts", it may be giving an error.
Ahh thanks. And yea, I am not adding an extra parameter in the actual scripts, just mashing the comma here to represent that parameters DO follow.

Quote:
Originally Posted by cbk1994 View Post
Use:

PHP Code:
clientr.weapon_img "weaponname.png"
for strings
I did this:

PHP Code:
clientr.weapon_img "raelyn_sword.png";

if (
trigger){
  
showimg index,clientr.weapon_img,x,y;

Still not producing an image.

Edit: Bah, I got it to work with #s.

*slap forehead*
__________________
*Don't let the door hit you on the way out.*

Last edited by Raelyn; 05-01-2009 at 02:49 AM.. Reason: Doh!
Reply With Quote
  #79  
Old 05-01-2009, 03:53 AM
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 use GS2 now! Don't be a slave to GS1 conventions.

PHP Code:
function onTrigger() {
  
with (findimg(index)) {
     
image clientr.weapon_img;
     
thiso.x;
     
thiso.y;
  }

__________________
Quote:
Reply With Quote
  #80  
Old 05-01-2009, 04:30 AM
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 Raelyn View Post
Ahh thanks. And yea, I am not adding an extra parameter in the actual scripts, just mashing the comma here to represent that parameters DO follow.



I did this:

PHP Code:
clientr.weapon_img "raelyn_sword.png";

if (
trigger){
  
showimg index,clientr.weapon_img,x,y;

Still not producing an image.

Edit: Bah, I got it to work with #s.

*slap forehead*
GS1 requires that you use the string 'function' for strings to work, which is major failure.

PHP Code:
showimg(200clientr.weapon_img3030); 
You can't expect GS2 to work if you don't use it correctly.
__________________
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 05:01 PM.


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