Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Triggering Variables in other Weapons (https://forums.graalonline.com/forums/showthread.php?t=134267554)

greggiles 12-13-2012 09:40 PM

Triggering Variables in other Weapons
 
I am making a custom attack system and I swear I tested this before and it worked.

On my Movement 'weapon' I set a variable --- canmove = 1;
Pretty much this checks to see if the player is allowed to move

On my Attack 'weapon' the "canmove" is set to 0. Works

THEN I have a ScheduleEvent function that sets the 'canmove' to 1 again...but it doesn't set.

PHP Code:

//MOVEMENT SNIPPET
//#CLIENTSIDE
function onCreated()
{
 
canatk 1;
 
canmove 1;
 
canjump 1;
 
disabledefmovement();
 
onTimeOut();


PHP Code:

//TEST WEAPON TO SET VARIABLES
//#CLIENTSIDE
function onKeyPressed(codekey)
{
 if (
key == "v")
 {
  
setAni("sword"NULL);
  
canmove 0;
  
scheduleEvent(1"onUnfreeze");
  }
  }
  
function 
onUnfreeze(){
player.chat "unfreeze";
client.canmove 1;


Like I said, it will set it to 0, but wont return it to 1

fowlplay4 12-13-2012 10:09 PM

Tip: Don't use variables in multiple scripts. Use public functions instead:

Weapon: -Movement

PHP Code:

//#CLIENTSIDE

public function enableMovement() {
  
this.canmove true;
}

public function 
disableMovement() {
  
this.canmove false;
}

// use this.canmove in your system 

then in your weapons:

PHP Code:

//#CLIENTSIDE
function onKeyPressed(codekey) {
  if (
key == "v") {
    (
"-Movement").disableMovement();
    
setani("sword""");
    
sleep(1);
    (
"-Movement").enableMovement();
  }



cbk1994 12-13-2012 10:14 PM

EDIT: Jer's response is right—I didn't pay attention to the variables—but if you want to support v5, keep the below in mind too.

Are you using v6? The only thing I see is that the scheduleEvent needs another parameter to support v5 and below. Functions like trigger, scheduleEvent, etc. all require an extra parameter for passing data, even if you don't want to use it. So just add another parameter (null will work fine) to the scheduleevent:

PHP Code:

scheduleEvent(1"onUnFreeze"null); 

edit 2: on second reading it's clear the variables are at least part of the problem. You're using "canmove" in some cases and "client.canmove" in others. If you change them all to "canmove" you should be fine, but the real solution is to organize your code better (see above).

greggiles 12-13-2012 10:31 PM

Quote:

edit 2: on second reading it's clear the variables are at least part of the problem. You're using "canmove" in some cases and "client.canmove" in others. If you change them all to "canmove" you should be fine, but the real solution is to organize your code better (see above).
The client.canmove was a mistype. sorry, that was never there in the original script

Stowen 12-13-2012 11:07 PM

Thanks Jer, I've been wondering how to use public functions. When I can give rep again, I'll make sure to hit you.


All times are GMT +2. The time now is 06:55 AM.

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