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
  #1  
Old 06-24-2006, 12:28 AM
Darkyoshi12345 Darkyoshi12345 is offline
Darky
Join Date: Jun 2006
Posts: 153
Darkyoshi12345 is on a distinguished road
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;
}

Reply With Quote
  #2  
Old 06-24-2006, 12:31 AM
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
Put //#CLIENTSIDE at the top. Also, isn't leftmousebutton an event of it's own?
Reply With Quote
  #3  
Old 06-24-2006, 12:38 AM
Darkyoshi12345 Darkyoshi12345 is offline
Darky
Join Date: Jun 2006
Posts: 153
Darkyoshi12345 is on a distinguished road
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.
Reply With Quote
  #4  
Old 06-24-2006, 07:37 AM
ApothiX ApothiX is offline
Okiesmokie
Join Date: May 2004
Posts: 1,447
ApothiX is on a distinguished road
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.
__________________


[06:24:19] * Parts: Skyld (i=silent@unaffiliated/skyld) ("Perhaps Okiesmokie did not realise that I like the boys. ")
Reply With Quote
  #5  
Old 06-24-2006, 05:51 PM
calani calani is offline
Scriptess
calani's Avatar
Join Date: Aug 2003
Location: asmgarden.gmap
Posts: 606
calani is on a distinguished road
Send a message via AIM to calani
leftmousebutton is a flag
__________________
Reply With Quote
  #6  
Old 06-24-2006, 07:00 PM
JustBreathe JustBreathe is offline
Registered User
Join Date: Jun 2006
Posts: 59
JustBreathe is on a distinguished road
PHP Code:
//#CLIENTSIDE
function onMouseDown()
  {
  if ( 
leftmousebutton )
    
putbomb1mousexmousey);
  } 
Reply With Quote
  #7  
Old 06-25-2006, 12:04 PM
Admins Admins is offline
Graal Administration
Join Date: Jan 2000
Location: Admins
Posts: 11,693
Admins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud of
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
Reply With Quote
  #8  
Old 06-25-2006, 12:16 PM
contiga contiga is offline
Graal2001 Administration
contiga's Avatar
Join Date: Jul 2004
Location: Netherlands
Posts: 419
contiga is an unknown quantity at this point
Send a message via ICQ to contiga Send a message via AIM to contiga Send a message via MSN to contiga Send a message via Yahoo to contiga
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);

__________________
AIM: Contiga122
MSN: [email protected]
Status:
Quote:
Originally Posted by unixmad View Post
I am also awake 3AM to help correct problems.
Quote:
Originally Posted by Bomy Island RC people
Daniel: HoudiniMan is a bad guy =p
*Bell: rofl. I first read that as houdini is a bad man. like the little kid that wants his mommy to keep her away from that boogie man
Daniel: xD
*Rufus: I wouldn't want my kids around him.
Reply With Quote
  #9  
Old 06-25-2006, 12:22 PM
JustBreathe JustBreathe is offline
Registered User
Join Date: Jun 2006
Posts: 59
JustBreathe is on a distinguished road
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!
Reply With Quote
  #10  
Old 06-25-2006, 12:26 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 contiga
Then you could activate it with any mouse button.. (left, right, middle, etc)
Make a function onAnyMouseButton() or so.
__________________
Skyld
Reply With Quote
  #11  
Old 06-25-2006, 07:20 PM
Gambet Gambet is offline
Registered User
Join Date: Oct 2003
Posts: 2,712
Gambet is on a distinguished road
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.
Reply With Quote
  #12  
Old 06-26-2006, 01:13 AM
ApothiX ApothiX is offline
Okiesmokie
Join Date: May 2004
Posts: 1,447
ApothiX is on a distinguished road
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.
__________________


[06:24:19] * Parts: Skyld (i=silent@unaffiliated/skyld) ("Perhaps Okiesmokie did not realise that I like the boys. ")
Reply With Quote
  #13  
Old 06-26-2006, 01:44 AM
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 ApothiX
From the wiki:

It's a variable.
'flag' is old engine speak for boolean variable.
__________________
Skyld
Reply With Quote
  #14  
Old 06-26-2006, 04:27 AM
calani calani is offline
Scriptess
calani's Avatar
Join Date: Aug 2003
Location: asmgarden.gmap
Posts: 606
calani is on a distinguished road
Send a message via AIM to calani
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.
__________________
Reply With Quote
  #15  
Old 06-26-2006, 10:01 AM
ApothiX ApothiX is offline
Okiesmokie
Join Date: May 2004
Posts: 1,447
ApothiX is on a distinguished road
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.
__________________


[06:24:19] * Parts: Skyld (i=silent@unaffiliated/skyld) ("Perhaps Okiesmokie did not realise that I like the boys. ")
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 12:05 AM.


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