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

Give player ammo?

broken avatar :(
Created 10 years ago
by Ege115
0 Members and 1 Guest are viewing this topic.
1,936 views
broken avatar :(
×
broken avatar :(
Location: se
Date Registered: 30 July 2013
Last active: 3 weeks ago
Posts
517
Respect
Forum Rank
Zombie Enslaver
Primary Group
Community Scripter
My Groups
More
My Contact & Social Links
More
×
Ege115's Groups
Community Scripter Has shown effort and knowledge in the area of scripting while being a part of the UGX-Mods community.
Ege115's Contact & Social LinksEge115
Are there any function OR any way were I can decide how much ammo I want to give the player for a specific weapon?
I checked the script reference but couldn't find what I wanted. Could have missed something.

Thanks in advance.
Last Edit: July 28, 2014, 12:10:57 am by Ege115
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: 21 March 2014
Last active: 2 years ago
Posts
227
Respect
Forum Rank
Mr. Elemental
Primary Group
Member
My Contact & Social Links
More
Personal Quote
I the Mighty
×
ConvictioNDR's Groups
Code Snippet
Plaintext
player giveWeapon( weapon );
player setWeaponAmmoClip( weapon, ammo_amount );
player setWeaponAmmoStock ( weapon, ammo_amount );
broken avatar :(
×
broken avatar :(
Location: se
Date Registered: 30 July 2013
Last active: 3 weeks ago
Posts
517
Respect
Forum Rank
Zombie Enslaver
Primary Group
Community Scripter
My Groups
More
My Contact & Social Links
More
×
Ege115's Groups
Community Scripter Has shown effort and knowledge in the area of scripting while being a part of the UGX-Mods community.
Ege115's Contact & Social LinksEge115
Thanks for the replies.
I'm trying to do something like this. Give the player the amount of ammunition that the player had in his previous weapon. As this gives the player a new weapon and takes the previous weapon.
Code Snippet
Plaintext
        current_weapon = self GetCurrentWeapon();
self.current_clip = self GetCurrentWeaponClipAmmo();
self.current_ammo = self GetFractionMaxAmmo( current_weapon );

if(self IsTouching(pistol_trigger) && self UseButtonPressed() && !self HasWeapon(weapon_file_name[0]) && self.pistol1 == true)
{
self TakeWeapon(current_weapon);
self GiveWeapon(weapon_file_name[0]);
self SwitchToWeapon(weapon_file_name[0]);
chosen_weapon_ammo = self GetCurrentWeaponClipAmmo();

if(self.current_ammo >= chosen_weapon_ammo)
{
iprintln("start ammo");
self Givestartammo(weapon_file_name[0]);
}
else
{
iprintln("current ammo");
self SetWeaponAmmoStock( weapon_file_name[0], self.current_ammo );
self SetWeaponAmmoClip( "weapon_file_name[0]", self.current_clip );
}
}
But the problem is, it gives the player the start ammo even if the "self.current_ammo" is less than  "chosen_weapon_ammo" when I test it ingame.
Why does it do that?
Last Edit: July 28, 2014, 08:25:41 am by Ege115
Marked as best answer by Ege115 10 years ago
broken avatar :(
×
broken avatar :(
[UGX] Documentation Writer & Programmer
Location: usLos Angeles, CA
Date Registered: 23 August 2013
Last active: 6 months 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
GetFractionMaxAmmo returns a fraction compared to what the player has.
What do you can do instead is getAmmoCount(string);
This returns total ammounition on the weapon, for example colt has 32 rounds and 8 in clip, and that would return 40.
If you want to get the stock just do
Code Snippet
Plaintext
			curr_weapon = self GetCurrentWeapon();
current_clip_ammo = self GetWeaponAmmoClip(curr_weapon);
current_ammo = self getAmmoCount(curr_weapon);
current_ammo_sub = self getAmmoCount(curr_weapon) - current_clip_ammo;

IPrintLn(current_clip_ammo);
IPrintLn(current_ammo);
IPrintLn(current_ammo_sub);

Last Edit: July 28, 2014, 04:23:51 pm by DidUknowiPwn
broken avatar :(
×
broken avatar :(
Location: se
Date Registered: 30 July 2013
Last active: 3 weeks ago
Posts
517
Respect
Forum Rank
Zombie Enslaver
Primary Group
Community Scripter
My Groups
More
My Contact & Social Links
More
×
Ege115's Groups
Community Scripter Has shown effort and knowledge in the area of scripting while being a part of the UGX-Mods community.
Ege115's Contact & Social LinksEge115
GetFractionMaxAmmo returns a fraction compared to what the player has.
What do you can do instead is getAmmoCount(string);
This returns total ammounition on the weapon, for example colt has 32 rounds and 8 in clip, and that would return 40.
If you want to get the stock just do
Code Snippet
Plaintext
			curr_weapon = self GetCurrentWeapon();
current_clip_ammo = self GetWeaponAmmoClip(curr_weapon);
current_ammo = self getAmmoCount(curr_weapon);
current_ammo_sub = self getAmmoCount(curr_weapon) - current_clip_ammo;

IPrintLn(current_clip_ammo);
IPrintLn(current_ammo);
IPrintLn(current_ammo_sub);

(Image removed from quote.)
Thank you, got it working and it works just perfect. ;)

 
Loading ...