UGX-Mods

Call of Duty 5: World at War => Help Desk => Scripting => Topic started by: DeletedUser on January 20, 2016, 09:12:34 pm

Title: [Help] GiveWeapon error
Post by: DeletedUser on January 20, 2016, 09:12:34 pm
So while i was rewriting my perk system i came a across a very strange error

My perk bottles are not given at all (i can give my bottle in game but not via script)

See here for more info (https://github.com/WARDOGSK93/CoD-Perk-System/issues/2)

if any one knows why this is happening it would be greatly appreciated

Edit: other than this error my perk system seems to work (solo still need to test coop)
Title: Re: [Help] GiveWeapon error
Post by: daedra descent on January 20, 2016, 09:17:57 pm
Sounds like it isn't precached to me.
Title: Re: [Help] GiveWeapon error
Post by: DeletedUser on January 20, 2016, 09:22:01 pm
Sounds like it isn't precached to me.

it must be preached as im precaching it when my perks are registered and the default weapon (if you pass a undefined var in the set weapon it defaults to this one) is precached during pre_init of my perk system

Jugg set_perk_weapon call (https://github.com/WARDOGSK93/CoD-Perk-System/blob/master/maps/wardog/perks/_wardog_perks_waw.gsc#L23)
set_perk_weapon function (https://github.com/WARDOGSK93/CoD-Perk-System/blob/master/maps/wardog/perks/_wardog_perks_util.gsc#L140)
Default weapon init (https://github.com/WARDOGSK93/CoD-Perk-System/blob/master/maps/wardog/perks/_wardog_perks.gsc#L28)

Edit: ive also tried precaching the weapon name directly (not passed as a var)

Edit 2: i also thought if it wasnt precached you couldnt give from console in game but i guess you learn something new every day
Title: Re: [Help] GiveWeapon error
Post by: RamboBadass on January 20, 2016, 09:27:40 pm
I think he means like this

Code Snippet
Plaintext
[/	// this map uses atleast 1 perk machine
PrecacheItem( "zombie_perk_bottle_doubletap" );
PrecacheItem( "zombie_perk_bottle_jugg" );
PrecacheItem( "zombie_perk_bottle_revive" );
PrecacheItem( "zombie_perk_bottle_sleight" );
PrecacheItem( "bo2_t6_wpn_zmb_perk_bottle_cherry_view" );
PrecacheItem( "zombie_perk_bottle_phd" );
PrecacheItem( "zombie_perk_bottle_staminup" );
PrecacheItem( "zombie_perk_bottle_mulekick" );
PrecacheItem( "zombie_perk_bottle_deadshot" );

PrecacheItem( "zombie_knuckle_crack" );code]

I don't know much about script but I think you have to precache them
Title: Re: [Help] GiveWeapon error
Post by: daedra descent on January 20, 2016, 09:28:45 pm
it must be preached as im precaching it when my perks are registered and the default weapon (if you pass a undefined var in the set weapon it defaults to this one) is precached during pre_init of my perk system

Jugg set_perk_weapon call (https://github.com/WARDOGSK93/CoD-Perk-System/blob/master/maps/wardog/perks/_wardog_perks_waw.gsc#L23)
set_perk_weapon function (https://github.com/WARDOGSK93/CoD-Perk-System/blob/master/maps/wardog/perks/_wardog_perks_util.gsc#L139)
Default weapon init (https://github.com/WARDOGSK93/CoD-Perk-System/blob/master/maps/wardog/perks/_wardog_perks.gsc#L23)

Edit: ive also tried precaching the weapon name directly (not passed as a var)


Edit 2: i also thought if it wasnt precached you couldnt give from console in game but i guess you learn something new every day

Is that pre init function called before load.gsc and isnt threaded/ wait before it?

If so, that is probably why.

On my phone ATM, sorry for not being clear.

All pre caching MUST be done before load with NO threading or waits before it.
Title: Re: [Help] GiveWeapon error
Post by: DeletedUser on January 20, 2016, 09:34:42 pm
Is that pre init function called before load.gsc and isnt threaded/ wait before it?

If so, that is probably why.

its called in _zombiemode just moved to below _load call in _zombiemode and the bottle still isnt given :(

Spoiler: click to open...
(https://i.gyazo.com/e938543d605138914648a9adc7586fd1.png)

(https://i.gyazo.com/52974476513dc748b7afe5ddddff9040.png)

Edit: also none of my pre_init functiosn are threaded / have a wait before them

Edit 2: should i revert to my old perk system (this version allows for each perk to have a seperate bottle my old version didnt)
Title: Re: [Help] GiveWeapon error
Post by: daedra descent on January 20, 2016, 10:04:12 pm
I think he means like this

Code Snippet
Plaintext
[/	// this map uses atleast 1 perk machine
PrecacheItem( "zombie_perk_bottle_doubletap" );
PrecacheItem( "zombie_perk_bottle_jugg" );
PrecacheItem( "zombie_perk_bottle_revive" );
PrecacheItem( "zombie_perk_bottle_sleight" );
PrecacheItem( "bo2_t6_wpn_zmb_perk_bottle_cherry_view" );
PrecacheItem( "zombie_perk_bottle_phd" );
PrecacheItem( "zombie_perk_bottle_staminup" );
PrecacheItem( "zombie_perk_bottle_mulekick" );
PrecacheItem( "zombie_perk_bottle_deadshot" );

PrecacheItem( "zombie_knuckle_crack" );code]

I don't know much about script but I think you have to precache them

Yes, like that. However, it shouldn't matter if you use a literal string or a variable as long as the variable is defined and is a string(maybe it isn't defined?).

its called in _zombiemode just moved to below _load call in _zombiemode and the bottle still isnt given :(

Spoiler: click to open...
(https://i.gyazo.com/e938543d605138914648a9adc7586fd1.png)

(https://i.gyazo.com/52974476513dc748b7afe5ddddff9040.png)

Edit: also none of my pre_init functiosn are threaded / have a wait before them

You should only precache weapons/models once. Also, the second call is AFTER _load, not before(where it should be.

Title: Re: [Help] GiveWeapon error
Post by: DeletedUser on January 20, 2016, 10:05:43 pm
Yes, like that. However, it shouldn't matter if you use a literal string or a variable as long as the variable is defined and is a string(maybe it isn't defined?).

You should only precache weapons/models once. Also, the second call is AFTER _load, not before(where it should be.
the second call was me moving it there just to check but i moved it back above _load (the first image)

Edit: the reason i have 2 precaches is just incase the weapon passed in maps\wardog\perks\_wardog_perks_util::set_perk_weapon is not the default bottle (set and precached in maps\wardog\perks\_wardog_perks::pre_init)
Title: Re: [Help] GiveWeapon error
Post by: daedra descent on January 20, 2016, 10:19:07 pm
the second call was me moving it there just to check but i moved it back above _load (the first image)

Edit: the reason i have 2 precaches is just incase the weapon passed in maps\wardog\perks\_wardog_perks_util::set_perk_weapon is not the default bottle (set and precached in maps\wardog\perks\_wardog_perks::pre_init)

Ah, okay.

precacheItem should precache the model by itself. All your doing there is precaching the model itself, which would only be useful if you wanted to spawn the model via script but don't have a weapon with the model precached elsewhere.

Edit: honestly, the only way i'm going to be able to figure this out at this rate is if i had a copy of whatever map your using to test these perks. I could then run developer and developer_script and see if it is indeed not being preached or if the variable isn't defined.
Title: Re: [Help] GiveWeapon error
Post by: DeletedUser on January 20, 2016, 10:29:56 pm
Ah, okay.

precacheItem should precache the model by itself. All your doing there is precaching the model itself, which would only be useful if you wanted to spawn the model via script but don't have a weapon with the model precached elsewhere.

Edit: honestly, the only way i'm going to be able to figure this out at this rate is if i had a copy of whatever map your using to test these perks. I could then run developer and developer_script and see if it is indeed not being preached or if the variable isn't defined.
i dont mind sending you a compiled version of my map as ive tried everything and cant it to work and just really want this fixed but im not going to send a uncompiled version out (:( sorry)

Edit: pm me if you want me to send the compiled map
Title: Re: [Help] GiveWeapon error
Post by: MakeCents on January 21, 2016, 12:28:53 am
You really should only use one weapon file. Your taking up a lot of weapon files that way.

For bottles just make sure you Precache the weapon file and add the models and weapon file to a csv your including in the mod (and checked while building mod). Most use the mod.csv. Missing one of those causes the can give in console works but not via script thing. I forget which one off hand. As a matter of fact, usually if you give on console, after that the script will give then for that game. Unless I misunderstood what you said.
Title: Re: [Help] GiveWeapon error
Post by: DeletedUser on January 21, 2016, 12:47:20 am
You really should only use one weapon file. Your taking up a lot of weapon files that way.

For bottles just make sure you Precache the weapon file and add the models and weapon file to a csv your including in the mod (and checked while building mod). Most use the mod.csv. Missing one of those causes the can give in console works but not via script thing. I forget which one off hand. As a matter of fact, usually if you give on console, after that the script will give then for that game. Unless I misunderstood what you said.
i am using 1 weapon file but with all waw, bo1 and bo2 perks that takes up almost all 16 slots in the weapon file so im trying to add the ability to call 1 function and change the weapon file (but for some reason it seems the weapon file isnt been saved even though it should)
Title: Re: [Help] GiveWeapon error
Post by: MakeCents on January 21, 2016, 01:07:22 am
Oh, I saw the one comment and all the precaches above and thought you were using more, my bad.
Title: Re: [Help] GiveWeapon error
Post by: DeletedUser on January 21, 2016, 01:14:52 am
Oh, I saw the one comment and all the precaches above and thought you were using more, my bad.
yeah the weapon file im using can be found here (https://github.com/WARDOGSK93/CoD-Perk-System/blob/master/weapons/sp/wardog_perk_bottle) dont know if all this can be caused be a mistake in the weapon file (i dont really know how weapon files work i tend to edit them with UGX Weapon editor and add the extra models in Sublime)
Title: Re: [Help] GiveWeapon error
Post by: DidUknowiPwn on January 21, 2016, 02:37:16 am
give by console vs giveweapon by script do completely different things.

GiveWeapon only gives it if the weapon was cached into the level at level-load vs give giving the loaded asset pool for weapons.

You missing the precache is the only thing wrong. (Are you 100% sure it's been precached though?)
Title: Re: [Help] GiveWeapon error
Post by: DeletedUser on January 21, 2016, 03:02:27 pm
give by console vs giveweapon by script do completely different things.

GiveWeapon only gives it if the weapon was cached into the level at level-load vs give giving the loaded asset pool for weapons.

You missing the precache is the only thing wrong. (Are you 100% sure it's been precached though?)

i 101% sure its been precached but after a nights rest im just gonna rewrite my system (its the only thing i can think of to fix it)
Title: Re: [Help] GiveWeapon error
Post by: MakeCents on January 21, 2016, 03:09:20 pm
i 101% sure its been precached but after a nights rest im just gonna rewrite my system (its the only thing i can think of to fix it)

I had this issue with my perk system a while ago and can't remember what fixed it. I too passed the string to precache the weapon file after init in another function. I almost want to say it fixed itself, but I don't remember. I currently still have that option but only use one weapon file so I precache it in my init function of my perk system which I call in zombiemode where the others are called. It very well could still not be working for multiple weapon files in the passing the string system, I don't know. But if you have precached the weapon file in the init function, or even tried in one of the zombiemode precache functions, hud or shader or whatever, to add the weapons/bottles/items there, checked for misspellings, I guess you don't have a choice then.
Title: Re: [Help] GiveWeapon error
Post by: DeletedUser on January 21, 2016, 03:33:12 pm
i 101% sure its been precached but after a nights rest im just gonna rewrite my system (its the only thing i can think of to fix it)

but im not 100% sure that i used the right SwitchWeapon function :-[ gotta love auto complete and not checking what it auto completes into

it was giving the bottle perfectly fine but i used SwitchToOffhand() instead of SwitchToWeapon() :o maybe next time il check whats been typed

Edit: this makes me feel so stupid that a simple error like this would cause such an issue  :-[
Title: Re: [Help] GiveWeapon error
Post by: Harry Bo21 on January 22, 2016, 08:25:29 am
did anyone check he is precaching the "weapon file" and not the model

Code Snippet
Plaintext
PrecacheItem( "perk_bottle_weapon_file" );

dont need to for guns and stuff because :

Code Snippet
Plaintext
add_zombie_weapon()

precaches those in that function


EDIT - didnt see that last post