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

CVARS probs..


Post New Thread Reply   
 
Thread Tools Display Modes
Xel0z
Senior Member
Join Date: Apr 2006
Location: Netherlands
Old 09-05-2009 , 14:32   Re: CVARS probs..
Reply With Quote #11

PHP Code:
// Heavy 

/* CVARS - copy and paste to shconfig.cfg

//Heavy
heavy_level 25
heavy_health 500
heavy_armor 1000
heavy_m249speed 670
heavy_mult 4.0
heavy_healpoints 25

*/

/*
*
*
*   Heavy with a minigun from TF2
*/

#include <amxmodx> 
#include <superheromod>
#include <fakemeta>

new gHeroID
new const gHeroName[]="Heavy"
new bool:gHasHeavy[SH_MAXSLOTS+1]
new 
gPcvarMultgPcvarHealPoints
new const g_v_model[] = "models/shmod/Super/v_m249.mdl"
new const g_p_model[] = "models/shmod/Super/p_m249.mdl"

public plugin_init() 
{
    
register_plugin("SUPERHERO Heavy""1.0""Lyserinc")
   
    new 
pcvarLevel register_cvar("heavy_level""25")
    new 
pcvarHealth register_cvar("heavy_health""500")
    new 
pcvarArmor register_cvar("heavy_armor""1000")
    new 
pcvarSpeed register_cvar("heavy_m249speed""670")
    
gPcvarMult register_cvar("heavy_mult""4.0")
    
gPcvarHealPoints register_cvar("heavy_healpoints""25")
    
    
gHeroID sh_create_hero(gHeroNamepcvarLevel)
    
sh_set_hero_info(gHeroID"Heavy Machinery""HP/AP/Strong m249")
    
sh_set_hero_hpap(gHeroIDpcvarHealthpcvarArmor)
    
sh_set_hero_speed(gHeroIDpcvarSpeed, {CSW_M249})
    
    
set_task(1.0"heavy_loop"___"b")
}

public 
sh_hero_init(idheroIDmode)
{
    if (
gHeroID != heroID) return
    
    switch(
mode)
    {
        case 
SH_HERO_ADD
        {
            
gHasHeavy[id] = true
            switchmodel
(id)
        }

        case 
SH_HERO_DROP
        {
            
gHasHeavy[id] = false
        
}
    }
}

public 
plugin_precache() 
{
    
precache_model(g_v_model)
    
precache_model(g_p_model)
}

public 
heavy_loop()
{
    if (!
sh_is_active()) return

    static 
players[SH_MAXSLOTS], playerCountplayeri
    get_players
(playersplayerCount"ah")

    for (
0playerCounti++) 
    {
        
player players[i]

        if (
gHasHeavy[player]) 
        {
            
sh_add_hp(playerget_pcvar_num(gPcvarHealPoints))
        }
    }
}

public 
client_damage(attackervictimdamagewpnindexhitplace)
{
    if (!
sh_is_active()) return
    if (!
is_user_alive(victim) || !is_user_connected(attacker)) return

    if (
gHasHeavy[attacker] && wpnindex == CSW_M249
    {
        new 
headshot hitplace == 0
        
new extraDamage floatround(damage get_pcvar_float(gPcvarMult) - damage)
        if (
extraDamage 0sh_extra_damage(victimattackerextraDamage"m249"headshot)
    }
}

public 
weapon_change(id)
{
    if (!
sh_is_active() || !gHasHeavy[id]) return

    if (
read_data(2) == CSW_M249switchmodel(id)
}

switchmodel(id)
{
    if (!
sh_is_active() || !is_user_alive(id) || !gHasHeavy[id]) return

    if (
get_user_weapon(id) == CSW_M249
    {
        
set_pev(idpev_viewmodel2engfunc(EngFunc_AllocStringg_v_model))
        
set_pev(idpev_weaponmodel2engfunc(EngFunc_AllocStringg_p_model))
    }

Think this should work.
__________________
Heroes: TESS-One Working on: Grit (Fixing bugs)

Last edited by Xel0z; 09-05-2009 at 14:35.
Xel0z is offline
Send a message via MSN to Xel0z
Jelle
[b]MOAR CANDY[/b]
Join Date: Aug 2009
Location: Denmark
Old 09-05-2009 , 14:53   Re: CVARS probs..
Reply With Quote #12

Xel0z: Is that the new way of doing it? I have never need it being done that way.

Anyway, if you just make the code for him, he wont learn anything. So just a hint to Lyserinc, make it by yourself if you really want to learn it.
Jelle is offline
Send a message via MSN to Jelle
Lyserinc
Member
Join Date: Aug 2009
Old 09-05-2009 , 15:03   Re: CVARS probs..
Reply With Quote #13

I did make my own but i just got the errors.. :/


EDIT: omg. first u dont spawn with the weapon second u dont get the model i wanted!! >_<

Last edited by Lyserinc; 09-05-2009 at 15:15.
Lyserinc is offline
Jelle
[b]MOAR CANDY[/b]
Join Date: Aug 2009
Location: Denmark
Old 09-05-2009 , 15:09   Re: CVARS probs..
Reply With Quote #14

Yes, that was the point I was trying to make for Xel0z. If he just makes the code for you, you wont learn anything about it. The best is to show you your errors. If you see my post, you see what you did wrong, right? That you learned from.

If I were you now, I would look at the code I posted, and then clean it up by looking at the tutorial, then you learn by your own mistakes. As I see it, that is the best way to learn something.
Jelle is offline
Send a message via MSN to Jelle
Lyserinc
Member
Join Date: Aug 2009
Old 09-05-2009 , 15:16   Re: CVARS probs..
Reply With Quote #15

Okay, thankyou but .. can someone just fast add so you spawn with the weapon and that the model will be like the model cause now its just a normal para.. o.o
Lyserinc is offline
Jelle
[b]MOAR CANDY[/b]
Join Date: Aug 2009
Location: Denmark
Old 09-05-2009 , 15:19   Re: CVARS probs..
Reply With Quote #16

You need to do it yourself to learn from it, but if your wish is for me to make it, I will, because, I learn from it myself too. This just means that I will take some experience from you.
I will look into it and make your code clean now. If you wish me not to upload it, write it, then I wont, however, I will start the work now.
Jelle is offline
Send a message via MSN to Jelle
Lyserinc
Member
Join Date: Aug 2009
Old 09-05-2009 , 15:21   Re: CVARS probs..
Reply With Quote #17

Oh thankyou so much you are a realy kind man! + Karma to u (:
Lyserinc is offline
Jelle
[b]MOAR CANDY[/b]
Join Date: Aug 2009
Location: Denmark
Old 09-05-2009 , 15:29   Re: CVARS probs..
Reply With Quote #18

I just want you to know this...

In your code you have done this twice like this:
Code:
    if (!hasPowers && gHasSuperPower[id] && is_user_alive(id)) { //check if they had power but dont know and are alive
           shRemHealthPower(id); //remove health power if this is the case
           
           //...

    if (!hasPowers && gHasSuperPower[id] && is_user_alive(id)) { //check if they had power but dont know and are alive
          shRemArmorPower(id); //remove armor power if this is the case
But doing this:
Code:
    if (!hasPowers && gHasSuperPower[id] && is_user_alive(id)) //check if they had power but dont know and are alive
    {
           shRemHealthPower(id); //remove health power if this is the case
      shRemArmorPower(id); //remove armor power if this is the case
    }
is much more efficient. Then it wont have to load the "if (!hasPowers && gHasSuperPower[id] && is_user_alive(id))" two times, making it all go faster...

Also remember, when making this "{" (opening bracket), you also need to close that with this "}" (closing bracket), when you are done in that area, you see how I did? If you do not do that, well, that will just make an awful lot of errors, witch looks like the ones that you got.

Try using your brain a bit

EDIT:
You also did this:
Code:
if(wpnid == WEAPON_ID_TO_CHANGE)
"WEAPON_ID_TO_CHANGE", should be the weapon that you want to do the extra damage.
In this case m249, the code for that is "CSW_M249"...

Last edited by Jelle; 09-05-2009 at 15:40.
Jelle is offline
Send a message via MSN to Jelle
Lyserinc
Member
Join Date: Aug 2009
Old 09-05-2009 , 15:43   Re: CVARS probs..
Reply With Quote #19

Okay but.. can u help me fixing so u spawn with the weapon and that the model will be the model i said it should be?
Lyserinc is offline
Jelle
[b]MOAR CANDY[/b]
Join Date: Aug 2009
Location: Denmark
Old 09-05-2009 , 15:46   Re: CVARS probs..
Reply With Quote #20

No, I wont at the first place. Use the tutorial and try yourself first, if you want to learn it.
If you do not care about learning it anyway, I can do it. But first I need to clean up your code witch I am doing right now...

EDIT:
I get an error in this line:
"heavy_set_model(id) //go to set model funciton"

The error:
"undefined symbol "heavy_set_model" on line 97"
And I really do not know why this come, plus, there are so many other mistakes in your code that gives like 10 warnings. If you want this to work, you have to start from scratch again and do it properly. I can do it for you, but still, you wont learn anything if I just do it for you...

Last edited by Jelle; 09-05-2009 at 15:56.
Jelle is offline
Send a message via MSN to Jelle
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 16:32.


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