Raised This Month: $ Target: $400
 0% 

If class x have own hp , grav and etc


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
DoviuX
Senior Member
Join Date: Jun 2009
Location: Lithuania
Old 10-03-2009 , 13:55   If class x have own hp , grav and etc
Reply With Quote #1

If class x have own hp , grav , speed

PHP Code:
    new const ZombieClass[][] = {
    
"0",
    
"1",
    
"2"
    
};

   public 
fw_PlayerPreThink(id
   { 
        if(!
is_user_alive(id)) 
            return 
FMRES_IGNORED
     
        static 
Floatvelocity[3], FloatTime 
        
static buttonflag 
        button 
pev(idpev_button
        
flag pev(idpev_flags
        
Time get_gametime() 
     
        if (
g_zombie[id] && PlayerClass[id] == 0
        { 
            if ( (!
g_infreezetime) && (button IN_DUCK) && (button IN_ATTACK) && (flag FL_ONGROUND)) 
            { 
                    static 
FloatcooldownFloatlheightlforce 
                    cooldown 
get_pcvar_float(cvar_cooldown
                    
lforce get_pcvar_num(cvar_lforce
                    
lheight get_pcvar_float(cvar_lheight
                    if (
Time cooldown g_LastLeap[id]) 
                        {  
                        
emit_sound(idCHAN_ITEMhunter_leap1.0ATTN_NORM0PITCH_NORM); 
                        
set_pev(idpev_buttonbutton & ~IN_ATTACK
                        
velocity_by_aim(idlforcevelocity
                        
velocity[2] = lheight 
                        set_pev
(idpev_velocityvelocity
                        
g_LastLeap[id] = Time 
                        

            } 
        } 
        if (!
g_infreezetime && g_zombie[id] && ZombieClass[id] == 0
        { 
        
set_user_maxspeed(id280.0)
        
set_user_health(id600)
        
set_user_gravity(id0.7)
        } 
        else if (!
g_infreezetime && g_zombie[id] && PlayerClass[id] == 1
        { 
        
set_user_maxspeed(id255.0)
        
set_user_health(id700)
        
set_user_gravity(id0.8)
        } 
        else if (!
g_infreezetime && g_zombie[id] && PlayerClass[id] == 2
        { 
        
set_user_maxspeed(id250.0)
        
set_user_health(id300)
        
set_user_gravity(id0.9)
        } 
     
        return 
FMRES_IGNORED 
    

DoviuX is offline
Send a message via Skype™ to DoviuX
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 10-03-2009 , 14:04   Re: If class x have own hp , grav and etc
Reply With Quote #2

PHP Code:
    new const ZombieClass[][] = {
    
"0",
    
"1",
    
"2"
    
}; 
If you are storing integer values in the array then you can use an integer array instead of a string array:

PHP Code:
new const ZombieClass[] = { }; 
You can also do something like this just for better readability
PHP Code:
enum _:ZombieClass
{
      
SkinnyZombie,     //0
      
FatZombie,        //1
      
SlowZombie        //2
};

new 
PlayerClass33 ];

//Assign player a zombie class
PlayerClassid ] = FatZombie;

//Check if player is a fat zombie
if ( PlayerClassid ] == FatZombie )
{
     
//... 
And

Code:
        if (!g_infreezetime && g_zombie[id] && ZombieClass[id] == 0)         {         set_user_maxspeed(id, 280.0)         set_user_health(id, 600)         set_user_gravity(id, 0.7)         }         else if (!g_infreezetime && g_zombie[id] && PlayerClass[id] == 1)

Looks like just a typo but ZombieClass[id] will throw an error if id > 2.

And a little overall indentation work wouldnt hurt either:
PHP Code:
public Function( params )
{
    new 
var1;
    new 
var2;

    if ( 
var1 == )
    {
        
//do stuff
        //do more stuff

        
for ( new var1 i++ )
        {
            
//loop code
        
}
    }

__________________

Last edited by Bugsy; 10-03-2009 at 14:27.
Bugsy is offline
Reply



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 22:39.


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