Scripts / How to add a weapon to player with AddPlayerWeapon(e)

Author
Message
PCS
8
Years of Service
User Offline
Joined: 7th Jul 2016
Playing:
Posted: 4th Nov 2021 07:43
HI all, this might sound like a noob question, but if the player is looting or searching a body and i want to let the player find a gun.
How will i do it with the function AddPlayerWeapon(e) ? what do i put in the bracket to tell the script to give the player a pistol or knife ?
Windows 10 Pro 64-bit
Intel(R) Core(TM) i5-4590S CPU @ 3.00GHz
RAM 16GB NVIDIA GeForce GT 730
DirectX Version: DirectX 11
AmenMoses
GameGuru Master
8
Years of Service
User Offline
Joined: 20th Feb 2016
Location: Portsmouth, England
Posted: 4th Nov 2021 10:06
You have to actually have a weapon asset on the map with a script attached.

When the player finds it or via the script it becomes available for use the script calls AddPlayerWeapon( e ) and the e value passed is the entity Id of the weapon asset (which is what the script is called with).

In order for it to actually be a weapon though there are a few other things needed, like settings in the .fpe file and a weaponspec file in gamecore, but for any stock weapon all that stuff is done so it's just a case of attaching a custom script.
Been there, done that, got all the T-Shirts!
PM
PCS
8
Years of Service
User Offline
Joined: 7th Jul 2016
Playing:
Posted: 4th Nov 2021 10:34 Edited at: 4th Nov 2021 10:36
@AmenMoses, yes I was thinking to make it easy i can just hide the weapon under the body and attach my search script on the weapon i want the player to find and then i can add the weapon easily.
Also Amen i have just tested your weapon script were you swap / exchange one weapon for another one. It works supper cool thanks.
Windows 10 Pro 64-bit
Intel(R) Core(TM) i5-4590S CPU @ 3.00GHz
RAM 16GB NVIDIA GeForce GT 730
DirectX Version: DirectX 11

Login to post a reply

Server time is: 2024-12-22 01:06:27
Your offset time is: 2024-12-22 01:06:27