#Bullets ammount and FireMode
116 messages · Page 1 of 1 (latest)
How about you even try what i sent you?
if (player.Player.equipment.asset is ItemGunAsset gunAsset) {
if (Assets.find(EAssetType.ITEM, gunAsset.getMagazineID()) is ItemMagazineAsset itemMagazineAsset) {
itemMagazineAsset.amount //Ammo
}
}```
That should work
FireMode should also be in ItemGunAssets
Not sure bout getting the magazine
Asset - these are the mod settings
Sort of
what???
no
thats the assets of what the player is holding
goober
i told you that already
This is from ItemGunAsset
Thanks, I'll try, but I doubt it
you are clearly doing something wrong and not following what i gave you
everything untill getting the magazine works 100%
after that im not that sure
what are you even doing
HUD
send me your code since you are doing something and not following what i atleast tried to make for you
var oFiremode = typeof(EFiremode).GetField("firemode", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(itemGunAsset);
if ((EFiremode)oFiremode == EFiremode.AUTO) {
//Do stuff
}```
Try this, using reflections.
Thats not how you get the data from a gun
Youll have to look at its state
didnt know about that, thanks
@boreal onyx
if (UnturnedPlayer.Player.equipment.asset is ItemGunAsset itemGunAsset) {
byte[] state = itemGunAsset.getState();
if (state[11]==0) {
//Safety
}
else if (state[11]==1) {
//Semi-Auto
}
else if (state[11]==2) {
//Auto
}
else if (state[11] == 3) {
//Burst
}
int AmmoCount = state[10];
}```
Heres what you need.
Oh, ty sir
Thanks, I'll check it out
And FireMode doesn't work
Also, if you remove the magazine, it will show bullets that are not there :0
It shows the numbers 1-(Number of max bullets in the magazine)
You didnt use the latest thing i sent you
State[10] is the ammo
EffectManager.sendUIEffectText(4920, Provider.findTransportConnection(Player.CSteamID), true, "textammo", state[10] + "/" + itemMagazineAsset.countMax);
Will play around with it
byte[] state = Player.Player.equipment.state;
that gets the state fromever the player is holding
asset is any kind of an assets class the player is holding
and you dont want to get state for example for a gas can
very wheir why that is broken
try holding a gas can and it will break
you need to check if the player is holding a gun
The game code is too strange
it is but its not related to this
public void Execute(IRocketPlayer caller, string[] command) {
if (caller == null) return;
UnturnedPlayer uCaller = caller as UnturnedPlayer;
if (uCaller.Player.equipment.asset == null)
return;
if (uCaller.Player.equipment.asset is ItemGunAsset gun) {
byte[] state = gun.getState();
ChatManager.serverSendMessage($"Ammo: {state[10]} | FireMode: {state[11]}", Color.green, null, uCaller.SteamPlayer()
, EChatMode.SAY, "https://dl.rbmkblaze.org/images/Sausageface.png", false);
}
}```
@keen crater @chrome trout Any idea why?
How I can get attachments gun?
xd
for getting magazine asset(There can be several magazines for a weapon)
yes
.
says here
ItemGunAsset.getState() is used by the game to get a random New state
Youll want to use PlayerEquipment.state
if (player.Player.equipment.asset is ItemGunAsset) {
int ammo = player.Player.equipment.state[10];
}```
Yes
🤓
I don’t quite understand where exactly attachments are
btw @chrome trout where is the exampleui gone, in what package is it, i want to try something
state[0],state[1],state[3],state[4],state[5]
did you even read it?
oh nvm xd
didnt relize it was in the description of bt's vid
uh sorry it was the first 10
sight state[0],state[1] tactical state[2],state[3] grip state[4],state[5] barrel state[6],state[7] ammo state[8],state[9]
They are split up into two bytes
well read the guide first to understand it please
even tho i could tell you everything, its better to read it all so you can actually understand how it works
Use Attachments.parseFromItemState() its static
ty guys
we ain't done yet mister.
You did a big L here when you used Provider.findTransportConnection, especially since there are properties in the SDG.Unturned.Player class that have the player's transport connection.
Please use player.Player.channel.owner.transportConnection before I begin a rampage of rage.
Also, you are adding variables to strings the old way, just use $"this is a string with a var in the middle {var1} and a var at the very end {var2}"
Don't do "this is a string with a var in the middle " + var1.ToString() + " and a var at the very end " + var2.ToString()
string interpolation(
) using that dollar sign is so much easier.
And I’m not home to check but if I remember correctly .SteamPlayer() is also a completely unnecessary loop by rocket, player.Player.channel.owner is faster
And to clarify, that method loops through each player every time you call it instead of accessing it directly, which isn’t ideal, especially with how many times you’re calling it (use local variables plz)
Sry forgot to turn off ping
All good, I'll ping you back in this reply and we'll call it even.
That is the first thing I changed when RocketModFix was created (no one is going to use that repo, but it goes to show how stupid that method is).
Will it improve optimization?
Apologies for the ping, logically yes
I have a habit
