Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   joining classes (https://forums.graalonline.com/forums/showthread.php?t=63028)

excaliber7388 12-27-2005 07:41 PM

joining classes
 
for some reason i can't join classes with this script (all names are correct, and the action is being called but none of the classes, even the ones that worked before, can be called like this anymore):
NPC Code:

if(actionserverside){
if(strequals(#p(0),lay)){
putnpc2 mousex,mousey,{join force field};
}
}
//#CLIENTSIDE

if(weaponfired || mousedown){
triggeraction 0,0,serverside,mousetest,lay;
}


ApothiX 12-27-2005 09:24 PM

Take out the space, rename the class to have an _, or use the new engine with quotes, join("force field");

either that, or it may have a problem with the mouse variables, because I don't think those are accessible serverside. Try sending them as parameters and use strtofloat(#p(2)) or whatever.

ZeLpH_MyStiK 12-27-2005 09:40 PM

Quote:

Originally Posted by ApothiX
Take out the space, rename the class to have an _, or use the new engine with quotes, join("force field");

either that, or it may have a problem with the mouse variables, because I don't think those are accessible serverside. Try sending them as parameters and use strtofloat(#p(2)) or whatever.

T'is true wisdom. I've actually never seen someone use space in a classname, not sure if it works. And mouse coordinates can't be read serverside.

excaliber7388 12-27-2005 10:02 PM

actually, none of the classes work, not even the graalats one X_X

ApothiX 12-27-2005 10:15 PM

Quote:

Originally Posted by excaliber7388
actually, none of the classes work, not even the graalats one X_X

:x I don't think you should really be joining the gralats class anyway.

Skyld 12-27-2005 11:13 PM

mousex and mousey are not available on the serverside. You will probably find that you are placing the NPCs, but on coordinates (0, 0) instead of your desired coordinates.

Inverness 12-28-2005 03:32 PM

When using quotes within quotes in GS2, you will need to put a back-slash before the quote that will be read as inside the string, a thanks to Malinko for pointing this fact out for me:
PHP Code:

putnpc2(player.0.5 vecx(player.dir),player.vecy(player.dir),"join(\"mud_item\");"); 

And since mousex and mousey are clientside-only you would just need to send them with the trigger.

ApothiX 12-28-2005 07:31 PM

Quote:

Originally Posted by Inverness
you will need to put a back-slash before the quote that will be read as inside the string

'tis called escaping the character :)

excaliber7388 12-29-2005 03:05 AM

nope, none of that works X_X none of the classes work, even the ones that worked before. And how do i send mousex and y with the trigger :confused:

ZeLpH_MyStiK 12-29-2005 12:38 PM

Quote:

Originally Posted by excaliber7388
nope, none of that works X_X none of the classes work, even the ones that worked before. And how do i send mousex and y with the trigger :confused:

Quote:

Originally Posted by ApothiX
Try sending them as parameters and use strtofloat(#p(2)) or whatever.

Try reading...

xAndrewx 12-29-2005 01:05 PM

add mousex/y to the triggeraction. Read the mousex/y from the triggeraction.

Skyld 12-29-2005 01:16 PM

This is your 23rd thread in the NPC Scripting forums that I have counted asking for help, and still, you do not read what people say. This annoys me, and others, so please learn to read what is said when people try to help.

What ApothiX says is correct. Add your parameters to the triggeraction (#v(mousex) and #v(mousey)). For example.
PHP Code:

triggeraction 0,0,serverside,MyWeapon,place,#v(mousex),#v(mousey); 

... and read them on the serverside using strtofloat(#p()). For example.
PHP Code:

if (actionserverside)
{
  if (
strequals(#p(0),place))
  
{
    
putnpc2 strtofloat(#p(1)),strtofloat(#p(2)),join classname;
  
}



Codein 12-29-2005 01:31 PM

I would have thought anyone would know mouse coordinates can only be read clientside :P

And you SHOULD be using/learning GS2 :P

Inverness 12-29-2005 05:04 PM

Quote:

Originally Posted by ApothiX
'tis called escaping the character :)

Hmm... I like it!

ApothiX 12-29-2005 07:30 PM

Quote:

Originally Posted by Codein
And you SHOULD be using/learning GS2 :P

Not all servers have the new engine enabled on them.

Quote:

Originally Posted by Inverness
Hmm... I like it!

It's like the quote is escaping from jail!

excaliber7388 12-30-2005 12:48 AM

here's the script im using, still will not work X_X probably something stupid....as usual
NPC Code:
if(actionserverside)
{
if(strequals(#p(0),mp))
{
playermp=playermp-1;
}
if(strequals(#p(0),mp2))
{
playermp=playermp+1;
}
if(strequals(#p(0),join))
{
putnpc2,strtofloat(#p(1)),strtofloat(#p(2)),{join force_field;};
}
}
//#CLIENTSIDE
if(mousedown && this.inuse==0 && strequals(#w,Force Field))
{
this.inuse=1;
timeout=.05;
}
else if(mousedown && this.inuse==1)
{
this.inuse=0;
timeout=0;
}
if(timeout && playermp>0 && this.used==0)
{
this.i=this.i+1;
showimg this.i,watermateria.png,mousex,mousey;
changeimgcolors this.i,.5,.75,1,.8;
triggeraction 0,0,serverside,Force Field,mp;
triggeraction 0,0,serverside,Force Field,join,#v(mousex),#v(mousey);
timeout=.05;
}
if(timeout && playermp>0 && this.used==1)
{
this.i=0;
this.used=0;
timeout=.05;
}
if(timeout && playermp=0)
{
this.inuse=0;
sleep 5;
for(this.o=0;this.o<this.i+1;this.o++)
{
hideimg this.o;
triggeraction 0,0,serverside,Force Field,mp2;
sleep .5;
}
timeout=0;
this.used=1;
this.i=0;
}
if(weaponfired)
{
say2 Press the mouse button#b
down when you are at the place#b
you would like to start the #b
force field, press it again to #b
stop;
}


....and the class:
NPC Code:

if(actionserverside)
{
if(strequals(#p(0),destroy))
{
destroy;
}
}
//#CLIENTSIDE
if(created)
{
setimg watermateria.png;
setshape 1,16,16;
blockagain;
timeout=5;
}
if(playertouchsme)
{
hurt 1;
}
if(timeout)
{
triggeraction 0,0,serverside,force_field,destroy;
}


Skyld 12-30-2005 12:51 AM

DO YOU NOT LEARN?

Follow these guidelines, specifically B.2.2, B.2.4 and C.1.

Edit: In fact, all of them.

excaliber7388 12-30-2005 01:00 AM

umm...rules were made to be broken? x_x sorry...but what would a scripting post from me be without poorly formatted scripts? anyway i fixed it... a little.

Skyld 12-30-2005 01:10 AM

Quote:

Originally Posted by excaliber7388
umm...rules were made to be broken?

Drop the stupid philosophy and help yourself already.
Quote:

Originally Posted by excaliber7388
x_x sorry...but what would a scripting post from me be without poorly formatted scripts?

It would be absolutely wonderful!
Quote:

Originally Posted by excaliber7388
anyway i fixed it... a little.

Posting bad code is unhelpful and annoying, and it makes it harder to find problems. I do not wish to be horrible, but seriously. This is well over your 20th "help me" thread and it still has not sunk in!

Yen 12-30-2005 01:16 AM

Skyld needs a hug. ;_;

-Hugs Skyld.-

Riot 12-30-2005 02:41 AM

Quote:

Originally Posted by excaliber7388
here's the script im using, still will not work X_X probably something stupid....as usual

Try this for starters:

In the weapon
  • Make your code easier to read, and more organized, such as doing:
    HTML Code:

    if (mousedown)
    {
      if (this.inuse == 0)
      {
        if (strequals(#w,Force Field))
        {
          this.inuse = 1;
          timeout = 0.05;
        }
      }
      else
      {
        this.inuse = 0;
        timeout = 0;
      }
    }

  • Don't use sleeps in a timeout (or even at all)
  • Your timeouts should be put together (like I did above with the mousedown)
  • I do not recommend doing a triggeraction to the server in any fast-moving timeout, it can (and probaby will) cause a decent amount of lag!

In the class
  • triggeractions do not work that way in classes
  • It would be better to just set the 5 second timeout on the serverside end, and just do if (timeout) destroy; instead of relying on the client to send a triggeraction

excaliber7388 12-30-2005 02:44 AM

ah skyld, you're never horrible ;) anyway, i'll try some of that, thanks. i guess the lag would explain why it returns more MP than it uses x_x

ApothiX 12-30-2005 10:52 AM

Quote:

Originally Posted by Skyld
This is well over your 20th "help me" thread and it still has not sunk in!

I think a 'temporary' block from accessing the Scripting Forums would help him greatly ;)

excaliber7388 12-30-2005 07:23 PM

ha ha asking questions is the best way to learn ;) and i'm working on that formating XD however, even after taking some of the advice here, the script still will not join the class x_x

Lance 12-30-2005 08:46 PM

Quote:

Originally Posted by excaliber7388
ha ha asking questions is the best way to learn ;) and i'm working on that formating XD however, even after taking some of the advice here, the script still will not join the class x_x

That would be because you have a comma after 'putnpc2' instead of a space.

ZeLpH_MyStiK 12-30-2005 08:55 PM

You do know that if you keep posting scripts on the forum intended for Dark Rival use, everyone in the world would gain knowledge of every script on the server...
*lawl*

ApothiX 12-30-2005 09:48 PM

Quote:

Originally Posted by ZeLpH_MyStiK
You do know that if you keep posting scripts on the forum intended for Dark Rival use, everyone in the world would gain knowledge of every script on the server...
*lawl*

And no one will want to play it, because they will then realise how poorly scripted it was.

excaliber7388 12-30-2005 10:03 PM

the scripts are improved after i post here, these aren't full scripts ;)

Skyld 12-30-2005 10:17 PM

Quote:

Originally Posted by excaliber7388
the scripts are improved after i post here, these aren't full scripts ;)

The fact is that we do not want you to post full scripts here and say "HEY FIX THIS". We want you to learn.

You need to apply some common sense, look at your script, identify and analyse the problem. Think it through. Why is this happening? What's causing this? What's surrounding this that could cause a problem? Read it all through. Ask yourself sensible questions before posting only the relevant code.

You do have a terrible habit of demanding we fix things for you.

If all else fails, go and hire a scripter that knows what they are doing.

ApothiX 12-31-2005 03:45 AM

Quote:

Originally Posted by Skyld
If all else fails, go and hire a scripter that knows what they are doing.

Amen.

excaliber7388 12-31-2005 04:37 AM

i really don't demand fixing, just an explanation of what i did wrong so i can learn it :| srry guys


All times are GMT +2. The time now is 09:21 AM.

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