Quote from: KAKAN on Feb 12, 2017, 04:03 AMplayerson.push( player ) instead of ID, is better.
That approach is flawed because of http://forum.vc-mp.org/?topic=2997.0 This implementation was further discussed here http://vcmp.liberty-unleashed.co.uk/forum/index.php?topic=2419.0 but doesn't work because the developers failed to understand or know what one of the main questions in that topic meant "Is the Player instance ever changed by the server without notification? So that I can switch the key to the new instance.".
Quote from: ...happymint_ on Feb 12, 2017, 01:41 AMCode Selectplayers <- {};
function onPlayerJoin( player )
{
players.rawset(player.Name,player);
}
function onPlayerPart( player, reason )
{
players.rawdelete(player.Name);
}
That also is flawed. Not in general. But only for VC:MP scripters. Because you know.
Why? Well, let's say that player 1 changes name from "looser" too "bigger looser" and player 2 changes name from "tiny looser" to "looser". Well then. A simple mistake in forgetting to update a table and your server logic is f*ed. And don't say you won't forget. Because you will. Somehow, somewhere.
And last but not least. Any answer given to you here is a total waste of time. Why? Because you don't understand the differences between tables and arrays. And because again, you're asking the wrong question. You shouldn't strive to understand which one is better. You should strive to understand how they work and then you'll inherently know which one is better for a certain situation.
Quote from: ...happymint_ on Feb 12, 2017, 01:41 AMCode Selectplayerson <- [];
function onPlayerJoin( player )
{
playerson.push( player.ID );
}
function onPlayerPart( player, reason )
{
playerson.remove( player.ID );
}
This again proves that you don't know how they work. Because if you use push instead of direct indexing then you're going to have to perform a manual search to find a certain ID.
I'm not even sure wtf this question is about anymore. Storing numbers, storing strings or storing players.