Raised This Month: $ Target: $400
 0% 

[Solved] How to save a player choice?


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
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
 



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 23:31.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode