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.
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.
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).
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
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.
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);?
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 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?
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?
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?
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
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
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:
// Will comment/remove this line once I get the imagecounter working instead. self SetClientDvar("hud_player_ammo_weapon", clipCount + "/" + stockCount);
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:
// Will comment/remove this line once I get the imagecounter working instead. self SetClientDvar("hud_player_ammo_weapon", clipCount + "/" + stockCount);
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...