Giving Player only a Weapon (No Ammo)
#1

As the title says, is this possible?
Reply
#2

Short Answer: No.

Reasoning: There are three functions related to weapons, SetPlayerArmedWeapon, GivePlayerWeapon and GetPlayerWeapon. The function you would want, GivePlayerWeapon, takes three arguments: playerid, weaponid, and ammo. The ammo parameter is not optional. You can, however, set it to a very small amount like one bullet as such:

Код:
GivePlayerWeapon(playerid, 29, 1);
N.B: Of course, you can give a melee weapon without ammo. The ammo parameter must be supplied with a number > 0, but it's not actually going to affect "how much" of the melee weapon the player will have. If you try to give the player a weapon with the ammo parameter at 0, the weapon will very quickly appear in the player's inventory and then disappear.
Reply
#3

Yes, you can create a function that uses SetPlayerAttachedObject, attach the model ID to the right hand (Bone 6) and save the weapon ID you wanna give as a var, once you wanna give him ammo, just get the var ID and replace the attached object with an actual weapon.
Reply
#4

You could attach the weapon object to the player also.

edit; why teh fuck am i so slow.
Reply
#5

Quote:
Originally Posted by -CaRRoT
Yes, you can create a function that uses SetPlayerAttachedObject, attach the model ID to the right hand (Bone 6) and save the weapon ID you wanna give as a var, once you wanna give him ammo, just get the var ID and replace the attached object with an actual weapon.
Didn't think of that, now I feel stupid.
Reply
#6

Thanks Guys, i thinking of it right now, but i have one problem, What if i ran out of ammo? Does the Attached Object will removed also?
Reply
#7

You don't need an attached object if you were already shooting, you only attach the object if you have 0 ammo, so the 2 scenarios you'd do that is that if you give someone a gun with no ammo, then you'd attach the object, or if you run out of ammo while shooting, you'd attach the object. Other than that, make sure to deattach it while having a gun with ammo.
Reply
#8

No. The weapon and the object are considered distinct entities.

Edit: Too slow, I guess. But I just did some quick testing with a Colt 45 weapon and Colt 45 model and while the object's attached, it will seem like the player's holding two guns. When the weapon runs out of ammo, it will disappear but the model will stay. I don't know about bigger weapons or differing weapons; I'd say it's best to follow what -CaRRoT outlined above me.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)