is in array ?
Hello, everyone!,
Okay, Suppose i have this: PHP Code:
check the value 1! I already tried with 2 for loop, dynamic arrays, tries and nothing help?! |
Re: is in array ?
arr1[0] == 1?
arr2[1] == 1? |
Re: is in array ?
you're right but the problem is i dont know the index
Code:
i think the for loop is solution, but no success |
Re: is in array ?
bump
|
Re: is in array ?
How to store and access your data. This is one of the first things you consider because it is the most central function of a plugin.
It's not worth using a static array for something like this. You only create limitations and the speed is really nothing to talk about. One dynamic array (array) that contains all the information about the skins (unique id, model, name, w/e...). One dynamic array (integer) for each player containing the unique id of all the skins they own. ArraySize() will replace iPlayerSkinsCount. The problem here is how to make a unique id for each skin so if one skin is removed from the server it won't corrupt the whole array and shift all of the skins. That problem could be solved by storing all of the information of the skin in each player array, but that's just bad practice and will increase the data size of each player, both online and offline. The simple solution would be to store a separate vault containing a unique identifier of a skin (a model name?) and connect that to a unique id. That way there's no possibility for corruption. Load it when the plugin loads the skins and give all the skins an unique id. If they don't have a unique id because they are new, give them one. |
Re: is in array ?
Quote:
What is the best way to create a unique id for each one skin ? Quote:
I have a problem whean im storing a skin data on plugin_precache when i put this *testing* PHP Code:
Code:
invalid array handle provided (0)PHP Code:
|
Re: is in array ?
Perhaps you are initiating the array after you try to add data to it.
For example, plugin_precache is called before plugin_init and plugin_cfg. Move array initialization to precache. I'm going to create a complete example on the whole system I had in mind. |
Re: is in array ?
Quote:
thankss for the help! Quote:
|
Re: is in array ?
I will gladly integrate it more into your plugin if you give me more information or the code.
This will keep track of all skins, their unique ID's and which skins the player has been given. Everything saved in nVault of course. Use AddSkinToPlayer() to give users skins and GetSkinInfo() to retrieve the information about a certain skin. If you want it more efficient you can use the trie directly instead of using GetSkinInfo(). To enumerate all skins (for a buy menu): Code:
To enumerate a player's skins (for a selection menu): Code:
If you have any questions just ask.
Spoiler
|
Re: is in array ?
god!!, dude you are a genius !! thankss!, i will learn with this plugin!, damm!
Quote:
I sent request on steam, because this is already off-topic, thanks, and keep coding, you are a master piece! |
| All times are GMT -4. The time now is 23:08. |
Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.