Raised This Month: $ Target: $400
 0% 

Better way to check if exist other than for loop


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 04-16-2021 , 22:20   Re: Better way to check if exist other than for loop
Reply With Quote #6

PHP Code:

#include <amxmodx>

#define MAX_PLAYERS 32

enum Skills
{
    
HasAllSkills,
    
HighJump,
    
Gravity,
    
NoClip,
    
UnlimitedMoney,
    
UnlimitedHealth,
    
UnlimitedAmmo,
    
OneShotKill
}
new 
bool:g_PlayerSkillsMAX_PLAYERS ][ Skills ];

public 
SkillGainid )
{
    new 
Skills:sRandomSkill GetRandomSkillid );
    
    if( 
sRandomSkill == HasAllSkills )
    {
        
//Player has all skills
    
}
    else
    {
        
//Player got skill sRandomSkill
        //Set_Skill( id , sRandomSkill , true)
        
g_PlayerSkillsid ][ sRandomSkill ] = true;
        
        
//Give the player the stuff
        
switch ( sRandomSkill )
        {
            case 
HighJump
            {
            }
            case 
Gravity
            {
            }
            case 
NoClip
            {
            }
            case 
UnlimitedMoney
            {
            }
            case 
UnlimitedHealth
            {
            }
            case 
UnlimitedAmmo
            {
            }
            case 
OneShotKill
            {
            }
        }
    }
}

public 
Skills:GetRandomSkillid )
{
    new 
Skills:sGetRandomSkills ] , iSkillIndex;

    for ( new 
Skills:sSkillID HighJump sSkillID Skills sSkillID++ )
    {
        if ( 
g_PlayerSkillsid ][ sSkillID ] == false )
        {
            
sGetRandomSkills:iSkillIndex++ ] = sSkillID;
        }
    }
    
    return 
iSkillIndex sGetRandom[ ( Skills:randomiSkillIndex ) ) ] : HasAllSkills;

__________________

Last edited by Bugsy; 04-16-2021 at 22:44.
Bugsy 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 17:38.


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