Jump to content

Skin Selection (Client-Side) with extreme Loading Times


Recommended Posts

Hi Scripters,

I made a Skin-Selection for my Server where you get three Keys Bound: One to choose the next Skin, one to choose the previous Skin and one to Change the Gender of the Skins. It protects already used Skins (that are saved in a MySQL Table) from being used another time and just shows civil Skins. (No Police, Medical or not working ones)

So my Server Script loads a List of already Used Skins and stores it in a Table named dbUsedSkins. It also loads an xml-File, which contains Information about every Skin like SkinID, Type (civil, not working, police, ...) and Gender (male or female). All the Information from the XML File is stored in a Table called dbSkins with a Syntax like dbSkins[skinid][field] (field = gender or type).

If now a new Client joins the Game the Server sends both Tables to the Client via triggerClientEvent and the Client Script stores them in Script-Global Tables named like the ones in the Server Script.

If the Player in the Skin Selection now presses the Key to get the next Skin, a repeat until Loop is called, which increases the actual skinid until the Skin with the skinid...

... is working. (Not "fucked")

... has the same Gender as the actual Skin of the Player.

... is not listed in dbUsedSkins.

If the Script found the next SkinID that fulfills these Conditions it sets it as the new Skin of the Player. (setPlayerSkin)

The Problem now is that this (changing the skin to the next one) takes very much time, which should not be and can not be. I can't find any logical reason for the long Loading time... (Sometimes MTA even freezes because of loading so long)

I arranged the relevant Code Snippets and posted them on the MTA Pastebin.

» http://mta.pastebin.com/m574cd26e

I appreaciate any Help or even Questions or at least if you read this Posting :D

Hope I get this Problem solved.

Greetz, Neon.

PS.: You may download an exported Version of my Skin Selection on http://www.neon-rpg.de/files/skinsel.zip.

Please note that it won't work the first Time you join the Server because the Client Events are called before the Resource is loaded. Second Time should work, because then you already downloaded the Client Script.

Link to comment

I haven't looked at the code but my advice is to comment the parts where you suspect the script turns bad (possibly somewhere inside a nested loop). And uncomment the sections line by line and see if the has any positive effect. It could very well be that at some point a function result inside the loop does not return the correct values. Even though this may not show as an error in your debug window the code could still raise internal exceptions during execution. I've seen it before when a function call inside a loop was not made in the correct way (typo, wrong parameters etc.) the script seemed to "lag".

Link to comment
The Problem now is that this (changing the skin to the next one) takes very much time, which should not be and can not be. I can't find any logical reason for the long Loading time... (Sometimes MTA even freezes because of loading so long)

It's a bug in DP2. The Client doesn't unload the previous skin so when you go trough a lot of skins it begins to lag and eventually even crash. This has been fixed in DP3 though.

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...