Home   Help Search Login Register  

Author Topic: SetObjectTexture and Weapons  (Read 1907 times)

0 Members and 1 Guest are viewing this topic.

Offline JasonO

  • OFPEC Patron
  • ****
  • Oh no...
    • The New Life RPG
SetObjectTexture and Weapons
« on: 17 Oct 2009, 13:31:01 »
Hey,

I want to use setObjectTexture on a weapon instead of an object, but I'm having trouble 'refering' to that weapon as a object. When I do use setObjectTexture I get "String, expected Object".

(secondaryWeapon unit1) setObjectTexture [0,"path/to/texture.paa"]

Any ideas how to get around this?

Thanks,
Jason


Offline JamesF1

  • Editors Depot Staff
  • *****
    • JamesBurgess.co.uk
Re: SetObjectTexture and Weapons
« Reply #1 on: 17 Oct 2009, 15:14:37 »
As far as I know, setObjectTexture won't actually work on weapons (well, in honesty, it doesn't work on most objects).

As for the error you're getting, secondaryWeapon (and all other weapon-related commands) return a weapon name, not an object.

Offline DeanosBeano

  • Addons Depot Staff
  • *****
  • SirDeanosbeano bstowed on me by sui ;)
    • Fraghaus
Re: SetObjectTexture and Weapons
« Reply #2 on: 17 Oct 2009, 17:03:27 »

 weapons are weird things , especially guns for units , i havent really ever worked on them ( so much time just to see the end of barrel in an fps ), anyway without  looking my guess would be that you would need to  put an  init in the actual weapon config , this init will look for a variable being true and this would change the texture .

 it maybe a piece of cake and just like flag texture but i can see problems iff you use above method i suggest here >
 
 problems . :
 not sure if weapons are allowed hidden selections
 not sure if weapons return nulobject when initeventhandler is used.
 all guns in map will change if parmaters are not complex .
all kind of mp locality things and ai guns etc etc.
I love ofp

Offline JasonO

  • OFPEC Patron
  • ****
  • Oh no...
    • The New Life RPG
Re: SetObjectTexture and Weapons
« Reply #3 on: 18 Oct 2009, 00:00:20 »
Hi,

Thanks for the replies guys.

I had a feeling this would be the case. Kinda makes the addon useless for what I wanted to do. It can still do the job with a hint or resource or something, but it would have been better with how I wanted it.

Basiclly it's a speed gun for a Role Playing mod. If you pointed it at a vehicle it would display its speed on the LCD screen at the back. I got the script to show the speed, split the speed into 3 digits so I can assign each LCD section a number (or space) and it works fine in a hint.

I don't think hidden selections work on weapons either. I went through my model.cfg and config.cpp and i've defined it all correctly yet the 3 faces all show grey boxes (they have no texture as default) so I guess that it won't work. I thought it might be me, but meh - it's not :(

I've used setObjectTexture many times before (see this video), but only on static objects and vehicles.

So, even if I was to find a way to put the gun as an object it would still not work. The idea I had at work today was nearestObject, as that returns an actual object. Maybe getting the classname of the weapon and finding the nearest one would work. I've done it with ammo before, so maybe that would work. But still, what I want to acheive won't work. Tested this anyway, didn't work. Arn't weapons like proxies or something? They're part of the unit rather than a seperate model. Like you cant createvehicle a weapon, only show it on the ground with adding it like a weapon into an ammocrate into a weaponholder thing.

The only other option I have is to use animations, but I think to animate 3 different faces with 10-12 possible characters or so isn't a good idea.
« Last Edit: 18 Oct 2009, 00:35:00 by JasonO »