Jump to content

Table with GUI image elements --> crash


MaddDogg

Recommended Posts

Hi,

I'm currently working on a car panel system, which uses among other things images, which are showing up when entering a car.

Those images are created at the client resource start and hidden by default.

I didn't have a problem with my system until some of my friends working with me wanted to have a look at the new scripted stuff.

But some of them just crashed when they entered a car, to be exact, at the point where the images where instructed to show up (code for that below).

This is the main code:

carSymbols["highbeams"] = guiCreateStaticImage(scrW*0.2530,scrH*0.9619,40,40,"images/icon_car_highbeams.png",false)
carSymbols["lights"] = guiCreateStaticImage(scrW*0.2095,scrH*0.9619,40,40,"images/icon_car_lights.png",false)
carSymbols["park"] = guiCreateStaticImage(scrW*0.5089,scrH*0.9619,40,40,"images/icon_car_park.png",false)
carSymbols["doors"] = guiCreateStaticImage(scrW*0.4690,scrH*0.9635,40,40,"images/icon_car_doors.png",false)
carSymbols["indicator_left"] = guiCreateStaticImage(scrW*0.3167,scrH*0.9619,40,40,"images/icon_car_indicator_left.png",false)
carSymbols["indicator_right"] = guiCreateStaticImage(scrW*0.3607,scrH*0.9619,40,40,"images/icon_car_indicator_right.png",false)
carSymbols["fuel"] = guiCreateStaticImage(scrW*0.6190,scrH*0.9619,40,40,"images/icon_car_fuel.png",false)
carSymbols["battery"] = guiCreateStaticImage(scrW*0.5482,scrH*0.9619,40,40,"images/icon_car_battery.png",false)
carSymbols["engine"] = guiCreateStaticImage(scrW*0.1655,scrH*0.9619,40,40,"images/icon_car_engine.png",false)
carSymbols["oil"] = guiCreateStaticImage(scrW*0.5863,scrH*0.9619,40,40,"images/icon_car_oil.png",false)
carSymbols["warn"] = guiCreateStaticImage(scrW*0.4298,scrH*0.9619,40,40,"images/icon_car_warn.png",false)

The following is responsible for making these images visible:

for key, imageElement in pairs(carSymbols) do
	guiSetVisible(imageElement, false)
end

I already tried several approaches to fix the problem like putting the loop to make the images visible into a command, but it doesn't matter, when these lines are called, as soon as the images are made visible, my friends have a crash.

I was able to narrow down the problem to the table. This means that when I don't put the images into carSymbols[] and give all of them "their own variable", my friend won't get a crash.

Btw the table is created at client resource start.

And the odd thing is that it works for 50% of the people who entered a car on my server, the other half got a crash.

So, can somebody explain to me, why this table is making such problems and why it is just effecting some of the people, who tried it out?

Thanks in advance!

Madd

Link to comment

hi,

to be honest, the easiest and probably best way to solve this is probably to just screw gui functions and use dx functions instead.i wouldn't wonder if the problem is more related to how gui treats images than to your code.

for key, imageElement in pairs(carSymbols) do
guiSetVisible(imageElement, false)
end

also this is supposed to be true i guess, not false.

a thing you could try is to give all the images a parent and only set the parents visibility. but i really recommend using dx functions instead, it's faster,better and more reliable.

Link to comment

Oh, my mistake, the code snippet was actually the one to hide it again, the actual one has a true in it.

I already thought about using dx functions for that, that would also probably be easier to handle since I constantly check for a change in element data and adapt the image according to that.

I'll try dx now, thanks for the help..

If I'll run into another problem, I will post it in here, else problem kinda solved. :D

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...