Raised This Month: $ Target: $400
 0% 

[HELP] Switch between const size numbers


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
DavidJr
Senior Member
Join Date: Apr 2012
Old 05-26-2014 , 10:33   Re: [HELP] Switch between const size numbers
Reply With Quote #4

I understand, but why do you still need case for constant variable? You can do it without swtich - case.

This is the example:
PHP Code:
new const Stuff[][] =
{
    
"",
    
"say /hp",
    
"say /armor"
}

new const 
healthPotion[] =
{
    
0,
    
10,
    
20,
    
30
}

new const 
armorPotion[] =
{
    
0,
    
10,
    
20,
    
30
}

public 
plugin_init()
{
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    for(new 
1sizeof(Stuff); i++) register_clcmd(Stuff[i], "TheOneFunction");
}


public 
TheOneFunction(iIndex)
{
    new 
szCmd[33];
    
read_argv(4szCmdsizeof szCmd);
    
    new 
iNum;
    
    if (
contain(szCmd"/hp"))
    {
        
replace(szCmdsizeof szCmd"/hp """);

        
iNum str_to_num(szCmd);
        new 
iHealth get_user_health(iIndex);
        
        
set_user_health(iIndexiHealth healthPotion[iNum]);
    }
    else if (
contain(szCmd"/ammo"))
    {
        
replace(szCmdsizeof szCmd"/ammo """);

        
iNum str_to_num(szCmd);
        new 
iArmor get_user_armor(iIndex);
        
        
set_user_armor(iIndexiArmor armorPotion[iNum]);
    }

__________________
What are you looking for here?

Last edited by DavidJr; 05-26-2014 at 11:43.
DavidJr 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 09:43.


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