Raised This Month: $ Target: $400
 0% 

Switch statements with strings


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
hornet
AMX Mod X Plugin Approver
Join Date: Mar 2010
Location: Australia
Old 05-05-2010 , 05:51   Switch statements with strings
Reply With Quote #1

Hi guys, I'm having trouble using a switch statement with strings.
I'm trying to get the name of the player's model, and I understand that the model name will return as the name of the model folder / model name without the file extension.
I have these models set as constants set before plugin_init() like so:
PHP Code:
new const modelname_up1="up1";
//etc 
Then this is my code:
PHP Code:
new playerModel[32];
cs_get_user_model(id,playerModel,32);

switch(
playerModel)
        {
            case 
modelname_up1:
            {
                
cs_set_user_model(id,modelname_zp1);
            }
            case 
modelname_up2:
            {
                
cs_set_user_model(id,modelname_zp2);
            }
            case 
modelname_up3:
            {
                
cs_set_user_model(id,modelname_zp3);
            }
            case 
modelname_up4:
            {
                
cs_set_user_model(id,modelname_zp4);
            }
        } 
On the switch statement line I'm getting the error:
Error: Array must be indexed (variable "-unknown-")

And on each of the case lines I'm getting:
Error: Must be a constant expression; assumed zero

Please help me solve this.
Thanks!
hornet is offline
 


Thread Tools
Display Modes

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 03:34.


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