View Single Post
FoxueR
Senior Member
Join Date: Jun 2011
Old 06-26-2011 , 22:22   Re: How to save a player choice?
Reply With Quote #5

Menu items start at 0, so it's probably better to initialize the choice to -1 or increment the menu items before storing them.

Also, notice there's a consistency in your code:

PHP Code:
switch ( item )
{
    case 
:
    {
        
g_myarray[id] = 1
    
}
    case 
:
    {
        
g_myarray[id] = 2
    
}
    case 
:
    {
        
g_myarray[id] = 3
    
}

Notice how, on case 2, you set g_myarray[id] to 2, etc. In this case, your code can be generalized to:

PHP Code:
g_myarray[id] = item 
You can, of course, add extra checks like:
PHP Code:
if ( item && item )
{
    
g_myarray[id] = item

__________________
¯\_(ツ)_/¯
FoxueR is offline