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 05-15-2012, 09:39 PM
Fysez Fysez is offline
Banned
Join Date: Apr 2012
Posts: 89
Fysez has a little shameless behaviour in the past
Sword/Gani Script - Help

I've got the whole Gani part working. Problem is,
Once I equip and use the item,
It doesn't allow me to un-equip?
PHP Code:
//#CLIENTSIDE
function onWeaponFired() {
if (
this.on false) {
this.on true;
setani("Gani"null);
replaceani("idle""Gani");
replaceani("walk""Gani2");
this.on true;
}else if (!
this.on){
setani("idle"null);
replaceani("idle""idle");
replaceani("walk""walk");
}

Reply With Quote
  #2  
Old 05-15-2012, 09:56 PM
Starfire2001 Starfire2001 is offline
Unholy Nation
Starfire2001's Avatar
Join Date: Dec 2010
Location: The streets.
Posts: 156
Starfire2001 will become famous soon enough
Quote:
Originally Posted by Fysez View Post
I've got the whole Gani part working. Problem is,
Once I equip and use the item,
It doesn't allow me to un-equip?
PHP Code:
//#CLIENTSIDE
function onWeaponFired() {
if (
this.on false) {
this.on true;
setani("Gani"null);
replaceani("idle""Gani");
replaceani("walk""Gani2");
this.on true;
}else if (!
this.on){
setani("idle"null);
replaceani("idle""idle");
}

A few things.

if (this.on = false)
should be
if(this.on == false)
= sets values, == checks for equivalency.

Even if that was fixed it still wouldn't work, !this.on is the same thing as this.on == false, so you are checking if the weapon is off in both your if statements.

Also your aren't setting this.on back to false at any point, so once you unequip it once its going think its still on and you won't be able to reequip it. And you aren't resetting your walk gani to walk when you turn it off.
__________________
-Ph8
Reply With Quote
  #3  
Old 05-15-2012, 10:07 PM
Fysez Fysez is offline
Banned
Join Date: Apr 2012
Posts: 89
Fysez has a little shameless behaviour in the past
Quote:
Originally Posted by Starfire2001 View Post
A few things.

if (this.on = false)
should be
if(this.on == false)
= sets values, == checks for equivalency.

Even if that was fixed it still wouldn't work, !this.on is the same thing as this.on == false, so you are checking if the weapon is off in both your if statements.

Also your aren't setting this.on back to false at any point, so once you unequip it once its going think its still on and you won't be able to reequip it. And you aren't resetting your walk gani to walk when you turn it off.
PHP Code:
//#CLIENTSIDE
function onWeaponFired() {
if (
this.on == false) {
this.on == true;
setani("Gani"null);
replaceani("idle""Gani");
replaceani("walk""Gani2");


}else if (
this.on == true){
this.on == false;
setani("idle"null);
replaceani("idle""idle");
replaceani("walk""walk");
}

Doesn't necessarily work either
Reply With Quote
  #4  
Old 05-15-2012, 10:28 PM
CujoDaMan CujoDaMan is offline
Shaded Legend Management
CujoDaMan's Avatar
Join Date: Aug 2004
Location: Canada, Nova Scotia
Posts: 108
CujoDaMan is an unknown quantity at this point
Send a message via AIM to CujoDaMan Send a message via MSN to CujoDaMan
Try this, it should work

PHP Code:
//#CLIENTSIDE
function onWeaponFired() {
  if (
this.use == 0) {
  
setani("Gani"null);
  
replaceani("idle""Gani");
  
replaceani("walk""Gani2");
  
this.use = 1;
  } else {
   
setani("idle"null);
   
replaceani("idle""idle");
   
replaceani("walk""walk");
   
this.use = 0;
  }

__________________
Last Manager of Shaded Legend
Reply With Quote
  #5  
Old 05-15-2012, 10:39 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
As Starfire2001 just said, a single equals sign is for assignment, while two are for testing equality.

Styling your code, as you should have done before posting:

PHP Code:
//#CLIENTSIDE
function onWeaponFired() {
  if (
this.on == false) {
    
this.on == true;
    
setani("Gani"null);
    
replaceani("idle""Gani");
    
replaceani("walk""Gani2");
  } else if (
this.on == true) {
    
this.on == false;
    
setani("idle"null);
    
replaceani("idle""idle");
    
replaceani("walk""walk");
  }

Removing some redundant stuff like "== true" and fixing your assignment (you would have known that if you'd read the tutorial I've linked to you several times now)

PHP Code:
//#CLIENTSIDE
function onWeaponFired() {
  if (! 
this.on) {
    
this.on true;
    
setani("Gani"null);
    
replaceani("idle""Gani");
    
replaceani("walk""Gani2");
  } else if (
this.on) {
    
this.on false;
    
setani("idle"null);
    
replaceani("idle""idle");
    
replaceani("walk""walk");
  }

It should work now. If it doesn't, list the steps you've used to try to debug it.
__________________
Reply With Quote
  #6  
Old 05-15-2012, 10:54 PM
Fysez Fysez is offline
Banned
Join Date: Apr 2012
Posts: 89
Fysez has a little shameless behaviour in the past
PHP Code:
//#CLIENTSIDE
function onWeaponFired() {
  if (
this.on == false) {
    
this.on == true;
    
setani("Gani"null);
    
replaceani("idle""Gani");

  } else if (
this.on == true) {
    
this.on == false;
    
setani("idle"null);
    
replaceani("idle""idle");

  }

Cujo's method did not work at all, But rather made it so I could not equip it at all. CBK, your's did the same. So I tried this and it seemed to work for Equipping, But then again, Not un-equipping. Not only am I back to where i started, But you all just confused me x.x lol
Reply With Quote
  #7  
Old 05-15-2012, 10:57 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
Did you even read what I said?

If you're copying and pasting, remember to remove the space at the end of the clientside line.
__________________
Reply With Quote
  #8  
Old 05-15-2012, 11:02 PM
callimuc callimuc is offline
callimuc's Avatar
Join Date: Nov 2010
Location: Germany
Posts: 1,015
callimuc is a splendid one to beholdcallimuc is a splendid one to beholdcallimuc is a splendid one to beholdcallimuc is a splendid one to beholdcallimuc is a splendid one to behold
Quote:
Originally Posted by Fysez View Post
PHP Code:
//#CLIENTSIDE
function onWeaponFired() {
  if (
this.on == false) {
    
this.on == true;
    
setani("Gani"null);
    
replaceani("idle""Gani");

  } else if (
this.on == true) {
    
this.on == false;
    
setani("idle"null);
    
replaceani("idle""idle");

  }

Cujo's method did not work at all, But rather made it so I could not equip it at all. CBK, your's did the same. So I tried this and it seemed to work for Equipping, But then again, Not un-equipping. Not only am I back to where i started, But you all just confused me x.x lol
Use the == only in the if statement. While setting the value just use = . So this should work

PHP Code:
//#CLIENTSIDE
function onWeaponFired() {
  if (
this.wearing == false) {
    
this.wearing true;
    
replaceani("idle""gani");
    
replaceani("walk""gani2");
  }
  else if (
this.wearing == true) {
    
this.wearing false;
    
replaceani("gani""idle");
    
replaceani("gani2""walk");
  }

__________________
MEEP!
Reply With Quote
  #9  
Old 05-15-2012, 11:03 PM
Fysez Fysez is offline
Banned
Join Date: Apr 2012
Posts: 89
Fysez has a little shameless behaviour in the past
Quote:
Originally Posted by cbk1994 View Post
Did you even read what I said?

If you're copying and pasting, remember to remove the space at the end of the clientside line.
'= false' helps me more than that of '! this.on'. If I wish to use it like that, So be it. But '! this.on' won't fix the problem i've asked help for x,x

I'd rather learn than not learn, and do "Style" instead. x.x
Reply With Quote
  #10  
Old 05-15-2012, 11:22 PM
Fysez Fysez is offline
Banned
Join Date: Apr 2012
Posts: 89
Fysez has a little shameless behaviour in the past
Quote:
Originally Posted by callimuc View Post
Use the == only in the if statement. While setting the value just use = . So this should work

PHP Code:
//#CLIENTSIDE
function onWeaponFired() {
  if (
this.wearing == false) {
    
this.wearing true;
    
replaceani("idle""gani");
    
replaceani("walk""gani2");
  }
  else if (
this.wearing == true) {
    
this.wearing false;
    
replaceani("gani""idle");
    
replaceani("gani2""walk");
  }

Doesn't work either.
Reply With Quote
  #11  
Old 05-15-2012, 11:33 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
Quote:
Originally Posted by Fysez View Post
'= false' helps me more than that of '! this.on'. If I wish to use it like that, So be it. But '! this.on' won't fix the problem i've asked help for x,x

I'd rather learn than not learn, and do "Style" instead. x.x
You can do whatever you want on the "== true" stuff—there are a lot of people who take a long time to understand why it's so silly, so I'll give you a pass on that. But there is no excuse for not styling your code as you write it or for posting unindented code.
__________________
Reply With Quote
  #12  
Old 05-15-2012, 11:43 PM
Fysez Fysez is offline
Banned
Join Date: Apr 2012
Posts: 89
Fysez has a little shameless behaviour in the past
Quote:
Originally Posted by cbk1994 View Post
You can do whatever you want on the "== true" stuff—there are a lot of people who take a long time to understand why it's so silly, so I'll give you a pass on that. But there is no excuse for not styling your code as you write it or for posting unindented code.
There is, Because I can write it as I please.
All I ask is for help on a script to make it work.
Not how to style and make my script look all pretty and sparkly.
Reply With Quote
  #13  
Old 05-16-2012, 01:17 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 Fysez View Post
There is, Because I can write it as I please.
All I ask is for help on a script to make it work.
Not how to style and make my script look all pretty and sparkly.
Do not expect help in this forum if you won't even take the time to make your code readable and get defensive every time someone with more experience than you gives you advice.
__________________
Reply With Quote
  #14  
Old 05-16-2012, 01:30 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
I fail to see how you're having an issue with a toggle but I can tell if you plan to make multiple weapons that use this same kind of system, you'll be incurring a bad time.

Toggles are very basic and typically done like this:

PHP Code:
//#CLIENTSIDE
function onWeaponFired() {
  if (
this.on) {
    
player.chat "I am no longer on.";
    
this.on false;
  } else {
    
player.chat "I am on.";
    
this.on true;
  }

If you completed my 'Staff Boots Challenge' on my tutorial you would have created a working toggle script.
__________________
Quote:
Reply With Quote
  #15  
Old 05-17-2012, 11:43 PM
Fysez Fysez is offline
Banned
Join Date: Apr 2012
Posts: 89
Fysez has a little shameless behaviour in the past
Quote:
Originally Posted by fowlplay4 View Post
I fail to see how you're having an issue with a toggle but I can tell if you plan to make multiple weapons that use this same kind of system, you'll be incurring a bad time.

Toggles are very basic and typically done like this:

PHP Code:
//#CLIENTSIDE
function onWeaponFired() {
  if (
this.on) {
    
player.chat "I am no longer on.";
    
this.on false;
  } else {
    
player.chat "I am on.";
    
this.on true;
  }

If you completed my 'Staff Boots Challenge' on my tutorial you would have created a working toggle script.
I used that to test it, But it wasn't working on my script.

So I made a seperate Test one with only that code, as a test.
Every time I pressed D, it said "I am no longer on.", It doesn't work either.
It would not turn on.
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 10:07 AM.


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