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 12-13-2012, 09:40 PM
greggiles greggiles is offline
Registered User
greggiles's Avatar
Join Date: Sep 2007
Posts: 149
greggiles has a spectacular aura about
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
Reply With Quote
  #2  
Old 12-13-2012, 10:09 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
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();
  }

__________________
Quote:
Reply With Quote
  #3  
Old 12-13-2012, 10:14 PM
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
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).
__________________
Reply With Quote
  #4  
Old 12-13-2012, 10:31 PM
greggiles greggiles is offline
Registered User
greggiles's Avatar
Join Date: Sep 2007
Posts: 149
greggiles has a spectacular aura about
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
Reply With Quote
  #5  
Old 12-13-2012, 11:07 PM
Stowen Stowen is offline
Graalian since '01
Join Date: Sep 2005
Location: Massachusets, USA
Posts: 156
Stowen will become famous soon enough
Send a message via AIM to Stowen Send a message via MSN to Stowen
Thanks Jer, I've been wondering how to use public functions. When I can give rep again, I'll make sure to hit you.
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 02:13 PM.


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