Scripts / How is g_PlayerGunID determined?

Author
Message
Moshroom
9
Years of Service
User Offline
Joined: 18th Jul 2015
Location: Finland
Posted: 15th Dec 2017 00:38
This prompts a number depending on what weapon is being equipped (an individual ID number for each weapon type):

I’m wondering what kind of logic controls the number behind each weapon. So far I’ve figured out that at least it is not defined in the Entity Propertirs nor text file associated with the weapon entity, it is not based on weapon category and it seems not to be based on weapon name or file name. Is it hardcoded somewhere below the surface, do I not know where to look or is there an automatic logic that I just haven’t figured out?
smallg
Community Leader
19
Years of Service
User Offline
Joined: 8th Dec 2005
Location:
Posted: 15th Dec 2017 15:30
Its a good question, it also changes for each user.
From my guess is that it just counts through all your weapon assets but that's just a guess, I never bothered to check once I knew it was too random I just use the names.
lua guide for GG
https://steamcommunity.com/sharedfiles/filedetails/?id=398177770
windows 10
i5 @4ghz, 8gb ram, AMD R9 200 series , directx 11
Belidos
3D Media Maker
9
Years of Service
User Offline
Joined: 23rd Nov 2015
Playing: The Game
Posted: 15th Dec 2017 16:03
I thought player gun ID was the slow it is assigned to when you pick it up, or am i thinking of something else.

Primary Desktop:
i7 7700,k NV1070 8GB, 16GB 3200mhz memory, 1x 2TB Hybrid, Win10.

Secondary Desktop:
i5 4760k, NV960 2GB, 16GB 2333mhz memory, 1x 2TB Hybrid, Win10.

Laptop:
i3, Intel 4000 series graphics, 6GB memory, 1x 500gb HDD, Win8.1.
smallg
Community Leader
19
Years of Service
User Offline
Joined: 8th Dec 2005
Location:
Posted: 15th Dec 2017 19:28
Quote: "I thought player gun ID was the slot it is assigned to when you pick it up, or am i thinking of something else."

there is a g_WeaponSlotGot = {} which is probably the one you're thinking of
lua guide for GG
https://steamcommunity.com/sharedfiles/filedetails/?id=398177770
windows 10
i5 @4ghz, 8gb ram, AMD R9 200 series , directx 11
Moshroom
9
Years of Service
User Offline
Joined: 18th Jul 2015
Location: Finland
Posted: 15th Dec 2017 21:31
Quote: "...it also changes for each user.
From my guess is that it just counts through all your weapon assets..."

So it might change if I download new weapon assets? Good to know. So when expanding the weapon system, it's reliable to save new data under the weapon name like this:

Not under the gun ID like this:
smallg
Community Leader
19
Years of Service
User Offline
Joined: 8th Dec 2005
Location:
Posted: 15th Dec 2017 21:42
yh much better to check the names - you can use g_PlayerGunName to return the string (as you noticed, it does give the folder) then combine that with
GetWeaponID ( GunNameString ) to find the ID if you need it for the other commands.
lua guide for GG
https://steamcommunity.com/sharedfiles/filedetails/?id=398177770
windows 10
i5 @4ghz, 8gb ram, AMD R9 200 series , directx 11

Login to post a reply

Server time is: 2024-12-23 00:44:58
Your offset time is: 2024-12-23 00:44:58