UGX-Mods 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 Facebook
Sign In with Twitch

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

broken avatar :(
Created 8 years ago
by Deleted User
0 Members and 1 Guest are viewing this topic.
9,162 views
broken avatar :(
  • DeletedUser
  • Deleted Member
×
broken avatar :(
DeletedUser
This user is deleted :(
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

Code Snippet
Plaintext
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");
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: 4 years 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


Code Snippet
Plaintext
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?


Code Snippet
Plaintext
player SwitchToWeapon(weapon)
broken avatar :(
  • DeletedUser
  • Deleted Member
×
broken avatar :(
DeletedUser
This user is deleted :(
These should work for giving weapons


Code Snippet
Plaintext
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?


Code Snippet
Plaintext
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: 6 years 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 :(
  • DeletedUser
  • Deleted Member
×
broken avatar :(
DeletedUser
This user is deleted :(
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

Spoiler: click to open...
Code Snippet
Plaintext
#using scripts\codescripts\struct;

#using scripts\shared\array_shared;
#using scripts\shared\callbacks_shared;
#using scripts\shared\clientfield_shared;
#using scripts\shared\compass;
#using scripts\shared\exploder_shared;
#using scripts\shared\flag_shared;
#using scripts\shared\laststand_shared;
#using scripts\shared\math_shared;
#using scripts\shared\scene_shared;
#using scripts\shared\util_shared;

#insert scripts\shared\shared.gsh;
#insert scripts\shared\version.gsh;

#insert scripts\zm\_zm_utility.gsh;

#using scripts\zm\_zm;
#using scripts\zm\_zm_audio;
#using scripts\zm\_zm_utility;
#using scripts\zm\_zm_score;
#using scripts\zm\_zm_weapons;

#namespace wardog_test_script;

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

function test_player_connect()
{
// level waittill("between_round_over");

// weapon = GetWeapon("pistol_standard");
// knife = GetWeapon("knife");
// grenade = GetWeapon("frag_grenade");

// string = "smg_standard";
// weapon = getWeapon(string);
// knife = GetWeapon("knife");
// grenade = GetWeapon("frag_grenade");

// self zm_weapons::weapon_give("smg_standard");
// self zm_weapons::weapon_give(GetWeapon("smg_standard"));
// self giveWeapon(weapon);
// self SwitchToWeapon(weapon);
// self zm_weapons::give_build_kit_weapon(weapon);
// self zm_weapons::weapon_give(weapon, false, false, false, true);
// self SetWeaponAmmoClip(weapon, 1);
// self SetWeaponAmmoStock(weapon, 0);

// self GiveWeapon(knife);

// self zm_utility::set_player_melee_weapon(knife);

// self GiveWeapon(grenade);
// self SetWeaponAmmoClip(grenade, 1);

// self zm_utility::set_player_lethal_grenade(grenade);
}
broken avatar :(
×
broken avatar :(
Location: cz
Date Registered: 28 September 2016
Last active: 6 years 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 :(
  • DeletedUser
  • Deleted Member
×
broken avatar :(
DeletedUser
This user is deleted :(
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: 6 years ago
Posts
5
Respect
Forum Rank
Legless Crawler
Primary Group
Member
×
karelkopp's Groups
karelkopp's Contact & Social Links
use this
Code Snippet
Plaintext
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 8 years ago
broken avatar :(
×
broken avatar :(
Location: us
Date Registered: 14 September 2013
Last active: 4 years 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:

Code Snippet
Plaintext
#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 :(
  • DeletedUser
  • Deleted Member
×
broken avatar :(
DeletedUser
This user is deleted :(
Just do:

Code Snippet
Plaintext
#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)
Spoiler: click to open...
Code Snippet
Plaintext
function pre_init()
{
callback::on_connect(&test_player_connect);
}

function test_player_connect()
{
    level flag::wait_till( "initial_blackscreen_passed" );
    self thread new_function();
}

function new_function()
{
    weapon = getweapon("ray_gun");
    self giveweapon(weapon);
    self switchtoweapon(weapon);
}
broken avatar :(
×
broken avatar :(
Location: us
Date Registered: 14 September 2013
Last active: 4 years 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 :(
  • DeletedUser
  • Deleted Member
×
broken avatar :(
DeletedUser
This user is deleted :(
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

Where im giving weapons
Where im calling player_init

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 See typo

 
Loading ...