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

CVARS probs..


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Lyserinc
Member
Join Date: Aug 2009
Old 09-04-2009 , 17:09   CVARS probs..
Reply With Quote #1

Oh finaly i made my own hero, from the ground! And i dont know how to get the CVARS??!

SMA Code:
Code:
// Heavy 


*/

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

#include <amxmodx> 
#include <superheromod> 

new gHeroName[]="Heavy" //creates a string varr to hold your hearo's name
new bool:gHasSuperPower[SH_MAXSLOTS+1] //creates a varr with an aray, with 1 slot per player 

public plugin_init() {
    register_plugin("SUPERHERO Super", "1.0", "Rolnaaba"); //register plugin (you should know what this is)
   
    register_cvar("Super_level", "1"); //level required to select hero
    
    shCreateHero(gHeroName, "Hero Power List", "Hero Discription", false, "Super_level"); 
    //superheromod.inc: 
    //stock  shCreateHero(heroName[], heroPower[], heroHelp[], bool:requiresKeyEvents, heroLevel[])
    
    register_srvcmd("Super_init", "Super_init"); //register your hero's init function with server

    shRegHeroInit(gHeroName, "Super_init"); //register your hero's init with superheromod
}


public Super_init() {
    new temp[6]; //declare a temperary varriable
    read_argv(1,temp,5); //reading the first argument will give you the id of the person who selected your hero
    new id = str_to_num(temp); //transfer the string returned into a number and store it as the id

    read_argv(2,temp,5); //second argument is whether they have the power or not
    
    new hasPowers = str_to_num(temp);

    gHasSuperPower[id] = (hasPowers != 0); //(hasPowers != 0) will either return 1 (if it is true that hasPowers != 0), or 0 (if it is false that hasPowers != 0)
}

public plugin_init() {
    //...
   
    register_cvar("Super_health", "500"); //cvar for health
    
    shSetMaxHealth(gHeroName, "Super_health"); //set health
}

public Super_init() {
    //...

    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
    }
}

public plugin_init() {
    //...
   
    register_cvar("Super_armor", "1000"); //cvar for armor
   
    shSetMaxArmor(gHeroName, "Super_armor"); //set armor
}

public Super_init() {
    //...

    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
    }
}

public plugin_init() {
    //...
   
    //see helpful links for event info
    register_event("Damage", "Event_damage","b");

    register_cvar("Supher_mult", "4.0"); //how much damage to do (1.5 x normal_damage)
}

public Event_damage(id) {
    if (!shModActive() || !is_user_alive(id)) return PLUGIN_CONTINUE;

    new damage = read_data(2); //this is covered in my events tut. (in helpful links)
    new weapon, bodypart, attacker = get_user_attacker(id, weapon, bodypart) //store what weapon used, bodypart hit, and attacker
    new headshot = bodypart == 1 ? 1 : 0 //this is just short for:
    /*if (bodypart == 1) {
        headshot = 1;
    } else {
        headshot = 0;
    }*/

    if(attacker <= 0 || attacker > SH_MAXSLOTS ) return PLUGIN_CONTINUE; //checks ifs it was world that did the damage, and if so just end function.

    if(gHasSuperPower[attacker] && is_user_alive(id)) { //if alive and have power
        
     new extraDamage = floatround(damage * get_cvar_float("Super_mult") - damage); //calculate extra damage ([damage done x multiplier] - damage done = extra damage)
    
        if (extraDamage > 0) {
            shExtraDamage( id, attacker, extraDamage, "Super damage Mult", headshot ); //superheromod.inc: stock shExtraDamage(id, attacker, damage, weaponDescription[], headshot = 0);
     }
    }
}

#include <fakemeta> //for model setting

new g_p_model; //must be outside plugin_init so it can be global
new g_v_model;


public plugin_precache() {
    //...
   
    g_p_model = precache_model("models/shmod/p_m249.mdl"); //makes players download the model
    g_v_model = precache_model("models/shmod/v_m249.mdl");
    g_w_model = precache_model("models/shmod/w_m249.mdl");
}

public Super_init() {
    //...

    if(hasPowers) { //if they have power
          Super_set_model(id) //go to set model funciton
    }
    //...
}

public Super_set_model(id) {
    if (!shModActive() || !is_user_alive(id) || !HasSuperPower[id])  return;

    new clip, ammo, wpnid = get_user_weapon(id,clip,ammo);

    if(wpnid == CSW_M249 ) {
        set_pev(id, pev_viewmodel, engfunc(EngFunc_AllocString, g_v_model));//view model
        set_pev(id, pev_weaponmodel, engfunc(EngFunc_AllocString, g_p_model));//player model
        set_pev(id, pev_worldmodel, engfunc(EngFunc_AllocString, g_w_model));//world model
    }
}

public plugin_init() {
    //...

    register_event("ResetHUD", "Event_spawn","b"); //called when someone joins or new spawn
    
    //...
}

public Event_spawn(id) {
    if(gHasSuperPower[id] && is_user_alive(id) && shModActive()) { //has power and alive and mod on
        shGiveWeapon(id,"weapon_m249"); //give a weapon
    }
}

AAND i see i got errors, can someone fix em too? x]]]

Last edited by Lyserinc; 09-04-2009 at 17:12.
Lyserinc is offline
Xel0z
Senior Member
Join Date: Apr 2006
Location: Netherlands
Old 09-04-2009 , 17:13   Re: CVARS probs..
Reply With Quote #2

Dude, that is some messed-up code. Do you even know what you are doing? Or are you just putting parts of other heroes together in an attempt to create your own ultimate hero?
__________________
Heroes: TESS-One Working on: Grit (Fixing bugs)
Xel0z is offline
Send a message via MSN to Xel0z
Lyserinc
Member
Join Date: Aug 2009
Old 09-04-2009 , 17:15   Re: CVARS probs..
Reply With Quote #3

Eum, i just follows this tut: http://forums.alliedmods.net/showthread.php?t=54155
Lyserinc is offline
Jelle
[b]MOAR CANDY[/b]
Join Date: Aug 2009
Location: Denmark
Old 09-04-2009 , 19:16   Re: CVARS probs..
Reply With Quote #4

You are doing it really much wrong.

There has to be only ONE plugin_init.

When you add health to your hero, you still be in the first plugin_init that you made in the first place. In there you make the cvar, and set the speed of the hero.

Also, "Super_init" has to be "heavy_init".
ALWAYS when it says "Super" you have to replace it with your own name for the hero.
Jelle is offline
Send a message via MSN to Jelle
Lyserinc
Member
Join Date: Aug 2009
Old 09-05-2009 , 05:13   Re: CVARS probs..
Reply With Quote #5

Okay thank you so so so much (: It was my first idea with the one plugin_init but on the tut they just said: Add this then add this... Well thanks anyways!
Lyserinc is offline
Lyserinc
Member
Join Date: Aug 2009
Old 09-05-2009 , 05:30   Re: CVARS probs..
Reply With Quote #6

URGH!! Now i have made some errors again.. Cant someone help me??!:
Code:
// Heavy 

/* CVARS - copy and paste to shconfig.cfg

//Heavy
heavy_level 25            //The level of the hero Default: 25 
heavy_healpoints 20            // the #of HP healed per second
YodaMan_knifespeed 670        // speed of Darth Maul in knife mode
YodaMan_knifemult 2.70        // multiplier for knife damage...

*/

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

#include <amxmodx> 
#include <superheromod>
#include <fakemeta> //for model setting

new g_p_model; //must be outside plugin_init so it can be global
new g_v_model; 

new gHeroName[]="Heavy" //creates a string varr to hold your hearo's name

new bool:gHasSuperPower[SH_MAXSLOTS+1] //creates a varr with an aray, with 1 slot per player


public plugin_init() {
    register_plugin("SUPERHERO Heavy", "UNKNOWN", "Lyserinc"); //register plugin (you should know what this is)
   
    register_cvar("Heavy_level", "25"); //level required to select hero

    shCreateHero(gHeroName, "Hero Power List", "Hero Discription", false, "Heavy_level"); 
    //superheromod.inc: 
    //stock  shCreateHero(heroName[], heroPower[], heroHelp[], bool:requiresKeyEvents, heroLevel[])

    register_srvcmd("Heavy_init", "Heavy_init"); //register your hero's init function with server
    
    shRegHeroInit(gHeroName, "Heavy_init"); //register your hero's init with superheromod
    
        //...
   
    register_cvar("Heavy_health", "500"); //cvar for health
   
    shSetMaxHealth(gHeroName, "Heavy_health"); //set health
    
        //...
   
    register_cvar("Heavy_armor", "1000"); //cvar for armor
   
    shSetMaxArmor(gHeroName, "Heavy_armor"); //set armor
    
        //...
   
    //see helpful links for event info
    register_event("Damage", "Event_damage","b");

    register_cvar("Supher_mult", "4.0"); //how much damage to do (1.5 x normal_damage)

}

public Heavy_init() {
    new temp[6]; //declare a temperary varriable
    read_argv(1,temp,5); //reading the first argument will give you the id of the person who selected your hero
    new id = str_to_num(temp); //transfer the string returned into a number and store it as the id
    
        read_argv(2,temp,5); //second argument is whether they have the power or not
    
    new hasPowers = str_to_num(temp);

    gHasSuperPower[id] = (hasPowers != 0); //(hasPowers != 0) will either return 1 (if it is true that hasPowers != 0), or 0 (if it is false that hasPowers != 0)
    
   
    //...

    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
          
              if (!shModActive() || !is_user_alive(id)) return PLUGIN_CONTINUE;

    new damage = read_data(2); //this is covered in my events tut. (in helpful links)
    new weapon, bodypart, attacker = get_user_attacker(id, weapon, bodypart) //store what weapon used, bodypart hit, and attacker
    new headshot = bodypart == 1 ? 1 : 0 //this is just short for:
    /*if (bodypart == 1) {
        headshot = 1;
    } else {
        headshot = 0;
    }*/

    if(attacker <= 0 || attacker > SH_MAXSLOTS ) return PLUGIN_CONTINUE; //checks ifs it was world that did the damage, and if so just end function.

    if(gHasSuperPower[attacker] && is_user_alive(id)) { //if alive and have power
        
     new extraDamage = floatround(damage * get_cvar_float("Super_mult") - damage); //calculate extra damage ([damage done x multiplier] - damage done = extra damage)
    
        if (extraDamage > 0) {
            shExtraDamage( id, attacker, extraDamage, "Super damage Mult", headshot ); //superheromod.inc: stock shExtraDamage(id, attacker, damage, weaponDescription[], headshot = 0);
            
            //...

    if(hasPowers) { //if they have power
          Super_set_model(id) //go to set model funciton
    }
    //...
       }
    
    }
}



public plugin_precache() {
    //...
   
    g_p_model = precache_model("models/shmod/Super/p_m249.mdl"); //makes players download the model
    g_v_model = precache_model("models/shmod/Super/v_m249.mdl");
}

public Heavy_set_model(id) {
    if (!shModActive() || !is_user_alive(id) || !HasSuperPower[id])  return;

    new clip, ammo, wpnid = get_user_weapon(id,clip,ammo);

    if(wpnid == WEAPON_ID_TO_CHANGE) {
        set_pev(id, pev_viewmodel, engfunc(EngFunc_AllocString, g_v_model));//view model
        set_pev(id, pev_weaponmodel, engfunc(EngFunc_AllocString, g_p_model));//player model
    }
}
EDIT: Ooh soorry for double post
Lyserinc is offline
Jelle
[b]MOAR CANDY[/b]
Join Date: Aug 2009
Location: Denmark
Old 09-05-2009 , 13:38   Re: CVARS probs..
Reply With Quote #7

You need to post the errors too. But Ill look into it.

EDIT:
You have a really messed up code. If you see what I did in your plugin_init
Code:
// Heavy 

/* CVARS - copy and paste to shconfig.cfg

//Heavy
heavy_level 25            //The level of the hero Default: 25 
heavy_healpoints 20            // the #of HP healed per second
YodaMan_knifespeed 670        // speed of Darth Maul in knife mode
YodaMan_knifemult 2.70        // multiplier for knife damage...

*/

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

#include <amxmodx> 
#include <superheromod>
#include <fakemeta> //for model setting

new g_p_model; //must be outside plugin_init so it can be global
new g_v_model; 

new gHeroName[]="Heavy" //creates a string varr to hold your hearo's name

new bool:gHasSuperPower[SH_MAXSLOTS+1] //creates a varr with an aray, with 1 slot per player


public plugin_init() {
    register_plugin("SUPERHERO Heavy", "UNKNOWN", "Lyserinc"); //register plugin (you should know what this is)
    
    //cvars
    register_cvar("Heavy_level", "25"); //level required to select hero
    register_cvar("Heavy_health", "500"); //cvar for health
    register_cvar("Heavy_armor", "1000"); //cvar for armor
    register_cvar("Heavy_mult", "4.0"); //cvar for damage

    shCreateHero(gHeroName, "Hero Power List", "Hero Discription", false, "Heavy_level"); 
    //superheromod.inc: 
    //stock  shCreateHero(heroName[], heroPower[], heroHelp[], bool:requiresKeyEvents, heroLevel[])

    register_srvcmd("Heavy_init", "Heavy_init"); //register your hero's init function with server
    
    shRegHeroInit(gHeroName, "Heavy_init"); //register your hero's init with superheromod
    
    //set functions
    shSetMaxHealth(gHeroName, "Heavy_health"); //set health
    shSetMaxArmor(gHeroName, "Heavy_armor"); //set armor
    
        //...
   
    //see helpful links for event info
    register_event("Damage", "Event_damage","b");

}

public Heavy_init() {
    new temp[6]; //declare a temperary varriable
    read_argv(1,temp,5); //reading the first argument will give you the id of the person who selected your hero
    new id = str_to_num(temp); //transfer the string returned into a number and store it as the id
    
        read_argv(2,temp,5); //second argument is whether they have the power or not
    
    new hasPowers = str_to_num(temp);

    gHasSuperPower[id] = (hasPowers != 0); //(hasPowers != 0) will either return 1 (if it is true that hasPowers != 0), or 0 (if it is false that hasPowers != 0)
    
   
    //...

    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
          
              if (!shModActive() || !is_user_alive(id)) return PLUGIN_CONTINUE;

    new damage = read_data(2); //this is covered in my events tut. (in helpful links)
    new weapon, bodypart, attacker = get_user_attacker(id, weapon, bodypart) //store what weapon used, bodypart hit, and attacker
    new headshot = bodypart == 1 ? 1 : 0 //this is just short for:
    /*if (bodypart == 1) {
        headshot = 1;
    } else {
        headshot = 0;
    }*/

    if(attacker <= 0 || attacker > SH_MAXSLOTS ) return PLUGIN_CONTINUE; //checks ifs it was world that did the damage, and if so just end function.

    if(gHasSuperPower[attacker] && is_user_alive(id)) { //if alive and have power
        
     new extraDamage = floatround(damage * get_cvar_float("Super_mult") - damage); //calculate extra damage ([damage done x multiplier] - damage done = extra damage)
    
        if (extraDamage > 0) {
            shExtraDamage( id, attacker, extraDamage, "Super damage Mult", headshot ); //superheromod.inc: stock shExtraDamage(id, attacker, damage, weaponDescription[], headshot = 0);
            
            //...

    if(hasPowers) { //if they have power
          Heavy_set_model(id) //go to set model funciton
    }
    //...
       }
    
    }
}



public plugin_precache() {
    //...
   
    g_p_model = precache_model("models/shmod/Super/p_m249.mdl"); //makes players download the model
    g_v_model = precache_model("models/shmod/Super/v_m249.mdl");
}

public Heavy_set_model(id) {
    if (!shModActive() || !is_user_alive(id) || !HasSuperPower[id])  return;

    new clip, ammo, wpnid = get_user_weapon(id,clip,ammo);

    if(wpnid == WEAPON_ID_TO_CHANGE) {
        set_pev(id, pev_viewmodel, engfunc(EngFunc_AllocString, g_v_model));//view model
        set_pev(id, pev_weaponmodel, engfunc(EngFunc_AllocString, g_p_model));//player model
    }
}
You see how I cleaned it up for you? Do that with everything in your code and it will be so much easier to read for yourself, and for everyone else who looks at it.

Try look at your own code, clean it up so it looks nice and easy to read.
After what I can see, you just copy paste what is written in the tutorial thread. You need to write it YOURSELF, and make the code clean from scratch, or else you wont really learn anything from it.

Do you even know what you have done so far?

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

omg.. i dont know, well thankyou as u know i am a newbie in making and you are a awsome teacher, +karma on u DD


EDIT: okay now u can see errors.. :

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

Well, thats what you need to learn. What I know, I learned pretty much by myself or vittu who has helped me allot, and some other nice guys in here.

Hehe, good teacher? I am here to help. But I can only help you with what I know, and that is not so much yet.
Anyway thanks for the karma
Jelle is offline
Send a message via MSN to Jelle
Lyserinc
Member
Join Date: Aug 2009
Old 09-05-2009 , 14:09   Re: CVARS probs..
Reply With Quote #10

Heh no problems, but can u help me with this: EDIT: okay now u can see errors.. :
Lyserinc is offline
Reply


Thread Tools
Display Modes

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:15.


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