Jump to content

Make weapon invisible, then put another model to its place?


KalashnikovZ

Recommended Posts

Posted

I'd like to set the weapon in my hand invisible, then put a model to it's place. I started editing a script, guys, please don't laugh, I'm a real beginner :D

function fegyo() 
   local weapon = createWeapon("m4", getElementPosition(localPlayer)) 
   setElementAlpha(localWeapon, 0) 
   setWeaponClipAmmo(weapon, 40) 
   setWeaponState(weapon, firing) 
end 
addCommandHandler(gun, fegyo) 

I would really enjoy someone's example script :'(

Posted
function customWep () 
 local weapon = givePedWeapon (source,31,5000) 
setElementAlpha(weapon, 0) 
local gunModel = createElement(object,'ModelId') -- ModelId = Find a unused Id and replace Dff, and TXD with gun model you want. -- 
attachElements ( gunModel, weapon) 
end 

Posted
function customWep () 
 local weapon = givePedWeapon (source,31,5000) 
setElementAlpha(weapon, 0) 
local gunModel = createElement(object,'ModelId') -- ModelId = Find a unused Id and replace Dff, and TXD with gun model you want. -- 
attachElements ( gunModel, weapon) 
end 

That won't work. givePedWeapon(..) does not return a weapon, it returns a boolean. Therefore, that will cause an error.

Posted

Oh btw it's

giveWeapon, not givePedWeapon 

- Messed up a bit there, but to the point of what you just said, it should return the weapon that was given, if that does not work, use

weapon = getPedWeapon(source) 

function customWep () 
 giveWeapon (source,31,5000) 
 local weapon = getPedWeapon(source) 
 setElementAlpha(weapon, 0) 
 local gunModel = createElement(object,'ModelId') -- ModelId = Find a unused Id and replace Dff, and TXD with gun model you want. -- 
attachElements ( gunModel, weapon) 
end 

- That should work, sorry about that, forgot about few things there. -

Posted

There isn't an element for the ped weapon and getPedWeapon returns an integer value.

The only way to make a weapon invisible is replacing the texture with a transparent one.

Posted

codylewiz, open the wiki and you'll see that it only returns/pushes back a boolean, not an element. Don't spread false information to the people who are willing to learn.

KalashnikovZ, do what Alexs_Steel said, it is the only (or at least the easiest) way to accomplish what you wish to do.

Posted
The getpedWeapon returns the weapon that is in his hand. Meaning it should allow him to set that transparent.

Player weapons aren't elements and getPedWeapon returns an int, Look at the wiki next time, The only solution is replace the weapon texture as Alexs said.

Posted

There was another page I was looking on that returned an object, I did the getPedWeapon off of memory and I thought that was the page I was looking at. I didn't recall correctly my mistake.

I did something similar to making new custom weapons a while ago, I'll see if I still have that script.

Posted
I know how can I change model of a weapon, of course engineLoadDFF, and TXD, I know it, but I'm heading to make 2 different models, for 1 weapon type.

You should replace the original texture with a transparent one and then attach an object as if it were the weapon.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...