Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Hat Weapon (https://forums.graalonline.com/forums/showthread.php?t=134260168)

iSlayer 08-12-2010 11:09 AM

Hat Weapon
 
Hi all, I'm trying to make a simple NPC when player fires it, it checks if the player has tht hat on, if he does it sets the hat to hat.png, if not it sets the players hat to the hat filename, someone please help me, this is what ive got so far

PHP Code:

//#CLIENTSIDE

function onWeaponFired()
{
  {
  if (
player.attr[1] = "ds-gasmask.png")
  
player.attr[1] = "hat.png"
  }
  else
  {
  
player.attr[1] = "ds-gasmask.png";
  }


Thanks!

Fulg0reSama 08-12-2010 11:24 AM

Quote:

Originally Posted by iSlayer (Post 1593109)
Hi all, I'm trying to make a simple NPC when player fires it, it checks if the player has tht hat on, if he does it sets the hat to hat.png, if not it sets the players hat to the hat filename, someone please help me, this is what ive got so far

PHP Code:

//#CLIENTSIDE

function onWeaponFired()
{
  {
  if (
player.attr[1] = "ds-gasmask.png")
  
player.attr[1] = "hat.png"
  }
  else
  {
  
player.attr[1] = "ds-gasmask.png";
  }


Thanks!

Your brackets are off.

PHP Code:

//#CLIENTSIDE
function onWeaponFired()
{
  if (
player.attr[1] = "ds-gasmask.png") {
  
player.attr[1] = "hat.png"
}
  else if (
player.attr[1] = "hat.png") {
  
player.attr[1] = "ds-gasmask.png'";


I think that'll work.

Crow 08-12-2010 11:45 AM

Quote:

Originally Posted by Fulg0reSama (Post 1593110)
Your brackets are off.

PHP Code:

//#CLIENTSIDE
function onWeaponFired()
{
  if (
player.attr[1] = "ds-gasmask.png") {
  
player.attr[1] = "hat.png"
}
  else if (
player.attr[1] = "hat.png") {
  
player.attr[1] = "ds-gasmask.png'";


I think that'll work.

Not quite what he wanted though, and your equal signs are off :p This should do:
PHP Code:

//#CLIENTSIDE
function onWeaponFired() {
  if (
player.attr[1] == "ds-gasmask.png") {
    
player.attr[1] = "hat.png"
  } else {
    
player.attr[1] = "ds-gasmask.png'";
  }


Remember: When comparing stuff, you need two equal signs.

iSlayer 08-12-2010 12:24 PM

Thanks guys!

Fulg0reSama 08-12-2010 12:43 PM

Quote:

Originally Posted by Crow (Post 1593111)
Remember: When comparing stuff, you need two equal signs.

Thanks for reminding, I haven't scripted in a long while.

fowlplay4 08-12-2010 10:19 PM

Tip: Create a -Hat system, and have your Hat weapons call one it's functions. That way if you want to add an haton, hatoff animation you don't have change all your Hat weapons.

I.e:

-Hat

PHP Code:

//#CLIENTSIDE

public function changeHat(hatimg) {
  if (
player.attr[1] == hatimg) { 
    
player.attr[1] = "hat.png";  
  } else { 
    
player.attr[1] = hatimg
  }


Hats/Gasmask:

PHP Code:

//#CLIENTSIDE

function onWeaponFired() {
  (@
"-Hat").changeHat("ds-gasmask.png");



iSlayer 08-13-2010 12:56 AM

and would I just put a command which sets the animation?

fowlplay4 08-13-2010 01:24 AM

Quote:

Originally Posted by iSlayer (Post 1593271)
and would I just put a command which sets the animation?

You would use setani in -Hat instead of in all of the Hats/*.

iSlayer 08-13-2010 06:07 AM

so if I make the gani hat_puton.gani for example and I put that after it sets the hat the gani should display the player putting on the specified hat, in other words. Thanks


All times are GMT +2. The time now is 08:07 PM.

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