Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Script Working Offline, Inaffective Online (https://forums.graalonline.com/forums/showthread.php?t=66868)

Darkyoshi12345 06-24-2006 12:28 AM

Script Working Offline, Inaffective Online
 
Yes, I know, this small sample script is simple and pointless (Particularly for an event), but what shall I do to make it work online? I'm quite a bit of a newbie at scripting, but I used to be able to back in the day.

NPC Code:

//Mouse Bomber
if (mousedown && leftmousebutton) {
putbomb 1,mousex,mousey;
}


Skyld 06-24-2006 12:31 AM

Put //#CLIENTSIDE at the top. Also, isn't leftmousebutton an event of it's own?

Darkyoshi12345 06-24-2006 12:38 AM

Quote:

Originally Posted by Skyld
Put //#CLIENTSIDE at the top. Also, isn't leftmousebutton an event of it's own?

Thanks. and "leftmousebutton" command is to make sure that theplayer has the leftmouse button. Mousedown will enable both right and left mouse buttons, but "Leftmousebutton" doesn't count as a click event.

ApothiX 06-24-2006 07:37 AM

Quote:

Originally Posted by Skyld
Put //#CLIENTSIDE at the top. Also, isn't leftmousebutton an event of it's own?

leftmousebutton is a variable I believe, set to true if the left mouse button is down and false if it's not.

calani 06-24-2006 05:51 PM

leftmousebutton is a flag ;)

JustBreathe 06-24-2006 07:00 PM

PHP Code:

//#CLIENTSIDE
function onMouseDown()
  {
  if ( 
leftmousebutton )
    
putbomb1mousexmousey);
  } 


Admins 06-25-2006 12:04 PM

The 'leftmousebutton' variable might not be set anymore at the time the script is run though, so if people click fast then it might not work.
So either do (in old script):
PHP Code:

//#CLIENTSIDE
if (mousedown && strequals(#p(0),left)) {
  
putbomb 1,mousex,mousey;


or (new scripting):
PHP Code:

//#CLIENTSIDE
function onMouseDown() {
  
putbomb 1,mousex,mousey;


The onMouseDown event is only invoked on left mouse click, there is also onRightMouseDown for the right mouse button, may be should add some onMiddleMouseDown too.
http://wiki.graal.net/index.php/Crea...ent/GuiControl

contiga 06-25-2006 12:16 PM

Quote:

PHP Code:

//#CLIENTSIDE 
function onMouseDown() { 
  
putbomb 1,mousex,mousey



Then you could activate it with any mouse button.. (left, right, middle, etc);

PHP Code:

//#CLIENTSIDE
function onMouseDown(button) {
  if (
button "left"
    
putbomb(1,mousex,mousey);



JustBreathe 06-25-2006 12:22 PM

Quote:

Originally Posted by contiga
Then you could activate it with any mouse button.. (left, right, middle, etc);

PHP Code:

//#CLIENTSIDE
function onMouseDown(button) {
  if (
button "left"
    
putbomb(1,mousex,mousey);



I vote for button as param!

PHP Code:

function onMouseDown()
  {
  if ( 
params.size() < )
    return 
onMouseDown"left" );
  }

function 
onRightMouseDown()
  {
  
this.trigger("MouseDown""right" );
  }

function 
onMiddleMouseDown()
  {
  
this.trigger("MouseDown""middle" );
  } 

for the win!

Skyld 06-25-2006 12:26 PM

Quote:

Originally Posted by contiga
Then you could activate it with any mouse button.. (left, right, middle, etc)

Make a function onAnyMouseButton() or so.

Gambet 06-25-2006 07:20 PM

What? I've always done..

NPC Code:

//#CLIENTSIDE
function onMouseDown()
{
if ( params[0] == "left" ) {
player.chat = "You have just left clicked!";
} else if ( params[0] == "right" ) {
player.chat = "You have just right clicked!";
} else if ( params[0] == "double" ) {
player.chat = "You have just double clicked!";
} else if ( params[0] == "middle" ) {
player.chat = "You have just clicked on your mouse wheel!";
}
}




..and it's always worked fine for me.

ApothiX 06-26-2006 01:13 AM

Quote:

Originally Posted by calani
leftmousebutton is a flag ;)

From the wiki:
Quote:

Originally Posted by wiki.graal.net
leftmousebutton - boolean (read only)

It's a variable.

Skyld 06-26-2006 01:44 AM

Quote:

Originally Posted by ApothiX
From the wiki:

It's a variable.

'flag' is old engine speak for boolean variable.

calani 06-26-2006 04:27 AM

what i mean by the term 'flag':
any var that is a bool
usually set by the engine
also usually read-only, but not always

some examples include
mousebuttons
player carying bush/bluerock/blackrock/sign etc
if the player has spin
if the player is male
etc.

ApothiX 06-26-2006 10:01 AM

In the old engine, the events were called flags, and that is what I thought you meant. I don't see why you attempted to correct me if we were both refering to the same thing.


All times are GMT +2. The time now is 08:07 PM.

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