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

Use images for Ammo Counter?

broken avatar :(
Created 10 years ago
by Deleted User
0 Members and 1 Guest are viewing this topic.
5,945 views
broken avatar :(
  • Exofile
  • Deleted Member
×
broken avatar :(
Exofile
This user is deleted :(
So I'm trying to modify a HUD, and I'd need the Ammo Counter to be images. How do I do this?

I don't know scripting, I can understand some, but can't write it myself.
I'm editing Dukip's MOTD hud, as I have no idea how to make the menufiles myself.
I have pretty much no experience with scripting for CoD, so telling me what to do would mean showing what to input for it to work, if you've got the time. :please:

I put "split", and is curious if there is a way to take a value such as 10, and turn it over into 1, 0 or similar, and have two images display, corresponding with 1 and 0.

Here is what I'd wish to have, where the name is moved, and the red ammo text is images(One for each number)


So here is an example of ways I'm curious if would work, I know the functions aren't real, but I'm just showing example of what I mean.

Code Snippet
Plaintext
if(dvar("hud_player_ammo_weapon", clipcount) == "10")
showImage(don't know the func for it.) ("insert_image_for_10_here")

or

if(dvar("hud_player_ammo_weapon", clipcount) == "10")
split(dvar("hud_player_ammo_weapon", clipcount) (outcome would be like 1 and 0)
showImage (insert_image_for_1_here) + (insert_image_for_0_here)

If you have a better suggestion of how to do it, I'm open for all suggestions, all response is appreciated.

Appreciate all help. :)
broken avatar :(
×
broken avatar :(
[UGX] Documentation Writer & Programmer
Location: usLos Angeles, CA
Date Registered: 23 August 2013
Last active: 2 years ago
Posts
1,322
Respect
Forum Rank
Zombie Colossus
Primary Group
UGX Team Member
My Groups
More
My Contact & Social Links
More
Personal Quote
(ง º ω º )ง u wont sum m8y?
Signature
Do not take life too seriously. You will never get out of it alive.
×
DidUknowiPwn's Groups
UGX Team Member
Donator ♥ Benevolent Soul who has our eternal gratitude and exclusive access to betas and the donator section of the forum.
Community Scripter Elite Has shown excellence and experience in the area of custom scripting in the UGX-Mods community.
BO3 Modtools Alpha
BO3 Modtools Alpha
This user has access to the Black Ops 3 Modtools Alpha
Well in GSC all you have to do is set a dvar that pertains to it. So would have to divide your current ammo stock by some amount like 10 until you have less than 1 then you know that number was the final one.

In menu you just need to 6 (XXX XXX) itemDefs with each one having exp material("hud_ammount_counter_X")
x ranging from 1-6 (or reversed 6-1 so it makes sense).
broken avatar :(
  • Exofile
  • Deleted Member
×
broken avatar :(
Exofile
This user is deleted :(
Wouldn't it be 10 x's? 0-9 in each line. 10 then 9 down to 0.
And  how do I set a dvar? I got no experience with scripting in CoD, all I know is Lua and Python. I could really need someone to show me what to put where, or atleast how the functions would be.
I've got no idea what an itemDef is either.
Sorry :please:
broken avatar :(
×
broken avatar :(
Location: esMadrid
Date Registered: 27 March 2015
Last active: 5 years ago
Posts
371
Respect
Forum Rank
Perk Hacker
Primary Group
Member
My Contact & Social Links
More
Personal Quote
JIGGLYPUFF used SING! YOU fell asleep!
Signature
×
Soy-Yo's Groups
Soy-Yo's Contact & Social LinksSoy-yoElCerdoRey
I only know how to split numbers, but maybe you don't need it.
Something like this:
Code Snippet
Plaintext
// n = the number you want to split
th = int( n / 1000 );
h = int( ( n % 1000 ) / 100 );
t = int( ( ( n % 1000 ) % 100 ) / 10 );
u = int( ( ( n % 1000 ) % 100 ) % 10 );
I used something similar for my map, so this might work.
broken avatar :(
×
broken avatar :(
Location: us
Date Registered: 14 September 2013
Last active: 5 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


I tried explaining most of it here.
http://ugx-mods.com/forum/index.php/topic,9199.0.html

Not sure if it will help, but if you haven't seen it.
broken avatar :(
  • Exofile
  • Deleted Member
×
broken avatar :(
Exofile
This user is deleted :(

I tried explaining most of it here.
http://ugx-mods.com/forum/index.php/topic,9199.0.html

Not sure if it will help, but if you haven't seen it.

Yeah, I spent a good while looking for a previous post, must've missed this one. Just as him, I'm using the T6 MOTD HUD. But I'm curious as to what I do with the .gsc? I have zero scripting experience in this, so when you say:
Quote
The dvar is a variable. So a variable ='s the name of the material. So the name of the material is set in gsc. When it is set, that is the material the menu uses. Each digit is only one number at a time.
I am not sure exactly what to put there?

Would it be self SetClientDvar("number_1", IMAGEHERE);?
broken avatar :(
×
broken avatar :(
Location: us
Date Registered: 14 September 2013
Last active: 5 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
If number_1 is your dvar, yeah. But most likely, that's your image, and position1 is your dvar. The itemdef will set the image to the dvar value. You set the dvar value to the image you want to see.

Code Snippet
Plaintext
self setclientdvar("position1", number);

number in this case, in gsc, represents the concatenation of your image prefix and the number you have separated from your ammo count, like soy posted.

If your using his math, then

Code Snippet
Plaintext
number = "number_" + th;

Or

Code Snippet
Plaintext
self setclientdvar("position1", "number_"+th);
self setclientdvar("position2", "number_"+h);


And so on
Last Edit: November 14, 2015, 11:30:56 pm by MakeCents
broken avatar :(
  • Exofile
  • Deleted Member
×
broken avatar :(
Exofile
This user is deleted :(
If number_1 is your dvar, yeah. But most likely, that's your image, and position1 is your dvar. The itemdef will set the image to the dvar value. You set the dvar value to the image you want to see.

Code Snippet
Plaintext
self setclientdvar("position1", number);

number in this case, in gsc, represents the concatenation of your image prefix and the number you have separated from your ammo count, like soy posted.

Ok, I understand it a bit more now. I read in the other thread that I could use number_, I assume it doesn't matter if I do number_ or number, as long as the image is named accordingly? (number_1 and so on, or number1 and so on)
So in the .gsc, it'd be like this? Am I forgetting anything, and more importantly, is it done right + in the right place in the .gsc?

Code Snippet
Plaintext
update_weapon_hud()
{
self endon("death");
self endon("disconnect");

//DUKIP - Create local vars.
newWeap = "";
clipCount = 0;
stockCount = 0;

while(true)
{
self waittill_any("reload_start", "reload", "weapon_change", "weapon_change_complete", "weapon_fired");

newWeap = self GetCurrentWeapon();
//DUKIP - Hide the ammo if our weapon is 'bad'.
//Don't hide if we our weapon is a grenade launcher i.e. M1 Garand's alt = m7_launcher
if(newWeap == "none" || (WeaponClass(newWeap) == "grenade" && !IsSubStr(newWeap, "m7")) || WeaponClass(newWeap) == "gas")
{
self SetClientDvar("hud_player_ammo_weapon", "");
wait 0.1;
continue;
}

clipCount = self GetWeaponAmmoClip(newWeap);
stockCount = self GetWeaponAmmoStock(newWeap);

self SetClientDvar("hud_player_ammo_weapon", clipCount + "/" + stockCount);
self SetClientDvar("pos1", number_);
self SetClientDvar("pos2", number_);
self SetClientDvar("pos3", number_);
self SetClientDvar("pos4", number_);
self SetClientDvar("pos5", number_);
self SetClientDvar("pos6", number_);
self SetClientDvar("pos7", number_);
}
}

Soy-Yo's split number was a bit confusing to me too, what values does th, h, t and u end up as? I understand % gives off what is remainding from the calculation, but I don't know what values it returns, if it makes sense?
broken avatar :(
×
broken avatar :(
Location: us
Date Registered: 14 September 2013
Last active: 5 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
You're very close. I updated my response. That should explain it better.
Last Edit: November 14, 2015, 11:38:16 pm by MakeCents
broken avatar :(
  • Exofile
  • Deleted Member
×
broken avatar :(
Exofile
This user is deleted :(
Oh, I see. But for his math, I'm not sure I understand it fully? What is th, what is h and so on. I see that it's a variable, but say n=57, what does the variables end up as? if N is for example stock ammo, is TH the first slot, H the second and so on?
broken avatar :(
×
broken avatar :(
Location: us
Date Registered: 14 September 2013
Last active: 5 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
th is thousandths, h is hundreds, and so on. You would calculate that per you clip and you stock ammo, which would be n

Except, you would only need hundreds for clip, and thousands for stock.
Last Edit: November 15, 2015, 12:21:51 am by MakeCents
broken avatar :(
×
broken avatar :(
[UGX] Documentation Writer & Programmer
Location: usLos Angeles, CA
Date Registered: 23 August 2013
Last active: 2 years ago
Posts
1,322
Respect
Forum Rank
Zombie Colossus
Primary Group
UGX Team Member
My Groups
More
My Contact & Social Links
More
Personal Quote
(ง º ω º )ง u wont sum m8y?
×
DidUknowiPwn's Groups
UGX Team Member
Donator ♥ Benevolent Soul who has our eternal gratitude and exclusive access to betas and the donator section of the forum.
Community Scripter Elite Has shown excellence and experience in the area of custom scripting in the UGX-Mods community.
BO3 Modtools Alpha
BO3 Modtools Alpha
This user has access to the Black Ops 3 Modtools Alpha
th is thousandths, h is hundreds, and so on. You would calculate that per you clip and you stock ammo, which would be n

Except, you would only need hundreds for clip, and thousands for stock.
Probably want to do it twice you know. Once for clip and once for stock.
Also you should wrap them around if statements like if(ammo > 0) { check for each type here i.e. >= 10 >= 100 >= 1000
broken avatar :(
×
broken avatar :(
Location: us
Date Registered: 14 September 2013
Last active: 5 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
Probably want to do it twice you know. Once for clip and once for stock.
Also you should wrap them around if statements like if(ammo > 0) { check for each type here i.e. >= 10 >= 100 >= 1000

Yup, it said that in what you quoted.  ;) Once he is able to show images from the clip and stock count, he will need to do more than just check for greater than 0, he will have to check for 0s to the left and if desired, adjust positions based on stock ammo. Then even adjust in menu the forecolor for ammo below 10. But that's later stuff imo.
Last Edit: November 15, 2015, 12:38:30 am by MakeCents
broken avatar :(
  • Exofile
  • Deleted Member
×
broken avatar :(
Exofile
This user is deleted :(
So I got some help from chat, pretty sure I got it working now, is there anything else I need to have in the .gsc?'
If not, where do I go from here?
Code:
Spoiler: click to open...
Code Snippet
Plaintext
update_weapon_hud()
{
self endon("death");
self endon("disconnect");

//DUKIP - Create local vars.
newWeap = "";
clipCount = 0;
stockCount = 0;

while(true)
{
self waittill_any("reload_start", "reload", "weapon_change", "weapon_change_complete", "weapon_fired");

newWeap = self GetCurrentWeapon();
//DUKIP - Hide the ammo if our weapon is 'bad'.
//Don't hide if we our weapon is a grenade launcher i.e. M1 Garand's alt = m7_launcher
if(newWeap == "none" || (WeaponClass(newWeap) == "grenade" && !IsSubStr(newWeap, "m7")) || WeaponClass(newWeap) == "gas")
{
self SetClientDvar("hud_player_ammo_weapon", "");
wait 0.1;
continue;
}

clipCount = self GetWeaponAmmoClip(newWeap);
stockCount = self GetWeaponAmmoStock(newWeap);

unitsClip = clipCount % 10;
tensClip = ((clipCount - unitsClip) % 100) / 10;
hundredsClip = (clipCount - (unitsClip + (tensClip * 10))) / 100;

unitsStock = clipCount % 10;
tensStock = ((clipCount - unitsStock) % 100) / 10;
hundredsStock = (clipCount - (unitsStock + (tensStock * 10))) / 100;

// Will comment/remove this line once I get the imagecounter working instead.
self SetClientDvar("hud_player_ammo_weapon", clipCount + "/" + stockCount);

self SetClientDvar("pos1", "number_"+hundredsClip);
self SetClientDvar("pos2", "number_"+tensClip);
self SetClientDvar("pos3", "number_"+unitsClip);
self SetClientDvar("pos4", "number_"+hundredsStock);
self SetClientDvar("pos5", "number_"+tensStock);
self SetClientDvar("pos6", "number_"+unitsStock);
}
}
broken avatar :(
×
broken avatar :(
Location: us
Date Registered: 14 September 2013
Last active: 5 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
So I got some help from chat, pretty sure I got it working now, is there anything else I need to have in the .gsc?'
If not, where do I go from here?
Code:
Spoiler: click to open...
Code Snippet
Plaintext
update_weapon_hud()
{
self endon("death");
self endon("disconnect");

//DUKIP - Create local vars.
newWeap = "";
clipCount = 0;
stockCount = 0;

while(true)
{
self waittill_any("reload_start", "reload", "weapon_change", "weapon_change_complete", "weapon_fired");

newWeap = self GetCurrentWeapon();
//DUKIP - Hide the ammo if our weapon is 'bad'.
//Don't hide if we our weapon is a grenade launcher i.e. M1 Garand's alt = m7_launcher
if(newWeap == "none" || (WeaponClass(newWeap) == "grenade" && !IsSubStr(newWeap, "m7")) || WeaponClass(newWeap) == "gas")
{
self SetClientDvar("hud_player_ammo_weapon", "");
wait 0.1;
continue;
}

clipCount = self GetWeaponAmmoClip(newWeap);
stockCount = self GetWeaponAmmoStock(newWeap);

unitsClip = clipCount % 10;
tensClip = ((clipCount - unitsClip) % 100) / 10;
hundredsClip = (clipCount - (unitsClip + (tensClip * 10))) / 100;

unitsStock = clipCount % 10;
tensStock = ((clipCount - unitsStock) % 100) / 10;
hundredsStock = (clipCount - (unitsStock + (tensStock * 10))) / 100;

// Will comment/remove this line once I get the imagecounter working instead.
self SetClientDvar("hud_player_ammo_weapon", clipCount + "/" + stockCount);

self SetClientDvar("pos1", "number_"+hundredsClip);
self SetClientDvar("pos2", "number_"+tensClip);
self SetClientDvar("pos3", "number_"+unitsClip);
self SetClientDvar("pos4", "number_"+hundredsStock);
self SetClientDvar("pos5", "number_"+tensStock);
self SetClientDvar("pos6", "number_"+unitsStock);
}
}

If your ammo stays under 6 digits that will work it seems. One thing you will see with this could be 002/005 or something like that, where you get 0's to the left, which you prob don't want. You'll have to add something to check that. So if the clip is <100 then set your dvar for the pos for the hundreds to whatever you set your itemdef to not be visible when, and so on with the others. If clip is <10, the hundreds and tens would be set to "" or "number_" depending on what you used...

 
Loading ...