PDA

View Full Version : y_ini saving variable twice


Cepillado
31/12/2015, 12:22 AM
Edit: I just fixed it, seems like you can't have spaces when saving variables.

I had:

INI_WriteInt(jFile, "Virtual World", vw);

and just changed it to:

INI_WriteInt(jFile, "VirtualWorld", vw);

AndySedeyn
31/12/2015, 12:27 AM
Saving the player's coordinates in the form of a string seems very inefficient to me. Unless someone can prove me wrong, I'll stick with that claim.
You're not closing the quotation mark following "money". Your file is not being closed. As for the virtual world, you're either saving it somewhere else too or it is because of the things I've mentioned above.

Also, I recommend saving data when their values change instead of saving everything when the player disconnects. I quote the wikipage for the OnPlayerDisconnect callback:
Some functions might not work correctly when used in this callback because the player is already disconnected when the callback is called. This means that you can't get unambiguous information from functions like GetPlayerIP and GetPlayerPos.

EDIT: I didn't know that could form a problem. Good to know.

Cepillado
31/12/2015, 01:09 AM
How would you save the player's coordinates?. I like using a string because I can save everything in just one line instead of using 4 different variables.

(And yes, the quotation mark following "money" was a mistake that I made during the post, it wasn't like that in the script)

AndySedeyn
31/12/2015, 01:19 AM
Save each coordinate on a new line as a float. I'm sure you like it that way, but you should prefer efficiency over preferred styles unless both styles have equal efficiency (which I doubt in this case).

Cepillado
31/12/2015, 01:45 AM
Why is it more efficient to save them each individually? I still sscanf them as a floats when I need to use them, is it somehow "faster" to just have them in their own variable? I feel like I save more space both in the .ini file and in the script by using strings, but I'm willing to change them if understand why that isn't the most efficient way to do it.

AndySedeyn
31/12/2015, 01:56 AM
Exactly that. You have to split the string in different values first before you can handle them individually while if you were to handle them individually in the first place, then the splitting of the string won't be needed any more. Then again, I'm unsure whether or not your method is truly less efficient than the method I use. Considering my logic in the beginning of this post, I believe it is slightly more efficient. Though, if the efficiency difference is minimal, then you won't have to worry about it. I'll work on a script to compare both methods in efficiency. As for now, take my advice with a pinch of salt.