Problems when calling the data table

Are your data table rows numbers? Or names? If it’s a number you can call it like so:

If it’s a name, just use the name…


It’s up to you how you name the rows:

344026-screenshot-1.png

344027-screenshot-2.png

Hi! I don’t speak English so I’m going to use a translator!

I’m implementing a shooting system in my game, everything is great so far, I can shoot … Reload … Change weapons … Precision system … But my problem comes when I have 2 weapons and I want to use a data table for the different weapons

The table is assembled with the basic variables that I use. My problem is that I don’t know how to “call” the lines of the tables. That is, if I use an AK47 (for example), I would like it to call the line of the AK47 in the table, since it is always being used line 1 … Use whatever weapon you use.

I’ve been porbando and testing for 3 afternoons and it’s impossible for me. I simply want to achieve that, that my character detects that I have an AK equipped and the line of the AK is 3, that he calls line 3 …

I don’t think it’s that complicated but I can’t get it, in the afternoon when I get home from work I’ll pass photos if necessary, thanks in advance!

But my idea / objective is that if I
carry an AK and pick up a pistol the
database changes to the pistol in the
same game (for example … That the
database goes from line 1 to 5, taking
into account that line 5 is the gun
logically), without having to go
through the BP and change it manually.

I don’t get it. You provide a RowName → you get a struct. There are no additional steps here.

the database changes to the pistol

What does this even mean? The Data Table (this is not a database!) is a bunch ot static data, organised into rows of structs. You query the DT with a Name and it spits out the associated struct. What to do with that struct is up to you…

Pseduoscript. Normally, you’d:

If you want to use numbers, check the link I posted at the very beginning.

if I carry an AK and pick up a pistol

Another, and much better solution than querying the data table, is to give each gun a struct data to begin with. You then pick up the gun and it already has all the data, no need to fetch it from anywhere.

Elegant and efficient, you do it only once when the gun is spawned / placed on the map. And the player is using the data the gun carries.

Not 100% sure I understand what’s going up there but consider the following:

  • struct and the DT:

  • the gun actor holds a Name for identification and a struct for its data:

  • when the gun actor is spawned, it will query the DT and assign the data row to its own variable. Next time you interact with this gun, you can use that variable, no need to query the DT anymore.

  • as a bonus, you can now modify gun data, since every gun has its own set.

And if you need to get the original data, use the Name identifier to fetch it from the DT.

Hi! Can you give me more information about that? I thought it would be easier to create a data table to call the line that corresponds to each weapon.

If there is another better option I will not hesitate to use it, currently my code is this:

344068-tabladedatos.png

As can be seen in the screenshots, my logic is that when I pick up a weapon from the ground, it selects a line from the database through the variable “NameWeapon” that NameWeapon = AK47 in the AK and M1911 in the pistol, for so if you take the gun you should call the M1911 line and then I have created a function “GetWeaponInfo” to facilitate when calling the weapons.

But as I said before … this is my logic, because it doesn’t work…

If there is something more polished and you know of a tutorial, I would not hesitate to do it, currently I did not want to advance much in adding weapons to madness and that if I can not even manage the ones I have well.

Thank you very much, greetings!

I edit to say that there is only data in the FireDelay since I was testing !!
I have added RowName to read me the lines of the data table, which I had yesterday fiddling with … today I deleted it, and now I have added it again, that is why in some capture RowName does not appear in GetWeaponInfo

Thank you so much for help me!

But it still doesn’t work for me …

The truth is that the BPs that you have passed to me have a lot of logic, but something fails, I have done it just as you have passed it to me and it did not work and then I have adapted it a bit, I think I am one step away from achieving it.

In the variable “GunName” I add the name of the weapon, right? ie … if it is the BP of the AK, GunName = AK47?
If it’s the one with the gun …
GunName = m1911?
I have been doing a follow-up with the game activated and UE4 finds the line of the AK in the database and gives it as good.

The problem that when playing … it does not recognize it, in the player I have created a variable called GunData (but it is not the same) to join it to break and that is where I think it fails, there playing it detects FireDelay to 0 (as I have it in the structure…)

Thank you very much for everything, I feel that I am one step away, but it is getting long long hahahaha

I GOT IT!

In the end, calling the BP Father of arms I have achieved it, now it needs to be logically polished … like anything that is implemented.

But working it works! When I pick up the AK my FireDelay is 1 (as the database says) and when I pick up the gun it is 2, the FireDelay thing was just a test, now that I know how it is implemented and how it works I will modify all the variables, damage, precision , reload, ammo …

Thank you very much again, I had been trying this 4 afternoons without result.