Question Trying to write a function that print's the console name of the currently equiped weapon

anonymoos12

Veteran
Messages
4
Reaction score
0
Points
551
I'm new to BO4 Zombies GSC scripting and just want to write a basic function that prints the console name of the currently held weapon (example: pistol_topbreak_t8 - for the Welling), just to get used to how scripting works.

My function so far:

Code:
sayCurrentWeapon()
{
    weapon = self GetCurrentWeapon();
    wait .1;
    self IPrintLnBold(weapon);
}

But it just gives a UI error in game when I call that function, so not sure what to do.

Either that, or I want to be able to list all of the weapons on the map, which I believe are held in an array called: level.zombies_weapons

but again, I have no idea how to hook into an array and print each of the items in it on its own line.
 
Last edited:

Eaqz

Well-Known Member
Messages
6
Reaction score
0
Points
201
Hi,

The error is because the "GetCurrentWeapon()" function returns an entity and not a string.

I think to get a weapon name you need to do this :

weap = self GetCurrentWeapon();
self IPrintLnBold(weap.name);
 
Last edited:

CF4_99

Veteran
Messages
145
Reaction score
54
Points
888
I'm new to BO4 Zombies GSC scripting and just want to write a basic function that prints the console name of the currently held weapon (example: pistol_topbreak_t8 - for the Welling), just to get used to how scripting works.

My function so far:

Code:
sayCurrentWeapon()
{
    weapon = self GetCurrentWeapon();
    wait .1;
    self IPrintLnBold(weapon);
}

But it just gives a UI error in game when I call that function, so not sure what to do.

Either that, or I want to be able to list all of the weapons on the map, which I believe are held in an array called: level.zombies_weapons

but again, I have no idea how to hook into an array and print each of the items in it on its own line.
GetCurrentWeapon no longer returns just the weapon name, it returns the whole weapon struct. So you would need to do self GetCurrentWeapon().name
 

Eaqz

Well-Known Member
Messages
6
Reaction score
0
Points
201
GetCurrentWeapon no longer returns just the weapon name, it returns the whole weapon struct. So you would need to do self GetCurrentWeapon().name
Hi,

That cannot work, you're calling the function .name() of a function and not the weapon struct.

You have to first store the weapon struct and then call the name function.

weapon = self GetCurrentWeapon();
self IPrintLnBold(weap.name);
 

SCP

Moderator
Staff member
Donator
Messages
413
Reaction score
398
Points
848
Hi,

That cannot work, you're calling the function .name() of a function and not the weapon struct.

You have to first store the weapon struct and then call the name function.
Are you sure about that? In the most programming languages it's the same
Code:
x = function()
x.name // y

function().name // y
 

CF4_99

Veteran
Messages
145
Reaction score
54
Points
888
Hi,

That cannot work, you're calling the function .name() of a function and not the weapon struct.

You have to first store the weapon struct and then call the name function.
That does work. You're more than welcome to go on bo3, or bo4 and try it yourself. You do not have to store it first.
Make sure you actually know what you're talking about before you try to contradict what someone says.
 

anonymoos12

Veteran
Messages
4
Reaction score
0
Points
551
Thanks everybody for your replies, I have tried your suggestions and have found the results below.

sayCurrentWeapon(){ weapon = self GetCurrentWeapon().Name; self iPrintLnBold("Weapon: "+weapon); }
returns this result:
Untitled-1.jpg


and if I replace ".Name" with ".Displayname":

sayCurrentWeapon(){ weapon = self GetCurrentWeapon().Displayname; self iPrintLnBold("Weapon: "+weapon); }

I get this result:
Untitled-2.jpg


So the Welling's "Name" is apparently: a9dd31e84aaab4e
and it's "Displayname" is apparently: 75f97bef3beea2c9
but what I really want is for it to display: pistol_topbreak_t8

Hopefully one of you knows how to find what I'm looking for :smile:
 
Last edited:

Eaqz

Well-Known Member
Messages
6
Reaction score
0
Points
201
Thanks everybody for your replies, I have tried your suggestions and have found the results below.

sayCurrentWeapon(){ weapon = self GetCurrentWeapon().Name; self iPrintLnBold("Weapon: "+weapon); }
returns this result:
View attachment 4555

and if I replace ".Name" with ".Displayname":

sayCurrentWeapon(){ weapon = self GetCurrentWeapon().Displayname; self iPrintLnBold("Weapon: "+weapon); }

I get this result:
View attachment 4557

So the Welling's "Name" is apparently: a9dd31e84aaab4e
and it's "Displayname" is apparently: 75f97bef3beea2c9
but what I really want is for it to display: pistol_topbreak_t8

Hopefully one of you knows how to find what I'm looking for :smile:
it is returning the hashed name
 

Eaqz

Well-Known Member
Messages
6
Reaction score
0
Points
201
That does work. You're more than welcome to go on bo3, or bo4 and try it yourself. You do not have to store it first.
Make sure you actually know what you're talking about before you try to contradict what someone says.
my bad
 

anonymoos12

Veteran
Messages
4
Reaction score
0
Points
551
it is returning the hashed name
Any known way of getting it to produce the non-hashed name instead?

I’ve found most of the weapon names through guessing and trial and error, but it’d be nice to have the rest of them. Ones I’m missing for example are the tempered blundergat, the spoon, the spork, the death of Orion, the kraken and it’s variants, the aether hero weapons - to name just a few.
 

Eaqz

Well-Known Member
Messages
6
Reaction score
0
Points
201
Any known way of getting it to produce the non-hashed name instead?

I’ve found most of the weapon names through guessing and trial and error, but it’d be nice to have the rest of them. Ones I’m missing for example are the tempered blundergat, the spoon, the spork, the death of Orion, the kraken and it’s variants, the aether hero weapons - to name just a few.
I'm not sure but I think you can just use the hash
GiveWeapon(GetWeapon(#"hash_a9dd31e84aaab4e"));

Here is a list of some weapons names I know if you want :

ray_gun_mk2v
ray_gun_mk2v_upgraded
ray_gun_mk2x
ray_gun_mk2x_dw
ray_gun_mk2y
ray_gun_mk2y_upgraded
ray_gun_mk2z
ray_gun_mk2z_upgraded

spknifeork = upgraded spork

ww_hand_h_uncharged ww_hand_c_uncharged ww_hand_g_uncharged ww_hand_o_uncharged
ww_hand_h_upgraded ww_hand_c_upgraded ww_hand_g_upgraded ww_hand_o_upgraded
ww_hand_h ww_hand_c ww_hand_g ww_hand_o

thundergun
thundergun_upgraded
ww_tesla_sniper_t8
ww_tesla_sniper_upgraded_t8
tundragun
tundragun_upgraded
music_box
 

anonymoos12

Veteran
Messages
4
Reaction score
0
Points
551
Thanks for your reply. I know that I can use the hashed names to “give” the weapon, but I’m currently working on a huge spreadsheet to document all of the unhashed names names for weapons, equipment, elixirs etc.

Thanks for sending me the ones you know, I didnt actually have the upgraded wunderwaffe on tag because _upgraded usually comes after t8, not before :smile:

I’ll share the spreadsheet here once I’m happy it’s complete to the best of my knowledge
 
Top