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 09-30-2010, 06:13 AM
khortez khortez is offline
PrototypeX
khortez's Avatar
Join Date: Dec 2008
Posts: 91
khortez will become famous soon enough
onMouseDown() not working, help?

Tried doing:

PHP Code:
function onMouseDown(button){
if(
button == "left")
triggerserver("gui"name"block"temp.xtemp.y);

but it doesn't work when i do it that way. it only works if i keep it the way it is below. someone mind telling how i can fix that? any help appreciated.



PHP Code:
function onActionServerSide(){
  if (
params[0] == "block"
    
temp.putnpc2(params[1], params[2], "");
   
temp.p.join("personal_khortez_block");
  }









//#CLIENTSIDE
function onKeyPressed(codekey){
if(
key == "z"){

this.on = !this.on;

if(
this.on){
settimer(0.05);
player.chat "Blocks on!";
}

else {

player.chat "Blocks off!";
}
  }
    } 
   




function 
onTimeOut(){
temp.int(mousex);
temp.int(mousey);
 
  if (
this.on){ 
    
    
showimg(1"cega_staffblock2-frozenlies0.png"temp.xtemp.y);
    
showtext(2temp.x+2temp.y+0.5"Palatino Linotype""i"player.nick);
    
    
changeimgcolors(11110.5);
    
    if(
leftmousebutton){
    
triggerserver("gui"name"block"temp.xtemp.y);
    }
    
    
setTimer0.05 );
   }
   
   else{ 
    
hideimgs2);
  
}
 } 
Reply With Quote
  #2  
Old 09-30-2010, 06:16 AM
Tigairius Tigairius is offline
The Cat
Tigairius's Avatar
Join Date: Jan 2007
Location: Missouri, USA
Posts: 4,240
Tigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant future
In your function, temp.x and temp.y is not defined. Try using mousex and mousey.
__________________


“Shoot for the moon. Even if you miss, you'll land among the stars.”
Reply With Quote
  #3  
Old 09-30-2010, 06:20 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
Have you tried seeing if button is actually "left"

I.e:
PHP Code:
//#CLIENTSIDE
function onMouseDown(button) {
  
player.chat "Param: " button;

I have memories of onMouseDown being only for left-clicks, so having logic button == "left" logic like that might not even be needed at all.
__________________
Quote:
Reply With Quote
  #4  
Old 09-30-2010, 06:21 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 fowlplay4 View Post
Have you tried seeing if button is actually "left"

I.e:
PHP Code:
//#CLIENTSIDE
function onMouseDown(button) {
  
player.chat "Param: " button;

I have memories of onMouseDown being only for left-clicks, so having logic button == "left" logic like that might not even be needed at all.
onMouseDown is for all buttons (if I recall correctly—fairly sure it is).
__________________
Reply With Quote
  #5  
Old 09-30-2010, 06:27 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
Oh well according to documentation for GUI Controls:

onMouseDown(keymodifier,mousescreenx,mousescreeny, clickcount) - the left mouse button has been pressed inside this control
http://wiki.graal.net/index.php/Crea...ent/GuiControl

but I guess this is one of those Graal being Graal things.
__________________
Quote:
Reply With Quote
  #6  
Old 09-30-2010, 06:38 AM
khortez khortez is offline
PrototypeX
khortez's Avatar
Join Date: Dec 2008
Posts: 91
khortez will become famous soon enough
thanks guys, tig was right. it was defined in another function but not in Mousedown()
Reply With Quote
  #7  
Old 09-30-2010, 04:52 PM
Crow Crow is offline
ǝɔɐɹq ʎןɹnɔ
Crow's Avatar
Join Date: Dec 2006
Location: Germany
Posts: 5,153
Crow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond repute
Quote:
Originally Posted by fowlplay4 View Post
but I guess this is one of those Graal being Graal things.
Kinda. It only applies to GUI controls. The regular onMouseDown() event features all other mouse buttons as well.
Reply With Quote
  #8  
Old 09-30-2010, 11:18 PM
khortez khortez is offline
PrototypeX
khortez's Avatar
Join Date: Dec 2008
Posts: 91
khortez will become famous soon enough
Okay so to avoid making posts, ill ask here. if i have to ill make a new thread but for now, to the point...

destroy(); for some reason is constantly deleting the weapon out of my inventory.... at least i believe it is. Why? and when i use it to delete the blocks i have placed, it doesnt delete them permanently. they show up again when i reconnect.

also id like to know what triggeraction means.
Reply With Quote
  #9  
Old 09-30-2010, 11:51 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
destroy() destroys the object that calls it, which is why it gets removed from your inventory.

triggeraction, sends a trigger to the x, y, with an action, and parameters. Honestly though just search the forums for triggerserver or triggeraction. There's plenty of examples out there that show how it works.

Tip: Search the forums for the answers, unless your question is completely specific to a situation you'll probably be able to find a solid answer.
__________________
Quote:
Reply With Quote
  #10  
Old 10-01-2010, 01:00 AM
khortez khortez is offline
PrototypeX
khortez's Avatar
Join Date: Dec 2008
Posts: 91
khortez will become famous soon enough
Thanks, i figured id go ahead and ask since i wanted to know why destroy(); was deleting my weapon. still i wonder why it wont delete the blocks i lay down permanently, it looks like their deleted on my screen until i reconnect.

oh and i know about triggerserver, saw chris vimes explain it to someone else on these forums. triggeraction i saw too but it wasnt explained, so it was fairly new to me
Reply With Quote
  #11  
Old 10-01-2010, 09:13 PM
DrakilorP2P DrakilorP2P is offline
Registered User
DrakilorP2P's Avatar
Join Date: Apr 2006
Posts: 755
DrakilorP2P is just really niceDrakilorP2P is just really nice
Quote:
Originally Posted by khortez View Post
and when i use it to delete the blocks i have placed, it doesnt delete them permanently. they show up again when i reconnect.
The blocks are only being deleted clientside and will remain serverside. You have to do the destroy()ing in the serverside part of the code.
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 11:08 PM.


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