Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   onMouseDown() not working, help? (https://forums.graalonline.com/forums/showthread.php?t=134260669)

khortez 09-30-2010 06:13 AM

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);
  
}
 } 


Tigairius 09-30-2010 06:16 AM

In your function, temp.x and temp.y is not defined. Try using mousex and mousey.

fowlplay4 09-30-2010 06:20 AM

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.

cbk1994 09-30-2010 06:21 AM

Quote:

Originally Posted by fowlplay4 (Post 1603170)
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).

fowlplay4 09-30-2010 06:27 AM

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.

khortez 09-30-2010 06:38 AM

thanks guys, tig was right. it was defined in another function but not in Mousedown()

Crow 09-30-2010 04:52 PM

Quote:

Originally Posted by fowlplay4 (Post 1603173)
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.

khortez 09-30-2010 11:18 PM

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.

fowlplay4 09-30-2010 11:51 PM

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.

khortez 10-01-2010 01:00 AM

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

DrakilorP2P 10-01-2010 09:13 PM

Quote:

Originally Posted by khortez (Post 1603302)
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.


All times are GMT +2. The time now is 01:58 AM.

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