Raised This Month: $51 Target: $400
 12% 

Hero problem!


Post New Thread Reply   
 
Thread Tools Display Modes
DarkGod
SourceMod DarkCrab
Join Date: Jul 2007
Location: Sweden
Old 05-11-2011 , 02:52   Re: Hero problem!
Reply With Quote #31

Quote:
Originally Posted by Jelle View Post
Also, I do use switch, but only when there is more than two if conditions.
Didn't see this before.
Only time you shouldn't use switch over if is when it's only a if or if and else. switch is always better than if and else if.
__________________
DarkGod is offline
Send a message via AIM to DarkGod Send a message via MSN to DarkGod
Jelle
[b]MOAR CANDY[/b]
Join Date: Aug 2009
Location: Denmark
Old 05-11-2011 , 03:01   Re: Hero problem!
Reply With Quote #32

Quote:
Originally Posted by DarkGod View Post
Didn't see this before.
Only time you shouldn't use switch over if is when it's only a if or if and else. switch is always better than if and else if.
I have always been told that two if statements is better than a switch, but using more than two, then using switch is better.

Using a switch for just one condition just seems odd.
__________________
No idea what to write here...
Jelle is offline
Send a message via MSN to Jelle
DarkGod
SourceMod DarkCrab
Join Date: Jul 2007
Location: Sweden
Old 05-11-2011 , 03:21   Re: Hero problem!
Reply With Quote #33

Quote:
Originally Posted by Jelle View Post
I have always been told that two if statements is better than a switch, but using more than two, then using switch is better.

Using a switch for just one condition just seems odd.
Did you read what I said? lol, if is better if you have a single if or an if and an else.
__________________
DarkGod is offline
Send a message via AIM to DarkGod Send a message via MSN to DarkGod
MuzzMikkel
Member
Join Date: Aug 2010
Location: Denmark
Old 05-11-2011 , 03:53   Re: Hero problem!
Reply With Quote #34

Quote:
Originally Posted by Jelle View Post
I wasn't really aware of that, thank you.



Post the whole code. Have you precached the weapon model correct?
I think so. But i also have another problem with unlimted bullets. When i have used a whole mag, it dosen't keep shooting?

Here is the whole code:


PHP Code:
/* Plugin generated by AMXX-Studio */

#include <superheromod>

new gHeroID
new gHasBones[SH_MAXSLOTS+1]
new const 
gBonesGalil[] = "models/shmod/Bones/Bones_v_galil.mdl"
new const gBonesDeagle[] = "models/shmod/Bones/Bones_v_deagle.mdl"
new const gBonesGalil2[] = "models/shmod/Bones/Bones_p_galil.mdl"
new const gBonesDeagle2[] = "models/shmod/Bones/Bones_p_deagle.mdl"
new const gBonesPlayer[] = "models/player/Bones/Bones.mdl"

public plugin_init()
{
    
register_plugin("SUPERHERO Bones""1.1""MuzzMikkel")
    
    new 
pcvarLevel register_cvar("Bones_level""10")
    new 
pcvarHealth register_cvar("Bones_health""450")
    new 
pcvarArmor register_cvar("Bones_armor""500")
    new 
pcvarSpeed register_cvar("Bones_speed""850")
    new 
pcvarGrav register_cvar("Bones_grav""2.5")
    new 
pcvarGalilMult register_cvar("Bones_galilmult""3.0")
    new 
pcvarDeagleMult register_cvar("Bones_deaglemult""2.1")
    
    
gHeroID sh_create_hero("Bones"pcvarLevel)
    
sh_set_hero_info(gHeroID"Bones the superkiller!""Get's a powerfull Galil / Dual golden deagle's")
    
    
sh_set_hero_dmgmult(gHeroIDpcvarGalilMultCSW_GALIL)
    
sh_set_hero_dmgmult(gHeroIDpcvarDeagleMultCSW_DEAGLE)
    
sh_set_hero_hpap(gHeroIDpcvarHealthpcvarArmor)
    
sh_set_hero_speed(gHeroIDpcvarSpeed)
    
sh_set_hero_grav(gHeroIDpcvarGrav)
    
    
register_event("CurWeapon""weapon_change""be""1=1")
    
}

public 
sh_hero_init(idheroIDmode)
{
    if ( 
gHeroID != heroID ) return
    
    switch(
mode)
    {
        case 
SH_HERO_ADD:
        {
            
gHasBones[id] = true
            Bones_weapons
(id)
            
switch_model(id)
            
Bones_morph(id)
        
        }
        
        case 
SH_HERO_DROP:
        {
            
gHasBones[id] = false
            Bones_unmorph
(id)
            if (
is_user_alive(id))
            
            {
                
sh_drop_weapon(idCSW_GALILtrue)
        
sh_drop_weapon(idCSW_DEAGLEtrue)
        
            }
        }
    }
}

public 
sh_client_spawn(id)
{
    if (
gHasBones[id])
    {
        
Bones_weapons(id)
    
Bones_morph(id)
    }
}

public 
weapon_change(id)
{
    if ( !
sh_is_active() || !gHasBones[id] ) return  
    
    new 
weaponID read_data(2)
    if (
weaponID !=CSW_GALIL) return
    if (
weaponID !=CSW_DEAGLE) return
    
    
switch_model(id)
    
    if (
read_data(3) == 0)
    {
        
sh_reload_ammo(id1)
    }
}

public 
plugin_precache()
{
    
precache_model(gBonesGalil); 
    
precache_model(gBonesGalil2);
    
precache_model(gBonesDeagle); 
    
precache_model(gBonesDeagle2);
    
precache_model(gBonesPlayer)
}

Bones_weapons(id)
{
    if (
sh_is_active() && is_user_alive(id) && gHasBones[id] )
    {
        
sh_give_weapon(idCSW_GALIL)
    
sh_give_weapon(idCSW_DEAGLE)
    }
}

switch_model(id)
{
    if (!
sh_is_active() || !is_user_alive(id) || !gHasBones[id] ) return
    
if ( 
get_user_weapon(id) == CSW_GALIL
{
        
set_pev(idpev_viewmodel2gBonesGalil)
    
set_pev(idpev_weaponmodel2gBonesGalil2)
}

else if ( 
get_user_weapon(id) == CSW_DEAGLE )
{
    
set_pev(idpev_viewmodel2gBonesDeagle)
    
set_pev(idpev_weaponmodel2gBonesDeagle2)
    }
}

Bones_morph(id)
{
    
cs_set_user_model(id"Bones")
}

Bones_unmorph(id)
{
    
cs_reset_user_model(id)

MuzzMikkel is offline
Send a message via MSN to MuzzMikkel
DarkGod
SourceMod DarkCrab
Join Date: Jul 2007
Location: Sweden
Old 05-11-2011 , 04:30   Re: Hero problem!
Reply With Quote #35

if (weaponID !=CSW_GALIL) return
if (
weaponID !=CSW_DEAGLE) return

You can't have both up at the same time.
__________________
DarkGod is offline
Send a message via AIM to DarkGod Send a message via MSN to DarkGod
MuzzMikkel
Member
Join Date: Aug 2010
Location: Denmark
Old 05-11-2011 , 04:38   Re: Hero problem!
Reply With Quote #36

Quote:
Originally Posted by DarkGod View Post
if (weaponID !=CSW_GALIL) return
if (
weaponID !=CSW_DEAGLE) return

You can't have both up at the same time.
How should i do then?
MuzzMikkel is offline
Send a message via MSN to MuzzMikkel
DarkGod
SourceMod DarkCrab
Join Date: Jul 2007
Location: Sweden
Old 05-11-2011 , 05:02   Re: Hero problem!
Reply With Quote #37

Quote:
Originally Posted by MuzzMikkel View Post
How should i do then?
Code:
if(weaponID == CSW_GALIL || weaponID == CSW_DEAGLE)        //stuff
__________________
DarkGod is offline
Send a message via AIM to DarkGod Send a message via MSN to DarkGod
Fr33m@n
Veteran Member
Join Date: May 2008
Location: France Marne
Old 05-11-2011 , 05:21   Re: Hero problem!
Reply With Quote #38

in if condition, else if :
|| = OR
&& = AND
!= is different to
== is strictly equal to

!something = contrary of something
example
PHP Code:
if ( !is_user_alive(id) )
{
    
//if the user is NOT alive, do this code.

basic useful condition.
Fr33m@n is offline
Jelle
[b]MOAR CANDY[/b]
Join Date: Aug 2009
Location: Denmark
Old 05-11-2011 , 05:34   Re: Hero problem!
Reply With Quote #39

Quote:
Originally Posted by DarkGod View Post
Did you read what I said? lol, if is better if you have a single if or an if and an else.
I thought you meant else if and not just else. I can see how if and else would be much better than a switch, and I normally do use it that way.

I also use else if, if I am checking something where what happens depends on two different conditions which can be more than two different things.
__________________
No idea what to write here...
Jelle is offline
Send a message via MSN to Jelle
MuzzMikkel
Member
Join Date: Aug 2010
Location: Denmark
Old 05-11-2011 , 05:46   Re: Hero problem!
Reply With Quote #40

Worked 100% thank you guys

Here's some bacon
The guys who helped me must ;)


Jelle:
Fr33m@n:
DarkGod:

-------------------------------------------------------------

The guys who helped me less ;)

RollerBlades:

PROBLEM SOLVED!!
MuzzMikkel is offline
Send a message via MSN to MuzzMikkel
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 09:40.


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