[Solved] How to give a weapon in BLack Ops 3?

broken avatar :(
Created 1164 days ago
by WARDOGSK93
0 Members and 1 Guest are viewing this topic.
5,181 views
broken avatar :(
×
broken avatar :(
Location: gbDonisthorpe
Date Registered: 28 October 2012
Last active: 10 days ago
Posts
489
Respect
Forum Rank
Perk Hacker
Primary Group
Member
My Contact & Social Links
More
Personal Quote
Turn caffeine into code.
Signature
[You are not allowed to view external links. Register or Login to see them]
×
WARDOGSK93's Groups
So im tryign to give my self weapons from script but everytime i try this i just a a "struct is not an entity" error



What i have tried so far

player GiveWeapon("ray_gun"); // Didnt think this would work
// -----------------------------------------
player GiveWeapon(GetWeapon("ray_gun"));
// -----------------------------------------
weapon = GetWeapon("ray_gun");

player GiveWeapon(weapon);
// -----------------------------------------
#using scripts\zm\_zm_weapons;

weapon = GetWeapon("ray_gun");

player zm_weapons::weapon_give(weapon);
// -----------------------------------------
#using scripts\zm\_zm_weapons;

player zm_weapons::weapon_give("ray_gun");
// -----------------------------------------
// tried all of the above but adding a SEE BELOW before them to make sure everything gets init'ed
level waittill("between_round_over");
Last Edit: September 30, 2016, 08:38:59 pm by WARDOGSK93
This topic contains a post which is marked as the Best Answer. Click here to view it.
broken avatar :(
×
broken avatar :(
Location: us
Date Registered: 14 September 2013
Last active: 259 days ago
Posts
1,895
Respect
Forum Rank
Zombie Destroyer
Primary Group
Community Scripter
My Groups
More
My Contact & Social Links
More
Personal Quote
BE ORIGINAL
Signature
×
MakeCents's Groups
Community Mapper Has released one or more maps to the UGX-Mods community which have been added to the UGX Map Manager.
Community Scripter Has shown effort and knowledge in the area of scripting while being a part of the UGX-Mods community.
BO3 Modtools Alpha
BO3 Modtools Alpha
This user has access to the Black Ops 3 Modtools Alpha
These should work for giving weapons


player GiveWeapon(GetWeapon("ray_gun"));
// -----------------------------------------
weapon = GetWeapon("ray_gun");

player GiveWeapon(weapon);

But you will also then need to switch to it. Is that the part that is missing? Did you try switching to it?


player SwitchToWeapon(weapon)
broken avatar :(
×
broken avatar :(
Location: gbDonisthorpe
Date Registered: 28 October 2012
Last active: 10 days ago
Posts
489
Respect
Forum Rank
Perk Hacker
Primary Group
Member
My Contact & Social Links
More
Personal Quote
Turn caffeine into code.
×
WARDOGSK93's Groups
These should work for giving weapons


player GiveWeapon(GetWeapon("ray_gun"));
// -----------------------------------------
weapon = GetWeapon("ray_gun");

player GiveWeapon(weapon);

But you will also then need to switch to it. Is that the part that is missing? Did you try switching to it?


player SwitchToWeapon(weapon)

no im straight up not getting the weapon, when the game tries to give me the weapon it throwss a error "struct is not an entity" even if i add a SwithToWeapon() or swith weapons in game i dont get it
broken avatar :(
×
broken avatar :(
Location: cz
Date Registered: 28 September 2016
Last active: 581 days ago
Posts
5
Respect
Forum Rank
Legless Crawler
Primary Group
Member
×
karelkopp's Groups
karelkopp's Contact & Social Links
its will be better to post here your complete script
broken avatar :(
×
broken avatar :(
Location: gbDonisthorpe
Date Registered: 28 October 2012
Last active: 10 days ago
Posts
489
Respect
Forum Rank
Perk Hacker
Primary Group
Member
My Contact & Social Links
More
Personal Quote
Turn caffeine into code.
×
WARDOGSK93's Groups
its will be better to post here your complete script

see the thing is i dont rly have a complete script just giving a weapon on player connect so ive pretty much given what i have

but yeah hers my script, currtly its all commented out cause none of it works no matter how i type it

Sorry but you are not allowed to view spoiler contents.
Last Edit: September 30, 2016, 04:33:26 pm by WARDOGSK93
broken avatar :(
×
broken avatar :(
Location: cz
Date Registered: 28 September 2016
Last active: 581 days ago
Posts
5
Respect
Forum Rank
Legless Crawler
Primary Group
Member
×
karelkopp's Groups
karelkopp's Contact & Social Links
so you must give weapon after spawn not after connect i think there is your problem
broken avatar :(
×
broken avatar :(
Location: gbDonisthorpe
Date Registered: 28 October 2012
Last active: 10 days ago
Posts
489
Respect
Forum Rank
Perk Hacker
Primary Group
Member
My Contact & Social Links
More
Personal Quote
Turn caffeine into code.
×
WARDOGSK93's Groups
so you must give weapon after spawn not after connect i think there is your problem

i thought so to thats why i added level waittill("between_round_over"); to waittill start of round 2 but i still got the error
broken avatar :(
×
broken avatar :(
Location: cz
Date Registered: 28 September 2016
Last active: 581 days ago
Posts
5
Respect
Forum Rank
Legless Crawler
Primary Group
Member
×
karelkopp's Groups
karelkopp's Contact & Social Links
use this
callback::on_spawned( &on_player_spawned );

function on_player_spawned()
{
self endon("disconnect");
        weapon = GetWeapon("ray_gun");
        self GiveWeapon(weapon);
        self SwitchToWeapon(weapon);   
}

Marked as best answer by treminaor on Today at 11:54:24 pm
broken avatar :(
×
broken avatar :(
Location: us
Date Registered: 14 September 2013
Last active: 259 days ago
Posts
1,895
Respect
Forum Rank
Zombie Destroyer
Primary Group
Community Scripter
My Groups
More
My Contact & Social Links
More
Personal Quote
BE ORIGINAL
×
MakeCents's Groups
Community Mapper Has released one or more maps to the UGX-Mods community which have been added to the UGX Map Manager.
Community Scripter Has shown effort and knowledge in the area of scripting while being a part of the UGX-Mods community.
BO3 Modtools Alpha
BO3 Modtools Alpha
This user has access to the Black Ops 3 Modtools Alpha
Just do:

#using scripts\shared\callbacks_shared;
#using scripts\shared\flag_shared;

#namespace wardog_test_script;

function pre_init()
{
callback::on_connect(&test_player_connect);
}

function test_player_connect()
{
    level flag::wait_till( "initial_blackscreen_passed" );
    weapon = getweapon("ray_gun");
    self giveweapon(weapon);
    self switchtoweapon(weapon);
}

That should work.
Last Edit: September 30, 2016, 05:15:54 pm by MakeCents
broken avatar :(
×
broken avatar :(
Location: gbDonisthorpe
Date Registered: 28 October 2012
Last active: 10 days ago
Posts
489
Respect
Forum Rank
Perk Hacker
Primary Group
Member
My Contact & Social Links
More
Personal Quote
Turn caffeine into code.
×
WARDOGSK93's Groups
Just do:

#using scripts\shared\callbacks_shared;
#using scripts\shared\flag_shared;

#namespace wardog_test_script;

function pre_init()
{
callback::on_connect(&test_player_connect);
}

function test_player_connect()
{
    level flag::wait_till( "initial_blackscreen_passed" );
    weapon = getweapon("ray_gun");
    self giveweapon(weapon);
    self switchtoweapon(weapon);
}

That should work.

This worked perfectly fine until i decied i wanted to call another function and give my weapon from what function

This does not work but above does

Reason i want to split the functions up is because i want to add my gamemode mod to BO3 and for that to work i need to init the player specfic to the gamemode (calling different functions)
Sorry but you are not allowed to view spoiler contents.
broken avatar :(
×
broken avatar :(
Location: us
Date Registered: 14 September 2013
Last active: 259 days ago
Posts
1,895
Respect
Forum Rank
Zombie Destroyer
Primary Group
Community Scripter
My Groups
More
My Contact & Social Links
More
Personal Quote
BE ORIGINAL
×
MakeCents's Groups
Community Mapper Has released one or more maps to the UGX-Mods community which have been added to the UGX Map Manager.
Community Scripter Has shown effort and knowledge in the area of scripting while being a part of the UGX-Mods community.
BO3 Modtools Alpha
BO3 Modtools Alpha
This user has access to the Black Ops 3 Modtools Alpha
what you posted above should work just fine as long as you still have the usings
broken avatar :(
×
broken avatar :(
Location: gbDonisthorpe
Date Registered: 28 October 2012
Last active: 10 days ago
Posts
489
Respect
Forum Rank
Perk Hacker
Primary Group
Member
My Contact & Social Links
More
Personal Quote
Turn caffeine into code.
×
WARDOGSK93's Groups
what you posted above should work just fine as long as you still have the usings

well for somereason it doesnt :( if its in the same function it works perfectly fine seperate it and the game throws that struct not entioty error

if it helps i just pushed all of my gamemode script to my GitHub

[You are not allowed to view external links. Register or Login to see them]
[You are not allowed to view external links. Register or Login to see them]

youl have to bit of digging to fine where the rest is called from

Double Post Merge: September 30, 2016, 08:38:43 pm
Wow the reason this wasnt workign was cause of a stupid typo i made in my callback system :( im so dumb [You are not allowed to view external links. Register or Login to see them]
Last Edit: September 30, 2016, 08:38:43 pm by WARDOGSK93

 

Login

or login with an authentication provider below
Sign In with Google
Sign In with Twitter
Sign In with Discord
Sign In with Steam
Sign In with Twitch
Loading ...